X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fmath.in.h;h=6b5966aecd0050d5d24e8527c6b52d82cac04e28;hb=4752c7c4aaba4eca621082dc8042646f6efd71ec;hp=94076815ae20d3476abb4e2f465075ce5e28552a;hpb=a5766f2b114a3a8ca55f7257aa9eef8b5ddc466a;p=gnulib.git diff --git a/lib/math.in.h b/lib/math.in.h index 94076815a..6b5966aec 100644 --- a/lib/math.in.h +++ b/lib/math.in.h @@ -35,6 +35,44 @@ /* The definition of _GL_WARN_ON_USE is copied here. */ +#ifdef __cplusplus +/* Helper macros to define type-generic function FUNC as overloaded functions, + rather than as macros like in C. POSIX declares these with an argument of + real-floating (that is, one of float, double, or long double). */ +# define _GL_MATH_CXX_REAL_FLOATING_DECL_1(func) \ +static inline int \ +_gl_cxx_ ## func ## f (float f) \ +{ \ + return func (f); \ +} \ +static inline int \ +_gl_cxx_ ## func ## d (double d) \ +{ \ + return func (d); \ +} \ +static inline int \ +_gl_cxx_ ## func ## l (long double l) \ +{ \ + return func (l); \ +} +# define _GL_MATH_CXX_REAL_FLOATING_DECL_2(func) \ +inline int \ +func (float f) \ +{ \ + return _gl_cxx_ ## func ## f (f); \ +} \ +inline int \ +func (double d) \ +{ \ + return _gl_cxx_ ## func ## d (d); \ +} \ +inline int \ +func (long double l) \ +{ \ + return _gl_cxx_ ## func ## l (l); \ +} +#endif + /* Helper macros to define a portability warning for the classification macro FUNC called with VALUE. POSIX declares the classification macros with an argument of real-floating (that is, @@ -198,6 +236,22 @@ _GL_WARN_ON_USE (atanl, "atanl is unportable - " #endif +#if @GNULIB_ATAN2F@ +# if !@HAVE_ATAN2F@ +# undef atan2f +_GL_FUNCDECL_SYS (atan2f, float, (float y, float x)); +# endif +_GL_CXXALIAS_SYS (atan2f, float, (float y, float x)); +_GL_CXXALIASWARN (atan2f); +#elif defined GNULIB_POSIXCHECK +# undef atan2f +# if HAVE_RAW_DECL_ATAN2F +_GL_WARN_ON_USE (atan2f, "atan2f is unportable - " + "use gnulib module atan2f for portability"); +# endif +#endif + + #if @GNULIB_CEILF@ # if @REPLACE_CEILF@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) @@ -258,6 +312,49 @@ _GL_WARN_ON_USE (ceill, "ceill is unportable - " #endif +#if @GNULIB_COPYSIGNF@ +# if !@HAVE_COPYSIGNF@ +_GL_FUNCDECL_SYS (copysignf, float, (float x, float y)); +# endif +_GL_CXXALIAS_SYS (copysignf, float, (float x, float y)); +_GL_CXXALIASWARN (copysignf); +#elif defined GNULIB_POSIXCHECK +# undef copysignf +# if HAVE_RAW_DECL_COPYSIGNF +_GL_WARN_ON_USE (copysignf, "copysignf is unportable - " + "use gnulib module copysignf for portability"); +# endif +#endif + +#if @GNULIB_COPYSIGN@ +# if !@HAVE_COPYSIGN@ +_GL_FUNCDECL_SYS (copysign, double, (double x, double y)); +# endif +_GL_CXXALIAS_SYS (copysign, double, (double x, double y)); +_GL_CXXALIASWARN (copysign); +#elif defined GNULIB_POSIXCHECK +# undef copysign +# if HAVE_RAW_DECL_COPYSIGN +_GL_WARN_ON_USE (copysign, "copysign is unportable - " + "use gnulib module copysign for portability"); +# endif +#endif + +#if @GNULIB_COPYSIGNL@ +# if !@HAVE_COPYSIGNL@ +_GL_FUNCDECL_SYS (copysignl, long double, (long double x, long double y)); +# endif +_GL_CXXALIAS_SYS (copysignl, long double, (long double x, long double y)); +_GL_CXXALIASWARN (copysignl); +#elif defined GNULIB_POSIXCHECK +# undef copysignl +# if HAVE_RAW_DECL_COPYSIGNL +_GL_WARN_ON_USE (copysign, "copysignl is unportable - " + "use gnulib module copysignl for portability"); +# endif +#endif + + #if @GNULIB_COSF@ # if !@HAVE_COSF@ # undef cosf @@ -288,6 +385,22 @@ _GL_WARN_ON_USE (cosl, "cosl is unportable - " #endif +#if @GNULIB_COSHF@ +# if !@HAVE_COSHF@ +# undef coshf +_GL_FUNCDECL_SYS (coshf, float, (float x)); +# endif +_GL_CXXALIAS_SYS (coshf, float, (float x)); +_GL_CXXALIASWARN (coshf); +#elif defined GNULIB_POSIXCHECK +# undef coshf +# if HAVE_RAW_DECL_COSHF +_GL_WARN_ON_USE (coshf, "coshf is unportable - " + "use gnulib module coshf for portability"); +# endif +#endif + + #if @GNULIB_EXPF@ # if !@HAVE_EXPF@ # undef expf @@ -394,6 +507,80 @@ _GL_WARN_ON_USE (floorl, "floorl is unportable - " #endif +#if @GNULIB_FMAF@ +# if @REPLACE_FMAF@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef fmaf +# define fmaf rpl_fmaf +# endif +_GL_FUNCDECL_RPL (fmaf, float, (float x, float y, float z)); +_GL_CXXALIAS_RPL (fmaf, float, (float x, float y, float z)); +# else +# if !@HAVE_FMAF@ +_GL_FUNCDECL_SYS (fmaf, float, (float x, float y, float z)); +# endif +_GL_CXXALIAS_SYS (fmaf, float, (float x, float y, float z)); +# endif +_GL_CXXALIASWARN (fmaf); +#elif defined GNULIB_POSIXCHECK +# undef fmaf +# if HAVE_RAW_DECL_FMAF +_GL_WARN_ON_USE (fmaf, "fmaf is unportable - " + "use gnulib module fmaf for portability"); +# endif +#endif + +#if @GNULIB_FMA@ +# if @REPLACE_FMA@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef fma +# define fma rpl_fma +# endif +_GL_FUNCDECL_RPL (fma, double, (double x, double y, double z)); +_GL_CXXALIAS_RPL (fma, double, (double x, double y, double z)); +# else +# if !@HAVE_FMA@ +_GL_FUNCDECL_SYS (fma, double, (double x, double y, double z)); +# endif +_GL_CXXALIAS_SYS (fma, double, (double x, double y, double z)); +# endif +_GL_CXXALIASWARN (fma); +#elif defined GNULIB_POSIXCHECK +# undef fma +# if HAVE_RAW_DECL_FMA +_GL_WARN_ON_USE (fma, "fma is unportable - " + "use gnulib module fma for portability"); +# endif +#endif + +#if @GNULIB_FMAL@ +# if @REPLACE_FMAL@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef fmal +# define fmal rpl_fmal +# endif +_GL_FUNCDECL_RPL (fmal, long double, + (long double x, long double y, long double z)); +_GL_CXXALIAS_RPL (fmal, long double, + (long double x, long double y, long double z)); +# else +# if !@HAVE_FMAL@ +_GL_FUNCDECL_SYS (fmal, long double, + (long double x, long double y, long double z)); +# endif +_GL_CXXALIAS_SYS (fmal, long double, + (long double x, long double y, long double z)); +# endif +_GL_CXXALIASWARN (fmal); +#elif defined GNULIB_POSIXCHECK +# undef fmal +# if HAVE_RAW_DECL_FMAL +_GL_WARN_ON_USE (fmal, "fmal is unportable - " + "use gnulib module fmal for portability"); +# endif +#endif + + #if @GNULIB_FMODF@ # if !@HAVE_FMODF@ # undef fmodf @@ -637,6 +824,49 @@ _GL_WARN_ON_USE (powf, "powf is unportable - " #endif +#if @GNULIB_RINTF@ +# if !@HAVE_RINTF@ +_GL_FUNCDECL_SYS (rintf, float, (float x)); +# endif +_GL_CXXALIAS_SYS (rintf, float, (float x)); +_GL_CXXALIASWARN (rintf); +#elif defined GNULIB_POSIXCHECK +# undef rintf +# if HAVE_RAW_DECL_RINTF +_GL_WARN_ON_USE (rintf, "rintf is unportable - " + "use gnulib module rintf for portability"); +# endif +#endif + +#if @GNULIB_RINT@ +# if !@HAVE_RINT@ +_GL_FUNCDECL_SYS (rint, double, (double x)); +# endif +_GL_CXXALIAS_SYS (rint, double, (double x)); +_GL_CXXALIASWARN (rint); +#elif defined GNULIB_POSIXCHECK +# undef rint +# if HAVE_RAW_DECL_RINT +_GL_WARN_ON_USE (rint, "rint is unportable - " + "use gnulib module rint for portability"); +# endif +#endif + +#if @GNULIB_RINTL@ +# if !@HAVE_RINTL@ +_GL_FUNCDECL_SYS (rintl, long double, (long double x)); +# endif +_GL_CXXALIAS_SYS (rintl, long double, (long double x)); +_GL_CXXALIASWARN (rintl); +#elif defined GNULIB_POSIXCHECK +# undef rintl +# if HAVE_RAW_DECL_RINTL +_GL_WARN_ON_USE (rintl, "rintl is unportable - " + "use gnulib module rintl for portability"); +# endif +#endif + + #if @GNULIB_ROUNDF@ # if @REPLACE_ROUNDF@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) @@ -737,6 +967,22 @@ _GL_WARN_ON_USE (sinl, "sinl is unportable - " #endif +#if @GNULIB_SINHF@ +# if !@HAVE_SINHF@ +# undef sinhf +_GL_FUNCDECL_SYS (sinhf, float, (float x)); +# endif +_GL_CXXALIAS_SYS (sinhf, float, (float x)); +_GL_CXXALIASWARN (sinhf); +#elif defined GNULIB_POSIXCHECK +# undef sinhf +# if HAVE_RAW_DECL_SINHF +_GL_WARN_ON_USE (sinhf, "sinhf is unportable - " + "use gnulib module sinhf for portability"); +# endif +#endif + + #if @GNULIB_SQRTF@ # if !@HAVE_SQRTF@ # undef sqrtf @@ -797,6 +1043,22 @@ _GL_WARN_ON_USE (tanl, "tanl is unportable - " #endif +#if @GNULIB_TANHF@ +# if !@HAVE_TANHF@ +# undef tanhf +_GL_FUNCDECL_SYS (tanhf, float, (float x)); +# endif +_GL_CXXALIAS_SYS (tanhf, float, (float x)); +_GL_CXXALIASWARN (tanhf); +#elif defined GNULIB_POSIXCHECK +# undef tanhf +# if HAVE_RAW_DECL_TANHF +_GL_WARN_ON_USE (tanhf, "tanhf is unportable - " + "use gnulib module tanhf for portability"); +# endif +#endif + + #if @GNULIB_TRUNCF@ # if @REPLACE_TRUNCF@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) @@ -880,6 +1142,13 @@ _GL_EXTERN_C int gl_isfinitel (long double x); sizeof (x) == sizeof (double) ? gl_isfinited (x) : \ gl_isfinitef (x)) # endif +# ifdef __cplusplus +# ifdef isfinite +_GL_MATH_CXX_REAL_FLOATING_DECL_1 (isfinite) +# undef isfinite +_GL_MATH_CXX_REAL_FLOATING_DECL_2 (isfinite) +# endif +# endif #elif defined GNULIB_POSIXCHECK # if defined isfinite _GL_WARN_REAL_FLOATING_DECL (isfinite); @@ -900,6 +1169,13 @@ _GL_EXTERN_C int gl_isinfl (long double x); sizeof (x) == sizeof (double) ? gl_isinfd (x) : \ gl_isinff (x)) # endif +# ifdef __cplusplus +# ifdef isinf +_GL_MATH_CXX_REAL_FLOATING_DECL_1 (isinf) +# undef isinf +_GL_MATH_CXX_REAL_FLOATING_DECL_2 (isinf) +# endif +# endif #elif defined GNULIB_POSIXCHECK # if defined isinf _GL_WARN_REAL_FLOATING_DECL (isinf); @@ -970,7 +1246,7 @@ _GL_EXTERN_C int isnand (double x); /* Test whether X is a NaN. */ # undef isnanl # define isnanl rpl_isnanl -_GL_EXTERN_C int isnanl (long double x); +_GL_EXTERN_C int isnanl (long double x) _GL_ATTRIBUTE_CONST; # endif #endif @@ -996,7 +1272,7 @@ _GL_EXTERN_C int rpl_isnand (double x); # if @HAVE_ISNANL@ && __GNUC__ >= 4 # define gl_isnan_l(x) __builtin_isnanl ((long double)(x)) # else -_GL_EXTERN_C int rpl_isnanl (long double x); +_GL_EXTERN_C int rpl_isnanl (long double x) _GL_ATTRIBUTE_CONST; # define gl_isnan_l(x) rpl_isnanl (x) # endif # undef isnan @@ -1011,9 +1287,17 @@ _GL_EXTERN_C int rpl_isnanl (long double x); sizeof (x) == sizeof (double) ? __builtin_isnan ((double)(x)) : \ __builtin_isnanf ((float)(x))) # endif +# ifdef __cplusplus +# ifdef isnan +_GL_MATH_CXX_REAL_FLOATING_DECL_1 (isnan) +# undef isnan +_GL_MATH_CXX_REAL_FLOATING_DECL_2 (isnan) +# endif +# else /* Ensure isnan is a macro. */ -# ifndef isnan -# define isnan isnan +# ifndef isnan +# define isnan isnan +# endif # endif #elif defined GNULIB_POSIXCHECK # if defined isnan @@ -1038,7 +1322,7 @@ _GL_WARN_REAL_FLOATING_DECL (isnan); _GL_EXTERN_C int gl_signbitf (float arg); _GL_EXTERN_C int gl_signbitd (double arg); _GL_EXTERN_C int gl_signbitl (long double arg); -# if __GNUC__ >= 2 && !__STRICT_ANSI__ +# if __GNUC__ >= 2 && !defined __STRICT_ANSI__ # define _GL_NUM_UINT_WORDS(type) \ ((sizeof (type) + sizeof (unsigned int) - 1) / sizeof (unsigned int)) # if defined FLT_SIGNBIT_WORD && defined FLT_SIGNBIT_BIT && !defined gl_signbitf @@ -1077,6 +1361,13 @@ _GL_EXTERN_C int gl_signbitl (long double arg); sizeof (x) == sizeof (double) ? gl_signbitd (x) : \ gl_signbitf (x)) # endif +# ifdef __cplusplus +# ifdef signbit +_GL_MATH_CXX_REAL_FLOATING_DECL_1 (signbit) +# undef signbit +_GL_MATH_CXX_REAL_FLOATING_DECL_2 (signbit) +# endif +# endif #elif defined GNULIB_POSIXCHECK # if defined signbit _GL_WARN_REAL_FLOATING_DECL (signbit);