• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===--------------- floatsitf_test.c - Test __floatsitf ------------------===//
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 __floatsitf for the compiler_rt library.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "int_lib.h"
15 #include <stdio.h>
16 
17 #if __LDBL_MANT_DIG__ == 113
18 
19 #include "fp_test.h"
20 
21 long COMPILER_RT_ABI double __floatsitf(int a);
22 
test__floatsitf(int a,uint64_t expectedHi,uint64_t expectedLo)23 int test__floatsitf(int a, uint64_t expectedHi, uint64_t expectedLo)
24 {
25     long double x = __floatsitf(a);
26     int ret = compareResultLD(x, expectedHi, expectedLo);
27 
28     if (ret)
29     {
30         printf("error in test__floatsitf(%d) = %.20Lf, "
31                "expected %.20Lf\n", a, x, fromRep128(expectedHi, expectedLo));
32     }
33     return ret;
34 }
35 
36 char assumption_1[sizeof(long double) * CHAR_BIT == 128] = {0};
37 
38 #endif
39 
main()40 int main()
41 {
42 #if __LDBL_MANT_DIG__ == 113
43     if (test__floatsitf(0x80000000, UINT64_C(0xc01e000000000000), UINT64_C(0x0)))
44         return 1;
45     if (test__floatsitf(0x7fffffff, UINT64_C(0x401dfffffffc0000), UINT64_C(0x0)))
46         return 1;
47     if (test__floatsitf(0, UINT64_C(0x0), UINT64_C(0x0)))
48         return 1;
49     if (test__floatsitf(0xffffffff, UINT64_C(0xbfff000000000000), UINT64_C(0x0)))
50         return 1;
51     if (test__floatsitf(0x12345678, UINT64_C(0x401b234567800000), UINT64_C(0x0)))
52         return 1;
53     if (test__floatsitf(-0x12345678, UINT64_C(0xc01b234567800000), UINT64_C(0x0)))
54         return 1;
55 
56 #else
57     printf("skipped\n");
58 
59 #endif
60     return 0;
61 }
62