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