Joerg Sonnenberger | 00a7da1 | 2014-09-16 20:34:41 +0000 | [diff] [blame] | 1 | //===--------------- 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 Nainar | cdce50b | 2015-07-01 12:26:56 -0700 | [diff] [blame] | 14 | #include "int_lib.h" |
Joerg Sonnenberger | 00a7da1 | 2014-09-16 20:34:41 +0000 | [diff] [blame] | 15 | #include <stdio.h> |
| 16 | |
| 17 | #if __LDBL_MANT_DIG__ == 113 |
| 18 | |
| 19 | #include "fp_test.h" |
| 20 | |
Pirama Arumuga Nainar | cdce50b | 2015-07-01 12:26:56 -0700 | [diff] [blame] | 21 | long COMPILER_RT_ABI double __floatsitf(int a); |
Joerg Sonnenberger | 00a7da1 | 2014-09-16 20:34:41 +0000 | [diff] [blame] | 22 | |
| 23 | int 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 | |
| 36 | char assumption_1[sizeof(long double) * CHAR_BIT == 128] = {0}; |
| 37 | |
| 38 | #endif |
| 39 | |
| 40 | int main() |
| 41 | { |
| 42 | #if __LDBL_MANT_DIG__ == 113 |
| 43 | if (test__floatsitf(0x7fffffff, UINT64_C(0x401dfffffffc0000), UINT64_C(0x0))) |
| 44 | return 1; |
| 45 | if (test__floatsitf(0, UINT64_C(0x0), UINT64_C(0x0))) |
| 46 | return 1; |
| 47 | if (test__floatsitf(0xffffffff, UINT64_C(0xbfff000000000000), UINT64_C(0x0))) |
| 48 | return 1; |
| 49 | if (test__floatsitf(0x12345678, UINT64_C(0x401b234567800000), UINT64_C(0x0))) |
| 50 | return 1; |
| 51 | if (test__floatsitf(-0x12345678, UINT64_C(0xc01b234567800000), UINT64_C(0x0))) |
| 52 | return 1; |
| 53 | |
| 54 | #else |
| 55 | printf("skipped\n"); |
| 56 | |
| 57 | #endif |
| 58 | return 0; |
| 59 | } |