1 //===--------------- extendsftf2_test.c - Test __extendsftf2 --------------===//
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 __extendsftf2 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 long double __extendsftf2(float a);
21 
test__extendsftf2(float a,uint64_t expectedHi,uint64_t expectedLo)22 int test__extendsftf2(float a, uint64_t expectedHi, uint64_t expectedLo)
23 {
24     long double x = __extendsftf2(a);
25     int ret = compareResultLD(x, expectedHi, expectedLo);
26 
27     if (ret)
28     {
29         printf("error in test__extendsftf2(%f) = %.20Lf, "
30                "expected %.20Lf\n", a, x, fromRep128(expectedHi, expectedLo));
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     // qNaN
43     if (test__extendsftf2(makeQNaN32(),
44                           UINT64_C(0x7fff800000000000),
45                           UINT64_C(0x0)))
46         return 1;
47     // NaN
48     if (test__extendsftf2(makeNaN32(UINT32_C(0x410000)),
49                           UINT64_C(0x7fff820000000000),
50                           UINT64_C(0x0)))
51         return 1;
52     // inf
53     if (test__extendsftf2(makeInf32(),
54                           UINT64_C(0x7fff000000000000),
55                           UINT64_C(0x0)))
56         return 1;
57     // zero
58     if (test__extendsftf2(0.0f, UINT64_C(0x0), UINT64_C(0x0)))
59         return 1;
60 
61     if (test__extendsftf2(0x1.23456p+5f,
62                           UINT64_C(0x4004234560000000),
63                           UINT64_C(0x0)))
64         return 1;
65     if (test__extendsftf2(0x1.edcbap-9f,
66                           UINT64_C(0x3ff6edcba0000000),
67                           UINT64_C(0x0)))
68         return 1;
69     if (test__extendsftf2(0x1.23456p+45f,
70                           UINT64_C(0x402c234560000000),
71                           UINT64_C(0x0)))
72         return 1;
73     if (test__extendsftf2(0x1.edcbap-45f,
74                           UINT64_C(0x3fd2edcba0000000),
75                           UINT64_C(0x0)))
76         return 1;
77 
78 #else
79     printf("skipped\n");
80 
81 #endif
82     return 0;
83 }
84