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