tgmath.c revision 134758
1/*-
2 * Copyright (c) 2004 Stefan Farfeleder <stefanf@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 *    notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 *    notice, this list of conditions and the following disclaimer in the
12 *    documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $FreeBSD: head/tools/regression/include/tgmath/tgmath.c 134758 2004-09-04 11:34:53Z stefanf $
27 */
28
29#include <sys/cdefs.h>
30/* All of our functions have side effects, __pure2 causes functions calls to
31 * be optimised away.  Stop that. */
32#undef __pure2
33#define	__pure2
34
35#include <assert.h>
36#include <stdio.h>
37#include <tgmath.h>
38
39int n_float, n_double, n_long_double;
40int n_float_complex, n_double_complex, n_long_double_complex;
41
42#define	TGMACRO(FNC)							\
43	TGMACRO_REAL(FNC)						\
44	TGMACRO_COMPLEX(c ## FNC)
45
46#define	TGMACRO_REAL(FNC)						\
47	float (FNC ## f)(float x) { n_float++; }			\
48	double (FNC)(double x) { n_double++; }				\
49	long double (FNC ## l)(long double x) { n_long_double++; }
50
51#define	TGMACRO_REAL_REAL(FNC)						\
52	float (FNC ## f)(float x, float y) { n_float++; }		\
53	double (FNC)(double x, double y) { n_double++; }		\
54	long double							\
55	(FNC ## l)(long double x, long double y) { n_long_double++; }
56
57#define	TGMACRO_REAL_FIXED_RET(FNC, TYPE)				\
58	TYPE (FNC ## f)(float x) { n_float++; }				\
59	TYPE (FNC)(double x) { n_double++; }				\
60	TYPE (FNC ## l)(long double x) { n_long_double++; }
61
62#define	TGMACRO_COMPLEX(FNC)						\
63	float complex (FNC ## f)(float complex x) { n_float_complex++; }\
64	double complex (FNC)(double complex x) { n_double_complex++; }	\
65	long double complex						\
66	(FNC ## l)(long double complex x) { n_long_double_complex++; }
67
68#define	TGMACRO_COMPLEX_REAL_RET(FNC)					\
69	float (FNC ## f)(float complex x) { n_float_complex++; }	\
70	double (FNC)(double complex x) { n_double_complex++; }		\
71	long double							\
72	(FNC ## l)(long double complex x) { n_long_double_complex++; }
73
74
75/* 7.22#4 */
76TGMACRO(acos)
77TGMACRO(asin)
78TGMACRO(atan)
79TGMACRO(acosh)
80TGMACRO(asinh)
81TGMACRO(atanh)
82TGMACRO(cos)
83TGMACRO(sin)
84TGMACRO(tan)
85TGMACRO(cosh)
86TGMACRO(sinh)
87TGMACRO(tanh)
88TGMACRO(exp)
89TGMACRO(log)
90TGMACRO_REAL_REAL(pow)
91float complex (cpowf)(float complex x, float complex y) { n_float_complex++; }
92double complex
93(cpow)(double complex x, double complex y) { n_double_complex++; }
94long double complex
95(cpowl)(long double complex x, long double complex y)
96{ n_long_double_complex++; }
97TGMACRO(sqrt)
98TGMACRO_REAL(fabs)
99TGMACRO_COMPLEX_REAL_RET(cabs)
100
101/* 7.22#5 */
102TGMACRO_REAL_REAL(atan2)
103TGMACRO_REAL(cbrt)
104TGMACRO_REAL(ceil)
105TGMACRO_REAL_REAL(copysign)
106TGMACRO_REAL(erf)
107TGMACRO_REAL(erfc)
108TGMACRO_REAL(exp2)
109TGMACRO_REAL(expm1)
110TGMACRO_REAL_REAL(fdim)
111TGMACRO_REAL(floor)
112float (fmaf)(float x, float y, float z) { n_float++; }
113double (fma)(double x, double y, double z) { n_double++; }
114long double
115(fmal)(long double x, long double y, long double z) { n_long_double++; }
116TGMACRO_REAL_REAL(fmax)
117TGMACRO_REAL_REAL(fmin)
118TGMACRO_REAL_REAL(fmod)
119float (frexpf)(float x, int *e) { n_float++; }
120double (frexp)(double x, int *e) { n_double++; }
121long double (frexpl)(long double x, int *e) { n_long_double++; }
122TGMACRO_REAL_REAL(hypot)
123TGMACRO_REAL_FIXED_RET(ilogb, int)
124float (ldexpf)(float x, int e) { n_float++; }
125double (ldexp)(double x, int e) { n_double++; }
126long double (ldexpl)(long double x, int e) { n_long_double++; }
127TGMACRO_REAL(lgamma)
128TGMACRO_REAL_FIXED_RET(llrint, long long)
129TGMACRO_REAL_FIXED_RET(llround, long long)
130TGMACRO_REAL(log10)
131TGMACRO_REAL(log1p)
132TGMACRO_REAL(log2)
133TGMACRO_REAL(logb)
134TGMACRO_REAL_FIXED_RET(lrint, long)
135TGMACRO_REAL_FIXED_RET(lround, long)
136TGMACRO_REAL(nearbyint)
137TGMACRO_REAL_REAL(nextafter)
138float (nexttowardf)(float x, long double y) { n_float++; }
139double (nexttoward)(double x, long double y) { n_double++; }
140long double (nexttowardl)(long double x, long double y) { n_long_double++; }
141TGMACRO_REAL_REAL(remainder)
142float (remquof)(float x, float y, int *q) { n_float++; }
143double (remquo)(double x, double y, int *q) { n_double++; }
144long double (remquol)(long double x, long double y, int *q) { n_long_double++; }
145TGMACRO_REAL(rint)
146TGMACRO_REAL(round)
147float (scalbnf)(float x, int n) { n_float++; }
148double (scalbn)(double x, int n) { n_double++; }
149long double (scalbnl)(long double x, int n) { n_long_double++; }
150float (scalblnf)(float x, long n) { n_float++; }
151double (scalbln)(double x, long n) { n_double++; }
152long double (scalblnl)(long double x, long n) { n_long_double++; }
153TGMACRO_REAL(tgamma)
154TGMACRO_REAL(trunc)
155
156/* 7.22#6 */
157TGMACRO_COMPLEX_REAL_RET(carg)
158TGMACRO_COMPLEX_REAL_RET(cimag)
159TGMACRO_COMPLEX(conj)
160TGMACRO_COMPLEX(cproj)
161TGMACRO_COMPLEX_REAL_RET(creal)
162
163
164long double ld;
165double d;
166float f;
167long double complex ldc;
168double complex dc;
169float complex fc;
170unsigned long long ull;
171int i;
172_Bool b;
173
174#define	SAMETYPE(EXP, TYPE)						\
175	__builtin_types_compatible_p(__typeof__(EXP), TYPE)
176
177#define	CLEAR_COUNTERS							\
178	(n_float = n_double = n_long_double = 0,			\
179	    n_float_complex = n_double_complex = n_long_double_complex = 0, 1)
180
181#define	RUN_TEST(EXP, TYPE)	(EXP, SAMETYPE(EXP, TYPE))
182
183#define	PASS_REAL_ARG_REAL_RET(FNC) PASS_REAL_ARG_REAL_RET_(FNC,)
184
185#define	PASS_REAL_ARG_REAL_RET_(FNC, SUFFIX)				\
186	CLEAR_COUNTERS &&						\
187	RUN_TEST(FNC(1.l), long double) &&				\
188	RUN_TEST(FNC(ld), long double) &&				\
189	n_long_double ## SUFFIX == 2 &&					\
190	RUN_TEST(FNC(1.), double) &&					\
191	RUN_TEST(FNC(d), double) &&					\
192	RUN_TEST(FNC(1ull), double) &&					\
193	RUN_TEST(FNC(ull), double) &&					\
194	RUN_TEST(FNC(1), double) &&					\
195	RUN_TEST(FNC(i), double) &&					\
196	RUN_TEST(FNC((_Bool)0), double) &&				\
197	RUN_TEST(FNC(b), double) &&					\
198	n_double ## SUFFIX == 8 &&					\
199	RUN_TEST(FNC(1.f), float) &&					\
200	RUN_TEST(FNC(f), float) &&					\
201	n_float ## SUFFIX == 2
202
203#define	PASS_REAL_ARG_FIXED_RET(FNC, RET)				\
204	CLEAR_COUNTERS &&						\
205	RUN_TEST(FNC(1.l), RET) &&					\
206	RUN_TEST(FNC(ld), RET) &&					\
207	n_long_double == 2 &&						\
208	RUN_TEST(FNC(1.), RET) &&					\
209	RUN_TEST(FNC(d), RET) &&					\
210	RUN_TEST(FNC(1ull), RET) &&					\
211	RUN_TEST(FNC(ull), RET) &&					\
212	RUN_TEST(FNC(1), RET) &&					\
213	RUN_TEST(FNC(i), RET) &&					\
214	RUN_TEST(FNC((_Bool)0), RET) &&					\
215	RUN_TEST(FNC(b), RET) &&					\
216	n_double == 8 &&						\
217	RUN_TEST(FNC(1.f), RET) &&					\
218	RUN_TEST(FNC(f), RET) &&					\
219	n_float == 2
220
221#define	PASS_REAL_FIXED_ARG_REAL_RET(FNC, ARG2)				\
222	CLEAR_COUNTERS &&						\
223	RUN_TEST(FNC(1.l, ARG2), long double) &&			\
224	RUN_TEST(FNC(ld, ARG2), long double) &&				\
225	n_long_double == 2 &&						\
226	RUN_TEST(FNC(1., ARG2), double) &&				\
227	RUN_TEST(FNC(d, ARG2), double) &&				\
228	RUN_TEST(FNC(1ull, ARG2), double) &&				\
229	RUN_TEST(FNC(ull, ARG2), double) &&				\
230	RUN_TEST(FNC(1, ARG2), double) &&				\
231	RUN_TEST(FNC(i, ARG2), double) &&				\
232	RUN_TEST(FNC((_Bool)0, ARG2), double) &&			\
233	RUN_TEST(FNC(b, ARG2), double) &&				\
234	n_double == 8 &&						\
235	RUN_TEST(FNC(1.f, ARG2), float) &&				\
236	RUN_TEST(FNC(f, ARG2), float) &&				\
237	n_float == 2
238
239#define	PASS_REAL_REAL_ARG_REAL_RET(FNC)				\
240	CLEAR_COUNTERS &&						\
241	RUN_TEST(FNC(1.l, 1.l), long double) &&				\
242	RUN_TEST(FNC(1.l, 1.), long double) &&				\
243	RUN_TEST(FNC(1.l, 1.f), long double) &&				\
244	RUN_TEST(FNC(1.l, 1), long double) &&				\
245	RUN_TEST(FNC(1.l, (_Bool)0), long double) &&			\
246	RUN_TEST(FNC(1.l, ld), long double) &&				\
247	RUN_TEST(FNC(1., ld), long double) &&				\
248	RUN_TEST(FNC(1.f, ld), long double) &&				\
249	RUN_TEST(FNC(1, ld), long double) &&				\
250	RUN_TEST(FNC((_Bool)0, ld), long double) &&			\
251	n_long_double == 10 &&						\
252	RUN_TEST(FNC(d, 1.), double) &&					\
253	RUN_TEST(FNC(d, 1.f), double) &&				\
254	RUN_TEST(FNC(d, 1l), double) &&					\
255	RUN_TEST(FNC(d, (_Bool)0), double) &&				\
256	RUN_TEST(FNC(1., 1.), double) &&				\
257	RUN_TEST(FNC(1.f, 1.), double) &&				\
258	RUN_TEST(FNC(1l, 1.), double) &&				\
259	RUN_TEST(FNC((_Bool)0, 1.), double) &&				\
260	RUN_TEST(FNC(1ull, f), double) &&				\
261	RUN_TEST(FNC(1.f, ull), double) &&				\
262	RUN_TEST(FNC(1, 1l), double) &&					\
263	RUN_TEST(FNC(1u, i), double) &&					\
264	RUN_TEST(FNC((_Bool)0, 1.f), double) &&				\
265	RUN_TEST(FNC(1.f, b), double) &&				\
266	n_double == 14 &&						\
267	RUN_TEST(FNC(1.f, 1.f), float) &&				\
268	RUN_TEST(FNC(1.f, 1.f), float) &&				\
269	RUN_TEST(FNC(f, 1.f), float) &&					\
270	RUN_TEST(FNC(f, f), float) &&					\
271	n_float == 4
272
273#define	PASS_REAL_REAL_FIXED_ARG_REAL_RET(FNC, ARG3)			\
274	CLEAR_COUNTERS &&						\
275	RUN_TEST(FNC(1.l, 1.l, ARG3), long double) &&			\
276	RUN_TEST(FNC(1.l, 1., ARG3), long double) &&			\
277	RUN_TEST(FNC(1.l, 1.f, ARG3), long double) &&			\
278	RUN_TEST(FNC(1.l, 1, ARG3), long double) &&			\
279	RUN_TEST(FNC(1.l, (_Bool)0, ARG3), long double) &&		\
280	RUN_TEST(FNC(1.l, ld, ARG3), long double) &&			\
281	RUN_TEST(FNC(1., ld, ARG3), long double) &&			\
282	RUN_TEST(FNC(1.f, ld, ARG3), long double) &&			\
283	RUN_TEST(FNC(1, ld, ARG3), long double) &&			\
284	RUN_TEST(FNC((_Bool)0, ld, ARG3), long double) &&		\
285	n_long_double == 10 &&						\
286	RUN_TEST(FNC(d, 1., ARG3), double) &&				\
287	RUN_TEST(FNC(d, 1.f, ARG3), double) &&				\
288	RUN_TEST(FNC(d, 1l, ARG3), double) &&				\
289	RUN_TEST(FNC(d, (_Bool)0, ARG3), double) &&			\
290	RUN_TEST(FNC(1., 1., ARG3), double) &&				\
291	RUN_TEST(FNC(1.f, 1., ARG3), double) &&				\
292	RUN_TEST(FNC(1l, 1., ARG3), double) &&				\
293	RUN_TEST(FNC((_Bool)0, 1., ARG3), double) &&			\
294	RUN_TEST(FNC(1ull, f, ARG3), double) &&				\
295	RUN_TEST(FNC(1.f, ull, ARG3), double) &&			\
296	RUN_TEST(FNC(1, 1l, ARG3), double) &&				\
297	RUN_TEST(FNC(1u, i, ARG3), double) &&				\
298	RUN_TEST(FNC((_Bool)0, 1.f, ARG3), double) &&			\
299	RUN_TEST(FNC(1.f, b, ARG3), double) &&				\
300	n_double == 14 &&						\
301	RUN_TEST(FNC(1.f, 1.f, ARG3), float) &&				\
302	RUN_TEST(FNC(1.f, 1.f, ARG3), float) &&				\
303	RUN_TEST(FNC(f, 1.f, ARG3), float) &&				\
304	RUN_TEST(FNC(f, f, ARG3), float) &&				\
305	n_float == 4
306
307#define	PASS_REAL_REAL_REAL_ARG_REAL_RET(FNC)				\
308	CLEAR_COUNTERS &&						\
309	RUN_TEST(FNC(ld, d, f), long double) &&				\
310	RUN_TEST(FNC(1, ld, ld), long double) &&			\
311	RUN_TEST(FNC(1, d, ld), long double) &&				\
312	n_long_double == 3 &&						\
313	RUN_TEST(FNC(1, f, 1.f), double) &&				\
314	RUN_TEST(FNC(f, d, 1.f), double) &&				\
315	RUN_TEST(FNC(f, 1.f, 1.), double) &&				\
316	n_double == 3 &&						\
317	RUN_TEST(FNC(f, 1.f, f), float) &&				\
318	n_float == 1
319
320#define	PASS_REAL_ARG_COMPLEX_RET(FNC)					\
321	CLEAR_COUNTERS &&						\
322	RUN_TEST(FNC(1.l), long double complex) &&			\
323	RUN_TEST(FNC(ld), long double complex) &&			\
324	n_long_double_complex == 2 &&					\
325	RUN_TEST(FNC(1.), double complex) &&				\
326	RUN_TEST(FNC(d), double complex) &&				\
327	RUN_TEST(FNC(1l), double complex) &&				\
328	RUN_TEST(FNC(i), double complex) &&				\
329	RUN_TEST(FNC(b), double complex) &&				\
330	n_double_complex == 5 &&					\
331	RUN_TEST(FNC(1.f), float complex) &&				\
332	RUN_TEST(FNC(f), float complex) &&				\
333	n_float_complex == 2
334
335#define	PASS_COMPLEX_ARG_COMPLEX_RET(FNC)				\
336	CLEAR_COUNTERS &&						\
337	RUN_TEST(FNC(ldc), long double complex) &&			\
338	n_long_double_complex == 1 &&					\
339	RUN_TEST(FNC(dc), double complex) &&				\
340	n_double_complex == 1 &&					\
341	RUN_TEST(FNC(fc), float complex) &&				\
342	RUN_TEST(FNC(I), float complex) &&				\
343	n_float_complex == 2
344
345#define	PASS_COMPLEX_ARG_REAL_RET(FNC)					\
346	CLEAR_COUNTERS &&						\
347	RUN_TEST(FNC(ldc), long double) &&				\
348	n_long_double_complex == 1 &&					\
349	RUN_TEST(FNC(dc), double) &&					\
350	n_double_complex == 1 &&					\
351	RUN_TEST(FNC(fc), float) &&					\
352	RUN_TEST(FNC(I), float) &&					\
353	n_float_complex == 2
354
355#define	PASS_COMPLEX_COMPLEX_ARG_COMPLEX_RET(FNC)			\
356	CLEAR_COUNTERS &&						\
357	RUN_TEST(FNC(ldc, ldc), long double complex) &&			\
358	RUN_TEST(FNC(ldc, dc), long double complex) &&			\
359	RUN_TEST(FNC(ldc, fc), long double complex) &&			\
360	RUN_TEST(FNC(ldc, ld), long double complex) &&			\
361	RUN_TEST(FNC(ldc, d), long double complex) &&			\
362	RUN_TEST(FNC(ldc, f), long double complex) &&			\
363	RUN_TEST(FNC(ldc, i), long double complex) &&			\
364	RUN_TEST(FNC(dc, ldc), long double complex) &&			\
365	RUN_TEST(FNC(I, ldc), long double complex) &&			\
366	RUN_TEST(FNC(1.l, ldc), long double complex) &&			\
367	RUN_TEST(FNC(1., ldc), long double complex) &&			\
368	RUN_TEST(FNC(1.f, ldc), long double complex) &&			\
369	RUN_TEST(FNC(1, ldc), long double complex) &&			\
370	RUN_TEST(FNC(ld, dc), long double complex) &&			\
371	RUN_TEST(FNC(ld, fc), long double complex) &&			\
372	RUN_TEST(FNC(I, 1.l), long double complex) &&			\
373	RUN_TEST(FNC(dc, 1.l), long double complex) &&			\
374	n_long_double_complex == 17 &&					\
375	RUN_TEST(FNC(dc, dc), double complex) &&			\
376	RUN_TEST(FNC(dc, fc), double complex) &&			\
377	RUN_TEST(FNC(dc, d), double complex) &&				\
378	RUN_TEST(FNC(dc, f), double complex) &&				\
379	RUN_TEST(FNC(dc, ull), double complex) &&			\
380	RUN_TEST(FNC(I, dc), double complex) &&				\
381	RUN_TEST(FNC(1., dc), double complex) &&			\
382	RUN_TEST(FNC(1, dc), double complex) &&				\
383	RUN_TEST(FNC(fc, d), double complex) &&				\
384	RUN_TEST(FNC(1, I), double complex) &&				\
385	n_double_complex == 10 &&					\
386	RUN_TEST(FNC(fc, fc), float complex) &&				\
387	RUN_TEST(FNC(fc, I), float complex) &&				\
388	RUN_TEST(FNC(1.f, fc), float complex) &&			\
389	n_float_complex == 3
390
391int failed = 0;
392#define	PRINT(STR, X) do {						\
393	int result = (X);						\
394	if (!result)							\
395		failed = 1;						\
396	printf("%s %s\n", result ? "PASS" : "FAIL", (STR));		\
397} while (0)
398
399int
400main(void)
401{
402	/* 7.22#4 */
403	PRINT("acos",
404	    PASS_REAL_ARG_REAL_RET(acos) &&
405	    PASS_COMPLEX_ARG_COMPLEX_RET(acos));
406
407	PRINT("asin",
408	    PASS_REAL_ARG_REAL_RET(asin) &&
409	    PASS_COMPLEX_ARG_COMPLEX_RET(asin));
410
411	PRINT("atan",
412	    PASS_REAL_ARG_REAL_RET(atan) &&
413	    PASS_COMPLEX_ARG_COMPLEX_RET(atan));
414
415	PRINT("acosh",
416	    PASS_REAL_ARG_REAL_RET(acosh) &&
417	    PASS_COMPLEX_ARG_COMPLEX_RET(acosh));
418
419	PRINT("asinh",
420	    PASS_REAL_ARG_REAL_RET(asinh) &&
421	    PASS_COMPLEX_ARG_COMPLEX_RET(asinh));
422
423	PRINT("atanh",
424	    PASS_REAL_ARG_REAL_RET(atanh) &&
425	    PASS_COMPLEX_ARG_COMPLEX_RET(atanh));
426
427	PRINT("cos",
428	    PASS_REAL_ARG_REAL_RET(cos) &&
429	    PASS_COMPLEX_ARG_COMPLEX_RET(cos));
430
431	PRINT("sin",
432	    PASS_REAL_ARG_REAL_RET(sin) &&
433	    PASS_COMPLEX_ARG_COMPLEX_RET(sin));
434
435	PRINT("tan",
436	    PASS_REAL_ARG_REAL_RET(tan) &&
437	    PASS_COMPLEX_ARG_COMPLEX_RET(tan));
438
439	PRINT("cosh",
440	    PASS_REAL_ARG_REAL_RET(cosh) &&
441	    PASS_COMPLEX_ARG_COMPLEX_RET(cosh));
442
443	PRINT("sinh",
444	    PASS_REAL_ARG_REAL_RET(sinh) &&
445	    PASS_COMPLEX_ARG_COMPLEX_RET(sinh));
446
447	PRINT("tanh",
448	    PASS_REAL_ARG_REAL_RET(tanh) &&
449	    PASS_COMPLEX_ARG_COMPLEX_RET(tanh));
450
451	PRINT("exp",
452	    PASS_REAL_ARG_REAL_RET(exp) &&
453	    PASS_COMPLEX_ARG_COMPLEX_RET(exp));
454
455	PRINT("log",
456	    PASS_REAL_ARG_REAL_RET(log) &&
457	    PASS_COMPLEX_ARG_COMPLEX_RET(log));
458
459	PRINT("pow",
460	    PASS_REAL_REAL_ARG_REAL_RET(pow) &&
461	    PASS_COMPLEX_COMPLEX_ARG_COMPLEX_RET(pow));
462
463	PRINT("sqrt",
464	    PASS_REAL_ARG_REAL_RET(sqrt) &&
465	    PASS_COMPLEX_ARG_COMPLEX_RET(sqrt));
466
467	PRINT("fabs",
468	    PASS_REAL_ARG_REAL_RET(fabs) &&
469	    PASS_COMPLEX_ARG_REAL_RET(fabs));
470
471	/* 7.22#5 */
472	PRINT("atan2",
473	    PASS_REAL_REAL_ARG_REAL_RET(atan2));
474
475	PRINT("cbrt",
476	    PASS_REAL_ARG_REAL_RET(cbrt));
477
478	PRINT("ceil",
479	    PASS_REAL_ARG_REAL_RET(ceil));
480
481	PRINT("copysign",
482	    PASS_REAL_REAL_ARG_REAL_RET(copysign));
483
484	PRINT("erf",
485	    PASS_REAL_ARG_REAL_RET(erf));
486
487	PRINT("erfc",
488	    PASS_REAL_ARG_REAL_RET(erfc));
489
490	PRINT("exp2",
491	    PASS_REAL_ARG_REAL_RET(exp2));
492
493	PRINT("expm1",
494	    PASS_REAL_ARG_REAL_RET(expm1));
495
496	PRINT("fdim",
497	    PASS_REAL_REAL_ARG_REAL_RET(fdim));
498
499	PRINT("floor",
500	    PASS_REAL_ARG_REAL_RET(floor));
501
502	PRINT("fma",
503	    PASS_REAL_REAL_REAL_ARG_REAL_RET(fma));
504
505	PRINT("fmax",
506	    PASS_REAL_REAL_ARG_REAL_RET(fmax));
507
508	PRINT("fmin",
509	    PASS_REAL_REAL_ARG_REAL_RET(fmin));
510
511	PRINT("fmod",
512	    PASS_REAL_REAL_ARG_REAL_RET(fmod));
513
514	PRINT("frexp",
515	    PASS_REAL_FIXED_ARG_REAL_RET(frexp, &i));
516
517	PRINT("hypot",
518	    PASS_REAL_REAL_ARG_REAL_RET(hypot));
519
520	PRINT("ilogb",
521	    PASS_REAL_ARG_FIXED_RET(ilogb, int));
522
523	PRINT("ldexp",
524	    PASS_REAL_FIXED_ARG_REAL_RET(ldexp, 1) &&
525	    PASS_REAL_FIXED_ARG_REAL_RET(ldexp, ld) &&
526	    PASS_REAL_FIXED_ARG_REAL_RET(ldexp, ldc));
527
528	PRINT("lgamma",
529	    PASS_REAL_ARG_REAL_RET(lgamma));
530
531	PRINT("llrint",
532	    PASS_REAL_ARG_FIXED_RET(llrint, long long));
533
534	PRINT("llround",
535	    PASS_REAL_ARG_FIXED_RET(llround, long long));
536
537	PRINT("log10",
538	    PASS_REAL_ARG_REAL_RET(log10));
539
540	PRINT("log1p",
541	    PASS_REAL_ARG_REAL_RET(log1p));
542
543	PRINT("log2",
544	    PASS_REAL_ARG_REAL_RET(log2));
545
546	PRINT("logb",
547	    PASS_REAL_ARG_REAL_RET(logb));
548
549	PRINT("lrint",
550	    PASS_REAL_ARG_FIXED_RET(lrint, long));
551
552	PRINT("lround",
553	    PASS_REAL_ARG_FIXED_RET(lround, long));
554
555	PRINT("nearbyint",
556	    PASS_REAL_ARG_REAL_RET(nearbyint));
557
558	PRINT("nextafter",
559	    PASS_REAL_REAL_ARG_REAL_RET(nextafter));
560
561	PRINT("nexttoward",
562	    PASS_REAL_FIXED_ARG_REAL_RET(nexttoward, 1) &&
563	    PASS_REAL_FIXED_ARG_REAL_RET(nexttoward, ull) &&
564	    PASS_REAL_FIXED_ARG_REAL_RET(nexttoward, d) &&
565	    PASS_REAL_FIXED_ARG_REAL_RET(nexttoward, fc));
566
567	PRINT("remainder",
568	    PASS_REAL_REAL_ARG_REAL_RET(remainder));
569
570	PRINT("remquo",
571	    PASS_REAL_REAL_FIXED_ARG_REAL_RET(remquo, &i));
572
573	PRINT("rint",
574	    PASS_REAL_ARG_REAL_RET(rint));
575
576	PRINT("round",
577	    PASS_REAL_ARG_REAL_RET(round));
578
579	PRINT("scalbn",
580	    PASS_REAL_FIXED_ARG_REAL_RET(scalbn, 1) &&
581	    PASS_REAL_FIXED_ARG_REAL_RET(scalbn, b) &&
582	    PASS_REAL_FIXED_ARG_REAL_RET(scalbn, I));
583
584	PRINT("scalbln",
585	    PASS_REAL_FIXED_ARG_REAL_RET(scalbln, i) &&
586	    PASS_REAL_FIXED_ARG_REAL_RET(scalbln, 1.l) &&
587	    PASS_REAL_FIXED_ARG_REAL_RET(scalbln, dc));
588
589	PRINT("tgamma",
590	    PASS_REAL_ARG_REAL_RET(tgamma));
591
592	PRINT("trunc",
593	    PASS_REAL_ARG_REAL_RET(trunc));
594
595	/* 7.22#6 */
596	PRINT("carg",
597	    PASS_REAL_ARG_REAL_RET_(carg, _complex) &&
598	    PASS_COMPLEX_ARG_REAL_RET(carg));
599
600	PRINT("cimag",
601	    PASS_REAL_ARG_REAL_RET_(cimag, _complex) &&
602	    PASS_COMPLEX_ARG_REAL_RET(cimag));
603
604	PRINT("conj",
605	    PASS_REAL_ARG_COMPLEX_RET(conj) &&
606	    PASS_COMPLEX_ARG_COMPLEX_RET(conj));
607
608	PRINT("cproj",
609	    PASS_REAL_ARG_COMPLEX_RET(cproj) &&
610	    PASS_COMPLEX_ARG_COMPLEX_RET(cproj));
611
612	PRINT("creal",
613	    PASS_REAL_ARG_REAL_RET_(creal, _complex) &&
614	    PASS_COMPLEX_ARG_REAL_RET(creal));
615
616	printf("%s <tgmath.h>\n", failed ? "FAIL" : "PASS");
617}
618