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