Weiming Zhao | 9b7bbec | 2017-03-21 05:32:51 +0000 | [diff] [blame] | 1 | // RUN: %clang_builtins %s %librt -o %t && %run %t |
Joerg Sonnenberger | ed35a3e | 2014-09-16 20:34:41 +0000 | [diff] [blame] | 2 | //===--------------- 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 Schuff | eb0ebc3 | 2015-04-24 15:45:57 +0000 | [diff] [blame] | 15 | #include "int_lib.h" |
Joerg Sonnenberger | ed35a3e | 2014-09-16 20:34:41 +0000 | [diff] [blame] | 16 | #include <stdio.h> |
| 17 | |
| 18 | #if __LDBL_MANT_DIG__ == 113 |
| 19 | |
| 20 | #include "fp_test.h" |
| 21 | |
Derek Schuff | eb0ebc3 | 2015-04-24 15:45:57 +0000 | [diff] [blame] | 22 | long COMPILER_RT_ABI double __floatsitf(int a); |
Joerg Sonnenberger | ed35a3e | 2014-09-16 20:34:41 +0000 | [diff] [blame] | 23 | |
| 24 | int 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 | |
| 37 | char assumption_1[sizeof(long double) * CHAR_BIT == 128] = {0}; |
| 38 | |
| 39 | #endif |
| 40 | |
| 41 | int main() |
| 42 | { |
| 43 | #if __LDBL_MANT_DIG__ == 113 |
Sergey Dmitrouk | a2ce083 | 2015-07-31 13:32:09 +0000 | [diff] [blame] | 44 | if (test__floatsitf(0x80000000, UINT64_C(0xc01e000000000000), UINT64_C(0x0))) |
| 45 | return 1; |
Joerg Sonnenberger | ed35a3e | 2014-09-16 20:34:41 +0000 | [diff] [blame] | 46 | 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 | } |