1 /* Test compilation of tgmath macros.
2 Copyright (C) 2001, 2003 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 static void compile_testl (void);
51 count_float
= count_double
= count_ldouble
= 0;
55 puts ("float function called for double test");
58 if (count_ldouble
!= 0)
60 puts ("long double function called for double test");
63 if (count_double
< NCALLS
+ NCALLS_INT
)
65 printf ("double functions not called often enough (%d)\n",
69 else if (count_double
> NCALLS
+ NCALLS_INT
)
71 printf ("double functions called too often (%d)\n",
76 count_float
= count_double
= count_ldouble
= 0;
78 if (count_double
!= 0)
80 puts ("double function called for float test");
83 if (count_ldouble
!= 0)
85 puts ("long double function called for float test");
88 if (count_float
< NCALLS
)
90 printf ("float functions not called often enough (%d)\n", count_float
);
93 else if (count_float
> NCALLS
)
95 printf ("float functions called too often (%d)\n",
100 #ifndef NO_LONG_DOUBLE
101 count_float
= count_double
= count_ldouble
= 0;
103 if (count_float
!= 0)
105 puts ("float function called for long double test");
108 if (count_double
!= 0)
110 puts ("double function called for long double test");
113 if (count_ldouble
< NCALLS
)
115 printf ("long double functions not called often enough (%d)\n",
119 else if (count_ldouble
> NCALLS
)
121 printf ("long double functions called too often (%d)\n",
130 /* Now generate the three functions. */
137 #define count count_double
138 #include "test-tgmath.c"
140 #define F(name) name##f
143 #define count count_float
144 #include "test-tgmath.c"
146 #ifndef NO_LONG_DOUBLE
147 #define F(name) name##l
148 #define TYPE long double
150 #define count count_ldouble
151 #include "test-tgmath.c"
157 #define P() puts (__FUNCTION__)
163 F(compile_test
) (void)
176 c
= atan2 (atan2 (a
, c
), atan2 (b
, x
));
178 b
= acosh (acosh (a
));
180 b
= asinh (asinh (a
));
182 b
= atanh (atanh (a
));
185 a
= log10 (log10 (x
));
186 b
= ldexp (ldexp (a
, 1), 5);
187 a
= frexp (frexp (x
, &i
), &i
);
188 b
= expm1 (expm1 (a
));
189 a
= log1p (log1p (x
));
193 a
= pow (pow (x
, a
), pow (c
, b
));
195 a
= hypot (hypot (x
, b
), hypot (c
, a
));
199 a
= floor (floor (x
));
200 b
= fmod (fmod (a
, b
), fmod (c
, x
));
201 a
= nearbyint (nearbyint (x
));
202 b
= round (round (a
));
203 a
= trunc (trunc (x
));
204 b
= remquo (remquo (a
, b
, &i
), remquo (c
, x
, &i
), &i
);
205 j
= lrint (x
) + lround (a
);
206 k
= llrint (b
) + llround (c
);
209 a
= tgamma (tgamma (x
));
210 b
= lgamma (lgamma (a
));
212 b
= nextafter (nextafter (a
, b
), nextafter (c
, x
));
213 a
= nexttoward (nexttoward (x
, a
), c
);
214 b
= remainder (remainder (a
, b
), remainder (c
, x
));
215 a
= scalb (scalb (x
, a
), (TYPE
) (6));
216 k
= scalbn (a
, 7) + scalbln (c
, 10l);
218 a
= fdim (fdim (x
, a
), fdim (c
, b
));
219 b
= fmax (fmax (a
, x
), fmax (c
, b
));
220 a
= fmin (fmin (x
, a
), fmin (c
, b
));
221 b
= fma (sin (a
), sin (x
), sin (c
));
225 b
= remquo (i
, a
, &i
);
281 (F(atan2
)) (TYPE x
, TYPE y
)
361 (F(ldexp
)) (TYPE x
, int y
)
369 (F(frexp
)) (TYPE x
, int *y
)
417 (F(pow
)) (TYPE x
, TYPE y
)
433 (F(hypot
)) (TYPE x
, TYPE y
)
473 (F(fmod
)) (TYPE x
, TYPE y
)
481 (F(nearbyint
)) (TYPE x
)
505 (F(remquo
)) (TYPE x
, TYPE y
, int *i
)
537 (F(llround
)) (TYPE x
)
585 (F(nextafter
)) (TYPE x
, TYPE y
)
593 (F(nexttoward
)) (TYPE x
, long double y
)
601 (F(remainder
)) (TYPE x
, TYPE y
)
609 (F(scalb
)) (TYPE x
, TYPE y
)
617 (F(scalbn
)) (TYPE x
, int y
)
625 (F(scalbln
)) (TYPE x
, long int y
)
641 (F(fdim
)) (TYPE x
, TYPE y
)
649 (F(fmin
)) (TYPE x
, TYPE y
)
657 (F(fmax
)) (TYPE x
, TYPE y
)
665 (F(fma
)) (TYPE x
, TYPE y
, TYPE z
)