tsan: deflake tests
[blocksruntime.git] / test / Unit / negvdi2_test.c
blob9617b95ff1058a9aff80ccd715a47399d2a4e109
1 //===-- negvdi2_test.c - Test __negvdi2 -----------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file tests __negvdi2 for the compiler_rt library.
12 //===----------------------------------------------------------------------===//
14 #include "int_lib.h"
15 #include <stdio.h>
17 // Returns: -a
19 // Effects: aborts if -a overflows
21 di_int __negvdi2(di_int a);
23 int test__negvdi2(di_int a)
25 di_int x = __negvdi2(a);
26 di_int expected = -a;
27 if (x != expected)
28 printf("error in __negvdi2(0x%llX) = %lld, expected %lld\n",
29 a, x, expected);
30 return x != expected;
33 int main()
35 // if (test__negvdi2(0x8000000000000000LL)) // should abort
36 // return 1;
37 if (test__negvdi2(0x0000000000000000LL))
38 return 1;
39 if (test__negvdi2(0x0000000000000001LL))
40 return 1;
41 if (test__negvdi2(0x0000000000000002LL))
42 return 1;
43 if (test__negvdi2(0x7FFFFFFFFFFFFFFELL))
44 return 1;
45 if (test__negvdi2(0x7FFFFFFFFFFFFFFFLL))
46 return 1;
47 if (test__negvdi2(0x8000000000000001LL))
48 return 1;
49 if (test__negvdi2(0x8000000000000002LL))
50 return 1;
51 if (test__negvdi2(0xFFFFFFFFFFFFFFFELL))
52 return 1;
53 if (test__negvdi2(0xFFFFFFFFFFFFFFFFLL))
54 return 1;
56 return 0;