1// RUN: %clang_builtins %s %librt -o %t && %run %t
2// REQUIRES: librt_has_floatunsitf
3
4#include "int_lib.h"
5#include <stdio.h>
6
7#if __LDBL_MANT_DIG__ == 113
8
9#include "fp_test.h"
10
11COMPILER_RT_ABI long double __floatunsitf(unsigned int a);
12
13int test__floatunsitf(unsigned int a, uint64_t expectedHi, uint64_t expectedLo)
14{
15 long double x = __floatunsitf(a);
16 int ret = compareResultLD(x, expectedHi, expectedLo);
17
18 if (ret){
19 printf("error in test__floatunsitf(%u) = %.20Lf, "
20 "expected %.20Lf\n", a, x, fromRep128(expectedHi, expectedLo));
21 }
22 return ret;
23}
24
25char assumption_1[sizeof(long double) * CHAR_BIT == 128] = {0};
26
27#endif
28
29int main()
30{
31#if __LDBL_MANT_DIG__ == 113
32 if (test__floatunsitf(0x7fffffff, UINT64_C(0x401dfffffffc0000), UINT64_C(0x0)))
33 return 1;
34 if (test__floatunsitf(0, UINT64_C(0x0), UINT64_C(0x0)))
35 return 1;
36 if (test__floatunsitf(0xffffffff, UINT64_C(0x401efffffffe0000), UINT64_C(0x0)))
37 return 1;
38 if (test__floatunsitf(0x12345678, UINT64_C(0x401b234567800000), UINT64_C(0x0)))
39 return 1;
40
41#else
42 printf("skipped\n");
43
44#endif
45 return 0;
46}
47