blob: c3d3fe949c4eca5685575c38711b09be33d5d751 [file] [log] [blame]
Joerg Sonnenbergered35a3e2014-09-16 20:34:41 +00001//===--------------- floatunsitf_test.c - Test __floatunsitf --------------===//
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 __floatunsitf for the compiler_rt library.
11//
12//===----------------------------------------------------------------------===//
13
Derek Schuffeb0ebc32015-04-24 15:45:57 +000014#include "int_lib.h"
Joerg Sonnenbergered35a3e2014-09-16 20:34:41 +000015#include <stdio.h>
16
17#if __LDBL_MANT_DIG__ == 113
18
19#include "fp_test.h"
20
Derek Schuffeb0ebc32015-04-24 15:45:57 +000021COMPILER_RT_ABI long double __floatunsitf(unsigned int a);
Joerg Sonnenbergered35a3e2014-09-16 20:34:41 +000022
23int test__floatunsitf(unsigned int a, uint64_t expectedHi, uint64_t expectedLo)
24{
25 long double x = __floatunsitf(a);
26 int ret = compareResultLD(x, expectedHi, expectedLo);
27
28 if (ret){
29 printf("error in test__floatunsitf(%u) = %.20Lf, "
30 "expected %.20Lf\n", a, x, fromRep128(expectedHi, expectedLo));
31 }
32 return ret;
33}
34
35char assumption_1[sizeof(long double) * CHAR_BIT == 128] = {0};
36
37#endif
38
39int main()
40{
41#if __LDBL_MANT_DIG__ == 113
42 if (test__floatunsitf(0x7fffffff, UINT64_C(0x401dfffffffc0000), UINT64_C(0x0)))
43 return 1;
44 if (test__floatunsitf(0, UINT64_C(0x0), UINT64_C(0x0)))
45 return 1;
46 if (test__floatunsitf(0xffffffff, UINT64_C(0x401efffffffe0000), UINT64_C(0x0)))
47 return 1;
48 if (test__floatunsitf(0x12345678, UINT64_C(0x401b234567800000), UINT64_C(0x0)))
49 return 1;
50
51#else
52 printf("skipped\n");
53
54#endif
55 return 0;
56}