]> git.proxmox.com Git - rustc.git/blob - src/libcompiler_builtins/compiler-rt/test/builtins/Unit/fixsfsivfp_test.c
New upstream version 1.28.0+dfsg1
[rustc.git] / src / libcompiler_builtins / compiler-rt / test / builtins / Unit / fixsfsivfp_test.c
1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2
3 //===-- fixsfsivfp_test.c - Test __fixsfsivfp -----------------------------===//
4 //
5 // The LLVM Compiler Infrastructure
6 //
7 // This file is dual licensed under the MIT and the University of Illinois Open
8 // Source Licenses. See LICENSE.TXT for details.
9 //
10 //===----------------------------------------------------------------------===//
11 //
12 // This file tests __fixsfsivfp for the compiler_rt library.
13 //
14 //===----------------------------------------------------------------------===//
15
16 #include <stdio.h>
17 #include <stdlib.h>
18 #include <math.h>
19
20
21 extern int __fixsfsivfp(float a);
22
23 #if __arm__ && __VFP_FP__
24 int test__fixsfsivfp(float a)
25 {
26 int actual = __fixsfsivfp(a);
27 int expected = a;
28 if (actual != expected)
29 printf("error in test__fixsfsivfp(%f) = %u, expected %u\n",
30 a, actual, expected);
31 return actual != expected;
32 }
33 #endif
34
35 int main()
36 {
37 #if __arm__ && __VFP_FP__
38 if (test__fixsfsivfp(0.0))
39 return 1;
40 if (test__fixsfsivfp(1.0))
41 return 1;
42 if (test__fixsfsivfp(-1.0))
43 return 1;
44 if (test__fixsfsivfp(2147483647.0))
45 return 1;
46 if (test__fixsfsivfp(-2147483648.0))
47 return 1;
48 if (test__fixsfsivfp(65536.0))
49 return 1;
50 #else
51 printf("skipped\n");
52 #endif
53 return 0;
54 }