1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_fixtfsi
3 //===--------------- fixtfsi_test.c - Test __fixtfsi ----------------------===//
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
9 //===----------------------------------------------------------------------===//
11 // This file tests __fixtfsi for the compiler_rt library.
13 //===----------------------------------------------------------------------===//
17 #if __LDBL_MANT_DIG__ == 113
21 int __fixtfsi(long double a
);
23 int test__fixtfsi(long double a
, int expected
)
26 int ret
= (x
!= expected
);
29 printf("error in test__fixtfsi(%.20Lf) = %d, "
30 "expected %d\n", a
, x
, expected
);
35 char assumption_1
[sizeof(long double) * CHAR_BIT
== 128] = {0};
41 #if __LDBL_MANT_DIG__ == 113
42 if (test__fixtfsi(makeInf128(), 0x7fffffff))
44 if (test__fixtfsi(0, 0x0))
46 if (test__fixtfsi(0x1.23456789abcdefp
+5, 0x24))
48 if (test__fixtfsi(0x1.23456789abcdefp
-3, 0x0))
50 if (test__fixtfsi(0x1.23456789abcdefp
+20, 0x123456))
52 if (test__fixtfsi(0x1.23456789abcdefp
+40, 0x7fffffff))
54 if (test__fixtfsi(0x1.23456789abcdefp
+256, 0x7fffffff))
56 if (test__fixtfsi(-0x1.23456789abcdefp
+20, 0xffedcbaa))
58 if (test__fixtfsi(-0x1.23456789abcdefp
+40, 0x80000000))