1 /* Test compilation of tgmath macros.
2 Copyright (C) 2001, 2003, 2004 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, write to the Free
19 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
23 #undef __NO_MATH_INLINES
24 #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);
53 count_float
= count_double
= count_ldouble
= 0;
57 puts ("float function called for double test");
60 if (count_ldouble
!= 0)
62 puts ("long double function called for double test");
65 if (count_double
< NCALLS
+ NCALLS_INT
)
67 printf ("double functions not called often enough (%d)\n",
71 else if (count_double
> NCALLS
+ NCALLS_INT
)
73 printf ("double functions called too often (%d)\n",
78 count_float
= count_double
= count_ldouble
= 0;
80 if (count_double
!= 0)
82 puts ("double function called for float test");
85 if (count_ldouble
!= 0)
87 puts ("long double function called for float test");
90 if (count_float
< NCALLS
)
92 printf ("float functions not called often enough (%d)\n", count_float
);
95 else if (count_float
> NCALLS
)
97 printf ("float functions called too often (%d)\n",
102 #ifndef NO_LONG_DOUBLE
103 count_float
= count_double
= count_ldouble
= 0;
105 if (count_float
!= 0)
107 puts ("float function called for long double test");
110 if (count_double
!= 0)
112 puts ("double function called for long double test");
115 if (count_ldouble
< NCALLS
)
117 printf ("long double functions not called often enough (%d)\n",
121 else if (count_ldouble
> NCALLS
)
123 printf ("long double functions called too often (%d)\n",
132 /* Now generate the three functions. */
139 #define count count_double
140 #include "test-tgmath.c"
142 #define F(name) name##f
145 #define count count_float
146 #include "test-tgmath.c"
148 #ifndef NO_LONG_DOUBLE
149 #define F(name) name##l
150 #define TYPE long double
152 #define count count_ldouble
153 #include "test-tgmath.c"
159 #define P() puts (__FUNCTION__)
165 F(compile_test
) (void)
178 c
= atan2 (atan2 (a
, c
), atan2 (b
, x
));
180 b
= acosh (acosh (a
));
182 b
= asinh (asinh (a
));
184 b
= atanh (atanh (a
));
187 a
= log10 (log10 (x
));
188 b
= ldexp (ldexp (a
, 1), 5);
189 a
= frexp (frexp (x
, &i
), &i
);
190 b
= expm1 (expm1 (a
));
191 a
= log1p (log1p (x
));
195 a
= pow (pow (x
, a
), pow (c
, b
));
197 a
= hypot (hypot (x
, b
), hypot (c
, a
));
201 a
= floor (floor (x
));
202 b
= fmod (fmod (a
, b
), fmod (c
, x
));
203 a
= nearbyint (nearbyint (x
));
204 b
= round (round (a
));
205 a
= trunc (trunc (x
));
206 b
= remquo (remquo (a
, b
, &i
), remquo (c
, x
, &i
), &i
);
207 j
= lrint (x
) + lround (a
);
208 k
= llrint (b
) + llround (c
);
211 a
= tgamma (tgamma (x
));
212 b
= lgamma (lgamma (a
));
214 b
= nextafter (nextafter (a
, b
), nextafter (c
, x
));
215 a
= nexttoward (nexttoward (x
, a
), c
);
216 b
= remainder (remainder (a
, b
), remainder (c
, x
));
217 a
= scalb (scalb (x
, a
), (TYPE
) (6));
218 k
= scalbn (a
, 7) + scalbln (c
, 10l);
220 a
= fdim (fdim (x
, a
), fdim (c
, b
));
221 b
= fmax (fmax (a
, x
), fmax (c
, b
));
222 a
= fmin (fmin (x
, a
), fmin (c
, b
));
223 b
= fma (sin (a
), sin (x
), sin (c
));
227 b
= remquo (i
, a
, &i
);
283 (F(atan2
)) (TYPE x
, TYPE y
)
363 (F(ldexp
)) (TYPE x
, int y
)
371 (F(frexp
)) (TYPE x
, int *y
)
419 (F(pow
)) (TYPE x
, TYPE y
)
435 (F(hypot
)) (TYPE x
, TYPE y
)
475 (F(fmod
)) (TYPE x
, TYPE y
)
483 (F(nearbyint
)) (TYPE x
)
507 (F(remquo
)) (TYPE x
, TYPE y
, int *i
)
539 (F(llround
)) (TYPE x
)
587 (F(nextafter
)) (TYPE x
, TYPE y
)
595 (F(nexttoward
)) (TYPE x
, long double y
)
603 (F(remainder
)) (TYPE x
, TYPE y
)
611 (F(scalb
)) (TYPE x
, TYPE y
)
619 (F(scalbn
)) (TYPE x
, int y
)
627 (F(scalbln
)) (TYPE x
, long int y
)
643 (F(fdim
)) (TYPE x
, TYPE y
)
651 (F(fmin
)) (TYPE x
, TYPE y
)
659 (F(fmax
)) (TYPE x
, TYPE y
)
667 (F(fma
)) (TYPE x
, TYPE y
, TYPE z
)