blob: 75b7eba7a02411de6e771c177fd29d9dcff03309 [file] [log] [blame]
Weiming Zhao9b7bbec2017-03-21 05:32:51 +00001// RUN: %clang_builtins %s %librt -o %t && %run %t
Nick Kledzik3d22a3a2009-09-11 20:13:32 +00002//===-- divsf3vfp_test.c - Test __divsf3vfp -------------------------------===//
3//
4// The LLVM Compiler Infrastructure
5//
Howard Hinnant5b791f62010-11-16 22:13:33 +00006// This file is dual licensed under the MIT and the University of Illinois Open
7// Source Licenses. See LICENSE.TXT for details.
Nick Kledzik3d22a3a2009-09-11 20:13:32 +00008//
9//===----------------------------------------------------------------------===//
10//
11// This file tests __divsf3vfp for the compiler_rt library.
12//
13//===----------------------------------------------------------------------===//
14
Derek Schuffeb0ebc32015-04-24 15:45:57 +000015#include "int_lib.h"
Nick Kledzik3d22a3a2009-09-11 20:13:32 +000016#include <stdio.h>
17#include <stdlib.h>
18#include <math.h>
19
20
Derek Schuffeb0ebc32015-04-24 15:45:57 +000021extern COMPILER_RT_ABI float __divsf3vfp(float a, float b);
Nick Kledzik3d22a3a2009-09-11 20:13:32 +000022
Weiming Zhaod77a6732017-02-15 23:59:09 +000023#if __arm__ && __VFP_FP__
Nick Kledzik3d22a3a2009-09-11 20:13:32 +000024int 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
35int main()
36{
Weiming Zhaod77a6732017-02-15 23:59:09 +000037#if __arm__ && __VFP_FP__
Nick Kledzik3d22a3a2009-09-11 20:13:32 +000038 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 Sonnenbergerd9bcddd2011-05-29 21:43:29 +000046#else
47 printf("skipped\n");
Nick Kledzik3d22a3a2009-09-11 20:13:32 +000048#endif
49 return 0;
50}