| 1 | // RUN: %clang_builtins %s %librt -o %t && %run %t |
| 2 | // REQUIRES: librt_has_fixdfsivfp |
| 3 | |
| 4 | #include <stdio.h> |
| 5 | #include <stdlib.h> |
| 6 | #include <math.h> |
| 7 | |
| 8 | |
| 9 | extern int __fixdfsivfp(double a); |
| 10 | |
| 11 | #if defined(__arm__) && defined(__ARM_FP) && (__ARM_FP & 0x8) |
| 12 | int test__fixdfsivfp(double a) |
| 13 | { |
| 14 | int actual = __fixdfsivfp(a); |
| 15 | int expected = a; |
| 16 | if (actual != expected) |
| 17 | printf("error in test__fixdfsivfp(%f) = %d, expected %d\n" , |
| 18 | a, actual, expected); |
| 19 | return actual != expected; |
| 20 | } |
| 21 | #endif |
| 22 | |
| 23 | int main() |
| 24 | { |
| 25 | #if defined(__arm__) && defined(__ARM_FP) && (__ARM_FP & 0x8) |
| 26 | if (test__fixdfsivfp(0.0)) |
| 27 | return 1; |
| 28 | if (test__fixdfsivfp(1.0)) |
| 29 | return 1; |
| 30 | if (test__fixdfsivfp(-1.0)) |
| 31 | return 1; |
| 32 | if (test__fixdfsivfp(2147483647)) |
| 33 | return 1; |
| 34 | if (test__fixdfsivfp(-2147483648.0)) |
| 35 | return 1; |
| 36 | #else |
| 37 | printf(format: "skipped\n" ); |
| 38 | #endif |
| 39 | return 0; |
| 40 | } |
| 41 | |