Update Gnulib to v0.0-5158-g7d06b32; remove `strcase' and `version-etc-fsf'.
[bpt/guile.git] / lib / math.in.h
CommitLineData
2e65b52f
LC
1/* A GNU-like <math.h>.
2
49114fd4 3 Copyright (C) 2002-2003, 2007-2011 Free Software Foundation, Inc.
2e65b52f
LC
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17
18#ifndef _GL_MATH_H
19
20#if __GNUC__ >= 3
21@PRAGMA_SYSTEM_HEADER@
22#endif
0f00f2c3 23@PRAGMA_COLUMNS@
2e65b52f
LC
24
25/* The include_next requires a split double-inclusion guard. */
26#@INCLUDE_NEXT_AS_FIRST_DIRECTIVE@ @NEXT_AS_FIRST_DIRECTIVE_MATH_H@
27
28#ifndef _GL_MATH_H
29#define _GL_MATH_H
30
31
32/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
33
34/* The definition of _GL_ARG_NONNULL is copied here. */
35
36/* The definition of _GL_WARN_ON_USE is copied here. */
37
38/* Helper macros to define a portability warning for the
39 classification macro FUNC called with VALUE. POSIX declares the
40 classification macros with an argument of real-floating (that is,
41 one of float, double, or long double). */
42#define _GL_WARN_REAL_FLOATING_DECL(func) \
43static inline int \
44rpl_ ## func ## f (float f) \
45{ \
46 return func (f); \
47} \
48static inline int \
49rpl_ ## func ## d (double d) \
50{ \
51 return func (d); \
52} \
53static inline int \
54rpl_ ## func ## l (long double l) \
55{ \
56 return func (l); \
57} \
58_GL_WARN_ON_USE (rpl_ ## func ## f, #func " is unportable - " \
59 "use gnulib module " #func " for portability"); \
60_GL_WARN_ON_USE (rpl_ ## func ## d, #func " is unportable - " \
61 "use gnulib module " #func " for portability"); \
62_GL_WARN_ON_USE (rpl_ ## func ## l, #func " is unportable - " \
63 "use gnulib module " #func " for portability")
64#define _GL_WARN_REAL_FLOATING_IMPL(func, value) \
65 (sizeof (value) == sizeof (float) ? rpl_ ## func ## f (value) \
66 : sizeof (value) == sizeof (double) ? rpl_ ## func ## d (value) \
67 : rpl_ ## func ## l (value))
68
69
70/* POSIX allows platforms that don't support NAN. But all major
71 machines in the past 15 years have supported something close to
72 IEEE NaN, so we define this unconditionally. We also must define
73 it on platforms like Solaris 10, where NAN is present but defined
74 as a function pointer rather than a floating point constant. */
75#if !defined NAN || @REPLACE_NAN@
49114fd4
LC
76# if !GNULIB_defined_NAN
77# undef NAN
2e65b52f 78 /* The Compaq (ex-DEC) C 6.4 compiler chokes on the expression 0.0 / 0.0. */
49114fd4 79# ifdef __DECC
2e65b52f
LC
80static float
81_NaN ()
82{
83 static float zero = 0.0f;
84 return zero / zero;
85}
49114fd4
LC
86# define NAN (_NaN())
87# else
88# define NAN (0.0f / 0.0f)
89# endif
90# define GNULIB_defined_NAN 1
2e65b52f
LC
91# endif
92#endif
93
94/* Solaris 10 defines HUGE_VAL, but as a function pointer rather
95 than a floating point constant. */
96#if @REPLACE_HUGE_VAL@
97# undef HUGE_VAL
98# define HUGE_VAL (1.0 / 0.0)
99#endif
100
101
102/* Write x as
103 x = mantissa * 2^exp
104 where
105 If x finite and nonzero: 0.5 <= |mantissa| < 1.0.
106 If x is zero: mantissa = x, exp = 0.
107 If x is infinite or NaN: mantissa = x, exp unspecified.
108 Store exp in *EXPPTR and return mantissa. */
109#if @GNULIB_FREXP@
110# if @REPLACE_FREXP@
111# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
112# define frexp rpl_frexp
113# endif
114_GL_FUNCDECL_RPL (frexp, double, (double x, int *expptr) _GL_ARG_NONNULL ((2)));
115_GL_CXXALIAS_RPL (frexp, double, (double x, int *expptr));
116# else
117_GL_CXXALIAS_SYS (frexp, double, (double x, int *expptr));
118# endif
119_GL_CXXALIASWARN (frexp);
120#elif defined GNULIB_POSIXCHECK
121# undef frexp
122/* Assume frexp is always declared. */
123_GL_WARN_ON_USE (frexp, "frexp is unportable - "
124 "use gnulib module frexp for portability");
125#endif
126
127
128#if @GNULIB_LOGB@
129# if !@HAVE_DECL_LOGB@
130_GL_EXTERN_C double logb (double x);
131# endif
132#elif defined GNULIB_POSIXCHECK
133# undef logb
134# if HAVE_RAW_DECL_LOGB
135_GL_WARN_ON_USE (logb, "logb is unportable - "
136 "use gnulib module logb for portability");
137# endif
138#endif
139
140
141#if @GNULIB_ACOSL@
142# if !@HAVE_ACOSL@ || !@HAVE_DECL_ACOSL@
143_GL_FUNCDECL_SYS (acosl, long double, (long double x));
144# endif
145_GL_CXXALIAS_SYS (acosl, long double, (long double x));
146_GL_CXXALIASWARN (acosl);
147#elif defined GNULIB_POSIXCHECK
148# undef acosl
149# if HAVE_RAW_DECL_ACOSL
150_GL_WARN_ON_USE (acosl, "acosl is unportable - "
151 "use gnulib module mathl for portability");
152# endif
153#endif
154
155
156#if @GNULIB_ASINL@
157# if !@HAVE_ASINL@ || !@HAVE_DECL_ASINL@
158_GL_FUNCDECL_SYS (asinl, long double, (long double x));
159# endif
160_GL_CXXALIAS_SYS (asinl, long double, (long double x));
161_GL_CXXALIASWARN (asinl);
162#elif defined GNULIB_POSIXCHECK
163# undef asinl
164# if HAVE_RAW_DECL_ASINL
165_GL_WARN_ON_USE (asinl, "asinl is unportable - "
166 "use gnulib module mathl for portability");
167# endif
168#endif
169
170
171#if @GNULIB_ATANL@
172# if !@HAVE_ATANL@ || !@HAVE_DECL_ATANL@
173_GL_FUNCDECL_SYS (atanl, long double, (long double x));
174# endif
175_GL_CXXALIAS_SYS (atanl, long double, (long double x));
176_GL_CXXALIASWARN (atanl);
177#elif defined GNULIB_POSIXCHECK
178# undef atanl
179# if HAVE_RAW_DECL_ATANL
180_GL_WARN_ON_USE (atanl, "atanl is unportable - "
181 "use gnulib module mathl for portability");
182# endif
183#endif
184
185
186#if @GNULIB_CEILF@
187# if @REPLACE_CEILF@
188# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
189# define ceilf rpl_ceilf
190# endif
191_GL_FUNCDECL_RPL (ceilf, float, (float x));
192_GL_CXXALIAS_RPL (ceilf, float, (float x));
193# else
194# if !@HAVE_DECL_CEILF@
195_GL_FUNCDECL_SYS (ceilf, float, (float x));
196# endif
197_GL_CXXALIAS_SYS (ceilf, float, (float x));
198# endif
199_GL_CXXALIASWARN (ceilf);
200#elif defined GNULIB_POSIXCHECK
201# undef ceilf
202# if HAVE_RAW_DECL_CEILF
203_GL_WARN_ON_USE (ceilf, "ceilf is unportable - "
204 "use gnulib module ceilf for portability");
205# endif
206#endif
207
49114fd4
LC
208#if @GNULIB_CEIL@
209# if @REPLACE_CEIL@
210# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
211# define ceil rpl_ceil
212# endif
213_GL_FUNCDECL_RPL (ceil, double, (double x));
214_GL_CXXALIAS_RPL (ceil, double, (double x));
215# else
216_GL_CXXALIAS_SYS (ceil, double, (double x));
217# endif
218_GL_CXXALIASWARN (ceil);
219#endif
220
2e65b52f
LC
221#if @GNULIB_CEILL@
222# if @REPLACE_CEILL@
223# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
224# define ceill rpl_ceill
225# endif
226_GL_FUNCDECL_RPL (ceill, long double, (long double x));
227_GL_CXXALIAS_RPL (ceill, long double, (long double x));
228# else
229# if !@HAVE_DECL_CEILL@
230_GL_FUNCDECL_SYS (ceill, long double, (long double x));
231# endif
232_GL_CXXALIAS_SYS (ceill, long double, (long double x));
233# endif
234_GL_CXXALIASWARN (ceill);
235#elif defined GNULIB_POSIXCHECK
236# undef ceill
237# if HAVE_RAW_DECL_CEILL
238_GL_WARN_ON_USE (ceill, "ceill is unportable - "
239 "use gnulib module ceill for portability");
240# endif
241#endif
242
243
244#if @GNULIB_COSL@
245# if !@HAVE_COSL@ || !@HAVE_DECL_COSL@
246_GL_FUNCDECL_SYS (cosl, long double, (long double x));
247# endif
248_GL_CXXALIAS_SYS (cosl, long double, (long double x));
249_GL_CXXALIASWARN (cosl);
250#elif defined GNULIB_POSIXCHECK
251# undef cosl
252# if HAVE_RAW_DECL_COSL
253_GL_WARN_ON_USE (cosl, "cosl is unportable - "
254 "use gnulib module mathl for portability");
255# endif
256#endif
257
258
259#if @GNULIB_EXPL@
260# if !@HAVE_EXPL@ || !@HAVE_DECL_EXPL@
261_GL_FUNCDECL_SYS (expl, long double, (long double x));
262# endif
263_GL_CXXALIAS_SYS (expl, long double, (long double x));
264_GL_CXXALIASWARN (expl);
265#elif defined GNULIB_POSIXCHECK
266# undef expl
267# if HAVE_RAW_DECL_EXPL
268_GL_WARN_ON_USE (expl, "expl is unportable - "
269 "use gnulib module mathl for portability");
270# endif
271#endif
272
273
274#if @GNULIB_FLOORF@
275# if @REPLACE_FLOORF@
276# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
277# define floorf rpl_floorf
278# endif
279_GL_FUNCDECL_RPL (floorf, float, (float x));
280_GL_CXXALIAS_RPL (floorf, float, (float x));
49114fd4 281# else
2e65b52f
LC
282# if !@HAVE_DECL_FLOORF@
283_GL_FUNCDECL_SYS (floorf, float, (float x));
284# endif
285_GL_CXXALIAS_SYS (floorf, float, (float x));
286# endif
287_GL_CXXALIASWARN (floorf);
288#elif defined GNULIB_POSIXCHECK
289# undef floorf
290# if HAVE_RAW_DECL_FLOORF
291_GL_WARN_ON_USE (floorf, "floorf is unportable - "
292 "use gnulib module floorf for portability");
293# endif
294#endif
295
49114fd4
LC
296#if @GNULIB_FLOOR@
297# if @REPLACE_FLOOR@
298# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
299# define floor rpl_floor
300# endif
301_GL_FUNCDECL_RPL (floor, double, (double x));
302_GL_CXXALIAS_RPL (floor, double, (double x));
303# else
304_GL_CXXALIAS_SYS (floor, double, (double x));
305# endif
306_GL_CXXALIASWARN (floor);
307#endif
308
2e65b52f
LC
309#if @GNULIB_FLOORL@
310# if @REPLACE_FLOORL@
311# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
312# define floorl rpl_floorl
313# endif
314_GL_FUNCDECL_RPL (floorl, long double, (long double x));
315_GL_CXXALIAS_RPL (floorl, long double, (long double x));
316# else
317# if !@HAVE_DECL_FLOORL@
318_GL_FUNCDECL_SYS (floorl, long double, (long double x));
319# endif
320_GL_CXXALIAS_SYS (floorl, long double, (long double x));
321# endif
322_GL_CXXALIASWARN (floorl);
323#elif defined GNULIB_POSIXCHECK
324# undef floorl
325# if HAVE_RAW_DECL_FLOORL
326_GL_WARN_ON_USE (floorl, "floorl is unportable - "
327 "use gnulib module floorl for portability");
328# endif
329#endif
330
331
332/* Write x as
333 x = mantissa * 2^exp
334 where
335 If x finite and nonzero: 0.5 <= |mantissa| < 1.0.
336 If x is zero: mantissa = x, exp = 0.
337 If x is infinite or NaN: mantissa = x, exp unspecified.
338 Store exp in *EXPPTR and return mantissa. */
339#if @GNULIB_FREXPL@ && @REPLACE_FREXPL@
340# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
341# define frexpl rpl_frexpl
342# endif
343_GL_FUNCDECL_RPL (frexpl, long double,
344 (long double x, int *expptr) _GL_ARG_NONNULL ((2)));
345_GL_CXXALIAS_RPL (frexpl, long double, (long double x, int *expptr));
346#else
347# if !@HAVE_DECL_FREXPL@
348_GL_FUNCDECL_SYS (frexpl, long double,
349 (long double x, int *expptr) _GL_ARG_NONNULL ((2)));
350# endif
351# if @GNULIB_FREXPL@
352_GL_CXXALIAS_SYS (frexpl, long double, (long double x, int *expptr));
353# endif
354#endif
355#if @GNULIB_FREXPL@ && !(@REPLACE_FREXPL@ && !@HAVE_DECL_FREXPL@)
356_GL_CXXALIASWARN (frexpl);
357#endif
358#if !@GNULIB_FREXPL@ && defined GNULIB_POSIXCHECK
359# undef frexpl
360# if HAVE_RAW_DECL_FREXPL
361_GL_WARN_ON_USE (frexpl, "frexpl is unportable - "
362 "use gnulib module frexpl for portability");
363# endif
364#endif
365
366
367/* Return x * 2^exp. */
368#if @GNULIB_LDEXPL@ && @REPLACE_LDEXPL@
369# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
370# define ldexpl rpl_ldexpl
371# endif
372_GL_FUNCDECL_RPL (ldexpl, long double, (long double x, int exp));
373_GL_CXXALIAS_RPL (ldexpl, long double, (long double x, int exp));
374#else
375# if !@HAVE_DECL_LDEXPL@
376_GL_FUNCDECL_SYS (ldexpl, long double, (long double x, int exp));
377# endif
378# if @GNULIB_LDEXPL@
379_GL_CXXALIAS_SYS (ldexpl, long double, (long double x, int exp));
380# endif
381#endif
382#if @GNULIB_LDEXPL@
383_GL_CXXALIASWARN (ldexpl);
384#endif
385#if !@GNULIB_LDEXPL@ && defined GNULIB_POSIXCHECK
386# undef ldexpl
387# if HAVE_RAW_DECL_LDEXPL
388_GL_WARN_ON_USE (ldexpl, "ldexpl is unportable - "
389 "use gnulib module ldexpl for portability");
390# endif
391#endif
392
393
394#if @GNULIB_LOGL@
395# if !@HAVE_LOGL@ || !@HAVE_DECL_LOGL@
396_GL_FUNCDECL_SYS (logl, long double, (long double x));
397# endif
398_GL_CXXALIAS_SYS (logl, long double, (long double x));
399_GL_CXXALIASWARN (logl);
400#elif defined GNULIB_POSIXCHECK
401# undef logl
402# if HAVE_RAW_DECL_LOGL
403_GL_WARN_ON_USE (logl, "logl is unportable - "
404 "use gnulib module mathl for portability");
405# endif
406#endif
407
408
409#if @GNULIB_ROUNDF@
410# if @REPLACE_ROUNDF@
411# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
412# undef roundf
413# define roundf rpl_roundf
414# endif
415_GL_FUNCDECL_RPL (roundf, float, (float x));
416_GL_CXXALIAS_RPL (roundf, float, (float x));
417# else
418# if !@HAVE_DECL_ROUNDF@
419_GL_FUNCDECL_SYS (roundf, float, (float x));
420# endif
421_GL_CXXALIAS_SYS (roundf, float, (float x));
422# endif
423_GL_CXXALIASWARN (roundf);
424#elif defined GNULIB_POSIXCHECK
425# undef roundf
426# if HAVE_RAW_DECL_ROUNDF
427_GL_WARN_ON_USE (roundf, "roundf is unportable - "
428 "use gnulib module roundf for portability");
429# endif
430#endif
431
432#if @GNULIB_ROUND@
433# if @REPLACE_ROUND@
434# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
435# undef round
436# define round rpl_round
437# endif
438_GL_FUNCDECL_RPL (round, double, (double x));
439_GL_CXXALIAS_RPL (round, double, (double x));
440# else
441# if !@HAVE_DECL_ROUND@
442_GL_FUNCDECL_SYS (round, double, (double x));
443# endif
444_GL_CXXALIAS_SYS (round, double, (double x));
445# endif
446_GL_CXXALIASWARN (round);
447#elif defined GNULIB_POSIXCHECK
448# undef round
449# if HAVE_RAW_DECL_ROUND
450_GL_WARN_ON_USE (round, "round is unportable - "
451 "use gnulib module round for portability");
452# endif
453#endif
454
455#if @GNULIB_ROUNDL@
456# if @REPLACE_ROUNDL@
457# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
458# undef roundl
459# define roundl rpl_roundl
460# endif
461_GL_FUNCDECL_RPL (roundl, long double, (long double x));
462_GL_CXXALIAS_RPL (roundl, long double, (long double x));
463# else
464# if !@HAVE_DECL_ROUNDL@
465_GL_FUNCDECL_SYS (roundl, long double, (long double x));
466# endif
467_GL_CXXALIAS_SYS (roundl, long double, (long double x));
468# endif
469_GL_CXXALIASWARN (roundl);
470#elif defined GNULIB_POSIXCHECK
471# undef roundl
472# if HAVE_RAW_DECL_ROUNDL
473_GL_WARN_ON_USE (roundl, "roundl is unportable - "
474 "use gnulib module roundl for portability");
475# endif
476#endif
477
478
479#if @GNULIB_SINL@
480# if !@HAVE_SINL@ || !@HAVE_DECL_SINL@
481_GL_FUNCDECL_SYS (sinl, long double, (long double x));
482# endif
483_GL_CXXALIAS_SYS (sinl, long double, (long double x));
484_GL_CXXALIASWARN (sinl);
485#elif defined GNULIB_POSIXCHECK
486# undef sinl
487# if HAVE_RAW_DECL_SINL
488_GL_WARN_ON_USE (sinl, "sinl is unportable - "
489 "use gnulib module mathl for portability");
490# endif
491#endif
492
493
494#if @GNULIB_SQRTL@
495# if !@HAVE_SQRTL@ || !@HAVE_DECL_SQRTL@
496_GL_FUNCDECL_SYS (sqrtl, long double, (long double x));
497# endif
498_GL_CXXALIAS_SYS (sqrtl, long double, (long double x));
499_GL_CXXALIASWARN (sqrtl);
500#elif defined GNULIB_POSIXCHECK
501# undef sqrtl
502# if HAVE_RAW_DECL_SQRTL
503_GL_WARN_ON_USE (sqrtl, "sqrtl is unportable - "
504 "use gnulib module mathl for portability");
505# endif
506#endif
507
508
509#if @GNULIB_TANL@
510# if !@HAVE_TANL@ || !@HAVE_DECL_TANL@
511_GL_FUNCDECL_SYS (tanl, long double, (long double x));
512# endif
513_GL_CXXALIAS_SYS (tanl, long double, (long double x));
514_GL_CXXALIASWARN (tanl);
515#elif defined GNULIB_POSIXCHECK
516# undef tanl
517# if HAVE_RAW_DECL_TANL
518_GL_WARN_ON_USE (tanl, "tanl is unportable - "
519 "use gnulib module mathl for portability");
520# endif
521#endif
522
523
524#if @GNULIB_TRUNCF@
49114fd4
LC
525# if @REPLACE_TRUNCF@
526# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
527# define truncf rpl_truncf
528# endif
529_GL_FUNCDECL_RPL (truncf, float, (float x));
530_GL_CXXALIAS_RPL (truncf, float, (float x));
531# else
532# if !@HAVE_DECL_TRUNCF@
2e65b52f 533_GL_FUNCDECL_SYS (truncf, float, (float x));
49114fd4 534# endif
2e65b52f 535_GL_CXXALIAS_SYS (truncf, float, (float x));
49114fd4 536# endif
2e65b52f
LC
537_GL_CXXALIASWARN (truncf);
538#elif defined GNULIB_POSIXCHECK
539# undef truncf
540# if HAVE_RAW_DECL_TRUNCF
541_GL_WARN_ON_USE (truncf, "truncf is unportable - "
542 "use gnulib module truncf for portability");
543# endif
544#endif
545
546#if @GNULIB_TRUNC@
49114fd4
LC
547# if @REPLACE_TRUNC@
548# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
549# define trunc rpl_trunc
550# endif
551_GL_FUNCDECL_RPL (trunc, double, (double x));
552_GL_CXXALIAS_RPL (trunc, double, (double x));
553# else
554# if !@HAVE_DECL_TRUNC@
2e65b52f 555_GL_FUNCDECL_SYS (trunc, double, (double x));
49114fd4 556# endif
2e65b52f 557_GL_CXXALIAS_SYS (trunc, double, (double x));
49114fd4 558# endif
2e65b52f
LC
559_GL_CXXALIASWARN (trunc);
560#elif defined GNULIB_POSIXCHECK
561# undef trunc
562# if HAVE_RAW_DECL_TRUNC
563_GL_WARN_ON_USE (trunc, "trunc is unportable - "
564 "use gnulib module trunc for portability");
565# endif
566#endif
567
568#if @GNULIB_TRUNCL@
569# if @REPLACE_TRUNCL@
570# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
571# undef truncl
572# define truncl rpl_truncl
573# endif
574_GL_FUNCDECL_RPL (truncl, long double, (long double x));
575_GL_CXXALIAS_RPL (truncl, long double, (long double x));
576# else
577# if !@HAVE_DECL_TRUNCL@
578_GL_FUNCDECL_SYS (truncl, long double, (long double x));
579# endif
580_GL_CXXALIAS_SYS (truncl, long double, (long double x));
581# endif
582_GL_CXXALIASWARN (truncl);
583#elif defined GNULIB_POSIXCHECK
584# undef truncl
585# if HAVE_RAW_DECL_TRUNCL
586_GL_WARN_ON_USE (truncl, "truncl is unportable - "
587 "use gnulib module truncl for portability");
588# endif
589#endif
590
591
592#if @GNULIB_ISFINITE@
593# if @REPLACE_ISFINITE@
594_GL_EXTERN_C int gl_isfinitef (float x);
595_GL_EXTERN_C int gl_isfinited (double x);
596_GL_EXTERN_C int gl_isfinitel (long double x);
597# undef isfinite
598# define isfinite(x) \
599 (sizeof (x) == sizeof (long double) ? gl_isfinitel (x) : \
600 sizeof (x) == sizeof (double) ? gl_isfinited (x) : \
601 gl_isfinitef (x))
602# endif
603#elif defined GNULIB_POSIXCHECK
604# if defined isfinite
605_GL_WARN_REAL_FLOATING_DECL (isfinite);
606# undef isfinite
607# define isfinite(x) _GL_WARN_REAL_FLOATING_IMPL (isfinite, x)
608# endif
609#endif
610
611
612#if @GNULIB_ISINF@
613# if @REPLACE_ISINF@
614_GL_EXTERN_C int gl_isinff (float x);
615_GL_EXTERN_C int gl_isinfd (double x);
616_GL_EXTERN_C int gl_isinfl (long double x);
617# undef isinf
618# define isinf(x) \
619 (sizeof (x) == sizeof (long double) ? gl_isinfl (x) : \
620 sizeof (x) == sizeof (double) ? gl_isinfd (x) : \
621 gl_isinff (x))
622# endif
623#elif defined GNULIB_POSIXCHECK
624# if defined isinf
625_GL_WARN_REAL_FLOATING_DECL (isinf);
626# undef isinf
627# define isinf(x) _GL_WARN_REAL_FLOATING_IMPL (isinf, x)
628# endif
629#endif
630
631
632#if @GNULIB_ISNANF@
633/* Test for NaN for 'float' numbers. */
634# if @HAVE_ISNANF@
635/* The original <math.h> included above provides a declaration of isnan macro
636 or (older) isnanf function. */
637# if __GNUC__ >= 4
638 /* GCC 4.0 and newer provides three built-ins for isnan. */
639# undef isnanf
640# define isnanf(x) __builtin_isnanf ((float)(x))
641# elif defined isnan
642# undef isnanf
643# define isnanf(x) isnan ((float)(x))
644# endif
645# else
646/* Test whether X is a NaN. */
647# undef isnanf
648# define isnanf rpl_isnanf
649_GL_EXTERN_C int isnanf (float x);
650# endif
651#endif
652
653#if @GNULIB_ISNAND@
654/* Test for NaN for 'double' numbers.
655 This function is a gnulib extension, unlike isnan() which applied only
656 to 'double' numbers earlier but now is a type-generic macro. */
657# if @HAVE_ISNAND@
0f00f2c3
LC
658/* The original <math.h> included above provides a declaration of isnan
659 macro. */
2e65b52f
LC
660# if __GNUC__ >= 4
661 /* GCC 4.0 and newer provides three built-ins for isnan. */
662# undef isnand
663# define isnand(x) __builtin_isnan ((double)(x))
664# else
665# undef isnand
666# define isnand(x) isnan ((double)(x))
667# endif
668# else
669/* Test whether X is a NaN. */
670# undef isnand
671# define isnand rpl_isnand
672_GL_EXTERN_C int isnand (double x);
673# endif
674#endif
675
676#if @GNULIB_ISNANL@
677/* Test for NaN for 'long double' numbers. */
678# if @HAVE_ISNANL@
0f00f2c3
LC
679/* The original <math.h> included above provides a declaration of isnan
680 macro or (older) isnanl function. */
2e65b52f
LC
681# if __GNUC__ >= 4
682 /* GCC 4.0 and newer provides three built-ins for isnan. */
683# undef isnanl
684# define isnanl(x) __builtin_isnanl ((long double)(x))
685# elif defined isnan
686# undef isnanl
687# define isnanl(x) isnan ((long double)(x))
688# endif
689# else
690/* Test whether X is a NaN. */
691# undef isnanl
692# define isnanl rpl_isnanl
693_GL_EXTERN_C int isnanl (long double x);
694# endif
695#endif
696
697/* This must come *after* the snippets for GNULIB_ISNANF and GNULIB_ISNANL! */
698#if @GNULIB_ISNAN@
699# if @REPLACE_ISNAN@
700/* We can't just use the isnanf macro (e.g.) as exposed by
701 isnanf.h (e.g.) here, because those may end up being macros
702 that recursively expand back to isnan. So use the gnulib
703 replacements for them directly. */
704# if @HAVE_ISNANF@ && __GNUC__ >= 4
49114fd4 705# define gl_isnan_f(x) __builtin_isnanf ((float)(x))
2e65b52f
LC
706# else
707_GL_EXTERN_C int rpl_isnanf (float x);
708# define gl_isnan_f(x) rpl_isnanf (x)
709# endif
710# if @HAVE_ISNAND@ && __GNUC__ >= 4
711# define gl_isnan_d(x) __builtin_isnan ((double)(x))
712# else
713_GL_EXTERN_C int rpl_isnand (double x);
714# define gl_isnan_d(x) rpl_isnand (x)
715# endif
716# if @HAVE_ISNANL@ && __GNUC__ >= 4
49114fd4 717# define gl_isnan_l(x) __builtin_isnanl ((long double)(x))
2e65b52f
LC
718# else
719_GL_EXTERN_C int rpl_isnanl (long double x);
720# define gl_isnan_l(x) rpl_isnanl (x)
721# endif
722# undef isnan
723# define isnan(x) \
724 (sizeof (x) == sizeof (long double) ? gl_isnan_l (x) : \
725 sizeof (x) == sizeof (double) ? gl_isnan_d (x) : \
726 gl_isnan_f (x))
49114fd4
LC
727# elif __GNUC__ >= 4
728# undef isnan
729# define isnan(x) \
730 (sizeof (x) == sizeof (long double) ? __builtin_isnanl ((long double)(x)) : \
731 sizeof (x) == sizeof (double) ? __builtin_isnan ((double)(x)) : \
732 __builtin_isnanf ((float)(x)))
2e65b52f 733# endif
ab4d62ad
LC
734/* Ensure isnan is a macro. */
735# ifndef isnan
736# define isnan isnan
737# endif
2e65b52f
LC
738#elif defined GNULIB_POSIXCHECK
739# if defined isnan
740_GL_WARN_REAL_FLOATING_DECL (isnan);
741# undef isnan
742# define isnan(x) _GL_WARN_REAL_FLOATING_IMPL (isnan, x)
743# endif
744#endif
745
746
747#if @GNULIB_SIGNBIT@
748# if @REPLACE_SIGNBIT_USING_GCC@
749# undef signbit
750 /* GCC 4.0 and newer provides three built-ins for signbit. */
751# define signbit(x) \
752 (sizeof (x) == sizeof (long double) ? __builtin_signbitl (x) : \
753 sizeof (x) == sizeof (double) ? __builtin_signbit (x) : \
754 __builtin_signbitf (x))
755# endif
756# if @REPLACE_SIGNBIT@
757# undef signbit
758_GL_EXTERN_C int gl_signbitf (float arg);
759_GL_EXTERN_C int gl_signbitd (double arg);
760_GL_EXTERN_C int gl_signbitl (long double arg);
761# if __GNUC__ >= 2 && !__STRICT_ANSI__
0f00f2c3
LC
762# define _GL_NUM_UINT_WORDS(type) \
763 ((sizeof (type) + sizeof (unsigned int) - 1) / sizeof (unsigned int))
2e65b52f
LC
764# if defined FLT_SIGNBIT_WORD && defined FLT_SIGNBIT_BIT && !defined gl_signbitf
765# define gl_signbitf_OPTIMIZED_MACRO
766# define gl_signbitf(arg) \
767 ({ union { float _value; \
0f00f2c3 768 unsigned int _word[_GL_NUM_UINT_WORDS (float)]; \
2e65b52f
LC
769 } _m; \
770 _m._value = (arg); \
771 (_m._word[FLT_SIGNBIT_WORD] >> FLT_SIGNBIT_BIT) & 1; \
772 })
773# endif
774# if defined DBL_SIGNBIT_WORD && defined DBL_SIGNBIT_BIT && !defined gl_signbitd
775# define gl_signbitd_OPTIMIZED_MACRO
776# define gl_signbitd(arg) \
0f00f2c3
LC
777 ({ union { double _value; \
778 unsigned int _word[_GL_NUM_UINT_WORDS (double)]; \
2e65b52f
LC
779 } _m; \
780 _m._value = (arg); \
781 (_m._word[DBL_SIGNBIT_WORD] >> DBL_SIGNBIT_BIT) & 1; \
782 })
783# endif
784# if defined LDBL_SIGNBIT_WORD && defined LDBL_SIGNBIT_BIT && !defined gl_signbitl
785# define gl_signbitl_OPTIMIZED_MACRO
786# define gl_signbitl(arg) \
787 ({ union { long double _value; \
0f00f2c3 788 unsigned int _word[_GL_NUM_UINT_WORDS (long double)]; \
2e65b52f
LC
789 } _m; \
790 _m._value = (arg); \
0f00f2c3 791 (_m._word[LDBL_SIGNBIT_WORD] >> LDBL_SIGNBIT_BIT) & 1; \
2e65b52f
LC
792 })
793# endif
794# endif
795# define signbit(x) \
796 (sizeof (x) == sizeof (long double) ? gl_signbitl (x) : \
797 sizeof (x) == sizeof (double) ? gl_signbitd (x) : \
798 gl_signbitf (x))
799# endif
800#elif defined GNULIB_POSIXCHECK
801# if defined signbit
802_GL_WARN_REAL_FLOATING_DECL (signbit);
803# undef signbit
804# define signbit(x) _GL_WARN_REAL_FLOATING_IMPL (signbit, x)
805# endif
806#endif
807
808
809#endif /* _GL_MATH_H */
810#endif /* _GL_MATH_H */