]> git.ipfire.org Git - thirdparty/glibc.git/blame - math/test-tgmath-ret.c
ia64: Regenerate ulps
[thirdparty/glibc.git] / math / test-tgmath-ret.c
CommitLineData
301a6724 1/* Test compilation of tgmath macros.
6d7e8eda 2 Copyright (C) 2003-2023 Free Software Foundation, Inc.
301a6724 3 This file is part of the GNU C Library.
301a6724
UD
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
59ba27a6 16 License along with the GNU C Library; if not, see
5a82c748 17 <https://www.gnu.org/licenses/>. */
301a6724
UD
18
19#include <math.h>
20#include <complex.h>
21#include <tgmath.h>
423c2b9d 22#include <stdint.h>
301a6724
UD
23#include <stdio.h>
24
25static float fx;
26static double dx;
27static long double lx;
423c2b9d
JM
28static int rm = FP_INT_UPWARD;
29static unsigned int width = 64;
301a6724
UD
30static int errors = 0;
31
32static void
33our_error (const char *c)
34{
35 puts (c);
36 ++errors;
37}
38
39/* First function where the return type is constant. */
40
423c2b9d
JM
41#define CHECK_RET_CONST_TYPE(func, rettype, arg, name, ...) \
42 if (sizeof (func (arg, ## __VA_ARGS__)) != sizeof (rettype)) \
301a6724
UD
43 our_error ("Return size of " #func " is wrong with " #name " argument");
44
423c2b9d
JM
45#define CHECK_RET_CONST_FLOAT(func, rettype, ...) \
46 CHECK_RET_CONST_TYPE (func, rettype, fx, float, ## __VA_ARGS__)
47#define CHECK_RET_CONST_DOUBLE(func, rettype, ...) \
48 CHECK_RET_CONST_TYPE (func, rettype, dx, double, ## __VA_ARGS__)
51737193 49#define CHECK_RET_CONST_LDOUBLE(func, rettype, ...) \
423c2b9d 50 CHECK_RET_CONST_TYPE (func, rettype, lx, long double, ## __VA_ARGS__)
301a6724 51
423c2b9d
JM
52#define CHECK_RET_CONST(func, rettype, ...) \
53static void \
54check_return_ ##func (void) \
55{ \
56 CHECK_RET_CONST_FLOAT (func, rettype, ## __VA_ARGS__) \
57 CHECK_RET_CONST_DOUBLE (func, rettype, ## __VA_ARGS__) \
58 CHECK_RET_CONST_LDOUBLE (func, rettype, ## __VA_ARGS__) \
301a6724
UD
59}
60
61CHECK_RET_CONST(ilogb, int)
55a38f82 62CHECK_RET_CONST(llogb, long)
301a6724
UD
63CHECK_RET_CONST(lrint, long)
64CHECK_RET_CONST(lround, long)
65CHECK_RET_CONST(llrint, long long)
66CHECK_RET_CONST(llround, long long)
423c2b9d
JM
67CHECK_RET_CONST(fromfp, intmax_t, rm, width)
68CHECK_RET_CONST(ufromfp, uintmax_t, rm, width)
69CHECK_RET_CONST(fromfpx, intmax_t, rm, width)
70CHECK_RET_CONST(ufromfpx, uintmax_t, rm, width)
301a6724
UD
71
72static int
73do_test (void)
74{
75 check_return_ilogb ();
55a38f82 76 check_return_llogb ();
301a6724
UD
77 check_return_lrint ();
78 check_return_lround ();
79 check_return_llrint ();
80 check_return_llround ();
423c2b9d
JM
81 check_return_fromfp ();
82 check_return_ufromfp ();
83 check_return_fromfpx ();
84 check_return_ufromfpx ();
301a6724 85
de477abc 86 printf ("%zd\n", sizeof (carg (lx)));
301a6724
UD
87
88 return errors != 0;
89}
90
91#define TEST_FUNCTION do_test ()
92#include "../test-skeleton.c"