]>
Commit | Line | Data |
---|---|---|
cc6a8d74 | 1 | /* Test totalorderl and totalordermagl for ldbl-96. |
04277e02 | 2 | Copyright (C) 2016-2019 Free Software Foundation, Inc. |
5e9d98a3 JM |
3 | This file is part of the GNU C Library. |
4 | ||
5 | The GNU C Library is free software; you can redistribute it and/or | |
6 | modify it under the terms of the GNU Lesser General Public | |
7 | License as published by the Free Software Foundation; either | |
8 | version 2.1 of the License, or (at your option) any later version. | |
9 | ||
10 | The GNU C Library is distributed in the hope that it will be useful, | |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | Lesser General Public License for more details. | |
14 | ||
15 | You should have received a copy of the GNU Lesser General Public | |
16 | License along with the GNU C Library; if not, see | |
5a82c748 | 17 | <https://www.gnu.org/licenses/>. */ |
5e9d98a3 JM |
18 | |
19 | #include <float.h> | |
20 | #include <math.h> | |
963394a2 | 21 | #include <math_ldbl.h> |
5e9d98a3 JM |
22 | #include <stdbool.h> |
23 | #include <stdint.h> | |
24 | #include <stdio.h> | |
25 | ||
26 | static const uint64_t tests[] = | |
27 | { | |
28 | 0, 1, 0x4000000000000000ULL, 0x4000000000000001ULL, | |
29 | 0x7fffffffffffffffULL | |
30 | }; | |
31 | ||
32 | static int | |
33 | do_test (void) | |
34 | { | |
35 | int result = 0; | |
36 | ||
37 | if (LDBL_MIN_EXP == -16382) | |
38 | for (size_t i = 0; i < sizeof (tests) / sizeof (tests[0]); i++) | |
39 | { | |
40 | long double ldx, ldy, ldnx, ldny; | |
41 | /* Verify that the high bit of the mantissa is ignored for | |
42 | infinities and NaNs for the M68K variant of this | |
43 | format. */ | |
44 | SET_LDOUBLE_WORDS (ldx, 0x7fff, | |
45 | tests[i] >> 32, tests[i] & 0xffffffffULL); | |
46 | SET_LDOUBLE_WORDS (ldy, 0x7fff, | |
47 | (tests[i] >> 32) | 0x80000000, | |
48 | tests[i] & 0xffffffffULL); | |
49 | SET_LDOUBLE_WORDS (ldnx, 0xffff, | |
50 | tests[i] >> 32, tests[i] & 0xffffffffULL); | |
51 | SET_LDOUBLE_WORDS (ldny, 0xffff, | |
52 | (tests[i] >> 32) | 0x80000000, | |
53 | tests[i] & 0xffffffffULL); | |
42760d76 JM |
54 | bool to1 = totalorderl (&ldx, &ldy); |
55 | bool to2 = totalorderl (&ldy, &ldx); | |
56 | bool to3 = totalorderl (&ldnx, &ldny); | |
57 | bool to4 = totalorderl (&ldny, &ldnx); | |
5e9d98a3 JM |
58 | if (to1 && to2 && to3 && to4) |
59 | printf ("PASS: test %zu\n", i); | |
60 | else | |
61 | { | |
62 | printf ("FAIL: test %zu\n", i); | |
63 | result = 1; | |
64 | } | |
42760d76 JM |
65 | to1 = totalordermagl (&ldx, &ldy); |
66 | to2 = totalordermagl (&ldy, &ldx); | |
67 | to3 = totalordermagl (&ldnx, &ldny); | |
68 | to4 = totalordermagl (&ldny, &ldnx); | |
cc6a8d74 JM |
69 | if (to1 && to2 && to3 && to4) |
70 | printf ("PASS: test %zu (totalordermagl)\n", i); | |
71 | else | |
72 | { | |
73 | printf ("FAIL: test %zu (totalordermagl)\n", i); | |
74 | result = 1; | |
75 | } | |
5e9d98a3 JM |
76 | } |
77 | ||
78 | return result; | |
79 | } | |
80 | ||
81 | #define TEST_FUNCTION do_test () | |
82 | #include "../test-skeleton.c" |