1/* Test compilation of tgmath macros.
2 Copyright (C) 2005-2024 Free Software Foundation, Inc.
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
17 <https://www.gnu.org/licenses/>. */
18
19#include <math.h>
20#include <complex.h>
21#include <tgmath.h>
22#include <stdio.h>
23
24static int errors = 0;
25
26static void
27our_error (const char *c)
28{
29 puts (s: c);
30 ++errors;
31}
32
33#define CHECK_RET_CONST_TYPE(func, rettype, name) \
34 if (sizeof (func) != sizeof (rettype)) \
35 our_error ("Return size of " #name " is " #func" wrong");
36
37#define CHECK_RET_CONST_FLOAT(func, name) \
38 CHECK_RET_CONST_TYPE (func, float, name)
39
40#define CHECK_RET_CONST_DOUBLE(func, name) \
41 CHECK_RET_CONST_TYPE (func, double, name)
42
43static int
44do_test (void)
45{
46 int i;
47 float f;
48 double d;
49
50 CHECK_RET_CONST_DOUBLE (sin (i), "sin (i)");
51 CHECK_RET_CONST_DOUBLE (pow (i, i), "pow (i, i)");
52 CHECK_RET_CONST_DOUBLE (pow (i, i), "pow (i, i)");
53 CHECK_RET_CONST_DOUBLE (pow (i, f), "pow (i, f)");
54 CHECK_RET_CONST_DOUBLE (pow (i, d), "pow (i, d)");
55 CHECK_RET_CONST_DOUBLE (pow (f, i), "pow (f, i)");
56 CHECK_RET_CONST_DOUBLE (pow (d, i), "pow (d, i)");
57 CHECK_RET_CONST_DOUBLE (fma (i, i, i), "fma (i, i, i)");
58 CHECK_RET_CONST_DOUBLE (fma (f, i, i), "fma (f, i, i)");
59 CHECK_RET_CONST_DOUBLE (fma (i, f, i), "fma (i, f, i)");
60 CHECK_RET_CONST_DOUBLE (fma (i, i, f), "fma (i, i, f)");
61 CHECK_RET_CONST_DOUBLE (fma (d, i, i), "fma (d, i, i)");
62 CHECK_RET_CONST_DOUBLE (fma (i, d, i), "fma (i, d, i)");
63 CHECK_RET_CONST_DOUBLE (fma (i, i, d), "fma (i, i, d)");
64
65 return errors != 0;
66}
67
68#define TEST_FUNCTION do_test ()
69#include "../test-skeleton.c"
70

source code of glibc/math/test-tgmath-int.c