blob: 4f18409a28353763213475836d16680c64ecc42d [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//===-- divdf3vfp_test.c - Test __divdf3vfp -------------------------------===//
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 __divdf3vfp 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
Weiming Zhaod77a6732017-02-15 23:59:09 +000021#if __arm__ && __VFP_FP__
Derek Schuffeb0ebc32015-04-24 15:45:57 +000022extern COMPILER_RT_ABI double __divdf3vfp(double a, double b);
Nick Kledzik3d22a3a2009-09-11 20:13:32 +000023
24int test__divdf3vfp(double a, double b)
25{
26 double actual = __divdf3vfp(a, b);
27 double expected = a / b;
28 if (actual != expected)
29 printf("error in test__divdf3vfp(%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__divdf3vfp(1.0, 1.0))
39 return 1;
40 if (test__divdf3vfp(12345.678, 1.23))
41 return 1;
42 if (test__divdf3vfp(-10.0, 0.25))
43 return 1;
44 if (test__divdf3vfp(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}