1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_absvdi2
8 // Returns: absolute value
10 // Effects: aborts if abs(x) < 0
12 COMPILER_RT_ABI di_int
__absvdi2(di_int a
);
14 int test__absvdi2(di_int a
)
16 di_int x
= __absvdi2(a
);
20 if (x
!= expected
|| expected
< 0)
21 printf("error in __absvdi2(0x%llX) = %lld, expected positive %lld\n",
28 // if (test__absvdi2(0x8000000000000000LL)) // should abort
30 if (test__absvdi2(0x0000000000000000LL
))
32 if (test__absvdi2(0x0000000000000001LL
))
34 if (test__absvdi2(0x0000000000000002LL
))
36 if (test__absvdi2(0x7FFFFFFFFFFFFFFELL
))
38 if (test__absvdi2(0x7FFFFFFFFFFFFFFFLL
))
40 if (test__absvdi2(0x8000000000000001LL
))
42 if (test__absvdi2(0x8000000000000002LL
))
44 if (test__absvdi2(0xFFFFFFFFFFFFFFFELL
))
46 if (test__absvdi2(0xFFFFFFFFFFFFFFFFLL
))
50 for (i
= 0; i
< 10000; ++i
)
51 if (test__absvdi2(((di_int
)rand() << 32) | rand()))