| 1 | // RUN: %clang_builtins %s %librt -o %t && %run %t |
| 2 | // REQUIRES: librt_has_fixunstfsi |
| 3 | |
| 4 | #include <stdio.h> |
| 5 | |
| 6 | #if __LDBL_MANT_DIG__ == 113 |
| 7 | |
| 8 | #include "fp_test.h" |
| 9 | |
| 10 | unsigned int __fixunstfsi(long double a); |
| 11 | |
| 12 | int test__fixunstfsi(long double a, unsigned int expected) |
| 13 | { |
| 14 | unsigned int x = __fixunstfsi(a); |
| 15 | int ret = (x != expected); |
| 16 | |
| 17 | if (ret) |
| 18 | { |
| 19 | printf("error in test__fixunstfsi(%.20Lf) = %u, " |
| 20 | "expected %u\n" , a, x, expected); |
| 21 | } |
| 22 | return ret; |
| 23 | } |
| 24 | |
| 25 | char assumption_1[sizeof(long double) * CHAR_BIT == 128] = {0}; |
| 26 | |
| 27 | #endif |
| 28 | |
| 29 | int main() |
| 30 | { |
| 31 | #if __LDBL_MANT_DIG__ == 113 |
| 32 | if (test__fixunstfsi(makeInf128(), UINT32_C(0xffffffff))) |
| 33 | return 1; |
| 34 | if (test__fixunstfsi(0, UINT32_C(0x0))) |
| 35 | return 1; |
| 36 | if (test__fixunstfsi(0x1.23456789abcdefp+5, UINT32_C(0x24))) |
| 37 | return 1; |
| 38 | if (test__fixunstfsi(0x1.23456789abcdefp-3, UINT32_C(0x0))) |
| 39 | return 1; |
| 40 | if (test__fixunstfsi(0x1.23456789abcdefp+20, UINT32_C(0x123456))) |
| 41 | return 1; |
| 42 | if (test__fixunstfsi(0x1.23456789abcdefp+40, UINT32_C(0xffffffff))) |
| 43 | return 1; |
| 44 | if (test__fixunstfsi(0x1.23456789abcdefp+256, UINT32_C(0xffffffff))) |
| 45 | return 1; |
| 46 | if (test__fixunstfsi(-0x1.23456789abcdefp+3, UINT32_C(0x0))) |
| 47 | return 1; |
| 48 | |
| 49 | if (test__fixunstfsi(0x1.p+32, 0xFFFFFFFFLL)) |
| 50 | return 1; |
| 51 | |
| 52 | #else |
| 53 | printf(format: "skipped\n" ); |
| 54 | |
| 55 | #endif |
| 56 | return 0; |
| 57 | } |
| 58 | |