1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_unordsf2vfp
3 
4 //===-- unordsf2vfp_test.c - Test __unordsf2vfp ---------------------------===//
5 //
6 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
7 // See https://llvm.org/LICENSE.txt for license information.
8 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
9 //
10 //===----------------------------------------------------------------------===//
11 //
12 // This file tests __unordsf2vfp for the compiler_rt library.
13 //
14 //===----------------------------------------------------------------------===//
15 
16 #include <stdlib.h>
17 #include <stdint.h>
18 #include <stdio.h>
19 #include <math.h>
20 
21 
22 extern int __unordsf2vfp(float a, float b);
23 
24 #if __arm__ && __VFP_FP__
test__unordsf2vfp(float a,float b)25 int test__unordsf2vfp(float a, float b)
26 {
27     int actual = __unordsf2vfp(a, b);
28 	int expected = (isnan(a) || isnan(b)) ? 1 : 0;
29     if (actual != expected)
30         printf("error in __unordsf2vfp(%f, %f) = %d, expected %d\n",
31                a, b, actual, expected);
32     return actual != expected;
33 }
34 #endif
35 
main()36 int main()
37 {
38 #if __arm__ && __VFP_FP__
39     if (test__unordsf2vfp(0.0, NAN))
40         return 1;
41     if (test__unordsf2vfp(NAN, 1.0))
42         return 1;
43     if (test__unordsf2vfp(NAN, NAN))
44         return 1;
45     if (test__unordsf2vfp(1.0, 1.0))
46         return 1;
47 #else
48     printf("skipped\n");
49 #endif
50     return 0;
51 }
52