1 //===-- absvdi2_test.c - Test __absvdi2 -----------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file tests __absvdi2 for the compiler_rt library.
12 //===----------------------------------------------------------------------===//
18 // Returns: absolute value
20 // Effects: aborts if abs(x) < 0
22 di_int
__absvdi2(di_int a
);
24 int test__absvdi2(di_int a
)
26 di_int x
= __absvdi2(a
);
30 if (x
!= expected
|| expected
< 0)
31 printf("error in __absvdi2(0x%llX) = %lld, expected positive %lld\n",
38 // if (test__absvdi2(0x8000000000000000LL)) // should abort
40 if (test__absvdi2(0x0000000000000000LL
))
42 if (test__absvdi2(0x0000000000000001LL
))
44 if (test__absvdi2(0x0000000000000002LL
))
46 if (test__absvdi2(0x7FFFFFFFFFFFFFFELL
))
48 if (test__absvdi2(0x7FFFFFFFFFFFFFFFLL
))
50 if (test__absvdi2(0x8000000000000001LL
))
52 if (test__absvdi2(0x8000000000000002LL
))
54 if (test__absvdi2(0xFFFFFFFFFFFFFFFELL
))
56 if (test__absvdi2(0xFFFFFFFFFFFFFFFFLL
))
60 for (i
= 0; i
< 10000; ++i
)
61 if (test__absvdi2(((di_int
)rand() << 32) | rand()))