Add new templates for IEEE wrappers
[glibc.git] / math / test-tgmath-ret.c
blob89c7f5337d05ddc0de1a38f115f5f47249474511
1 /* Test compilation of tgmath macros.
2 Copyright (C) 2003-2017 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Andreas Jaeger <aj@suse.de>, 2003.
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.
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.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
20 #include <math.h>
21 #include <complex.h>
22 #include <tgmath.h>
23 #include <stdint.h>
24 #include <stdio.h>
26 static float fx;
27 static double dx;
28 static long double lx;
29 static int rm = FP_INT_UPWARD;
30 static unsigned int width = 64;
31 static int errors = 0;
33 static void
34 our_error (const char *c)
36 puts (c);
37 ++errors;
40 /* First function where the return type is constant. */
42 #define CHECK_RET_CONST_TYPE(func, rettype, arg, name, ...) \
43 if (sizeof (func (arg, ## __VA_ARGS__)) != sizeof (rettype)) \
44 our_error ("Return size of " #func " is wrong with " #name " argument");
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__)
50 #ifdef NO_LONG_DOUBLE
51 # define CHECK_RET_CONST_LDOUBLE(func, rettype, ...)
52 #else
53 # define CHECK_RET_CONST_LDOUBLE(func, rettype, ...) \
54 CHECK_RET_CONST_TYPE (func, rettype, lx, long double, ## __VA_ARGS__)
55 #endif
57 #define CHECK_RET_CONST(func, rettype, ...) \
58 static void \
59 check_return_ ##func (void) \
60 { \
61 CHECK_RET_CONST_FLOAT (func, rettype, ## __VA_ARGS__) \
62 CHECK_RET_CONST_DOUBLE (func, rettype, ## __VA_ARGS__) \
63 CHECK_RET_CONST_LDOUBLE (func, rettype, ## __VA_ARGS__) \
66 CHECK_RET_CONST(ilogb, int)
67 CHECK_RET_CONST(llogb, long)
68 CHECK_RET_CONST(lrint, long)
69 CHECK_RET_CONST(lround, long)
70 CHECK_RET_CONST(llrint, long long)
71 CHECK_RET_CONST(llround, long long)
72 CHECK_RET_CONST(fromfp, intmax_t, rm, width)
73 CHECK_RET_CONST(ufromfp, uintmax_t, rm, width)
74 CHECK_RET_CONST(fromfpx, intmax_t, rm, width)
75 CHECK_RET_CONST(ufromfpx, uintmax_t, rm, width)
77 static int
78 do_test (void)
80 check_return_ilogb ();
81 check_return_llogb ();
82 check_return_lrint ();
83 check_return_lround ();
84 check_return_llrint ();
85 check_return_llround ();
86 check_return_fromfp ();
87 check_return_ufromfp ();
88 check_return_fromfpx ();
89 check_return_ufromfpx ();
91 printf ("%Zd\n", sizeof(carg (lx)));
93 return errors != 0;
96 #define TEST_FUNCTION do_test ()
97 #include "../test-skeleton.c"