1 /* Test compilation of tgmath macros.
2 Copyright (C) 2001-2022 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
));
256 a
= exp10 (exp10 (x
));
258 a
= pow (pow (x
, a
), pow (c
, b
));
260 a
= hypot (hypot (x
, b
), hypot (c
, a
));
264 a
= floor (floor (x
));
265 b
= fmod (fmod (a
, b
), fmod (c
, x
));
266 a
= nearbyint (nearbyint (x
));
267 b
= round (round (a
));
268 c
= roundeven (roundeven (a
));
269 a
= trunc (trunc (x
));
270 b
= remquo (remquo (a
, b
, &i
), remquo (c
, x
, &i
), &i
);
271 j
= lrint (x
) + lround (a
);
272 k
= llrint (b
) + llround (c
);
273 m
= fromfp (a
, FP_INT_UPWARD
, 2) + fromfpx (b
, FP_INT_DOWNWARD
, 3);
274 um
= ufromfp (c
, FP_INT_TONEAREST
, 4) + ufromfpx (a
, FP_INT_TOWARDZERO
, 5);
277 a
= tgamma (tgamma (x
));
278 b
= lgamma (lgamma (a
));
280 b
= nextafter (nextafter (a
, b
), nextafter (c
, x
));
281 a
= nextdown (nextdown (a
));
282 b
= nexttoward (nexttoward (x
, a
), c
);
283 a
= nextup (nextup (a
));
284 b
= remainder (remainder (a
, b
), remainder (c
, x
));
285 a
= scalb (scalb (x
, a
), (TYPE
) (6));
286 k
= scalbn (a
, 7) + scalbln (c
, 10l);
289 a
= fdim (fdim (x
, a
), fdim (c
, b
));
290 b
= fmax (fmax (a
, x
), fmax (c
, b
));
291 a
= fmin (fmin (x
, a
), fmin (c
, b
));
292 b
= fmaxmag (fmaxmag (a
, x
), fmaxmag (c
, b
));
293 a
= fminmag (fminmag (x
, a
), fminmag (c
, b
));
294 b
= fmaximum (fmaximum (a
, x
), fmaximum (c
, b
));
295 a
= fminimum (fminimum (x
, a
), fminimum (c
, b
));
296 b
= fmaximum_num (fmaximum_num (a
, x
), fmaximum_num (c
, b
));
297 a
= fminimum_num (fminimum_num (x
, a
), fminimum_num (c
, b
));
298 b
= fmaximum_mag (fmaximum_mag (a
, x
), fmaximum_mag (c
, b
));
299 a
= fminimum_mag (fminimum_mag (x
, a
), fminimum_mag (c
, b
));
300 b
= fmaximum_mag_num (fmaximum_mag_num (a
, x
), fmaximum_mag_num (c
, b
));
301 a
= fminimum_mag_num (fminimum_mag_num (x
, a
), fminimum_mag_num (c
, b
));
302 b
= fma (sin (a
), sin (x
), sin (c
));
306 b
= remquo (i
, a
, &i
);
310 x
= a
+ b
+ c
+ i
+ j
+ k
+ m
+ um
;
323 z
= acosh (acosh (d
));
325 z
= asinh (asinh (d
));
327 z
= atanh (atanh (d
));
333 z
= pow (pow (a
, d
), pow (b
, z
));
334 d
= cproj (cproj (z
));
335 z
+= fabs (cproj (a
));
337 b
= creal (creal (d
));
338 c
= cimag (cimag (z
));
339 x
+= a
+ b
+ c
+ i
+ j
+ k
;
342 if (saved_count
!= count
)
383 a
= remquo (y
, y
, &i
);
384 j
= lrint (y
) + lround (y
);
385 k
= llrint (y
) + llround (y
);
386 m
= fromfp (y
, FP_INT_UPWARD
, 6) + fromfpx (y
, FP_INT_DOWNWARD
, 7);
387 um
= (ufromfp (y
, FP_INT_TONEAREST
, 8)
388 + ufromfpx (y
, FP_INT_TOWARDZERO
, 9));
394 a
= nextafter (y
, y
);
395 a
= nexttoward (y
, y
);
396 a
= remainder (y
, y
);
397 a
= scalb (y
, (const TYPE
) (6));
398 k
= scalbn (y
, 7) + scalbln (y
, 10l);
408 a
= fmaximum_num (y
, y
);
409 a
= fminimum_num (y
, y
);
410 a
= fmaximum_mag (y
, y
);
411 a
= fminimum_mag (y
, y
);
412 a
= fmaximum_mag_num (y
, y
);
413 a
= fminimum_mag_num (y
, y
);
418 a
= remquo (i
, y
, &i
);
423 d
= cos ((const complex TYPE
) z
);
424 d
= acos ((const complex TYPE
) z
);
425 d
= sin ((const complex TYPE
) z
);
426 d
= asin ((const complex TYPE
) z
);
427 d
= tan ((const complex TYPE
) z
);
428 d
= atan ((const complex TYPE
) z
);
429 d
= cosh ((const complex TYPE
) z
);
430 d
= acosh ((const complex TYPE
) z
);
431 d
= sinh ((const complex TYPE
) z
);
432 d
= asinh ((const complex TYPE
) z
);
433 d
= tanh ((const complex TYPE
) z
);
434 d
= atanh ((const complex TYPE
) z
);
435 d
= exp ((const complex TYPE
) z
);
436 d
= log ((const complex TYPE
) z
);
437 d
= sqrt ((const complex TYPE
) z
);
438 d
= pow ((const complex TYPE
) z
, (const complex TYPE
) z
);
439 d
= fabs ((const complex TYPE
) z
);
440 d
= carg ((const complex TYPE
) z
);
441 d
= creal ((const complex TYPE
) z
);
442 d
= cimag ((const complex TYPE
) z
);
443 d
= conj ((const complex TYPE
) z
);
444 d
= cproj ((const complex TYPE
) z
);
501 (F(atan2
)) (TYPE x
, TYPE y
)
581 (F(ldexp
)) (TYPE x
, int y
)
589 (F(frexp
)) (TYPE x
, int *y
)
645 (F(pow
)) (TYPE x
, TYPE y
)
661 (F(hypot
)) (TYPE x
, TYPE y
)
701 (F(fmod
)) (TYPE x
, TYPE y
)
709 (F(nearbyint
)) (TYPE x
)
725 (F(roundeven
)) (TYPE x
)
741 (F(remquo
)) (TYPE x
, TYPE y
, int *i
)
773 (F(llround
)) (TYPE x
)
781 (F(fromfp
)) (TYPE x
, int round
, unsigned int width
)
789 (F(fromfpx
)) (TYPE x
, int round
, unsigned int width
)
797 (F(ufromfp
)) (TYPE x
, int round
, unsigned int width
)
805 (F(ufromfpx
)) (TYPE x
, int round
, unsigned int width
)
853 (F(nextafter
)) (TYPE x
, TYPE y
)
861 (F(nextdown
)) (TYPE x
)
869 (F(nexttoward
)) (TYPE x
, long double y
)
885 (F(remainder
)) (TYPE x
, TYPE y
)
893 (F(scalb
)) (TYPE x
, TYPE y
)
901 (F(scalbn
)) (TYPE x
, int y
)
909 (F(scalbln
)) (TYPE x
, long int y
)
933 (F(fdim
)) (TYPE x
, TYPE y
)
941 (F(fmin
)) (TYPE x
, TYPE y
)
949 (F(fmax
)) (TYPE x
, TYPE y
)
957 (F(fminmag
)) (TYPE x
, TYPE y
)
965 (F(fmaxmag
)) (TYPE x
, TYPE y
)
973 (F(fminimum
)) (TYPE x
, TYPE y
)
981 (F(fmaximum
)) (TYPE x
, TYPE y
)
989 (F(fminimum_num
)) (TYPE x
, TYPE y
)
997 (F(fmaximum_num
)) (TYPE x
, TYPE y
)
1005 (F(fminimum_mag
)) (TYPE x
, TYPE y
)
1013 (F(fmaximum_mag
)) (TYPE x
, TYPE y
)
1021 (F(fminimum_mag_num
)) (TYPE x
, TYPE y
)
1029 (F(fmaximum_mag_num
)) (TYPE x
, TYPE y
)
1037 (F(fma
)) (TYPE x
, TYPE y
, TYPE z
)
1045 (F(cacos
)) (complex TYPE x
)
1053 (F(casin
)) (complex TYPE x
)
1061 (F(catan
)) (complex TYPE x
)
1069 (F(ccos
)) (complex TYPE x
)
1077 (F(csin
)) (complex TYPE x
)
1085 (F(ctan
)) (complex TYPE x
)
1093 (F(cacosh
)) (complex TYPE x
)
1101 (F(casinh
)) (complex TYPE x
)
1109 (F(catanh
)) (complex TYPE x
)
1117 (F(ccosh
)) (complex TYPE x
)
1125 (F(csinh
)) (complex TYPE x
)
1133 (F(ctanh
)) (complex TYPE x
)
1141 (F(cexp
)) (complex TYPE x
)
1149 (F(clog
)) (complex TYPE x
)
1157 (F(csqrt
)) (complex TYPE x
)
1165 (F(cpow
)) (complex TYPE x
, complex TYPE y
)
1173 (F(cabs
)) (complex TYPE x
)
1181 (F(carg
)) (complex TYPE x
)
1189 (F(creal
)) (complex TYPE x
)
1197 (F(cimag
)) (complex TYPE x
)
1205 (F(conj
)) (complex TYPE x
)
1213 (F(cproj
)) (complex TYPE x
)