1 /* A GNU-like <math.h>.
3 Copyright (C) 2002-2003, 2007-2012 Free Software Foundation, Inc.
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU 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.
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 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
18 #ifndef _@GUARD_PREFIX@_MATH_H
21 @PRAGMA_SYSTEM_HEADER@
25 /* The include_next requires a split double-inclusion guard. */
26 #@INCLUDE_NEXT_AS_FIRST_DIRECTIVE@ @NEXT_AS_FIRST_DIRECTIVE_MATH_H@
28 #ifndef _@GUARD_PREFIX@_MATH_H
29 #define _@GUARD_PREFIX@_MATH_H
32 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
34 /* The definition of _GL_ARG_NONNULL is copied here. */
36 /* The definition of _GL_WARN_ON_USE is copied here. */
39 /* Helper macros to define type-generic function FUNC as overloaded functions,
40 rather than as macros like in C. POSIX declares these with an argument of
41 real-floating (that is, one of float, double, or long double). */
42 # define _GL_MATH_CXX_REAL_FLOATING_DECL_1(func) \
44 _gl_cxx_ ## func ## f (float f) \
49 _gl_cxx_ ## func ## d (double d) \
54 _gl_cxx_ ## func ## l (long double l) \
58 # define _GL_MATH_CXX_REAL_FLOATING_DECL_2(func) \
62 return _gl_cxx_ ## func ## f (f); \
67 return _gl_cxx_ ## func ## d (d); \
70 func (long double l) \
72 return _gl_cxx_ ## func ## l (l); \
76 /* Helper macros to define a portability warning for the
77 classification macro FUNC called with VALUE. POSIX declares the
78 classification macros with an argument of real-floating (that is,
79 one of float, double, or long double). */
80 #define _GL_WARN_REAL_FLOATING_DECL(func) \
82 rpl_ ## func ## f (float f) \
87 rpl_ ## func ## d (double d) \
92 rpl_ ## func ## l (long double l) \
96 _GL_WARN_ON_USE (rpl_ ## func ## f, #func " is unportable - " \
97 "use gnulib module " #func " for portability"); \
98 _GL_WARN_ON_USE (rpl_ ## func ## d, #func " is unportable - " \
99 "use gnulib module " #func " for portability"); \
100 _GL_WARN_ON_USE (rpl_ ## func ## l, #func " is unportable - " \
101 "use gnulib module " #func " for portability")
102 #define _GL_WARN_REAL_FLOATING_IMPL(func, value) \
103 (sizeof (value) == sizeof (float) ? rpl_ ## func ## f (value) \
104 : sizeof (value) == sizeof (double) ? rpl_ ## func ## d (value) \
105 : rpl_ ## func ## l (value))
109 /* Pull in a function that fixes the 'int' to 'long double' conversion
111 _GL_EXTERN_C void _Qp_itoq (long double *, int);
112 static void (*_gl_math_fix_itold) (long double *, int) = _Qp_itoq;
116 /* POSIX allows platforms that don't support NAN. But all major
117 machines in the past 15 years have supported something close to
118 IEEE NaN, so we define this unconditionally. We also must define
119 it on platforms like Solaris 10, where NAN is present but defined
120 as a function pointer rather than a floating point constant. */
121 #if !defined NAN || @REPLACE_NAN@
122 # if !GNULIB_defined_NAN
124 /* The Compaq (ex-DEC) C 6.4 compiler and the Microsoft MSVC 9 compiler
125 choke on the expression 0.0 / 0.0. */
126 # if defined __DECC || defined _MSC_VER
130 static float zero = 0.0f;
133 # define NAN (_NaN())
135 # define NAN (0.0f / 0.0f)
137 # define GNULIB_defined_NAN 1
141 /* Solaris 10 defines HUGE_VAL, but as a function pointer rather
142 than a floating point constant. */
143 #if @REPLACE_HUGE_VAL@
145 # define HUGE_VAL (1.0 / 0.0)
152 _GL_FUNCDECL_SYS (acosf, float, (float x));
154 _GL_CXXALIAS_SYS (acosf, float, (float x));
155 _GL_CXXALIASWARN (acosf);
156 #elif defined GNULIB_POSIXCHECK
158 # if HAVE_RAW_DECL_ACOSF
159 _GL_WARN_ON_USE (acosf, "acosf is unportable - "
160 "use gnulib module acosf for portability");
165 # if !@HAVE_ACOSL@ || !@HAVE_DECL_ACOSL@
166 _GL_FUNCDECL_SYS (acosl, long double, (long double x));
168 _GL_CXXALIAS_SYS (acosl, long double, (long double x));
169 _GL_CXXALIASWARN (acosl);
170 #elif defined GNULIB_POSIXCHECK
172 # if HAVE_RAW_DECL_ACOSL
173 _GL_WARN_ON_USE (acosl, "acosl is unportable - "
174 "use gnulib module mathl for portability");
182 _GL_FUNCDECL_SYS (asinf, float, (float x));
184 _GL_CXXALIAS_SYS (asinf, float, (float x));
185 _GL_CXXALIASWARN (asinf);
186 #elif defined GNULIB_POSIXCHECK
188 # if HAVE_RAW_DECL_ASINF
189 _GL_WARN_ON_USE (asinf, "asinf is unportable - "
190 "use gnulib module asinf for portability");
195 # if !@HAVE_ASINL@ || !@HAVE_DECL_ASINL@
197 _GL_FUNCDECL_SYS (asinl, long double, (long double x));
199 _GL_CXXALIAS_SYS (asinl, long double, (long double x));
200 _GL_CXXALIASWARN (asinl);
201 #elif defined GNULIB_POSIXCHECK
203 # if HAVE_RAW_DECL_ASINL
204 _GL_WARN_ON_USE (asinl, "asinl is unportable - "
205 "use gnulib module mathl for portability");
213 _GL_FUNCDECL_SYS (atanf, float, (float x));
215 _GL_CXXALIAS_SYS (atanf, float, (float x));
216 _GL_CXXALIASWARN (atanf);
217 #elif defined GNULIB_POSIXCHECK
219 # if HAVE_RAW_DECL_ATANF
220 _GL_WARN_ON_USE (atanf, "atanf is unportable - "
221 "use gnulib module atanf for portability");
226 # if !@HAVE_ATANL@ || !@HAVE_DECL_ATANL@
227 _GL_FUNCDECL_SYS (atanl, long double, (long double x));
229 _GL_CXXALIAS_SYS (atanl, long double, (long double x));
230 _GL_CXXALIASWARN (atanl);
231 #elif defined GNULIB_POSIXCHECK
233 # if HAVE_RAW_DECL_ATANL
234 _GL_WARN_ON_USE (atanl, "atanl is unportable - "
235 "use gnulib module mathl for portability");
243 _GL_FUNCDECL_SYS (atan2f, float, (float y, float x));
245 _GL_CXXALIAS_SYS (atan2f, float, (float y, float x));
246 _GL_CXXALIASWARN (atan2f);
247 #elif defined GNULIB_POSIXCHECK
249 # if HAVE_RAW_DECL_ATAN2F
250 _GL_WARN_ON_USE (atan2f, "atan2f is unportable - "
251 "use gnulib module atan2f for portability");
258 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
260 # define ceilf rpl_ceilf
262 _GL_FUNCDECL_RPL (ceilf, float, (float x));
263 _GL_CXXALIAS_RPL (ceilf, float, (float x));
265 # if !@HAVE_DECL_CEILF@
267 _GL_FUNCDECL_SYS (ceilf, float, (float x));
269 _GL_CXXALIAS_SYS (ceilf, float, (float x));
271 _GL_CXXALIASWARN (ceilf);
272 #elif defined GNULIB_POSIXCHECK
274 # if HAVE_RAW_DECL_CEILF
275 _GL_WARN_ON_USE (ceilf, "ceilf is unportable - "
276 "use gnulib module ceilf for portability");
282 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
283 # define ceil rpl_ceil
285 _GL_FUNCDECL_RPL (ceil, double, (double x));
286 _GL_CXXALIAS_RPL (ceil, double, (double x));
288 _GL_CXXALIAS_SYS (ceil, double, (double x));
290 _GL_CXXALIASWARN (ceil);
295 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
297 # define ceill rpl_ceill
299 _GL_FUNCDECL_RPL (ceill, long double, (long double x));
300 _GL_CXXALIAS_RPL (ceill, long double, (long double x));
302 # if !@HAVE_DECL_CEILL@
304 _GL_FUNCDECL_SYS (ceill, long double, (long double x));
306 _GL_CXXALIAS_SYS (ceill, long double, (long double x));
308 _GL_CXXALIASWARN (ceill);
309 #elif defined GNULIB_POSIXCHECK
311 # if HAVE_RAW_DECL_CEILL
312 _GL_WARN_ON_USE (ceill, "ceill is unportable - "
313 "use gnulib module ceill for portability");
318 #if @GNULIB_COPYSIGNF@
319 # if !@HAVE_COPYSIGNF@
320 _GL_FUNCDECL_SYS (copysignf, float, (float x, float y));
322 _GL_CXXALIAS_SYS (copysignf, float, (float x, float y));
323 _GL_CXXALIASWARN (copysignf);
324 #elif defined GNULIB_POSIXCHECK
326 # if HAVE_RAW_DECL_COPYSIGNF
327 _GL_WARN_ON_USE (copysignf, "copysignf is unportable - "
328 "use gnulib module copysignf for portability");
332 #if @GNULIB_COPYSIGN@
333 # if !@HAVE_COPYSIGN@
334 _GL_FUNCDECL_SYS (copysign, double, (double x, double y));
336 _GL_CXXALIAS_SYS (copysign, double, (double x, double y));
337 _GL_CXXALIASWARN (copysign);
338 #elif defined GNULIB_POSIXCHECK
340 # if HAVE_RAW_DECL_COPYSIGN
341 _GL_WARN_ON_USE (copysign, "copysign is unportable - "
342 "use gnulib module copysign for portability");
346 #if @GNULIB_COPYSIGNL@
347 # if !@HAVE_COPYSIGNL@
348 _GL_FUNCDECL_SYS (copysignl, long double, (long double x, long double y));
350 _GL_CXXALIAS_SYS (copysignl, long double, (long double x, long double y));
351 _GL_CXXALIASWARN (copysignl);
352 #elif defined GNULIB_POSIXCHECK
354 # if HAVE_RAW_DECL_COPYSIGNL
355 _GL_WARN_ON_USE (copysign, "copysignl is unportable - "
356 "use gnulib module copysignl for portability");
364 _GL_FUNCDECL_SYS (cosf, float, (float x));
366 _GL_CXXALIAS_SYS (cosf, float, (float x));
367 _GL_CXXALIASWARN (cosf);
368 #elif defined GNULIB_POSIXCHECK
370 # if HAVE_RAW_DECL_COSF
371 _GL_WARN_ON_USE (cosf, "cosf is unportable - "
372 "use gnulib module cosf for portability");
377 # if !@HAVE_COSL@ || !@HAVE_DECL_COSL@
379 _GL_FUNCDECL_SYS (cosl, long double, (long double x));
381 _GL_CXXALIAS_SYS (cosl, long double, (long double x));
382 _GL_CXXALIASWARN (cosl);
383 #elif defined GNULIB_POSIXCHECK
385 # if HAVE_RAW_DECL_COSL
386 _GL_WARN_ON_USE (cosl, "cosl is unportable - "
387 "use gnulib module mathl for portability");
395 _GL_FUNCDECL_SYS (coshf, float, (float x));
397 _GL_CXXALIAS_SYS (coshf, float, (float x));
398 _GL_CXXALIASWARN (coshf);
399 #elif defined GNULIB_POSIXCHECK
401 # if HAVE_RAW_DECL_COSHF
402 _GL_WARN_ON_USE (coshf, "coshf is unportable - "
403 "use gnulib module coshf for portability");
411 _GL_FUNCDECL_SYS (expf, float, (float x));
413 _GL_CXXALIAS_SYS (expf, float, (float x));
414 _GL_CXXALIASWARN (expf);
415 #elif defined GNULIB_POSIXCHECK
417 # if HAVE_RAW_DECL_EXPF
418 _GL_WARN_ON_USE (expf, "expf is unportable - "
419 "use gnulib module expf for portability");
424 # if !@HAVE_EXPL@ || !@HAVE_DECL_EXPL@
426 _GL_FUNCDECL_SYS (expl, long double, (long double x));
428 _GL_CXXALIAS_SYS (expl, long double, (long double x));
429 _GL_CXXALIASWARN (expl);
430 #elif defined GNULIB_POSIXCHECK
432 # if HAVE_RAW_DECL_EXPL
433 _GL_WARN_ON_USE (expl, "expl is unportable - "
434 "use gnulib module mathl for portability");
442 _GL_FUNCDECL_SYS (fabsf, float, (float x));
444 _GL_CXXALIAS_SYS (fabsf, float, (float x));
445 _GL_CXXALIASWARN (fabsf);
446 #elif defined GNULIB_POSIXCHECK
448 # if HAVE_RAW_DECL_FABSF
449 _GL_WARN_ON_USE (fabsf, "fabsf is unportable - "
450 "use gnulib module fabsf for portability");
456 # if @REPLACE_FLOORF@
457 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
459 # define floorf rpl_floorf
461 _GL_FUNCDECL_RPL (floorf, float, (float x));
462 _GL_CXXALIAS_RPL (floorf, float, (float x));
464 # if !@HAVE_DECL_FLOORF@
466 _GL_FUNCDECL_SYS (floorf, float, (float x));
468 _GL_CXXALIAS_SYS (floorf, float, (float x));
470 _GL_CXXALIASWARN (floorf);
471 #elif defined GNULIB_POSIXCHECK
473 # if HAVE_RAW_DECL_FLOORF
474 _GL_WARN_ON_USE (floorf, "floorf is unportable - "
475 "use gnulib module floorf for portability");
481 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
482 # define floor rpl_floor
484 _GL_FUNCDECL_RPL (floor, double, (double x));
485 _GL_CXXALIAS_RPL (floor, double, (double x));
487 _GL_CXXALIAS_SYS (floor, double, (double x));
489 _GL_CXXALIASWARN (floor);
493 # if @REPLACE_FLOORL@
494 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
496 # define floorl rpl_floorl
498 _GL_FUNCDECL_RPL (floorl, long double, (long double x));
499 _GL_CXXALIAS_RPL (floorl, long double, (long double x));
501 # if !@HAVE_DECL_FLOORL@
503 _GL_FUNCDECL_SYS (floorl, long double, (long double x));
505 _GL_CXXALIAS_SYS (floorl, long double, (long double x));
507 _GL_CXXALIASWARN (floorl);
508 #elif defined GNULIB_POSIXCHECK
510 # if HAVE_RAW_DECL_FLOORL
511 _GL_WARN_ON_USE (floorl, "floorl is unportable - "
512 "use gnulib module floorl for portability");
519 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
521 # define fmaf rpl_fmaf
523 _GL_FUNCDECL_RPL (fmaf, float, (float x, float y, float z));
524 _GL_CXXALIAS_RPL (fmaf, float, (float x, float y, float z));
527 _GL_FUNCDECL_SYS (fmaf, float, (float x, float y, float z));
529 _GL_CXXALIAS_SYS (fmaf, float, (float x, float y, float z));
531 _GL_CXXALIASWARN (fmaf);
532 #elif defined GNULIB_POSIXCHECK
534 # if HAVE_RAW_DECL_FMAF
535 _GL_WARN_ON_USE (fmaf, "fmaf is unportable - "
536 "use gnulib module fmaf for portability");
542 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
546 _GL_FUNCDECL_RPL (fma, double, (double x, double y, double z));
547 _GL_CXXALIAS_RPL (fma, double, (double x, double y, double z));
550 _GL_FUNCDECL_SYS (fma, double, (double x, double y, double z));
552 _GL_CXXALIAS_SYS (fma, double, (double x, double y, double z));
554 _GL_CXXALIASWARN (fma);
555 #elif defined GNULIB_POSIXCHECK
557 # if HAVE_RAW_DECL_FMA
558 _GL_WARN_ON_USE (fma, "fma is unportable - "
559 "use gnulib module fma for portability");
565 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
567 # define fmal rpl_fmal
569 _GL_FUNCDECL_RPL (fmal, long double,
570 (long double x, long double y, long double z));
571 _GL_CXXALIAS_RPL (fmal, long double,
572 (long double x, long double y, long double z));
575 _GL_FUNCDECL_SYS (fmal, long double,
576 (long double x, long double y, long double z));
578 _GL_CXXALIAS_SYS (fmal, long double,
579 (long double x, long double y, long double z));
581 _GL_CXXALIASWARN (fmal);
582 #elif defined GNULIB_POSIXCHECK
584 # if HAVE_RAW_DECL_FMAL
585 _GL_WARN_ON_USE (fmal, "fmal is unportable - "
586 "use gnulib module fmal for portability");
594 _GL_FUNCDECL_SYS (fmodf, float, (float x, float y));
596 _GL_CXXALIAS_SYS (fmodf, float, (float x, float y));
597 _GL_CXXALIASWARN (fmodf);
598 #elif defined GNULIB_POSIXCHECK
600 # if HAVE_RAW_DECL_FMODF
601 _GL_WARN_ON_USE (fmodf, "fmodf is unportable - "
602 "use gnulib module fmodf for portability");
610 If x finite and nonzero: 0.5 <= |mantissa| < 1.0.
611 If x is zero: mantissa = x, exp = 0.
612 If x is infinite or NaN: mantissa = x, exp unspecified.
613 Store exp in *EXPPTR and return mantissa. */
615 # if @REPLACE_FREXPF@
616 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
618 # define frexpf rpl_frexpf
620 _GL_FUNCDECL_RPL (frexpf, float, (float x, int *expptr) _GL_ARG_NONNULL ((2)));
621 _GL_CXXALIAS_RPL (frexpf, float, (float x, int *expptr));
625 _GL_FUNCDECL_SYS (frexpf, float, (float x, int *expptr) _GL_ARG_NONNULL ((2)));
627 _GL_CXXALIAS_SYS (frexpf, float, (float x, int *expptr));
629 _GL_CXXALIASWARN (frexpf);
630 #elif defined GNULIB_POSIXCHECK
632 # if HAVE_RAW_DECL_FREXPF
633 _GL_WARN_ON_USE (frexpf, "frexpf is unportable - "
634 "use gnulib module frexpf for portability");
641 If x finite and nonzero: 0.5 <= |mantissa| < 1.0.
642 If x is zero: mantissa = x, exp = 0.
643 If x is infinite or NaN: mantissa = x, exp unspecified.
644 Store exp in *EXPPTR and return mantissa. */
647 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
648 # define frexp rpl_frexp
650 _GL_FUNCDECL_RPL (frexp, double, (double x, int *expptr) _GL_ARG_NONNULL ((2)));
651 _GL_CXXALIAS_RPL (frexp, double, (double x, int *expptr));
653 _GL_CXXALIAS_SYS (frexp, double, (double x, int *expptr));
655 _GL_CXXALIASWARN (frexp);
656 #elif defined GNULIB_POSIXCHECK
658 /* Assume frexp is always declared. */
659 _GL_WARN_ON_USE (frexp, "frexp is unportable - "
660 "use gnulib module frexp for portability");
666 If x finite and nonzero: 0.5 <= |mantissa| < 1.0.
667 If x is zero: mantissa = x, exp = 0.
668 If x is infinite or NaN: mantissa = x, exp unspecified.
669 Store exp in *EXPPTR and return mantissa. */
670 #if @GNULIB_FREXPL@ && @REPLACE_FREXPL@
671 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
673 # define frexpl rpl_frexpl
675 _GL_FUNCDECL_RPL (frexpl, long double,
676 (long double x, int *expptr) _GL_ARG_NONNULL ((2)));
677 _GL_CXXALIAS_RPL (frexpl, long double, (long double x, int *expptr));
679 # if !@HAVE_DECL_FREXPL@
680 _GL_FUNCDECL_SYS (frexpl, long double,
681 (long double x, int *expptr) _GL_ARG_NONNULL ((2)));
684 _GL_CXXALIAS_SYS (frexpl, long double, (long double x, int *expptr));
687 #if @GNULIB_FREXPL@ && !(@REPLACE_FREXPL@ && !@HAVE_DECL_FREXPL@)
688 _GL_CXXALIASWARN (frexpl);
690 #if !@GNULIB_FREXPL@ && defined GNULIB_POSIXCHECK
692 # if HAVE_RAW_DECL_FREXPL
693 _GL_WARN_ON_USE (frexpl, "frexpl is unportable - "
694 "use gnulib module frexpl for portability");
699 /* Return x * 2^exp. */
703 _GL_FUNCDECL_SYS (ldexpf, float, (float x, int exp));
705 _GL_CXXALIAS_SYS (ldexpf, float, (float x, int exp));
706 _GL_CXXALIASWARN (ldexpf);
707 #elif defined GNULIB_POSIXCHECK
709 # if HAVE_RAW_DECL_LDEXPF
710 _GL_WARN_ON_USE (ldexpf, "ldexpf is unportable - "
711 "use gnulib module ldexpf for portability");
715 /* Return x * 2^exp. */
716 #if @GNULIB_LDEXPL@ && @REPLACE_LDEXPL@
717 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
719 # define ldexpl rpl_ldexpl
721 _GL_FUNCDECL_RPL (ldexpl, long double, (long double x, int exp));
722 _GL_CXXALIAS_RPL (ldexpl, long double, (long double x, int exp));
724 # if !@HAVE_DECL_LDEXPL@
725 _GL_FUNCDECL_SYS (ldexpl, long double, (long double x, int exp));
728 _GL_CXXALIAS_SYS (ldexpl, long double, (long double x, int exp));
732 _GL_CXXALIASWARN (ldexpl);
734 #if !@GNULIB_LDEXPL@ && defined GNULIB_POSIXCHECK
736 # if HAVE_RAW_DECL_LDEXPL
737 _GL_WARN_ON_USE (ldexpl, "ldexpl is unportable - "
738 "use gnulib module ldexpl for portability");
744 # if !@HAVE_DECL_LOGB@
745 _GL_EXTERN_C double logb (double x);
747 #elif defined GNULIB_POSIXCHECK
749 # if HAVE_RAW_DECL_LOGB
750 _GL_WARN_ON_USE (logb, "logb is unportable - "
751 "use gnulib module logb for portability");
759 _GL_FUNCDECL_SYS (logf, float, (float x));
761 _GL_CXXALIAS_SYS (logf, float, (float x));
762 _GL_CXXALIASWARN (logf);
763 #elif defined GNULIB_POSIXCHECK
765 # if HAVE_RAW_DECL_LOGF
766 _GL_WARN_ON_USE (logf, "logf is unportable - "
767 "use gnulib module logf for portability");
772 # if !@HAVE_LOGL@ || !@HAVE_DECL_LOGL@
774 _GL_FUNCDECL_SYS (logl, long double, (long double x));
776 _GL_CXXALIAS_SYS (logl, long double, (long double x));
777 _GL_CXXALIASWARN (logl);
778 #elif defined GNULIB_POSIXCHECK
780 # if HAVE_RAW_DECL_LOGL
781 _GL_WARN_ON_USE (logl, "logl is unportable - "
782 "use gnulib module mathl for portability");
790 _GL_FUNCDECL_SYS (log10f, float, (float x));
792 _GL_CXXALIAS_SYS (log10f, float, (float x));
793 _GL_CXXALIASWARN (log10f);
794 #elif defined GNULIB_POSIXCHECK
796 # if HAVE_RAW_DECL_LOG10F
797 _GL_WARN_ON_USE (log10f, "log10f is unportable - "
798 "use gnulib module log10f for portability");
806 _GL_FUNCDECL_SYS (modff, float, (float x, float *iptr) _GL_ARG_NONNULL ((2)));
808 _GL_CXXALIAS_SYS (modff, float, (float x, float *iptr));
809 _GL_CXXALIASWARN (modff);
810 #elif defined GNULIB_POSIXCHECK
812 # if HAVE_RAW_DECL_MODFF
813 _GL_WARN_ON_USE (modff, "modff is unportable - "
814 "use gnulib module modff for portability");
822 _GL_FUNCDECL_SYS (powf, float, (float x, float y));
824 _GL_CXXALIAS_SYS (powf, float, (float x, float y));
825 _GL_CXXALIASWARN (powf);
826 #elif defined GNULIB_POSIXCHECK
828 # if HAVE_RAW_DECL_POWF
829 _GL_WARN_ON_USE (powf, "powf is unportable - "
830 "use gnulib module powf for portability");
837 _GL_FUNCDECL_SYS (rintf, float, (float x));
839 _GL_CXXALIAS_SYS (rintf, float, (float x));
840 _GL_CXXALIASWARN (rintf);
841 #elif defined GNULIB_POSIXCHECK
843 # if HAVE_RAW_DECL_RINTF
844 _GL_WARN_ON_USE (rintf, "rintf is unportable - "
845 "use gnulib module rintf for portability");
851 _GL_FUNCDECL_SYS (rint, double, (double x));
853 _GL_CXXALIAS_SYS (rint, double, (double x));
854 _GL_CXXALIASWARN (rint);
855 #elif defined GNULIB_POSIXCHECK
857 # if HAVE_RAW_DECL_RINT
858 _GL_WARN_ON_USE (rint, "rint is unportable - "
859 "use gnulib module rint for portability");
865 _GL_FUNCDECL_SYS (rintl, long double, (long double x));
867 _GL_CXXALIAS_SYS (rintl, long double, (long double x));
868 _GL_CXXALIASWARN (rintl);
869 #elif defined GNULIB_POSIXCHECK
871 # if HAVE_RAW_DECL_RINTL
872 _GL_WARN_ON_USE (rintl, "rintl is unportable - "
873 "use gnulib module rintl for portability");
879 # if @REPLACE_ROUNDF@
880 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
882 # define roundf rpl_roundf
884 _GL_FUNCDECL_RPL (roundf, float, (float x));
885 _GL_CXXALIAS_RPL (roundf, float, (float x));
887 # if !@HAVE_DECL_ROUNDF@
888 _GL_FUNCDECL_SYS (roundf, float, (float x));
890 _GL_CXXALIAS_SYS (roundf, float, (float x));
892 _GL_CXXALIASWARN (roundf);
893 #elif defined GNULIB_POSIXCHECK
895 # if HAVE_RAW_DECL_ROUNDF
896 _GL_WARN_ON_USE (roundf, "roundf is unportable - "
897 "use gnulib module roundf for portability");
903 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
905 # define round rpl_round
907 _GL_FUNCDECL_RPL (round, double, (double x));
908 _GL_CXXALIAS_RPL (round, double, (double x));
910 # if !@HAVE_DECL_ROUND@
911 _GL_FUNCDECL_SYS (round, double, (double x));
913 _GL_CXXALIAS_SYS (round, double, (double x));
915 _GL_CXXALIASWARN (round);
916 #elif defined GNULIB_POSIXCHECK
918 # if HAVE_RAW_DECL_ROUND
919 _GL_WARN_ON_USE (round, "round is unportable - "
920 "use gnulib module round for portability");
925 # if @REPLACE_ROUNDL@
926 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
928 # define roundl rpl_roundl
930 _GL_FUNCDECL_RPL (roundl, long double, (long double x));
931 _GL_CXXALIAS_RPL (roundl, long double, (long double x));
933 # if !@HAVE_DECL_ROUNDL@
934 _GL_FUNCDECL_SYS (roundl, long double, (long double x));
936 _GL_CXXALIAS_SYS (roundl, long double, (long double x));
938 _GL_CXXALIASWARN (roundl);
939 #elif defined GNULIB_POSIXCHECK
941 # if HAVE_RAW_DECL_ROUNDL
942 _GL_WARN_ON_USE (roundl, "roundl is unportable - "
943 "use gnulib module roundl for portability");
951 _GL_FUNCDECL_SYS (sinf, float, (float x));
953 _GL_CXXALIAS_SYS (sinf, float, (float x));
954 _GL_CXXALIASWARN (sinf);
955 #elif defined GNULIB_POSIXCHECK
957 # if HAVE_RAW_DECL_SINF
958 _GL_WARN_ON_USE (sinf, "sinf is unportable - "
959 "use gnulib module sinf for portability");
964 # if !@HAVE_SINL@ || !@HAVE_DECL_SINL@
966 _GL_FUNCDECL_SYS (sinl, long double, (long double x));
968 _GL_CXXALIAS_SYS (sinl, long double, (long double x));
969 _GL_CXXALIASWARN (sinl);
970 #elif defined GNULIB_POSIXCHECK
972 # if HAVE_RAW_DECL_SINL
973 _GL_WARN_ON_USE (sinl, "sinl is unportable - "
974 "use gnulib module mathl for portability");
982 _GL_FUNCDECL_SYS (sinhf, float, (float x));
984 _GL_CXXALIAS_SYS (sinhf, float, (float x));
985 _GL_CXXALIASWARN (sinhf);
986 #elif defined GNULIB_POSIXCHECK
988 # if HAVE_RAW_DECL_SINHF
989 _GL_WARN_ON_USE (sinhf, "sinhf is unportable - "
990 "use gnulib module sinhf for portability");
998 _GL_FUNCDECL_SYS (sqrtf, float, (float x));
1000 _GL_CXXALIAS_SYS (sqrtf, float, (float x));
1001 _GL_CXXALIASWARN (sqrtf);
1002 #elif defined GNULIB_POSIXCHECK
1004 # if HAVE_RAW_DECL_SQRTF
1005 _GL_WARN_ON_USE (sqrtf, "sqrtf is unportable - "
1006 "use gnulib module sqrtf for portability");
1011 # if !@HAVE_SQRTL@ || !@HAVE_DECL_SQRTL@
1013 _GL_FUNCDECL_SYS (sqrtl, long double, (long double x));
1015 _GL_CXXALIAS_SYS (sqrtl, long double, (long double x));
1016 _GL_CXXALIASWARN (sqrtl);
1017 #elif defined GNULIB_POSIXCHECK
1019 # if HAVE_RAW_DECL_SQRTL
1020 _GL_WARN_ON_USE (sqrtl, "sqrtl is unportable - "
1021 "use gnulib module mathl for portability");
1029 _GL_FUNCDECL_SYS (tanf, float, (float x));
1031 _GL_CXXALIAS_SYS (tanf, float, (float x));
1032 _GL_CXXALIASWARN (tanf);
1033 #elif defined GNULIB_POSIXCHECK
1035 # if HAVE_RAW_DECL_TANF
1036 _GL_WARN_ON_USE (tanf, "tanf is unportable - "
1037 "use gnulib module tanf for portability");
1042 # if !@HAVE_TANL@ || !@HAVE_DECL_TANL@
1044 _GL_FUNCDECL_SYS (tanl, long double, (long double x));
1046 _GL_CXXALIAS_SYS (tanl, long double, (long double x));
1047 _GL_CXXALIASWARN (tanl);
1048 #elif defined GNULIB_POSIXCHECK
1050 # if HAVE_RAW_DECL_TANL
1051 _GL_WARN_ON_USE (tanl, "tanl is unportable - "
1052 "use gnulib module mathl for portability");
1060 _GL_FUNCDECL_SYS (tanhf, float, (float x));
1062 _GL_CXXALIAS_SYS (tanhf, float, (float x));
1063 _GL_CXXALIASWARN (tanhf);
1064 #elif defined GNULIB_POSIXCHECK
1066 # if HAVE_RAW_DECL_TANHF
1067 _GL_WARN_ON_USE (tanhf, "tanhf is unportable - "
1068 "use gnulib module tanhf for portability");
1074 # if @REPLACE_TRUNCF@
1075 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1076 # define truncf rpl_truncf
1078 _GL_FUNCDECL_RPL (truncf, float, (float x));
1079 _GL_CXXALIAS_RPL (truncf, float, (float x));
1081 # if !@HAVE_DECL_TRUNCF@
1082 _GL_FUNCDECL_SYS (truncf, float, (float x));
1084 _GL_CXXALIAS_SYS (truncf, float, (float x));
1086 _GL_CXXALIASWARN (truncf);
1087 #elif defined GNULIB_POSIXCHECK
1089 # if HAVE_RAW_DECL_TRUNCF
1090 _GL_WARN_ON_USE (truncf, "truncf is unportable - "
1091 "use gnulib module truncf for portability");
1096 # if @REPLACE_TRUNC@
1097 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1098 # define trunc rpl_trunc
1100 _GL_FUNCDECL_RPL (trunc, double, (double x));
1101 _GL_CXXALIAS_RPL (trunc, double, (double x));
1103 # if !@HAVE_DECL_TRUNC@
1104 _GL_FUNCDECL_SYS (trunc, double, (double x));
1106 _GL_CXXALIAS_SYS (trunc, double, (double x));
1108 _GL_CXXALIASWARN (trunc);
1109 #elif defined GNULIB_POSIXCHECK
1111 # if HAVE_RAW_DECL_TRUNC
1112 _GL_WARN_ON_USE (trunc, "trunc is unportable - "
1113 "use gnulib module trunc for portability");
1118 # if @REPLACE_TRUNCL@
1119 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1121 # define truncl rpl_truncl
1123 _GL_FUNCDECL_RPL (truncl, long double, (long double x));
1124 _GL_CXXALIAS_RPL (truncl, long double, (long double x));
1126 # if !@HAVE_DECL_TRUNCL@
1127 _GL_FUNCDECL_SYS (truncl, long double, (long double x));
1129 _GL_CXXALIAS_SYS (truncl, long double, (long double x));
1131 _GL_CXXALIASWARN (truncl);
1132 #elif defined GNULIB_POSIXCHECK
1134 # if HAVE_RAW_DECL_TRUNCL
1135 _GL_WARN_ON_USE (truncl, "truncl is unportable - "
1136 "use gnulib module truncl for portability");
1141 /* Definitions of function-like macros come here, after the function
1145 #if @GNULIB_ISFINITE@
1146 # if @REPLACE_ISFINITE@
1147 _GL_EXTERN_C int gl_isfinitef (float x);
1148 _GL_EXTERN_C int gl_isfinited (double x);
1149 _GL_EXTERN_C int gl_isfinitel (long double x);
1151 # define isfinite(x) \
1152 (sizeof (x) == sizeof (long double) ? gl_isfinitel (x) : \
1153 sizeof (x) == sizeof (double) ? gl_isfinited (x) : \
1158 _GL_MATH_CXX_REAL_FLOATING_DECL_1 (isfinite)
1160 _GL_MATH_CXX_REAL_FLOATING_DECL_2 (isfinite)
1163 #elif defined GNULIB_POSIXCHECK
1164 # if defined isfinite
1165 _GL_WARN_REAL_FLOATING_DECL (isfinite);
1167 # define isfinite(x) _GL_WARN_REAL_FLOATING_IMPL (isfinite, x)
1173 # if @REPLACE_ISINF@
1174 _GL_EXTERN_C int gl_isinff (float x);
1175 _GL_EXTERN_C int gl_isinfd (double x);
1176 _GL_EXTERN_C int gl_isinfl (long double x);
1179 (sizeof (x) == sizeof (long double) ? gl_isinfl (x) : \
1180 sizeof (x) == sizeof (double) ? gl_isinfd (x) : \
1185 _GL_MATH_CXX_REAL_FLOATING_DECL_1 (isinf)
1187 _GL_MATH_CXX_REAL_FLOATING_DECL_2 (isinf)
1190 #elif defined GNULIB_POSIXCHECK
1192 _GL_WARN_REAL_FLOATING_DECL (isinf);
1194 # define isinf(x) _GL_WARN_REAL_FLOATING_IMPL (isinf, x)
1200 /* Test for NaN for 'float' numbers. */
1202 /* The original <math.h> included above provides a declaration of isnan macro
1203 or (older) isnanf function. */
1205 /* GCC 4.0 and newer provides three built-ins for isnan. */
1207 # define isnanf(x) __builtin_isnanf ((float)(x))
1208 # elif defined isnan
1210 # define isnanf(x) isnan ((float)(x))
1213 /* Test whether X is a NaN. */
1215 # define isnanf rpl_isnanf
1216 _GL_EXTERN_C int isnanf (float x);
1221 /* Test for NaN for 'double' numbers.
1222 This function is a gnulib extension, unlike isnan() which applied only
1223 to 'double' numbers earlier but now is a type-generic macro. */
1225 /* The original <math.h> included above provides a declaration of isnan
1228 /* GCC 4.0 and newer provides three built-ins for isnan. */
1230 # define isnand(x) __builtin_isnan ((double)(x))
1233 # define isnand(x) isnan ((double)(x))
1236 /* Test whether X is a NaN. */
1238 # define isnand rpl_isnand
1239 _GL_EXTERN_C int isnand (double x);
1244 /* Test for NaN for 'long double' numbers. */
1246 /* The original <math.h> included above provides a declaration of isnan
1247 macro or (older) isnanl function. */
1249 /* GCC 4.0 and newer provides three built-ins for isnan. */
1251 # define isnanl(x) __builtin_isnanl ((long double)(x))
1252 # elif defined isnan
1254 # define isnanl(x) isnan ((long double)(x))
1257 /* Test whether X is a NaN. */
1259 # define isnanl rpl_isnanl
1260 _GL_EXTERN_C int isnanl (long double x) _GL_ATTRIBUTE_CONST;
1264 /* This must come *after* the snippets for GNULIB_ISNANF and GNULIB_ISNANL! */
1266 # if @REPLACE_ISNAN@
1267 /* We can't just use the isnanf macro (e.g.) as exposed by
1268 isnanf.h (e.g.) here, because those may end up being macros
1269 that recursively expand back to isnan. So use the gnulib
1270 replacements for them directly. */
1271 # if @HAVE_ISNANF@ && __GNUC__ >= 4
1272 # define gl_isnan_f(x) __builtin_isnanf ((float)(x))
1274 _GL_EXTERN_C int rpl_isnanf (float x);
1275 # define gl_isnan_f(x) rpl_isnanf (x)
1277 # if @HAVE_ISNAND@ && __GNUC__ >= 4
1278 # define gl_isnan_d(x) __builtin_isnan ((double)(x))
1280 _GL_EXTERN_C int rpl_isnand (double x);
1281 # define gl_isnan_d(x) rpl_isnand (x)
1283 # if @HAVE_ISNANL@ && __GNUC__ >= 4
1284 # define gl_isnan_l(x) __builtin_isnanl ((long double)(x))
1286 _GL_EXTERN_C int rpl_isnanl (long double x) _GL_ATTRIBUTE_CONST;
1287 # define gl_isnan_l(x) rpl_isnanl (x)
1291 (sizeof (x) == sizeof (long double) ? gl_isnan_l (x) : \
1292 sizeof (x) == sizeof (double) ? gl_isnan_d (x) : \
1294 # elif __GNUC__ >= 4
1297 (sizeof (x) == sizeof (long double) ? __builtin_isnanl ((long double)(x)) : \
1298 sizeof (x) == sizeof (double) ? __builtin_isnan ((double)(x)) : \
1299 __builtin_isnanf ((float)(x)))
1303 _GL_MATH_CXX_REAL_FLOATING_DECL_1 (isnan)
1305 _GL_MATH_CXX_REAL_FLOATING_DECL_2 (isnan)
1308 /* Ensure isnan is a macro. */
1310 # define isnan isnan
1313 #elif defined GNULIB_POSIXCHECK
1315 _GL_WARN_REAL_FLOATING_DECL (isnan);
1317 # define isnan(x) _GL_WARN_REAL_FLOATING_IMPL (isnan, x)
1322 #if @GNULIB_SIGNBIT@
1323 # if @REPLACE_SIGNBIT_USING_GCC@
1325 /* GCC 4.0 and newer provides three built-ins for signbit. */
1326 # define signbit(x) \
1327 (sizeof (x) == sizeof (long double) ? __builtin_signbitl (x) : \
1328 sizeof (x) == sizeof (double) ? __builtin_signbit (x) : \
1329 __builtin_signbitf (x))
1331 # if @REPLACE_SIGNBIT@
1333 _GL_EXTERN_C int gl_signbitf (float arg);
1334 _GL_EXTERN_C int gl_signbitd (double arg);
1335 _GL_EXTERN_C int gl_signbitl (long double arg);
1336 # if __GNUC__ >= 2 && !defined __STRICT_ANSI__
1337 # define _GL_NUM_UINT_WORDS(type) \
1338 ((sizeof (type) + sizeof (unsigned int) - 1) / sizeof (unsigned int))
1339 # if defined FLT_SIGNBIT_WORD && defined FLT_SIGNBIT_BIT && !defined gl_signbitf
1340 # define gl_signbitf_OPTIMIZED_MACRO
1341 # define gl_signbitf(arg) \
1342 ({ union { float _value; \
1343 unsigned int _word[_GL_NUM_UINT_WORDS (float)]; \
1345 _m._value = (arg); \
1346 (_m._word[FLT_SIGNBIT_WORD] >> FLT_SIGNBIT_BIT) & 1; \
1349 # if defined DBL_SIGNBIT_WORD && defined DBL_SIGNBIT_BIT && !defined gl_signbitd
1350 # define gl_signbitd_OPTIMIZED_MACRO
1351 # define gl_signbitd(arg) \
1352 ({ union { double _value; \
1353 unsigned int _word[_GL_NUM_UINT_WORDS (double)]; \
1355 _m._value = (arg); \
1356 (_m._word[DBL_SIGNBIT_WORD] >> DBL_SIGNBIT_BIT) & 1; \
1359 # if defined LDBL_SIGNBIT_WORD && defined LDBL_SIGNBIT_BIT && !defined gl_signbitl
1360 # define gl_signbitl_OPTIMIZED_MACRO
1361 # define gl_signbitl(arg) \
1362 ({ union { long double _value; \
1363 unsigned int _word[_GL_NUM_UINT_WORDS (long double)]; \
1365 _m._value = (arg); \
1366 (_m._word[LDBL_SIGNBIT_WORD] >> LDBL_SIGNBIT_BIT) & 1; \
1370 # define signbit(x) \
1371 (sizeof (x) == sizeof (long double) ? gl_signbitl (x) : \
1372 sizeof (x) == sizeof (double) ? gl_signbitd (x) : \
1377 _GL_MATH_CXX_REAL_FLOATING_DECL_1 (signbit)
1379 _GL_MATH_CXX_REAL_FLOATING_DECL_2 (signbit)
1382 #elif defined GNULIB_POSIXCHECK
1383 # if defined signbit
1384 _GL_WARN_REAL_FLOATING_DECL (signbit);
1386 # define signbit(x) _GL_WARN_REAL_FLOATING_IMPL (signbit, x)
1391 #endif /* _@GUARD_PREFIX@_MATH_H */
1392 #endif /* _@GUARD_PREFIX@_MATH_H */