]> git.proxmox.com Git - rustc.git/blob - src/libcompiler_builtins/compiler-rt/test/builtins/Unit/fixtfsi_test.c
New upstream version 1.25.0+dfsg1
[rustc.git] / src / libcompiler_builtins / compiler-rt / test / builtins / Unit / fixtfsi_test.c
1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 //===--------------- fixtfsi_test.c - Test __fixtfsi ----------------------===//
3 //
4 // The LLVM Compiler Infrastructure
5 //
6 // This file is dual licensed under the MIT and the University of Illinois Open
7 // Source Licenses. See LICENSE.TXT for details.
8 //
9 //===----------------------------------------------------------------------===//
10 //
11 // This file tests __fixtfsi for the compiler_rt library.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #include <stdio.h>
16
17 #if __LDBL_MANT_DIG__ == 113
18
19 #include "fp_test.h"
20
21 int __fixtfsi(long double a);
22
23 int test__fixtfsi(long double a, int expected)
24 {
25 int x = __fixtfsi(a);
26 int ret = (x != expected);
27
28 if (ret){
29 printf("error in test__fixtfsi(%.20Lf) = %d, "
30 "expected %d\n", a, x, expected);
31 }
32 return ret;
33 }
34
35 char assumption_1[sizeof(long double) * CHAR_BIT == 128] = {0};
36
37 #endif
38
39 int main()
40 {
41 #if __LDBL_MANT_DIG__ == 113
42 if (test__fixtfsi(makeInf128(), 0x7fffffff))
43 return 1;
44 if (test__fixtfsi(0, 0x0))
45 return 1;
46 if (test__fixtfsi(0x1.23456789abcdefp+5, 0x24))
47 return 1;
48 if (test__fixtfsi(0x1.23456789abcdefp-3, 0x0))
49 return 1;
50 if (test__fixtfsi(0x1.23456789abcdefp+20, 0x123456))
51 return 1;
52 if (test__fixtfsi(0x1.23456789abcdefp+40, 0x7fffffff))
53 return 1;
54 if (test__fixtfsi(0x1.23456789abcdefp+256, 0x7fffffff))
55 return 1;
56 if (test__fixtfsi(-0x1.23456789abcdefp+20, 0xffedcbaa))
57 return 1;
58 if (test__fixtfsi(-0x1.23456789abcdefp+40, 0x80000000))
59 return 1;
60
61 #else
62 printf("skipped\n");
63
64 #endif
65 return 0;
66 }