Weiming Zhao | 9b7bbec | 2017-03-21 05:32:51 +0000 | [diff] [blame] | 1 | // RUN: %clang_builtins %s %librt -o %t && %run %t |
Dan Liew | 5be7eb3 | 2019-10-17 18:12:49 +0000 | [diff] [blame] | 2 | // REQUIRES: librt_has_floatunssisfvfp |
Nick Kledzik | ad160c0 | 2009-09-14 23:26:56 +0000 | [diff] [blame] | 3 | |
| 4 | #include <stdio.h> |
| 5 | #include <stdlib.h> |
| 6 | #include <math.h> |
Derek Schuff | eb0ebc3 | 2015-04-24 15:45:57 +0000 | [diff] [blame] | 7 | #include "int_lib.h" |
Nick Kledzik | ad160c0 | 2009-09-14 23:26:56 +0000 | [diff] [blame] | 8 | |
Derek Schuff | eb0ebc3 | 2015-04-24 15:45:57 +0000 | [diff] [blame] | 9 | extern COMPILER_RT_ABI float __floatunssisfvfp(unsigned int a); |
Nick Kledzik | ad160c0 | 2009-09-14 23:26:56 +0000 | [diff] [blame] | 10 | |
Weiming Zhao | d77a673 | 2017-02-15 23:59:09 +0000 | [diff] [blame] | 11 | #if __arm__ && __VFP_FP__ |
Nick Kledzik | ad160c0 | 2009-09-14 23:26:56 +0000 | [diff] [blame] | 12 | int test__floatunssisfvfp(unsigned int a) |
| 13 | { |
| 14 | float actual = __floatunssisfvfp(a); |
| 15 | float expected = a; |
| 16 | if (actual != expected) |
| 17 | printf("error in test__floatunssisfvfp(%u) = %f, expected %f\n", |
| 18 | a, actual, expected); |
| 19 | return actual != expected; |
| 20 | } |
| 21 | #endif |
| 22 | |
| 23 | int main() |
| 24 | { |
Weiming Zhao | d77a673 | 2017-02-15 23:59:09 +0000 | [diff] [blame] | 25 | #if __arm__ && __VFP_FP__ |
Nick Kledzik | ad160c0 | 2009-09-14 23:26:56 +0000 | [diff] [blame] | 26 | if (test__floatunssisfvfp(0)) |
| 27 | return 1; |
| 28 | if (test__floatunssisfvfp(1)) |
| 29 | return 1; |
| 30 | if (test__floatunssisfvfp(0x7FFFFFFF)) |
| 31 | return 1; |
| 32 | if (test__floatunssisfvfp(0x80000000)) |
| 33 | return 1; |
| 34 | if (test__floatunssisfvfp(0xFFFFFFFF)) |
| 35 | return 1; |
Joerg Sonnenberger | d9bcddd | 2011-05-29 21:43:29 +0000 | [diff] [blame] | 36 | #else |
| 37 | printf("skipped\n"); |
Nick Kledzik | ad160c0 | 2009-09-14 23:26:56 +0000 | [diff] [blame] | 38 | #endif |
| 39 | return 0; |
| 40 | } |