1 //===--------------- fixunstfsi_test.c - Test __fixunstfsi ----------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file tests __fixunstfsi for the compiler_rt library.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include <stdio.h>
15 
16 #if __LDBL_MANT_DIG__ == 113
17 
18 #include "fp_test.h"
19 
20 unsigned int __fixunstfsi(long double a);
21 
test__fixunstfsi(long double a,unsigned int expected)22 int test__fixunstfsi(long double a, unsigned int expected)
23 {
24     unsigned int x = __fixunstfsi(a);
25     int ret = (x != expected);
26 
27     if (ret)
28     {
29         printf("error in test__fixunstfsi(%.20Lf) = %u, "
30                "expected %u\n", a, x, expected);
31     }
32     return ret;
33 }
34 
35 char assumption_1[sizeof(long double) * CHAR_BIT == 128] = {0};
36 
37 #endif
38 
main()39 int main()
40 {
41 #if __LDBL_MANT_DIG__ == 113
42     if (test__fixunstfsi(makeInf128(), UINT32_C(0xffffffff)))
43         return 1;
44     if (test__fixunstfsi(0, UINT32_C(0x0)))
45         return 1;
46     if (test__fixunstfsi(0x1.23456789abcdefp+5, UINT32_C(0x24)))
47         return 1;
48     if (test__fixunstfsi(0x1.23456789abcdefp-3, UINT32_C(0x0)))
49         return 1;
50     if (test__fixunstfsi(0x1.23456789abcdefp+20, UINT32_C(0x123456)))
51         return 1;
52     if (test__fixunstfsi(0x1.23456789abcdefp+40, UINT32_C(0xffffffff)))
53         return 1;
54     if (test__fixunstfsi(0x1.23456789abcdefp+256, UINT32_C(0xffffffff)))
55         return 1;
56     if (test__fixunstfsi(-0x1.23456789abcdefp+3, UINT32_C(0x0)))
57         return 1;
58 
59     if (test__fixunstfsi(0x1.p+32, 0xFFFFFFFFLL))
60         return 1;
61 
62 #else
63     printf("skipped\n");
64 
65 #endif
66     return 0;
67 }
68