blob: 6f98721b0a5492e0fa7a4e12b5577fae02438095 [file] [log] [blame]
Joerg Sonnenberger00a7da12014-09-16 20:34:41 +00001//===--------------- floatsitf_test.c - Test __floatsitf ------------------===//
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 __floatsitf for the compiler_rt library.
11//
12//===----------------------------------------------------------------------===//
13
Pirama Arumuga Nainarcdce50b2015-07-01 12:26:56 -070014#include "int_lib.h"
Joerg Sonnenberger00a7da12014-09-16 20:34:41 +000015#include <stdio.h>
16
17#if __LDBL_MANT_DIG__ == 113
18
19#include "fp_test.h"
20
Pirama Arumuga Nainarcdce50b2015-07-01 12:26:56 -070021long COMPILER_RT_ABI double __floatsitf(int a);
Joerg Sonnenberger00a7da12014-09-16 20:34:41 +000022
23int test__floatsitf(int a, uint64_t expectedHi, uint64_t expectedLo)
24{
25 long double x = __floatsitf(a);
26 int ret = compareResultLD(x, expectedHi, expectedLo);
27
28 if (ret)
29 {
30 printf("error in test__floatsitf(%d) = %.20Lf, "
31 "expected %.20Lf\n", a, x, fromRep128(expectedHi, expectedLo));
32 }
33 return ret;
34}
35
36char assumption_1[sizeof(long double) * CHAR_BIT == 128] = {0};
37
38#endif
39
40int main()
41{
42#if __LDBL_MANT_DIG__ == 113
Pirama Arumuga Nainar799172d2016-03-03 15:50:30 -080043 if (test__floatsitf(0x80000000, UINT64_C(0xc01e000000000000), UINT64_C(0x0)))
44 return 1;
Joerg Sonnenberger00a7da12014-09-16 20:34:41 +000045 if (test__floatsitf(0x7fffffff, UINT64_C(0x401dfffffffc0000), UINT64_C(0x0)))
46 return 1;
47 if (test__floatsitf(0, UINT64_C(0x0), UINT64_C(0x0)))
48 return 1;
49 if (test__floatsitf(0xffffffff, UINT64_C(0xbfff000000000000), UINT64_C(0x0)))
50 return 1;
51 if (test__floatsitf(0x12345678, UINT64_C(0x401b234567800000), UINT64_C(0x0)))
52 return 1;
53 if (test__floatsitf(-0x12345678, UINT64_C(0xc01b234567800000), UINT64_C(0x0)))
54 return 1;
55
56#else
57 printf("skipped\n");
58
59#endif
60 return 0;
61}