1 /* Test compilation of tgmath macros.
2 Copyright (C) 2001-2020 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Jakub Jelinek <jakub@redhat.com> and
5 Ulrich Drepper <drepper@redhat.com>, 2001.
7 The GNU C Library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
12 The GNU C Library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
17 You should have received a copy of the GNU Lesser General Public
18 License along with the GNU C Library; if not, see
19 <https://www.gnu.org/licenses/>. */
30 static void compile_test (void);
31 static void compile_testf (void);
32 #if LDBL_MANT_DIG > DBL_MANT_DIG
33 static void compile_testl (void);
39 const float fy
= 1.25;
40 const double dy
= 1.25;
41 const long double ly
= 1.25;
44 complex long double lz
;
46 volatile int count_double
;
47 volatile int count_float
;
48 volatile int count_ldouble
;
49 volatile int count_cdouble
;
50 volatile int count_cfloat
;
51 volatile int count_cldouble
;
62 count_float
= count_double
= count_ldouble
= 0;
63 count_cfloat
= count_cdouble
= count_cldouble
= 0;
65 if (count_float
!= 0 || count_cfloat
!= 0)
67 puts ("float function called for double test");
70 if (count_ldouble
!= 0 || count_cldouble
!= 0)
72 puts ("long double function called for double test");
75 if (count_double
< NCALLS
+ NCALLS_INT
)
77 printf ("double functions not called often enough (%d)\n",
81 else if (count_double
> NCALLS
+ NCALLS_INT
)
83 printf ("double functions called too often (%d)\n",
87 if (count_cdouble
< NCCALLS
)
89 printf ("double complex functions not called often enough (%d)\n",
93 else if (count_cdouble
> NCCALLS
)
95 printf ("double complex functions called too often (%d)\n",
100 count_float
= count_double
= count_ldouble
= 0;
101 count_cfloat
= count_cdouble
= count_cldouble
= 0;
103 if (count_double
!= 0 || count_cdouble
!= 0)
105 puts ("double function called for float test");
108 if (count_ldouble
!= 0 || count_cldouble
!= 0)
110 puts ("long double function called for float test");
113 if (count_float
< NCALLS
)
115 printf ("float functions not called often enough (%d)\n", count_float
);
118 else if (count_float
> NCALLS
)
120 printf ("float functions called too often (%d)\n",
124 if (count_cfloat
< NCCALLS
)
126 printf ("float complex functions not called often enough (%d)\n",
130 else if (count_cfloat
> NCCALLS
)
132 printf ("float complex functions called too often (%d)\n",
137 #if LDBL_MANT_DIG > DBL_MANT_DIG
138 count_float
= count_double
= count_ldouble
= 0;
139 count_cfloat
= count_cdouble
= count_cldouble
= 0;
141 if (count_float
!= 0 || count_cfloat
!= 0)
143 puts ("float function called for long double test");
146 if (count_double
!= 0 || count_cdouble
!= 0)
148 puts ("double function called for long double test");
151 if (count_ldouble
< NCALLS
)
153 printf ("long double functions not called often enough (%d)\n",
157 else if (count_ldouble
> NCALLS
)
159 printf ("long double functions called too often (%d)\n",
163 if (count_cldouble
< NCCALLS
)
165 printf ("long double complex functions not called often enough (%d)\n",
169 else if (count_cldouble
> NCCALLS
)
171 printf ("long double complex functions called too often (%d)\n",
180 /* Now generate the three functions. */
189 #define count count_double
190 #define ccount count_cdouble
191 #include "test-tgmath.c"
193 #define F(name) name##f
198 #define count count_float
199 #define ccount count_cfloat
200 #include "test-tgmath.c"
202 #if LDBL_MANT_DIG > DBL_MANT_DIG
203 #define F(name) name##l
204 #define TYPE long double
208 #define count count_ldouble
209 #define ccount count_cldouble
210 #include "test-tgmath.c"
213 #define TEST_FUNCTION do_test ()
214 #include "../test-skeleton.c"
219 #define P() puts (__FUNCTION__)
225 F(compile_test
) (void)
242 c
= atan2 (atan2 (a
, c
), atan2 (b
, x
));
244 b
= acosh (acosh (a
));
246 b
= asinh (asinh (a
));
248 b
= atanh (atanh (a
));
251 a
= log10 (log10 (x
));
252 b
= ldexp (ldexp (a
, 1), 5);
253 a
= frexp (frexp (x
, &i
), &i
);
254 b
= expm1 (expm1 (a
));
255 a
= log1p (log1p (x
));
259 a
= pow (pow (x
, a
), pow (c
, b
));
261 a
= hypot (hypot (x
, b
), hypot (c
, a
));
265 a
= floor (floor (x
));
266 b
= fmod (fmod (a
, b
), fmod (c
, x
));
267 a
= nearbyint (nearbyint (x
));
268 b
= round (round (a
));
269 c
= roundeven (roundeven (a
));
270 a
= trunc (trunc (x
));
271 b
= remquo (remquo (a
, b
, &i
), remquo (c
, x
, &i
), &i
);
272 j
= lrint (x
) + lround (a
);
273 k
= llrint (b
) + llround (c
);
274 m
= fromfp (a
, FP_INT_UPWARD
, 2) + fromfpx (b
, FP_INT_DOWNWARD
, 3);
275 um
= ufromfp (c
, FP_INT_TONEAREST
, 4) + ufromfpx (a
, FP_INT_TOWARDZERO
, 5);
278 a
= tgamma (tgamma (x
));
279 b
= lgamma (lgamma (a
));
281 b
= nextafter (nextafter (a
, b
), nextafter (c
, x
));
282 a
= nextdown (nextdown (a
));
283 b
= nexttoward (nexttoward (x
, a
), c
);
284 a
= nextup (nextup (a
));
285 b
= remainder (remainder (a
, b
), remainder (c
, x
));
286 a
= scalb (scalb (x
, a
), (TYPE
) (6));
287 k
= scalbn (a
, 7) + scalbln (c
, 10l);
290 a
= fdim (fdim (x
, a
), fdim (c
, b
));
291 b
= fmax (fmax (a
, x
), fmax (c
, b
));
292 a
= fmin (fmin (x
, a
), fmin (c
, b
));
293 b
= fmaxmag (fmaxmag (a
, x
), fmaxmag (c
, b
));
294 a
= fminmag (fminmag (x
, a
), fminmag (c
, b
));
295 b
= fma (sin (a
), sin (x
), sin (c
));
299 b
= remquo (i
, a
, &i
);
303 x
= a
+ b
+ c
+ i
+ j
+ k
+ m
+ um
;
316 z
= acosh (acosh (d
));
318 z
= asinh (asinh (d
));
320 z
= atanh (atanh (d
));
326 z
= pow (pow (a
, d
), pow (b
, z
));
327 d
= cproj (cproj (z
));
328 z
+= fabs (cproj (a
));
330 b
= creal (creal (d
));
331 c
= cimag (cimag (z
));
332 x
+= a
+ b
+ c
+ i
+ j
+ k
;
335 if (saved_count
!= count
)
375 a
= remquo (y
, y
, &i
);
376 j
= lrint (y
) + lround (y
);
377 k
= llrint (y
) + llround (y
);
378 m
= fromfp (y
, FP_INT_UPWARD
, 6) + fromfpx (y
, FP_INT_DOWNWARD
, 7);
379 um
= (ufromfp (y
, FP_INT_TONEAREST
, 8)
380 + ufromfpx (y
, FP_INT_TOWARDZERO
, 9));
386 a
= nextafter (y
, y
);
387 a
= nexttoward (y
, y
);
388 a
= remainder (y
, y
);
389 a
= scalb (y
, (const TYPE
) (6));
390 k
= scalbn (y
, 7) + scalbln (y
, 10l);
402 a
= remquo (i
, y
, &i
);
407 d
= cos ((const complex TYPE
) z
);
408 d
= acos ((const complex TYPE
) z
);
409 d
= sin ((const complex TYPE
) z
);
410 d
= asin ((const complex TYPE
) z
);
411 d
= tan ((const complex TYPE
) z
);
412 d
= atan ((const complex TYPE
) z
);
413 d
= cosh ((const complex TYPE
) z
);
414 d
= acosh ((const complex TYPE
) z
);
415 d
= sinh ((const complex TYPE
) z
);
416 d
= asinh ((const complex TYPE
) z
);
417 d
= tanh ((const complex TYPE
) z
);
418 d
= atanh ((const complex TYPE
) z
);
419 d
= exp ((const complex TYPE
) z
);
420 d
= log ((const complex TYPE
) z
);
421 d
= sqrt ((const complex TYPE
) z
);
422 d
= pow ((const complex TYPE
) z
, (const complex TYPE
) z
);
423 d
= fabs ((const complex TYPE
) z
);
424 d
= carg ((const complex TYPE
) z
);
425 d
= creal ((const complex TYPE
) z
);
426 d
= cimag ((const complex TYPE
) z
);
427 d
= conj ((const complex TYPE
) z
);
428 d
= cproj ((const complex TYPE
) z
);
485 (F(atan2
)) (TYPE x
, TYPE y
)
565 (F(ldexp
)) (TYPE x
, int y
)
573 (F(frexp
)) (TYPE x
, int *y
)
621 (F(pow
)) (TYPE x
, TYPE y
)
637 (F(hypot
)) (TYPE x
, TYPE y
)
677 (F(fmod
)) (TYPE x
, TYPE y
)
685 (F(nearbyint
)) (TYPE x
)
701 (F(roundeven
)) (TYPE x
)
717 (F(remquo
)) (TYPE x
, TYPE y
, int *i
)
749 (F(llround
)) (TYPE x
)
757 (F(fromfp
)) (TYPE x
, int round
, unsigned int width
)
765 (F(fromfpx
)) (TYPE x
, int round
, unsigned int width
)
773 (F(ufromfp
)) (TYPE x
, int round
, unsigned int width
)
781 (F(ufromfpx
)) (TYPE x
, int round
, unsigned int width
)
829 (F(nextafter
)) (TYPE x
, TYPE y
)
837 (F(nextdown
)) (TYPE x
)
845 (F(nexttoward
)) (TYPE x
, long double y
)
861 (F(remainder
)) (TYPE x
, TYPE y
)
869 (F(scalb
)) (TYPE x
, TYPE y
)
877 (F(scalbn
)) (TYPE x
, int y
)
885 (F(scalbln
)) (TYPE x
, long int y
)
909 (F(fdim
)) (TYPE x
, TYPE y
)
917 (F(fmin
)) (TYPE x
, TYPE y
)
925 (F(fmax
)) (TYPE x
, TYPE y
)
933 (F(fminmag
)) (TYPE x
, TYPE y
)
941 (F(fmaxmag
)) (TYPE x
, TYPE y
)
949 (F(fma
)) (TYPE x
, TYPE y
, TYPE z
)
957 (F(cacos
)) (complex TYPE x
)
965 (F(casin
)) (complex TYPE x
)
973 (F(catan
)) (complex TYPE x
)
981 (F(ccos
)) (complex TYPE x
)
989 (F(csin
)) (complex TYPE x
)
997 (F(ctan
)) (complex TYPE x
)
1005 (F(cacosh
)) (complex TYPE x
)
1013 (F(casinh
)) (complex TYPE x
)
1021 (F(catanh
)) (complex TYPE x
)
1029 (F(ccosh
)) (complex TYPE x
)
1037 (F(csinh
)) (complex TYPE x
)
1045 (F(ctanh
)) (complex TYPE x
)
1053 (F(cexp
)) (complex TYPE x
)
1061 (F(clog
)) (complex TYPE x
)
1069 (F(csqrt
)) (complex TYPE x
)
1077 (F(cpow
)) (complex TYPE x
, complex TYPE y
)
1085 (F(cabs
)) (complex TYPE x
)
1093 (F(carg
)) (complex TYPE x
)
1101 (F(creal
)) (complex TYPE x
)
1109 (F(cimag
)) (complex TYPE x
)
1117 (F(conj
)) (complex TYPE x
)
1125 (F(cproj
)) (complex TYPE x
)