]>
Commit | Line | Data |
---|---|---|
301a6724 | 1 | /* Test compilation of tgmath macros. |
04277e02 | 2 | Copyright (C) 2003-2019 Free Software Foundation, Inc. |
301a6724 UD |
3 | This file is part of the GNU C Library. |
4 | Contributed by Andreas Jaeger <aj@suse.de>, 2003. | |
5 | ||
6 | The GNU C Library is free software; you can redistribute it and/or | |
7 | modify it under the terms of the GNU Lesser General Public | |
8 | License as published by the Free Software Foundation; either | |
9 | version 2.1 of the License, or (at your option) any later version. | |
10 | ||
11 | The GNU C Library is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | Lesser General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU Lesser General Public | |
59ba27a6 | 17 | License along with the GNU C Library; if not, see |
5a82c748 | 18 | <https://www.gnu.org/licenses/>. */ |
301a6724 UD |
19 | |
20 | #include <math.h> | |
21 | #include <complex.h> | |
22 | #include <tgmath.h> | |
423c2b9d | 23 | #include <stdint.h> |
301a6724 UD |
24 | #include <stdio.h> |
25 | ||
26 | static float fx; | |
27 | static double dx; | |
28 | static long double lx; | |
423c2b9d JM |
29 | static int rm = FP_INT_UPWARD; |
30 | static unsigned int width = 64; | |
301a6724 UD |
31 | static int errors = 0; |
32 | ||
33 | static void | |
34 | our_error (const char *c) | |
35 | { | |
36 | puts (c); | |
37 | ++errors; | |
38 | } | |
39 | ||
40 | /* First function where the return type is constant. */ | |
41 | ||
423c2b9d JM |
42 | #define CHECK_RET_CONST_TYPE(func, rettype, arg, name, ...) \ |
43 | if (sizeof (func (arg, ## __VA_ARGS__)) != sizeof (rettype)) \ | |
301a6724 UD |
44 | our_error ("Return size of " #func " is wrong with " #name " argument"); |
45 | ||
423c2b9d JM |
46 | #define CHECK_RET_CONST_FLOAT(func, rettype, ...) \ |
47 | CHECK_RET_CONST_TYPE (func, rettype, fx, float, ## __VA_ARGS__) | |
48 | #define CHECK_RET_CONST_DOUBLE(func, rettype, ...) \ | |
49 | CHECK_RET_CONST_TYPE (func, rettype, dx, double, ## __VA_ARGS__) | |
51737193 | 50 | #define CHECK_RET_CONST_LDOUBLE(func, rettype, ...) \ |
423c2b9d | 51 | CHECK_RET_CONST_TYPE (func, rettype, lx, long double, ## __VA_ARGS__) |
301a6724 | 52 | |
423c2b9d JM |
53 | #define CHECK_RET_CONST(func, rettype, ...) \ |
54 | static void \ | |
55 | check_return_ ##func (void) \ | |
56 | { \ | |
57 | CHECK_RET_CONST_FLOAT (func, rettype, ## __VA_ARGS__) \ | |
58 | CHECK_RET_CONST_DOUBLE (func, rettype, ## __VA_ARGS__) \ | |
59 | CHECK_RET_CONST_LDOUBLE (func, rettype, ## __VA_ARGS__) \ | |
301a6724 UD |
60 | } |
61 | ||
62 | CHECK_RET_CONST(ilogb, int) | |
55a38f82 | 63 | CHECK_RET_CONST(llogb, long) |
301a6724 UD |
64 | CHECK_RET_CONST(lrint, long) |
65 | CHECK_RET_CONST(lround, long) | |
66 | CHECK_RET_CONST(llrint, long long) | |
67 | CHECK_RET_CONST(llround, long long) | |
423c2b9d JM |
68 | CHECK_RET_CONST(fromfp, intmax_t, rm, width) |
69 | CHECK_RET_CONST(ufromfp, uintmax_t, rm, width) | |
70 | CHECK_RET_CONST(fromfpx, intmax_t, rm, width) | |
71 | CHECK_RET_CONST(ufromfpx, uintmax_t, rm, width) | |
301a6724 UD |
72 | |
73 | static int | |
74 | do_test (void) | |
75 | { | |
76 | check_return_ilogb (); | |
55a38f82 | 77 | check_return_llogb (); |
301a6724 UD |
78 | check_return_lrint (); |
79 | check_return_lround (); | |
80 | check_return_llrint (); | |
81 | check_return_llround (); | |
423c2b9d JM |
82 | check_return_fromfp (); |
83 | check_return_ufromfp (); | |
84 | check_return_fromfpx (); | |
85 | check_return_ufromfpx (); | |
301a6724 | 86 | |
c4f50205 | 87 | printf ("%Zd\n", sizeof (carg (lx))); |
301a6724 UD |
88 | |
89 | return errors != 0; | |
90 | } | |
91 | ||
92 | #define TEST_FUNCTION do_test () | |
93 | #include "../test-skeleton.c" |