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
31 static void compile_test (void);
32 static void compile_testf (void);
33 #ifndef NO_LONG_DOUBLE
34 static void compile_testl (void);
40 const float fy
= 1.25;
41 const double dy
= 1.25;
42 const long double ly
= 1.25;
45 complex long double lz
;
63 count_float
= count_double
= count_ldouble
= 0;
64 count_cfloat
= count_cdouble
= count_cldouble
= 0;
66 if (count_float
!= 0 || count_cfloat
!= 0)
68 puts ("float function called for double test");
71 if (count_ldouble
!= 0 || count_cldouble
!= 0)
73 puts ("long double function called for double test");
76 if (count_double
< NCALLS
+ NCALLS_INT
)
78 printf ("double functions not called often enough (%d)\n",
82 else if (count_double
> NCALLS
+ NCALLS_INT
)
84 printf ("double functions called too often (%d)\n",
88 if (count_cdouble
< NCCALLS
)
90 printf ("double complex functions not called often enough (%d)\n",
94 else if (count_cdouble
> NCCALLS
)
96 printf ("double complex functions called too often (%d)\n",
101 count_float
= count_double
= count_ldouble
= 0;
102 count_cfloat
= count_cdouble
= count_cldouble
= 0;
104 if (count_double
!= 0 || count_cdouble
!= 0)
106 puts ("double function called for float test");
109 if (count_ldouble
!= 0 || count_cldouble
!= 0)
111 puts ("long double function called for float test");
114 if (count_float
< NCALLS
)
116 printf ("float functions not called often enough (%d)\n", count_float
);
119 else if (count_float
> NCALLS
)
121 printf ("float functions called too often (%d)\n",
125 if (count_cfloat
< NCCALLS
)
127 printf ("float complex functions not called often enough (%d)\n",
131 else if (count_cfloat
> NCCALLS
)
133 printf ("float complex functions called too often (%d)\n",
138 #ifndef NO_LONG_DOUBLE
139 count_float
= count_double
= count_ldouble
= 0;
140 count_cfloat
= count_cdouble
= count_cldouble
= 0;
142 if (count_float
!= 0 || count_cfloat
!= 0)
144 puts ("float function called for long double test");
147 if (count_double
!= 0 || count_cdouble
!= 0)
149 puts ("double function called for long double test");
152 if (count_ldouble
< NCALLS
)
154 printf ("long double functions not called often enough (%d)\n",
158 else if (count_ldouble
> NCALLS
)
160 printf ("long double functions called too often (%d)\n",
164 if (count_cldouble
< NCCALLS
)
166 printf ("long double complex functions not called often enough (%d)\n",
170 else if (count_cldouble
> NCCALLS
)
172 printf ("long double complex functions called too often (%d)\n",
181 /* Now generate the three functions. */
190 #define count count_double
191 #define ccount count_cdouble
192 #include "test-tgmath.c"
194 #define F(name) name##f
199 #define count count_float
200 #define ccount count_cfloat
201 #include "test-tgmath.c"
203 #ifndef NO_LONG_DOUBLE
204 #define F(name) name##l
205 #define TYPE long double
209 #define count count_ldouble
210 #define ccount count_cldouble
211 #include "test-tgmath.c"
214 #define TEST_FUNCTION do_test ()
215 #include "../test-skeleton.c"
220 #define P() puts (__FUNCTION__)
226 F(compile_test
) (void)
243 c
= atan2 (atan2 (a
, c
), atan2 (b
, x
));
245 b
= acosh (acosh (a
));
247 b
= asinh (asinh (a
));
249 b
= atanh (atanh (a
));
252 a
= log10 (log10 (x
));
253 b
= ldexp (ldexp (a
, 1), 5);
254 a
= frexp (frexp (x
, &i
), &i
);
255 b
= expm1 (expm1 (a
));
256 a
= log1p (log1p (x
));
260 a
= pow (pow (x
, a
), pow (c
, b
));
262 a
= hypot (hypot (x
, b
), hypot (c
, a
));
266 a
= floor (floor (x
));
267 b
= fmod (fmod (a
, b
), fmod (c
, x
));
268 a
= nearbyint (nearbyint (x
));
269 b
= round (round (a
));
270 c
= roundeven (roundeven (a
));
271 a
= trunc (trunc (x
));
272 b
= remquo (remquo (a
, b
, &i
), remquo (c
, x
, &i
), &i
);
273 j
= lrint (x
) + lround (a
);
274 k
= llrint (b
) + llround (c
);
275 m
= fromfp (a
, FP_INT_UPWARD
, 2) + fromfpx (b
, FP_INT_DOWNWARD
, 3);
276 um
= ufromfp (c
, FP_INT_TONEAREST
, 4) + ufromfpx (a
, FP_INT_TOWARDZERO
, 5);
279 a
= tgamma (tgamma (x
));
280 b
= lgamma (lgamma (a
));
282 b
= nextafter (nextafter (a
, b
), nextafter (c
, x
));
283 a
= nextdown (nextdown (a
));
284 b
= nexttoward (nexttoward (x
, a
), c
);
285 a
= nextup (nextup (a
));
286 b
= remainder (remainder (a
, b
), remainder (c
, x
));
287 a
= scalb (scalb (x
, a
), (TYPE
) (6));
288 k
= scalbn (a
, 7) + scalbln (c
, 10l);
291 a
= fdim (fdim (x
, a
), fdim (c
, b
));
292 b
= fmax (fmax (a
, x
), fmax (c
, b
));
293 a
= fmin (fmin (x
, a
), fmin (c
, b
));
294 b
= fmaxmag (fmaxmag (a
, x
), fmaxmag (c
, b
));
295 a
= fminmag (fminmag (x
, a
), fminmag (c
, b
));
296 b
= fma (sin (a
), sin (x
), sin (c
));
297 a
= totalorder (totalorder (x
, b
), totalorder (c
, x
));
298 b
= totalordermag (totalordermag (x
, a
), totalordermag (c
, x
));
302 b
= remquo (i
, a
, &i
);
306 x
= a
+ b
+ c
+ i
+ j
+ k
+ m
+ um
;
319 z
= acosh (acosh (d
));
321 z
= asinh (asinh (d
));
323 z
= atanh (atanh (d
));
329 z
= pow (pow (a
, d
), pow (b
, z
));
330 d
= cproj (cproj (z
));
331 z
+= fabs (cproj (a
));
333 b
= creal (creal (d
));
334 c
= cimag (cimag (z
));
335 x
+= a
+ b
+ c
+ i
+ j
+ k
;
338 if (saved_count
!= count
)
378 a
= remquo (y
, y
, &i
);
379 j
= lrint (y
) + lround (y
);
380 k
= llrint (y
) + llround (y
);
381 m
= fromfp (y
, FP_INT_UPWARD
, 6) + fromfpx (y
, FP_INT_DOWNWARD
, 7);
382 um
= (ufromfp (y
, FP_INT_TONEAREST
, 8)
383 + ufromfpx (y
, FP_INT_TOWARDZERO
, 9));
389 a
= nextafter (y
, y
);
390 a
= nexttoward (y
, y
);
391 a
= remainder (y
, y
);
392 a
= scalb (y
, (const TYPE
) (6));
393 k
= scalbn (y
, 7) + scalbln (y
, 10l);
402 a
= totalorder (y
, y
);
403 a
= totalordermag (y
, y
);
407 a
= remquo (i
, y
, &i
);
412 d
= cos ((const complex TYPE
) z
);
413 d
= acos ((const complex TYPE
) z
);
414 d
= sin ((const complex TYPE
) z
);
415 d
= asin ((const complex TYPE
) z
);
416 d
= tan ((const complex TYPE
) z
);
417 d
= atan ((const complex TYPE
) z
);
418 d
= cosh ((const complex TYPE
) z
);
419 d
= acosh ((const complex TYPE
) z
);
420 d
= sinh ((const complex TYPE
) z
);
421 d
= asinh ((const complex TYPE
) z
);
422 d
= tanh ((const complex TYPE
) z
);
423 d
= atanh ((const complex TYPE
) z
);
424 d
= exp ((const complex TYPE
) z
);
425 d
= log ((const complex TYPE
) z
);
426 d
= sqrt ((const complex TYPE
) z
);
427 d
= pow ((const complex TYPE
) z
, (const complex TYPE
) z
);
428 d
= fabs ((const complex TYPE
) z
);
429 d
= carg ((const complex TYPE
) z
);
430 d
= creal ((const complex TYPE
) z
);
431 d
= cimag ((const complex TYPE
) z
);
432 d
= conj ((const complex TYPE
) z
);
433 d
= cproj ((const complex TYPE
) z
);
490 (F(atan2
)) (TYPE x
, TYPE y
)
570 (F(ldexp
)) (TYPE x
, int y
)
578 (F(frexp
)) (TYPE x
, int *y
)
626 (F(pow
)) (TYPE x
, TYPE y
)
642 (F(hypot
)) (TYPE x
, TYPE y
)
682 (F(fmod
)) (TYPE x
, TYPE y
)
690 (F(nearbyint
)) (TYPE x
)
706 (F(roundeven
)) (TYPE x
)
722 (F(remquo
)) (TYPE x
, TYPE y
, int *i
)
754 (F(llround
)) (TYPE x
)
762 (F(fromfp
)) (TYPE x
, int round
, unsigned int width
)
770 (F(fromfpx
)) (TYPE x
, int round
, unsigned int width
)
778 (F(ufromfp
)) (TYPE x
, int round
, unsigned int width
)
786 (F(ufromfpx
)) (TYPE x
, int round
, unsigned int width
)
834 (F(nextafter
)) (TYPE x
, TYPE y
)
842 (F(nextdown
)) (TYPE x
)
850 (F(nexttoward
)) (TYPE x
, long double y
)
866 (F(remainder
)) (TYPE x
, TYPE y
)
874 (F(scalb
)) (TYPE x
, TYPE y
)
882 (F(scalbn
)) (TYPE x
, int y
)
890 (F(scalbln
)) (TYPE x
, long int y
)
914 (F(fdim
)) (TYPE x
, TYPE y
)
922 (F(fmin
)) (TYPE x
, TYPE y
)
930 (F(fmax
)) (TYPE x
, TYPE y
)
938 (F(fminmag
)) (TYPE x
, TYPE y
)
946 (F(fmaxmag
)) (TYPE x
, TYPE y
)
954 (F(fma
)) (TYPE x
, TYPE y
, TYPE z
)
962 (F(totalorder
)) (TYPE x
, TYPE y
)
970 (F(totalordermag
)) (TYPE x
, TYPE y
)
978 (F(cacos
)) (complex TYPE x
)
986 (F(casin
)) (complex TYPE x
)
994 (F(catan
)) (complex TYPE x
)
1002 (F(ccos
)) (complex TYPE x
)
1010 (F(csin
)) (complex TYPE x
)
1018 (F(ctan
)) (complex TYPE x
)
1026 (F(cacosh
)) (complex TYPE x
)
1034 (F(casinh
)) (complex TYPE x
)
1042 (F(catanh
)) (complex TYPE x
)
1050 (F(ccosh
)) (complex TYPE x
)
1058 (F(csinh
)) (complex TYPE x
)
1066 (F(ctanh
)) (complex TYPE x
)
1074 (F(cexp
)) (complex TYPE x
)
1082 (F(clog
)) (complex TYPE x
)
1090 (F(csqrt
)) (complex TYPE x
)
1098 (F(cpow
)) (complex TYPE x
, complex TYPE y
)
1106 (F(cabs
)) (complex TYPE x
)
1114 (F(carg
)) (complex TYPE x
)
1122 (F(creal
)) (complex TYPE x
)
1130 (F(cimag
)) (complex TYPE x
)
1138 (F(conj
)) (complex TYPE x
)
1146 (F(cproj
)) (complex TYPE x
)