/* A GNU-like <math.h>.
- Copyright (C) 2002-2003, 2007-2016 Free Software Foundation, Inc.
+ Copyright (C) 2002-2003, 2007-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
#ifndef _@GUARD_PREFIX@_MATH_H
#ifndef _@GUARD_PREFIX@_MATH_H
#define _@GUARD_PREFIX@_MATH_H
+/* On OpenVMS, NAN, INFINITY, and HUGEVAL macros are defined in <fp.h>. */
+#if defined __VMS && ! defined NAN
+# include <fp.h>
+#endif
+
#ifndef _GL_INLINE_HEADER_BEGIN
#error "Please include config.h first."
#endif
return func (l); \
}
# define _GL_MATH_CXX_REAL_FLOATING_DECL_2(func) \
+_GL_BEGIN_NAMESPACE \
inline int \
func (float f) \
{ \
func (long double l) \
{ \
return _gl_cxx_ ## func ## l (l); \
-}
+} \
+_GL_END_NAMESPACE
#endif
/* Helper macros to define a portability warning for the
#endif
-/* Ensure FP_ILOGB0 and FP_ILOGBNAN are defined. */
-#if !(defined FP_ILOGB0 && defined FP_ILOGBNAN)
+#if defined FP_ILOGB0 && defined FP_ILOGBNAN
+ /* Ensure FP_ILOGB0 and FP_ILOGBNAN are correct. */
+# if defined __HAIKU__
+ /* Haiku: match what ilogb() does */
+# undef FP_ILOGB0
+# undef FP_ILOGBNAN
+# define FP_ILOGB0 (- 2147483647 - 1) /* INT_MIN */
+# define FP_ILOGBNAN (- 2147483647 - 1) /* INT_MIN */
+# endif
+#else
+ /* Ensure FP_ILOGB0 and FP_ILOGBNAN are defined. */
# if defined __NetBSD__ || defined __sgi
/* NetBSD, IRIX 6.5: match what ilogb() does */
# define FP_ILOGB0 (- 2147483647 - 1) /* INT_MIN */
#if @GNULIB_ACOSF@
-# if !@HAVE_ACOSF@
-# undef acosf
+# if @REPLACE_ACOSF@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef acosf
+# define acosf rpl_acosf
+# endif
+_GL_FUNCDECL_RPL (acosf, float, (float x));
+_GL_CXXALIAS_RPL (acosf, float, (float x));
+# else
+# if !@HAVE_ACOSF@
+# undef acosf
_GL_FUNCDECL_SYS (acosf, float, (float x));
-# endif
+# endif
_GL_CXXALIAS_SYS (acosf, float, (float x));
+# endif
_GL_CXXALIASWARN (acosf);
#elif defined GNULIB_POSIXCHECK
# undef acosf
#if @GNULIB_ASINF@
-# if !@HAVE_ASINF@
-# undef asinf
+# if @REPLACE_ASINF@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef asinf
+# define asinf rpl_asinf
+# endif
+_GL_FUNCDECL_RPL (asinf, float, (float x));
+_GL_CXXALIAS_RPL (asinf, float, (float x));
+# else
+# if !@HAVE_ASINF@
+# undef asinf
_GL_FUNCDECL_SYS (asinf, float, (float x));
-# endif
+# endif
_GL_CXXALIAS_SYS (asinf, float, (float x));
+# endif
_GL_CXXALIASWARN (asinf);
#elif defined GNULIB_POSIXCHECK
# undef asinf
#if @GNULIB_ATANF@
-# if !@HAVE_ATANF@
-# undef atanf
+# if @REPLACE_ATANF@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef atanf
+# define atanf rpl_atanf
+# endif
+_GL_FUNCDECL_RPL (atanf, float, (float x));
+_GL_CXXALIAS_RPL (atanf, float, (float x));
+# else
+# if !@HAVE_ATANF@
+# undef atanf
_GL_FUNCDECL_SYS (atanf, float, (float x));
-# endif
+# endif
_GL_CXXALIAS_SYS (atanf, float, (float x));
+# endif
_GL_CXXALIASWARN (atanf);
#elif defined GNULIB_POSIXCHECK
# undef atanf
#if @GNULIB_ATAN2F@
-# if !@HAVE_ATAN2F@
-# undef atan2f
+# if @REPLACE_ATAN2F@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef atan2f
+# define atan2f rpl_atan2f
+# endif
+_GL_FUNCDECL_RPL (atan2f, float, (float y, float x));
+_GL_CXXALIAS_RPL (atan2f, float, (float y, float x));
+# else
+# if !@HAVE_ATAN2F@
+# undef atan2f
_GL_FUNCDECL_SYS (atan2f, float, (float y, float x));
-# endif
+# endif
_GL_CXXALIAS_SYS (atan2f, float, (float y, float x));
+# endif
_GL_CXXALIASWARN (atan2f);
#elif defined GNULIB_POSIXCHECK
# undef atan2f
#if @GNULIB_CEIL@
# if @REPLACE_CEIL@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef ceil
# define ceil rpl_ceil
# endif
_GL_FUNCDECL_RPL (ceil, double, (double x));
#if @GNULIB_COSF@
-# if !@HAVE_COSF@
-# undef cosf
+# if @REPLACE_COSF@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef cosf
+# define cosf rpl_cosf
+# endif
+_GL_FUNCDECL_RPL (cosf, float, (float x));
+_GL_CXXALIAS_RPL (cosf, float, (float x));
+# else
+# if !@HAVE_COSF@
+# undef cosf
_GL_FUNCDECL_SYS (cosf, float, (float x));
-# endif
+# endif
_GL_CXXALIAS_SYS (cosf, float, (float x));
+# endif
_GL_CXXALIASWARN (cosf);
#elif defined GNULIB_POSIXCHECK
# undef cosf
#if @GNULIB_COSHF@
-# if !@HAVE_COSHF@
-# undef coshf
+# if @REPLACE_COSHF@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef coshf
+# define coshf rpl_coshf
+# endif
+_GL_FUNCDECL_RPL (coshf, float, (float x));
+_GL_CXXALIAS_RPL (coshf, float, (float x));
+# else
+# if !@HAVE_COSHF@
+# undef coshf
_GL_FUNCDECL_SYS (coshf, float, (float x));
-# endif
+# endif
_GL_CXXALIAS_SYS (coshf, float, (float x));
+# endif
_GL_CXXALIASWARN (coshf);
#elif defined GNULIB_POSIXCHECK
# undef coshf
#if @GNULIB_EXPF@
-# if !@HAVE_EXPF@
-# undef expf
+# if @REPLACE_EXPF@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef expf
+# define expf rpl_expf
+# endif
+_GL_FUNCDECL_RPL (expf, float, (float x));
+_GL_CXXALIAS_RPL (expf, float, (float x));
+# else
+# if !@HAVE_EXPF@
+# undef expf
_GL_FUNCDECL_SYS (expf, float, (float x));
-# endif
+# endif
_GL_CXXALIAS_SYS (expf, float, (float x));
+# endif
_GL_CXXALIASWARN (expf);
#elif defined GNULIB_POSIXCHECK
# undef expf
#if @GNULIB_FLOOR@
# if @REPLACE_FLOOR@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef floor
# define floor rpl_floor
# endif
_GL_FUNCDECL_RPL (floor, double, (double x));
#if @GNULIB_FREXP@
# if @REPLACE_FREXP@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef frexp
# define frexp rpl_frexp
# endif
_GL_FUNCDECL_RPL (frexp, double, (double x, int *expptr) _GL_ARG_NONNULL ((2)));
# else
_GL_CXXALIAS_SYS (frexp, double, (double x, int *expptr));
# endif
-_GL_CXXALIASWARN (frexp);
+_GL_CXXALIASWARN1 (frexp, double, (double x, int *expptr));
#elif defined GNULIB_POSIXCHECK
# undef frexp
/* Assume frexp is always declared. */
#endif
#if @GNULIB_ILOGBL@
-# if !@HAVE_ILOGBL@
+# if @REPLACE_ILOGBL@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef ilogbl
+# define ilogbl rpl_ilogbl
+# endif
+_GL_FUNCDECL_RPL (ilogbl, int, (long double x));
+_GL_CXXALIAS_RPL (ilogbl, int, (long double x));
+# else
+# if !@HAVE_ILOGBL@
_GL_FUNCDECL_SYS (ilogbl, int, (long double x));
-# endif
+# endif
_GL_CXXALIAS_SYS (ilogbl, int, (long double x));
+# endif
_GL_CXXALIASWARN (ilogbl);
#elif defined GNULIB_POSIXCHECK
# undef ilogbl
#if @GNULIB_SINF@
-# if !@HAVE_SINF@
-# undef sinf
+# if @REPLACE_SINF@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef sinf
+# define sinf rpl_sinf
+# endif
+_GL_FUNCDECL_RPL (sinf, float, (float x));
+_GL_CXXALIAS_RPL (sinf, float, (float x));
+# else
+# if !@HAVE_SINF@
+ # undef sinf
_GL_FUNCDECL_SYS (sinf, float, (float x));
-# endif
+# endif
_GL_CXXALIAS_SYS (sinf, float, (float x));
+# endif
_GL_CXXALIASWARN (sinf);
#elif defined GNULIB_POSIXCHECK
# undef sinf
#if @GNULIB_SINHF@
-# if !@HAVE_SINHF@
-# undef sinhf
+# if @REPLACE_SINHF@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef sinhf
+# define sinhf rpl_sinhf
+# endif
+_GL_FUNCDECL_RPL (sinhf, float, (float x));
+_GL_CXXALIAS_RPL (sinhf, float, (float x));
+# else
+# if !@HAVE_SINHF@
+# undef sinhf
_GL_FUNCDECL_SYS (sinhf, float, (float x));
-# endif
+# endif
_GL_CXXALIAS_SYS (sinhf, float, (float x));
+# endif
_GL_CXXALIASWARN (sinhf);
#elif defined GNULIB_POSIXCHECK
# undef sinhf
#if @GNULIB_SQRTF@
-# if !@HAVE_SQRTF@
-# undef sqrtf
+# if @REPLACE_SQRTF@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef sqrtf
+# define sqrtf rpl_sqrtf
+# endif
+_GL_FUNCDECL_RPL (sqrtf, float, (float x));
+_GL_CXXALIAS_RPL (sqrtf, float, (float x));
+# else
+# if !@HAVE_SQRTF@
+# undef sqrtf
_GL_FUNCDECL_SYS (sqrtf, float, (float x));
-# endif
+# endif
_GL_CXXALIAS_SYS (sqrtf, float, (float x));
+# endif
_GL_CXXALIASWARN (sqrtf);
#elif defined GNULIB_POSIXCHECK
# undef sqrtf
#if @GNULIB_TANF@
-# if !@HAVE_TANF@
-# undef tanf
+# if @REPLACE_TANF@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef tanf
+# define tanf rpl_tanf
+# endif
+_GL_FUNCDECL_RPL (tanf, float, (float x));
+_GL_CXXALIAS_RPL (tanf, float, (float x));
+# else
+# if !@HAVE_TANF@
+# undef tanf
_GL_FUNCDECL_SYS (tanf, float, (float x));
-# endif
+# endif
_GL_CXXALIAS_SYS (tanf, float, (float x));
+# endif
_GL_CXXALIASWARN (tanf);
#elif defined GNULIB_POSIXCHECK
# undef tanf
#if @GNULIB_TANHF@
-# if !@HAVE_TANHF@
-# undef tanhf
+# if @REPLACE_TANHF@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef tanhf
+# define tanhf rpl_tanhf
+# endif
+_GL_FUNCDECL_RPL (tanhf, float, (float x));
+_GL_CXXALIAS_RPL (tanhf, float, (float x));
+# else
+# if !@HAVE_TANHF@
+# undef tanhf
_GL_FUNCDECL_SYS (tanhf, float, (float x));
-# endif
+# endif
_GL_CXXALIAS_SYS (tanhf, float, (float x));
+# endif
_GL_CXXALIASWARN (tanhf);
#elif defined GNULIB_POSIXCHECK
# undef tanhf
#if @GNULIB_TRUNCF@
# if @REPLACE_TRUNCF@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef truncf
# define truncf rpl_truncf
# endif
_GL_FUNCDECL_RPL (truncf, float, (float x));
#if @GNULIB_TRUNC@
# if @REPLACE_TRUNC@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef trunc
# define trunc rpl_trunc
# endif
_GL_FUNCDECL_RPL (trunc, double, (double x));
gl_isfinitef (x))
# endif
# ifdef __cplusplus
-# ifdef isfinite
+# if defined isfinite || defined GNULIB_NAMESPACE
_GL_MATH_CXX_REAL_FLOATING_DECL_1 (isfinite)
# undef isfinite
_GL_MATH_CXX_REAL_FLOATING_DECL_2 (isfinite)
gl_isinff (x))
# endif
# ifdef __cplusplus
-# ifdef isinf
+# if defined isinf || defined GNULIB_NAMESPACE
_GL_MATH_CXX_REAL_FLOATING_DECL_1 (isinf)
# undef isinf
_GL_MATH_CXX_REAL_FLOATING_DECL_2 (isinf)
__builtin_isnanf ((float)(x)))
# endif
# ifdef __cplusplus
-# ifdef isnan
+# if defined isnan || defined GNULIB_NAMESPACE
_GL_MATH_CXX_REAL_FLOATING_DECL_1 (isnan)
# undef isnan
_GL_MATH_CXX_REAL_FLOATING_DECL_2 (isnan)
gl_signbitf (x))
# endif
# ifdef __cplusplus
-# ifdef signbit
+# if defined signbit || defined GNULIB_NAMESPACE
_GL_MATH_CXX_REAL_FLOATING_DECL_1 (signbit)
# undef signbit
_GL_MATH_CXX_REAL_FLOATING_DECL_2 (signbit)