1*7c3d14c8STreehugger Robot //===--------------- floatsitf_test.c - Test __floatsitf ------------------===//
2*7c3d14c8STreehugger Robot //
3*7c3d14c8STreehugger Robot // The LLVM Compiler Infrastructure
4*7c3d14c8STreehugger Robot //
5*7c3d14c8STreehugger Robot // This file is dual licensed under the MIT and the University of Illinois Open
6*7c3d14c8STreehugger Robot // Source Licenses. See LICENSE.TXT for details.
7*7c3d14c8STreehugger Robot //
8*7c3d14c8STreehugger Robot //===----------------------------------------------------------------------===//
9*7c3d14c8STreehugger Robot //
10*7c3d14c8STreehugger Robot // This file tests __floatsitf for the compiler_rt library.
11*7c3d14c8STreehugger Robot //
12*7c3d14c8STreehugger Robot //===----------------------------------------------------------------------===//
13*7c3d14c8STreehugger Robot
14*7c3d14c8STreehugger Robot #include "int_lib.h"
15*7c3d14c8STreehugger Robot #include <stdio.h>
16*7c3d14c8STreehugger Robot
17*7c3d14c8STreehugger Robot #if __LDBL_MANT_DIG__ == 113
18*7c3d14c8STreehugger Robot
19*7c3d14c8STreehugger Robot #include "fp_test.h"
20*7c3d14c8STreehugger Robot
21*7c3d14c8STreehugger Robot long COMPILER_RT_ABI double __floatsitf(int a);
22*7c3d14c8STreehugger Robot
test__floatsitf(int a,uint64_t expectedHi,uint64_t expectedLo)23*7c3d14c8STreehugger Robot int test__floatsitf(int a, uint64_t expectedHi, uint64_t expectedLo)
24*7c3d14c8STreehugger Robot {
25*7c3d14c8STreehugger Robot long double x = __floatsitf(a);
26*7c3d14c8STreehugger Robot int ret = compareResultLD(x, expectedHi, expectedLo);
27*7c3d14c8STreehugger Robot
28*7c3d14c8STreehugger Robot if (ret)
29*7c3d14c8STreehugger Robot {
30*7c3d14c8STreehugger Robot printf("error in test__floatsitf(%d) = %.20Lf, "
31*7c3d14c8STreehugger Robot "expected %.20Lf\n", a, x, fromRep128(expectedHi, expectedLo));
32*7c3d14c8STreehugger Robot }
33*7c3d14c8STreehugger Robot return ret;
34*7c3d14c8STreehugger Robot }
35*7c3d14c8STreehugger Robot
36*7c3d14c8STreehugger Robot char assumption_1[sizeof(long double) * CHAR_BIT == 128] = {0};
37*7c3d14c8STreehugger Robot
38*7c3d14c8STreehugger Robot #endif
39*7c3d14c8STreehugger Robot
main()40*7c3d14c8STreehugger Robot int main()
41*7c3d14c8STreehugger Robot {
42*7c3d14c8STreehugger Robot #if __LDBL_MANT_DIG__ == 113
43*7c3d14c8STreehugger Robot if (test__floatsitf(0x80000000, UINT64_C(0xc01e000000000000), UINT64_C(0x0)))
44*7c3d14c8STreehugger Robot return 1;
45*7c3d14c8STreehugger Robot if (test__floatsitf(0x7fffffff, UINT64_C(0x401dfffffffc0000), UINT64_C(0x0)))
46*7c3d14c8STreehugger Robot return 1;
47*7c3d14c8STreehugger Robot if (test__floatsitf(0, UINT64_C(0x0), UINT64_C(0x0)))
48*7c3d14c8STreehugger Robot return 1;
49*7c3d14c8STreehugger Robot if (test__floatsitf(0xffffffff, UINT64_C(0xbfff000000000000), UINT64_C(0x0)))
50*7c3d14c8STreehugger Robot return 1;
51*7c3d14c8STreehugger Robot if (test__floatsitf(0x12345678, UINT64_C(0x401b234567800000), UINT64_C(0x0)))
52*7c3d14c8STreehugger Robot return 1;
53*7c3d14c8STreehugger Robot if (test__floatsitf(-0x12345678, UINT64_C(0xc01b234567800000), UINT64_C(0x0)))
54*7c3d14c8STreehugger Robot return 1;
55*7c3d14c8STreehugger Robot
56*7c3d14c8STreehugger Robot #else
57*7c3d14c8STreehugger Robot printf("skipped\n");
58*7c3d14c8STreehugger Robot
59*7c3d14c8STreehugger Robot #endif
60*7c3d14c8STreehugger Robot return 0;
61*7c3d14c8STreehugger Robot }
62