blob: f8d700b3bd25e7be5ecdd7948372acf892fc0dfb [file] [log] [blame]
Weiming Zhao9b7bbec2017-03-21 05:32:51 +00001// RUN: %clang_builtins %s %librt -o %t && %run %t
Joerg Sonnenbergered35a3e2014-09-16 20:34:41 +00002//===--------------- floatsitf_test.c - Test __floatsitf ------------------===//
3//
4// The LLVM Compiler Infrastructure
5//
6// This file is dual licensed under the MIT and the University of Illinois Open
7// Source Licenses. See LICENSE.TXT for details.
8//
9//===----------------------------------------------------------------------===//
10//
11// This file tests __floatsitf for the compiler_rt library.
12//
13//===----------------------------------------------------------------------===//
14
Derek Schuffeb0ebc32015-04-24 15:45:57 +000015#include "int_lib.h"
Joerg Sonnenbergered35a3e2014-09-16 20:34:41 +000016#include <stdio.h>
17
18#if __LDBL_MANT_DIG__ == 113
19
20#include "fp_test.h"
21
Derek Schuffeb0ebc32015-04-24 15:45:57 +000022long COMPILER_RT_ABI double __floatsitf(int a);
Joerg Sonnenbergered35a3e2014-09-16 20:34:41 +000023
24int test__floatsitf(int a, uint64_t expectedHi, uint64_t expectedLo)
25{
26 long double x = __floatsitf(a);
27 int ret = compareResultLD(x, expectedHi, expectedLo);
28
29 if (ret)
30 {
31 printf("error in test__floatsitf(%d) = %.20Lf, "
32 "expected %.20Lf\n", a, x, fromRep128(expectedHi, expectedLo));
33 }
34 return ret;
35}
36
37char assumption_1[sizeof(long double) * CHAR_BIT == 128] = {0};
38
39#endif
40
41int main()
42{
43#if __LDBL_MANT_DIG__ == 113
Sergey Dmitrouka2ce0832015-07-31 13:32:09 +000044 if (test__floatsitf(0x80000000, UINT64_C(0xc01e000000000000), UINT64_C(0x0)))
45 return 1;
Joerg Sonnenbergered35a3e2014-09-16 20:34:41 +000046 if (test__floatsitf(0x7fffffff, UINT64_C(0x401dfffffffc0000), UINT64_C(0x0)))
47 return 1;
48 if (test__floatsitf(0, UINT64_C(0x0), UINT64_C(0x0)))
49 return 1;
50 if (test__floatsitf(0xffffffff, UINT64_C(0xbfff000000000000), UINT64_C(0x0)))
51 return 1;
52 if (test__floatsitf(0x12345678, UINT64_C(0x401b234567800000), UINT64_C(0x0)))
53 return 1;
54 if (test__floatsitf(-0x12345678, UINT64_C(0xc01b234567800000), UINT64_C(0x0)))
55 return 1;
56
57#else
58 printf("skipped\n");
59
60#endif
61 return 0;
62}