• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===--------------- extenddftf2_test.c - Test __extenddftf2 --------------===//
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 __extenddftf2 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 COMPILER_RT_ABI long double __extenddftf2(double a);
22 
test__extenddftf2(double a,uint64_t expectedHi,uint64_t expectedLo)23 int test__extenddftf2(double a, uint64_t expectedHi, uint64_t expectedLo)
24 {
25     long double x = __extenddftf2(a);
26     int ret = compareResultLD(x, expectedHi, expectedLo);
27 
28     if (ret){
29         printf("error in test__extenddftf2(%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__extenddftf2(makeQNaN64(),
44                           UINT64_C(0x7fff800000000000),
45                           UINT64_C(0x0)))
46         return 1;
47     // NaN
48     if (test__extenddftf2(makeNaN64(UINT64_C(0x7100000000000)),
49                           UINT64_C(0x7fff710000000000),
50                           UINT64_C(0x0)))
51         return 1;
52     // inf
53     if (test__extenddftf2(makeInf64(),
54                           UINT64_C(0x7fff000000000000),
55                           UINT64_C(0x0)))
56         return 1;
57     // zero
58     if (test__extenddftf2(0.0, UINT64_C(0x0), UINT64_C(0x0)))
59         return 1;
60 
61     if (test__extenddftf2(0x1.23456789abcdefp+5,
62                           UINT64_C(0x400423456789abcd),
63                           UINT64_C(0xf000000000000000)))
64         return 1;
65     if (test__extenddftf2(0x1.edcba987654321fp-9,
66                           UINT64_C(0x3ff6edcba9876543),
67                           UINT64_C(0x2000000000000000)))
68         return 1;
69     if (test__extenddftf2(0x1.23456789abcdefp+45,
70                           UINT64_C(0x402c23456789abcd),
71                           UINT64_C(0xf000000000000000)))
72         return 1;
73     if (test__extenddftf2(0x1.edcba987654321fp-45,
74                           UINT64_C(0x3fd2edcba9876543),
75                           UINT64_C(0x2000000000000000)))
76         return 1;
77 
78 #else
79     printf("skipped\n");
80 
81 #endif
82     return 0;
83 }
84