1 /* Test compilation of tgmath macros.
2 Copyright (C) 2001-2021 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
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.
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.
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/>. */
28 static void compile_test (void);
29 static void compile_testf (void);
30 #if LDBL_MANT_DIG > DBL_MANT_DIG
31 static void compile_testl (void);
37 const float fy = 1.25;
38 const double dy = 1.25;
39 const long double ly = 1.25;
42 complex long double lz;
44 volatile int count_double;
45 volatile int count_float;
46 volatile int count_ldouble;
47 volatile int count_cdouble;
48 volatile int count_cfloat;
49 volatile int count_cldouble;
60 count_float = count_double = count_ldouble = 0;
61 count_cfloat = count_cdouble = count_cldouble = 0;
63 if (count_float != 0 || count_cfloat != 0)
65 puts ("float function called for double test");
68 if (count_ldouble != 0 || count_cldouble != 0)
70 puts ("long double function called for double test");
73 if (count_double < NCALLS + NCALLS_INT)
75 printf ("double functions not called often enough (%d)\n",
79 else if (count_double > NCALLS + NCALLS_INT)
81 printf ("double functions called too often (%d)\n",
85 if (count_cdouble < NCCALLS)
87 printf ("double complex functions not called often enough (%d)\n",
91 else if (count_cdouble > NCCALLS)
93 printf ("double complex functions called too often (%d)\n",
98 count_float = count_double = count_ldouble = 0;
99 count_cfloat = count_cdouble = count_cldouble = 0;
101 if (count_double != 0 || count_cdouble != 0)
103 puts ("double function called for float test");
106 if (count_ldouble != 0 || count_cldouble != 0)
108 puts ("long double function called for float test");
111 if (count_float < NCALLS)
113 printf ("float functions not called often enough (%d)\n", count_float);
116 else if (count_float > NCALLS)
118 printf ("float functions called too often (%d)\n",
122 if (count_cfloat < NCCALLS)
124 printf ("float complex functions not called often enough (%d)\n",
128 else if (count_cfloat > NCCALLS)
130 printf ("float complex functions called too often (%d)\n",
135 #if LDBL_MANT_DIG > DBL_MANT_DIG
136 count_float = count_double = count_ldouble = 0;
137 count_cfloat = count_cdouble = count_cldouble = 0;
139 if (count_float != 0 || count_cfloat != 0)
141 puts ("float function called for long double test");
144 if (count_double != 0 || count_cdouble != 0)
146 puts ("double function called for long double test");
149 if (count_ldouble < NCALLS)
151 printf ("long double functions not called often enough (%d)\n",
155 else if (count_ldouble > NCALLS)
157 printf ("long double functions called too often (%d)\n",
161 if (count_cldouble < NCCALLS)
163 printf ("long double complex functions not called often enough (%d)\n",
167 else if (count_cldouble > NCCALLS)
169 printf ("long double complex functions called too often (%d)\n",
178 /* Now generate the three functions. */
187 #define count count_double
188 #define ccount count_cdouble
189 #include "test-tgmath.c"
191 #define F(name) name##f
196 #define count count_float
197 #define ccount count_cfloat
198 #include "test-tgmath.c"
200 #if LDBL_MANT_DIG > DBL_MANT_DIG
201 #define F(name) name##l
202 #define TYPE long double
206 #define count count_ldouble
207 #define ccount count_cldouble
208 #include "test-tgmath.c"
211 #define TEST_FUNCTION do_test ()
212 #include "../test-skeleton.c"
217 #define P() puts (__FUNCTION__)
223 F(compile_test) (void)
240 c = atan2 (atan2 (a, c), atan2 (b, x));
242 b = acosh (acosh (a));
244 b = asinh (asinh (a));
246 b = atanh (atanh (a));
249 a = log10 (log10 (x));
250 b = ldexp (ldexp (a, 1), 5);
251 a = frexp (frexp (x, &i), &i);
252 b = expm1 (expm1 (a));
253 a = log1p (log1p (x));
257 a = pow (pow (x, a), pow (c, b));
259 a = hypot (hypot (x, b), hypot (c, a));
263 a = floor (floor (x));
264 b = fmod (fmod (a, b), fmod (c, x));
265 a = nearbyint (nearbyint (x));
266 b = round (round (a));
267 c = roundeven (roundeven (a));
268 a = trunc (trunc (x));
269 b = remquo (remquo (a, b, &i), remquo (c, x, &i), &i);
270 j = lrint (x) + lround (a);
271 k = llrint (b) + llround (c);
272 m = fromfp (a, FP_INT_UPWARD, 2) + fromfpx (b, FP_INT_DOWNWARD, 3);
273 um = ufromfp (c, FP_INT_TONEAREST, 4) + ufromfpx (a, FP_INT_TOWARDZERO, 5);
276 a = tgamma (tgamma (x));
277 b = lgamma (lgamma (a));
279 b = nextafter (nextafter (a, b), nextafter (c, x));
280 a = nextdown (nextdown (a));
281 b = nexttoward (nexttoward (x, a), c);
282 a = nextup (nextup (a));
283 b = remainder (remainder (a, b), remainder (c, x));
284 a = scalb (scalb (x, a), (TYPE) (6));
285 k = scalbn (a, 7) + scalbln (c, 10l);
288 a = fdim (fdim (x, a), fdim (c, b));
289 b = fmax (fmax (a, x), fmax (c, b));
290 a = fmin (fmin (x, a), fmin (c, b));
291 b = fmaxmag (fmaxmag (a, x), fmaxmag (c, b));
292 a = fminmag (fminmag (x, a), fminmag (c, b));
293 b = fma (sin (a), sin (x), sin (c));
297 b = remquo (i, a, &i);
301 x = a + b + c + i + j + k + m + um;
314 z = acosh (acosh (d));
316 z = asinh (asinh (d));
318 z = atanh (atanh (d));
324 z = pow (pow (a, d), pow (b, z));
325 d = cproj (cproj (z));
326 z += fabs (cproj (a));
328 b = creal (creal (d));
329 c = cimag (cimag (z));
330 x += a + b + c + i + j + k;
333 if (saved_count != count)
373 a = remquo (y, y, &i);
374 j = lrint (y) + lround (y);
375 k = llrint (y) + llround (y);
376 m = fromfp (y, FP_INT_UPWARD, 6) + fromfpx (y, FP_INT_DOWNWARD, 7);
377 um = (ufromfp (y, FP_INT_TONEAREST, 8)
378 + ufromfpx (y, FP_INT_TOWARDZERO, 9));
384 a = nextafter (y, y);
385 a = nexttoward (y, y);
386 a = remainder (y, y);
387 a = scalb (y, (const TYPE) (6));
388 k = scalbn (y, 7) + scalbln (y, 10l);
400 a = remquo (i, y, &i);
405 d = cos ((const complex TYPE) z);
406 d = acos ((const complex TYPE) z);
407 d = sin ((const complex TYPE) z);
408 d = asin ((const complex TYPE) z);
409 d = tan ((const complex TYPE) z);
410 d = atan ((const complex TYPE) z);
411 d = cosh ((const complex TYPE) z);
412 d = acosh ((const complex TYPE) z);
413 d = sinh ((const complex TYPE) z);
414 d = asinh ((const complex TYPE) z);
415 d = tanh ((const complex TYPE) z);
416 d = atanh ((const complex TYPE) z);
417 d = exp ((const complex TYPE) z);
418 d = log ((const complex TYPE) z);
419 d = sqrt ((const complex TYPE) z);
420 d = pow ((const complex TYPE) z, (const complex TYPE) z);
421 d = fabs ((const complex TYPE) z);
422 d = carg ((const complex TYPE) z);
423 d = creal ((const complex TYPE) z);
424 d = cimag ((const complex TYPE) z);
425 d = conj ((const complex TYPE) z);
426 d = cproj ((const complex TYPE) z);
483 (F(atan2)) (TYPE x, TYPE y)
563 (F(ldexp)) (TYPE x, int y)
571 (F(frexp)) (TYPE x, int *y)
619 (F(pow)) (TYPE x, TYPE y)
635 (F(hypot)) (TYPE x, TYPE y)
675 (F(fmod)) (TYPE x, TYPE y)
683 (F(nearbyint)) (TYPE x)
699 (F(roundeven)) (TYPE x)
715 (F(remquo)) (TYPE x, TYPE y, int *i)
747 (F(llround)) (TYPE x)
755 (F(fromfp)) (TYPE x, int round, unsigned int width)
763 (F(fromfpx)) (TYPE x, int round, unsigned int width)
771 (F(ufromfp)) (TYPE x, int round, unsigned int width)
779 (F(ufromfpx)) (TYPE x, int round, unsigned int width)
827 (F(nextafter)) (TYPE x, TYPE y)
835 (F(nextdown)) (TYPE x)
843 (F(nexttoward)) (TYPE x, long double y)
859 (F(remainder)) (TYPE x, TYPE y)
867 (F(scalb)) (TYPE x, TYPE y)
875 (F(scalbn)) (TYPE x, int y)
883 (F(scalbln)) (TYPE x, long int y)
907 (F(fdim)) (TYPE x, TYPE y)
915 (F(fmin)) (TYPE x, TYPE y)
923 (F(fmax)) (TYPE x, TYPE y)
931 (F(fminmag)) (TYPE x, TYPE y)
939 (F(fmaxmag)) (TYPE x, TYPE y)
947 (F(fma)) (TYPE x, TYPE y, TYPE z)
955 (F(cacos)) (complex TYPE x)
963 (F(casin)) (complex TYPE x)
971 (F(catan)) (complex TYPE x)
979 (F(ccos)) (complex TYPE x)
987 (F(csin)) (complex TYPE x)
995 (F(ctan)) (complex TYPE x)
1003 (F(cacosh)) (complex TYPE x)
1011 (F(casinh)) (complex TYPE x)
1019 (F(catanh)) (complex TYPE x)
1027 (F(ccosh)) (complex TYPE x)
1035 (F(csinh)) (complex TYPE x)
1043 (F(ctanh)) (complex TYPE x)
1051 (F(cexp)) (complex TYPE x)
1059 (F(clog)) (complex TYPE x)
1067 (F(csqrt)) (complex TYPE x)
1075 (F(cpow)) (complex TYPE x, complex TYPE y)
1083 (F(cabs)) (complex TYPE x)
1091 (F(carg)) (complex TYPE x)
1099 (F(creal)) (complex TYPE x)
1107 (F(cimag)) (complex TYPE x)
1115 (F(conj)) (complex TYPE x)
1123 (F(cproj)) (complex TYPE x)