1// RUN: %clang_builtins %s %librt -o %t && %run %t
2// REQUIRES: librt_has_truncdfsf2vfp
3
4#include "int_lib.h"
5#include <stdio.h>
6#include <stdlib.h>
7#include <math.h>
8
9
10extern COMPILER_RT_ABI float __truncdfsf2vfp(double a);
11
12#if defined(__arm__) && defined(__ARM_FP) && (__ARM_FP & 0x8)
13int test__truncdfsf2vfp(double a)
14{
15 float actual = __truncdfsf2vfp(a);
16 float expected = a;
17 if (actual != expected)
18 printf("error in test__truncdfsf2vfp(%f) = %f, expected %f\n",
19 a, actual, expected);
20 return actual != expected;
21}
22#endif
23
24int main()
25{
26#if defined(__arm__) && defined(__ARM_FP) && (__ARM_FP & 0x8)
27 if (test__truncdfsf2vfp(0.0))
28 return 1;
29 if (test__truncdfsf2vfp(1.0))
30 return 1;
31 if (test__truncdfsf2vfp(-1.0))
32 return 1;
33 if (test__truncdfsf2vfp(3.1415926535))
34 return 1;
35 if (test__truncdfsf2vfp(123.456))
36 return 1;
37#else
38 printf(format: "skipped\n");
39#endif
40 return 0;
41}
42

source code of compiler-rt/test/builtins/Unit/truncdfsf2vfp_test.c