]> git.proxmox.com Git - rustc.git/blame - src/compiler-rt/test/builtins/Unit/fixtfdi_test.c
New upstream version 1.19.0+dfsg3
[rustc.git] / src / compiler-rt / test / builtins / Unit / fixtfdi_test.c
CommitLineData
92a42be0
SL
1//===--------------- fixtfdi_test.c - Test __fixtfdi ----------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file tests __fixtfdi for the compiler_rt library.
11//
12//===----------------------------------------------------------------------===//
13
14#include "int_lib.h"
15#include <stdio.h>
16
17#if __LDBL_MANT_DIG__ == 113
18
19#include "fp_test.h"
20
21di_int __fixtfdi(long double a);
22
23int test__fixtfdi(long double a, di_int expected)
24{
25 di_int x = __fixtfdi(a);
26 int ret = (x != expected);
27
28 if (ret)
29 {
30 printf("error in test__fixtfdi(%.20Lf) = %llX, "
31 "expected %llX\n", a, x, expected);
32 }
33 return ret;
34}
35
36char assumption_1[sizeof(long double) * CHAR_BIT == 128] = {0};
37
38#endif
39
40int main()
41{
42#if __LDBL_MANT_DIG__ == 113
43 if (test__fixtfdi(makeInf128(), 0x7fffffffffffffffLL))
44 return 1;
45 if (test__fixtfdi(0, 0x0))
46 return 1;
47 if (test__fixtfdi(0x1.23456789abcdefp+5L, 0x24LL))
48 return 1;
49 if (test__fixtfdi(0x1.23456789abcdefp-3L, 0x0LL))
50 return 1;
51 if (test__fixtfdi(0x1.23456789abcdef12345678p+20L, 0x123456LL))
52 return 1;
53 if (test__fixtfdi(0x1.23456789abcdef12345678p+40L, 0x123456789abLL))
54 return 1;
55 if (test__fixtfdi(0x1.23456789abcdef12345678p+60L, 0x123456789abcdef1LL))
56 return 1;
57 if (test__fixtfdi(0x1.23456789abcdefp+256L, 0x7fffffffffffffffLL))
58 return 1;
59 if (test__fixtfdi(-0x1.23456789abcdefp+20L, 0xffffffffffedcbaaLL))
60 return 1;
61 if (test__fixtfdi(-0x1.23456789abcdefp+40L, 0xfffffedcba987655LL))
62 return 1;
63 if (test__fixtfdi(-0x1.23456789abcdefp+256L, 0x8000000000000000LL))
64 return 1;
65
66#else
67 printf("skipped\n");
68
69#endif
70 return 0;
71}