| 1 | // REQUIRES: arm-target-arch || armv6m-target-arch |
| 2 | // RUN: %clang_builtins %s %librt -o %t && %run %t |
| 3 | |
| 4 | #include <stdio.h> |
| 5 | #include <stdlib.h> |
| 6 | #include <math.h> |
| 7 | |
| 8 | |
| 9 | #if __arm__ |
| 10 | extern __attribute__((pcs("aapcs" ))) float __aeabi_frsub(float a, float b); |
| 11 | |
| 12 | int test__aeabi_frsub(float a, float b, float expected) |
| 13 | { |
| 14 | float actual = __aeabi_frsub(a, b); |
| 15 | if (actual != expected) |
| 16 | printf("error in __aeabi_frsub(%f, %f) = %f, expected %f\n" , |
| 17 | a, b, actual, expected); |
| 18 | return actual != expected; |
| 19 | } |
| 20 | #endif |
| 21 | |
| 22 | int main() |
| 23 | { |
| 24 | #if __arm__ |
| 25 | if (test__aeabi_frsub(1.0, 1.0, 0.0)) |
| 26 | return 1; |
| 27 | if (test__aeabi_frsub(1234.567, 765.4321, -469.134900)) |
| 28 | return 1; |
| 29 | if (test__aeabi_frsub(-123.0, -678.0, -555.0)) |
| 30 | return 1; |
| 31 | if (test__aeabi_frsub(0.0, -0.0, 0.0)) |
| 32 | return 1; |
| 33 | #else |
| 34 | printf(format: "skipped\n" ); |
| 35 | #endif |
| 36 | return 0; |
| 37 | } |
| 38 | |