xref: /netbsd-src/sys/external/bsd/compiler_rt/dist/test/Unit/gtsf2vfp_test.c (revision b9829059e8a75f40496c2d279251f331078ac82e)
1*b9829059Sjoerg //===-- gtsf2vfp_test.c - Test __gtsf2vfp ---------------------------------===//
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 __gtsf2vfp for the compiler_rt library.
11*b9829059Sjoerg //
12*b9829059Sjoerg //===----------------------------------------------------------------------===//
13*b9829059Sjoerg 
14*b9829059Sjoerg #include <stdlib.h>
15*b9829059Sjoerg #include <stdint.h>
16*b9829059Sjoerg #include <stdio.h>
17*b9829059Sjoerg #include <math.h>
18*b9829059Sjoerg 
19*b9829059Sjoerg 
20*b9829059Sjoerg extern int __gtsf2vfp(float a, float b);
21*b9829059Sjoerg 
22*b9829059Sjoerg #if __arm__
test__gtsf2vfp(float a,float b)23*b9829059Sjoerg int test__gtsf2vfp(float a, float b)
24*b9829059Sjoerg {
25*b9829059Sjoerg     int actual = __gtsf2vfp(a, b);
26*b9829059Sjoerg 	int expected = (a > b) ? 1 : 0;
27*b9829059Sjoerg     if (actual != expected)
28*b9829059Sjoerg         printf("error in __gtsf2vfp(%f, %f) = %d, expected %d\n",
29*b9829059Sjoerg                a, b, actual, expected);
30*b9829059Sjoerg     return actual != expected;
31*b9829059Sjoerg }
32*b9829059Sjoerg #endif
33*b9829059Sjoerg 
main()34*b9829059Sjoerg int main()
35*b9829059Sjoerg {
36*b9829059Sjoerg #if __arm__
37*b9829059Sjoerg     if (test__gtsf2vfp(0.0, 0.0))
38*b9829059Sjoerg         return 1;
39*b9829059Sjoerg     if (test__gtsf2vfp(1.0, 0.0))
40*b9829059Sjoerg         return 1;
41*b9829059Sjoerg     if (test__gtsf2vfp(-1.0, -2.0))
42*b9829059Sjoerg         return 1;
43*b9829059Sjoerg     if (test__gtsf2vfp(-2.0, -1.0))
44*b9829059Sjoerg         return 1;
45*b9829059Sjoerg     if (test__gtsf2vfp(HUGE_VALF, 1.0))
46*b9829059Sjoerg         return 1;
47*b9829059Sjoerg     if (test__gtsf2vfp(1.0, HUGE_VALF))
48*b9829059Sjoerg         return 1;
49*b9829059Sjoerg #else
50*b9829059Sjoerg     printf("skipped\n");
51*b9829059Sjoerg #endif
52*b9829059Sjoerg     return 0;
53*b9829059Sjoerg }
54