xref: /netbsd-src/sys/external/bsd/compiler_rt/dist/test/Unit/floatsidfvfp_test.c (revision b9829059e8a75f40496c2d279251f331078ac82e)
1*b9829059Sjoerg //===-- floatsidfvfp_test.c - Test __floatsidfvfp -------------------------===//
2*b9829059Sjoerg //
3*b9829059Sjoerg //                     The LLVM Compiler Infrastructure
4*b9829059Sjoerg //
5*b9829059Sjoerg // This file is dual licensed under the MIT and the University of Illinois Open
6*b9829059Sjoerg // Source Licenses. See LICENSE.TXT for details.
7*b9829059Sjoerg //
8*b9829059Sjoerg //===----------------------------------------------------------------------===//
9*b9829059Sjoerg //
10*b9829059Sjoerg // This file tests __floatsidfvfp for the compiler_rt library.
11*b9829059Sjoerg //
12*b9829059Sjoerg //===----------------------------------------------------------------------===//
13*b9829059Sjoerg 
14*b9829059Sjoerg #include <stdio.h>
15*b9829059Sjoerg #include <stdlib.h>
16*b9829059Sjoerg #include <math.h>
17*b9829059Sjoerg 
18*b9829059Sjoerg 
19*b9829059Sjoerg extern double __floatsidfvfp(int a);
20*b9829059Sjoerg 
21*b9829059Sjoerg #if __arm__
test__floatsidfvfp(int a)22*b9829059Sjoerg int test__floatsidfvfp(int a)
23*b9829059Sjoerg {
24*b9829059Sjoerg     double actual = __floatsidfvfp(a);
25*b9829059Sjoerg     double expected = a;
26*b9829059Sjoerg     if (actual != expected)
27*b9829059Sjoerg         printf("error in test__ floatsidfvfp(%d) = %f, expected %f\n",
28*b9829059Sjoerg                a, actual, expected);
29*b9829059Sjoerg     return actual != expected;
30*b9829059Sjoerg }
31*b9829059Sjoerg #endif
32*b9829059Sjoerg 
main()33*b9829059Sjoerg int main()
34*b9829059Sjoerg {
35*b9829059Sjoerg #if __arm__
36*b9829059Sjoerg     if (test__floatsidfvfp(0))
37*b9829059Sjoerg         return 1;
38*b9829059Sjoerg     if (test__floatsidfvfp(1))
39*b9829059Sjoerg         return 1;
40*b9829059Sjoerg     if (test__floatsidfvfp(-1))
41*b9829059Sjoerg         return 1;
42*b9829059Sjoerg     if (test__floatsidfvfp(0x7FFFFFFF))
43*b9829059Sjoerg         return 1;
44*b9829059Sjoerg     if (test__floatsidfvfp(0x80000000))
45*b9829059Sjoerg         return 1;
46*b9829059Sjoerg #else
47*b9829059Sjoerg     printf("skipped\n");
48*b9829059Sjoerg #endif
49*b9829059Sjoerg     return 0;
50*b9829059Sjoerg }
51