1*7c3d14c8STreehugger Robot //===-- floatunditf_test.c - Test __floatunditf ---------------------------===//
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 __floatunditf 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 <math.h>
16*7c3d14c8STreehugger Robot #include <complex.h>
17*7c3d14c8STreehugger Robot #include <stdio.h>
18*7c3d14c8STreehugger Robot
19*7c3d14c8STreehugger Robot #if __LDBL_MANT_DIG__ == 113
20*7c3d14c8STreehugger Robot
21*7c3d14c8STreehugger Robot #include "fp_test.h"
22*7c3d14c8STreehugger Robot
23*7c3d14c8STreehugger Robot // Returns: long integer converted to long double
24*7c3d14c8STreehugger Robot
25*7c3d14c8STreehugger Robot COMPILER_RT_ABI long double __floatunditf(unsigned long long a);
26*7c3d14c8STreehugger Robot
test__floatunditf(unsigned long long a,uint64_t expectedHi,uint64_t expectedLo)27*7c3d14c8STreehugger Robot int test__floatunditf(unsigned long long a, uint64_t expectedHi, uint64_t expectedLo)
28*7c3d14c8STreehugger Robot {
29*7c3d14c8STreehugger Robot long double x = __floatunditf(a);
30*7c3d14c8STreehugger Robot int ret = compareResultLD(x, expectedHi, expectedLo);
31*7c3d14c8STreehugger Robot
32*7c3d14c8STreehugger Robot if (ret)
33*7c3d14c8STreehugger Robot printf("error in __floatunditf(%Lu) = %.20Lf, "
34*7c3d14c8STreehugger Robot "expected %.20Lf\n", a, x, fromRep128(expectedHi, expectedLo));
35*7c3d14c8STreehugger Robot return ret;
36*7c3d14c8STreehugger Robot }
37*7c3d14c8STreehugger Robot
38*7c3d14c8STreehugger Robot char assumption_1[sizeof(long double) * CHAR_BIT == 128] = {0};
39*7c3d14c8STreehugger Robot
40*7c3d14c8STreehugger Robot #endif
41*7c3d14c8STreehugger Robot
main()42*7c3d14c8STreehugger Robot int main()
43*7c3d14c8STreehugger Robot {
44*7c3d14c8STreehugger Robot #if __LDBL_MANT_DIG__ == 113
45*7c3d14c8STreehugger Robot if (test__floatunditf(0xffffffffffffffffULL, UINT64_C(0x403effffffffffff), UINT64_C(0xfffe000000000000)))
46*7c3d14c8STreehugger Robot return 1;
47*7c3d14c8STreehugger Robot if (test__floatunditf(0xfffffffffffffffeULL, UINT64_C(0x403effffffffffff), UINT64_C(0xfffc000000000000)))
48*7c3d14c8STreehugger Robot return 1;
49*7c3d14c8STreehugger Robot if (test__floatunditf(0x8000000000000000ULL, UINT64_C(0x403e000000000000), UINT64_C(0x0)))
50*7c3d14c8STreehugger Robot return 1;
51*7c3d14c8STreehugger Robot if (test__floatunditf(0x7fffffffffffffffULL, UINT64_C(0x403dffffffffffff), UINT64_C(0xfffc000000000000)))
52*7c3d14c8STreehugger Robot return 1;
53*7c3d14c8STreehugger Robot if (test__floatunditf(0x123456789abcdef1ULL, UINT64_C(0x403b23456789abcd), UINT64_C(0xef10000000000000)))
54*7c3d14c8STreehugger Robot return 1;
55*7c3d14c8STreehugger Robot if (test__floatunditf(0x2ULL, UINT64_C(0x4000000000000000), UINT64_C(0x0)))
56*7c3d14c8STreehugger Robot return 1;
57*7c3d14c8STreehugger Robot if (test__floatunditf(0x1ULL, UINT64_C(0x3fff000000000000), UINT64_C(0x0)))
58*7c3d14c8STreehugger Robot return 1;
59*7c3d14c8STreehugger Robot if (test__floatunditf(0x0ULL, UINT64_C(0x0), UINT64_C(0x0)))
60*7c3d14c8STreehugger Robot return 1;
61*7c3d14c8STreehugger Robot
62*7c3d14c8STreehugger Robot #else
63*7c3d14c8STreehugger Robot printf("skipped\n");
64*7c3d14c8STreehugger Robot
65*7c3d14c8STreehugger Robot #endif
66*7c3d14c8STreehugger Robot return 0;
67*7c3d14c8STreehugger Robot }
68