Weiming Zhao | 9b7bbec | 2017-03-21 05:32:51 +0000 | [diff] [blame] | 1 | // RUN: %clang_builtins %s %librt -o %t && %run %t |
Nick Kledzik | 3d22a3a | 2009-09-11 20:13:32 +0000 | [diff] [blame] | 2 | //===-- divsf3vfp_test.c - Test __divsf3vfp -------------------------------===// |
| 3 | // |
| 4 | // The LLVM Compiler Infrastructure |
| 5 | // |
Howard Hinnant | 5b791f6 | 2010-11-16 22:13:33 +0000 | [diff] [blame] | 6 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 7 | // Source Licenses. See LICENSE.TXT for details. |
Nick Kledzik | 3d22a3a | 2009-09-11 20:13:32 +0000 | [diff] [blame] | 8 | // |
| 9 | //===----------------------------------------------------------------------===// |
| 10 | // |
| 11 | // This file tests __divsf3vfp for the compiler_rt library. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
Derek Schuff | eb0ebc3 | 2015-04-24 15:45:57 +0000 | [diff] [blame] | 15 | #include "int_lib.h" |
Nick Kledzik | 3d22a3a | 2009-09-11 20:13:32 +0000 | [diff] [blame] | 16 | #include <stdio.h> |
| 17 | #include <stdlib.h> |
| 18 | #include <math.h> |
| 19 | |
| 20 | |
Derek Schuff | eb0ebc3 | 2015-04-24 15:45:57 +0000 | [diff] [blame] | 21 | extern COMPILER_RT_ABI float __divsf3vfp(float a, float b); |
Nick Kledzik | 3d22a3a | 2009-09-11 20:13:32 +0000 | [diff] [blame] | 22 | |
Weiming Zhao | d77a673 | 2017-02-15 23:59:09 +0000 | [diff] [blame] | 23 | #if __arm__ && __VFP_FP__ |
Nick Kledzik | 3d22a3a | 2009-09-11 20:13:32 +0000 | [diff] [blame] | 24 | int test__divsf3vfp(float a, float b) |
| 25 | { |
| 26 | float actual = __divsf3vfp(a, b); |
| 27 | float expected = a / b; |
| 28 | if (actual != expected) |
| 29 | printf("error in test__divsf3vfp(%f, %f) = %f, expected %f\n", |
| 30 | a, b, actual, expected); |
| 31 | return actual != expected; |
| 32 | } |
| 33 | #endif |
| 34 | |
| 35 | int main() |
| 36 | { |
Weiming Zhao | d77a673 | 2017-02-15 23:59:09 +0000 | [diff] [blame] | 37 | #if __arm__ && __VFP_FP__ |
Nick Kledzik | 3d22a3a | 2009-09-11 20:13:32 +0000 | [diff] [blame] | 38 | if (test__divsf3vfp(1.0, 1.0)) |
| 39 | return 1; |
| 40 | if (test__divsf3vfp(12345.678, 1.23)) |
| 41 | return 1; |
| 42 | if (test__divsf3vfp(0.0, HUGE_VALF)) |
| 43 | return 1; |
| 44 | if (test__divsf3vfp(10.0, -2.0)) |
| 45 | return 1; |
Joerg Sonnenberger | d9bcddd | 2011-05-29 21:43:29 +0000 | [diff] [blame] | 46 | #else |
| 47 | printf("skipped\n"); |
Nick Kledzik | 3d22a3a | 2009-09-11 20:13:32 +0000 | [diff] [blame] | 48 | #endif |
| 49 | return 0; |
| 50 | } |