1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_fixunstfsi
6 #if __LDBL_MANT_DIG__ == 113
10 unsigned int __fixunstfsi(long double a
);
12 int test__fixunstfsi(long double a
, unsigned int expected
)
14 unsigned int x
= __fixunstfsi(a
);
15 int ret
= (x
!= expected
);
19 printf("error in test__fixunstfsi(%.20Lf) = %u, "
20 "expected %u\n", a
, x
, expected
);
25 char assumption_1
[sizeof(long double) * CHAR_BIT
== 128] = {0};
31 #if __LDBL_MANT_DIG__ == 113
32 if (test__fixunstfsi(makeInf128(), UINT32_C(0xffffffff)))
34 if (test__fixunstfsi(0, UINT32_C(0x0)))
36 if (test__fixunstfsi(0x1.23456789abcdefp
+5, UINT32_C(0x24)))
38 if (test__fixunstfsi(0x1.23456789abcdefp
-3, UINT32_C(0x0)))
40 if (test__fixunstfsi(0x1.23456789abcdefp
+20, UINT32_C(0x123456)))
42 if (test__fixunstfsi(0x1.23456789abcdefp
+40, UINT32_C(0xffffffff)))
44 if (test__fixunstfsi(0x1.23456789abcdefp
+256, UINT32_C(0xffffffff)))
46 if (test__fixunstfsi(-0x1.23456789abcdefp
+3, UINT32_C(0x0)))
49 if (test__fixunstfsi(0x1.p
+32, 0xFFFFFFFFLL
))