]>
git.proxmox.com Git - rustc.git/blob - src/compiler-rt/test/builtins/Unit/fixunstfti_test.c
1 //===-- fixunstfti_test.c - Test __fixunstfti -----------------------------===//
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 __fixunstfti for the compiler_rt library.
12 //===----------------------------------------------------------------------===//
16 #if __LDBL_MANT_DIG__ == 113
21 // Returns: convert a to a unsigned long long, rounding toward zero.
22 // Negative values all become zero.
24 // Assumption: long double is a 128 bit floating point type
25 // tu_int is a 128 bit integral type
26 // value in long double is representable in tu_int or is negative
27 // (no range checking performed)
29 COMPILER_RT_ABI tu_int
__fixunstfti(long double a
);
31 int test__fixunstfti(long double a
, tu_int expected
)
33 tu_int x
= __fixunstfti(a
);
40 expectedt
.all
= expected
;
42 printf("error in __fixunstfti(%.20Lf) = 0x%.16llX%.16llX, "
43 "expected 0x%.16llX%.16llX\n",
44 a
, xt
.s
.high
, xt
.s
.low
, expectedt
.s
.high
, expectedt
.s
.low
);
49 char assumption_1
[sizeof(tu_int
) == 4*sizeof(su_int
)] = {0};
50 char assumption_2
[sizeof(tu_int
)*CHAR_BIT
== 128] = {0};
51 char assumption_3
[sizeof(long double)*CHAR_BIT
== 128] = {0};
57 #if __LDBL_MANT_DIG__ == 113
58 if (test__fixunstfti(makeInf128(), make_ti(0xffffffffffffffffLL
,
59 0xffffffffffffffffLL
)))
62 if (test__fixunstfti(0.0, 0))
65 if (test__fixunstfti(0.5, 0))
67 if (test__fixunstfti(0.99, 0))
69 if (test__fixunstfti(1.0, 1))
71 if (test__fixunstfti(1.5, 1))
73 if (test__fixunstfti(1.99, 1))
75 if (test__fixunstfti(2.0, 2))
77 if (test__fixunstfti(2.01, 2))
79 if (test__fixunstfti(-0.01, 0))
81 if (test__fixunstfti(-0.99, 0))
84 if (test__fixunstfti(0x1.p
+128, make_ti(0xffffffffffffffffLL
,
85 0xffffffffffffffffLL
)))
88 if (test__fixunstfti(0x1.FFFFFEp
+126, make_ti(0x7fffff8000000000LL
, 0x0)))
90 if (test__fixunstfti(0x1.FFFFFEp
+127, make_ti(0xffffff0000000000LL
, 0x0)))
92 if (test__fixunstfti(0x1.FFFFFEp
+128, make_ti(0xffffffffffffffffLL
,
93 0xffffffffffffffffLL
)))
95 if (test__fixunstfti(0x1.FFFFFEp
+129, make_ti(0xffffffffffffffffLL
,
96 0xffffffffffffffffLL
)))