1 /* Test compilation of tgmath macros.
2 Copyright (C) 2001-2017 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 <http://www.gnu.org/licenses/>. */
22 #undef __NO_MATH_INLINES
23 #define __NO_MATH_INLINES 1
32 static void compile_test (void);
33 static void compile_testf (void);
34 #if LDBL_MANT_DIG > DBL_MANT_DIG
35 static void compile_testl (void);
41 const float fy
= 1.25;
42 const double dy
= 1.25;
43 const long double ly
= 1.25;
46 complex long double lz
;
64 count_float
= count_double
= count_ldouble
= 0;
65 count_cfloat
= count_cdouble
= count_cldouble
= 0;
67 if (count_float
!= 0 || count_cfloat
!= 0)
69 puts ("float function called for double test");
72 if (count_ldouble
!= 0 || count_cldouble
!= 0)
74 puts ("long double function called for double test");
77 if (count_double
< NCALLS
+ NCALLS_INT
)
79 printf ("double functions not called often enough (%d)\n",
83 else if (count_double
> NCALLS
+ NCALLS_INT
)
85 printf ("double functions called too often (%d)\n",
89 if (count_cdouble
< NCCALLS
)
91 printf ("double complex functions not called often enough (%d)\n",
95 else if (count_cdouble
> NCCALLS
)
97 printf ("double complex functions called too often (%d)\n",
102 count_float
= count_double
= count_ldouble
= 0;
103 count_cfloat
= count_cdouble
= count_cldouble
= 0;
105 if (count_double
!= 0 || count_cdouble
!= 0)
107 puts ("double function called for float test");
110 if (count_ldouble
!= 0 || count_cldouble
!= 0)
112 puts ("long double function called for float test");
115 if (count_float
< NCALLS
)
117 printf ("float functions not called often enough (%d)\n", count_float
);
120 else if (count_float
> NCALLS
)
122 printf ("float functions called too often (%d)\n",
126 if (count_cfloat
< NCCALLS
)
128 printf ("float complex functions not called often enough (%d)\n",
132 else if (count_cfloat
> NCCALLS
)
134 printf ("float complex functions called too often (%d)\n",
139 #if LDBL_MANT_DIG > DBL_MANT_DIG
140 count_float
= count_double
= count_ldouble
= 0;
141 count_cfloat
= count_cdouble
= count_cldouble
= 0;
143 if (count_float
!= 0 || count_cfloat
!= 0)
145 puts ("float function called for long double test");
148 if (count_double
!= 0 || count_cdouble
!= 0)
150 puts ("double function called for long double test");
153 if (count_ldouble
< NCALLS
)
155 printf ("long double functions not called often enough (%d)\n",
159 else if (count_ldouble
> NCALLS
)
161 printf ("long double functions called too often (%d)\n",
165 if (count_cldouble
< NCCALLS
)
167 printf ("long double complex functions not called often enough (%d)\n",
171 else if (count_cldouble
> NCCALLS
)
173 printf ("long double complex functions called too often (%d)\n",
182 /* Now generate the three functions. */
191 #define count count_double
192 #define ccount count_cdouble
193 #include "test-tgmath.c"
195 #define F(name) name##f
200 #define count count_float
201 #define ccount count_cfloat
202 #include "test-tgmath.c"
204 #if LDBL_MANT_DIG > DBL_MANT_DIG
205 #define F(name) name##l
206 #define TYPE long double
210 #define count count_ldouble
211 #define ccount count_cldouble
212 #include "test-tgmath.c"
215 #define TEST_FUNCTION do_test ()
216 #include "../test-skeleton.c"
221 #define P() puts (__FUNCTION__)
227 F(compile_test
) (void)
244 c
= atan2 (atan2 (a
, c
), atan2 (b
, x
));
246 b
= acosh (acosh (a
));
248 b
= asinh (asinh (a
));
250 b
= atanh (atanh (a
));
253 a
= log10 (log10 (x
));
254 b
= ldexp (ldexp (a
, 1), 5);
255 a
= frexp (frexp (x
, &i
), &i
);
256 b
= expm1 (expm1 (a
));
257 a
= log1p (log1p (x
));
261 a
= pow (pow (x
, a
), pow (c
, b
));
263 a
= hypot (hypot (x
, b
), hypot (c
, a
));
267 a
= floor (floor (x
));
268 b
= fmod (fmod (a
, b
), fmod (c
, x
));
269 a
= nearbyint (nearbyint (x
));
270 b
= round (round (a
));
271 c
= roundeven (roundeven (a
));
272 a
= trunc (trunc (x
));
273 b
= remquo (remquo (a
, b
, &i
), remquo (c
, x
, &i
), &i
);
274 j
= lrint (x
) + lround (a
);
275 k
= llrint (b
) + llround (c
);
276 m
= fromfp (a
, FP_INT_UPWARD
, 2) + fromfpx (b
, FP_INT_DOWNWARD
, 3);
277 um
= ufromfp (c
, FP_INT_TONEAREST
, 4) + ufromfpx (a
, FP_INT_TOWARDZERO
, 5);
280 a
= tgamma (tgamma (x
));
281 b
= lgamma (lgamma (a
));
283 b
= nextafter (nextafter (a
, b
), nextafter (c
, x
));
284 a
= nextdown (nextdown (a
));
285 b
= nexttoward (nexttoward (x
, a
), c
);
286 a
= nextup (nextup (a
));
287 b
= remainder (remainder (a
, b
), remainder (c
, x
));
288 a
= scalb (scalb (x
, a
), (TYPE
) (6));
289 k
= scalbn (a
, 7) + scalbln (c
, 10l);
292 a
= fdim (fdim (x
, a
), fdim (c
, b
));
293 b
= fmax (fmax (a
, x
), fmax (c
, b
));
294 a
= fmin (fmin (x
, a
), fmin (c
, b
));
295 b
= fmaxmag (fmaxmag (a
, x
), fmaxmag (c
, b
));
296 a
= fminmag (fminmag (x
, a
), fminmag (c
, b
));
297 b
= fma (sin (a
), sin (x
), sin (c
));
298 a
= totalorder (x
, b
);
299 b
= totalordermag (x
, a
);
303 b
= remquo (i
, a
, &i
);
307 x
= a
+ b
+ c
+ i
+ j
+ k
+ m
+ um
;
320 z
= acosh (acosh (d
));
322 z
= asinh (asinh (d
));
324 z
= atanh (atanh (d
));
330 z
= pow (pow (a
, d
), pow (b
, z
));
331 d
= cproj (cproj (z
));
332 z
+= fabs (cproj (a
));
334 b
= creal (creal (d
));
335 c
= cimag (cimag (z
));
336 x
+= a
+ b
+ c
+ i
+ j
+ k
;
339 if (saved_count
!= count
)
379 a
= remquo (y
, y
, &i
);
380 j
= lrint (y
) + lround (y
);
381 k
= llrint (y
) + llround (y
);
382 m
= fromfp (y
, FP_INT_UPWARD
, 6) + fromfpx (y
, FP_INT_DOWNWARD
, 7);
383 um
= (ufromfp (y
, FP_INT_TONEAREST
, 8)
384 + ufromfpx (y
, FP_INT_TOWARDZERO
, 9));
390 a
= nextafter (y
, y
);
391 a
= nexttoward (y
, y
);
392 a
= remainder (y
, y
);
393 a
= scalb (y
, (const TYPE
) (6));
394 k
= scalbn (y
, 7) + scalbln (y
, 10l);
403 a
= totalorder (y
, y
);
404 a
= totalordermag (y
, y
);
408 a
= remquo (i
, y
, &i
);
413 d
= cos ((const complex TYPE
) z
);
414 d
= acos ((const complex TYPE
) z
);
415 d
= sin ((const complex TYPE
) z
);
416 d
= asin ((const complex TYPE
) z
);
417 d
= tan ((const complex TYPE
) z
);
418 d
= atan ((const complex TYPE
) z
);
419 d
= cosh ((const complex TYPE
) z
);
420 d
= acosh ((const complex TYPE
) z
);
421 d
= sinh ((const complex TYPE
) z
);
422 d
= asinh ((const complex TYPE
) z
);
423 d
= tanh ((const complex TYPE
) z
);
424 d
= atanh ((const complex TYPE
) z
);
425 d
= exp ((const complex TYPE
) z
);
426 d
= log ((const complex TYPE
) z
);
427 d
= sqrt ((const complex TYPE
) z
);
428 d
= pow ((const complex TYPE
) z
, (const complex TYPE
) z
);
429 d
= fabs ((const complex TYPE
) z
);
430 d
= carg ((const complex TYPE
) z
);
431 d
= creal ((const complex TYPE
) z
);
432 d
= cimag ((const complex TYPE
) z
);
433 d
= conj ((const complex TYPE
) z
);
434 d
= cproj ((const complex TYPE
) z
);
491 (F(atan2
)) (TYPE x
, TYPE y
)
571 (F(ldexp
)) (TYPE x
, int y
)
579 (F(frexp
)) (TYPE x
, int *y
)
627 (F(pow
)) (TYPE x
, TYPE y
)
643 (F(hypot
)) (TYPE x
, TYPE y
)
683 (F(fmod
)) (TYPE x
, TYPE y
)
691 (F(nearbyint
)) (TYPE x
)
707 (F(roundeven
)) (TYPE x
)
723 (F(remquo
)) (TYPE x
, TYPE y
, int *i
)
755 (F(llround
)) (TYPE x
)
763 (F(fromfp
)) (TYPE x
, int round
, unsigned int width
)
771 (F(fromfpx
)) (TYPE x
, int round
, unsigned int width
)
779 (F(ufromfp
)) (TYPE x
, int round
, unsigned int width
)
787 (F(ufromfpx
)) (TYPE x
, int round
, unsigned int width
)
835 (F(nextafter
)) (TYPE x
, TYPE y
)
843 (F(nextdown
)) (TYPE x
)
851 (F(nexttoward
)) (TYPE x
, long double y
)
867 (F(remainder
)) (TYPE x
, TYPE y
)
875 (F(scalb
)) (TYPE x
, TYPE y
)
883 (F(scalbn
)) (TYPE x
, int y
)
891 (F(scalbln
)) (TYPE x
, long int y
)
915 (F(fdim
)) (TYPE x
, TYPE y
)
923 (F(fmin
)) (TYPE x
, TYPE y
)
931 (F(fmax
)) (TYPE x
, TYPE y
)
939 (F(fminmag
)) (TYPE x
, TYPE y
)
947 (F(fmaxmag
)) (TYPE x
, TYPE y
)
955 (F(fma
)) (TYPE x
, TYPE y
, TYPE z
)
963 (F(totalorder
)) (TYPE x
, TYPE y
)
971 (F(totalordermag
)) (TYPE x
, TYPE y
)
979 (F(cacos
)) (complex TYPE x
)
987 (F(casin
)) (complex TYPE x
)
995 (F(catan
)) (complex TYPE x
)
1003 (F(ccos
)) (complex TYPE x
)
1011 (F(csin
)) (complex TYPE x
)
1019 (F(ctan
)) (complex TYPE x
)
1027 (F(cacosh
)) (complex TYPE x
)
1035 (F(casinh
)) (complex TYPE x
)
1043 (F(catanh
)) (complex TYPE x
)
1051 (F(ccosh
)) (complex TYPE x
)
1059 (F(csinh
)) (complex TYPE x
)
1067 (F(ctanh
)) (complex TYPE x
)
1075 (F(cexp
)) (complex TYPE x
)
1083 (F(clog
)) (complex TYPE x
)
1091 (F(csqrt
)) (complex TYPE x
)
1099 (F(cpow
)) (complex TYPE x
, complex TYPE y
)
1107 (F(cabs
)) (complex TYPE x
)
1115 (F(carg
)) (complex TYPE x
)
1123 (F(creal
)) (complex TYPE x
)
1131 (F(cimag
)) (complex TYPE x
)
1139 (F(conj
)) (complex TYPE x
)
1147 (F(cproj
)) (complex TYPE x
)