1 //===-- absvti2_test.c - Test __absvti2 -----------------------------------===//
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 __absvti2 for the compiler_rt library.
12 //===----------------------------------------------------------------------===//
20 // Returns: absolute value
22 // Effects: aborts if abs(x) < 0
24 ti_int
__absvti2(ti_int a
);
26 int test__absvti2(ti_int a
)
28 ti_int x
= __absvti2(a
);
32 if (x
!= expected
|| expected
< 0)
39 expectedt
.all
= expected
;
40 printf("error in __absvti2(0x%llX%.16llX) = "
41 "0x%llX%.16llX, expected positive 0x%llX%.16llX\n",
42 at
.s
.high
, at
.s
.low
, xt
.s
.high
, xt
.s
.low
,
43 expectedt
.s
.high
, expectedt
.s
.low
);
54 // if (test__absvti2(make_ti(0x8000000000000000LL, 0))) // should abort
56 if (test__absvti2(0x0000000000000000LL
))
58 if (test__absvti2(0x0000000000000001LL
))
60 if (test__absvti2(0x0000000000000002LL
))
62 if (test__absvti2(make_ti(0x7FFFFFFFFFFFFFFFLL
, 0xFFFFFFFFFFFFFFFELL
)))
64 if (test__absvti2(make_ti(0x7FFFFFFFFFFFFFFFLL
, 0xFFFFFFFFFFFFFFFFLL
)))
66 if (test__absvti2(make_ti(0x8000000000000000LL
, 0x0000000000000001LL
)))
68 if (test__absvti2(make_ti(0x8000000000000000LL
, 0x0000000000000002LL
)))
70 if (test__absvti2(make_ti(0xFFFFFFFFFFFFFFFFLL
, 0xFFFFFFFFFFFFFFFELL
)))
72 if (test__absvti2(make_ti(0xFFFFFFFFFFFFFFFFLL
, 0xFFFFFFFFFFFFFFFFLL
)))
76 for (i
= 0; i
< 10000; ++i
)
77 if (test__absvti2(make_ti(((ti_int
)rand() << 32) | rand(),
78 ((ti_int
)rand() << 32) | rand())))