Cleanups to math.h that prevent namespace conflicts with C++.
Reviewed by: bde MFC after: 3 days
This commit is contained in:
parent
bf0354c0f2
commit
a3fc79de87
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=253215
@ -80,27 +80,33 @@ extern const union __nan_un {
|
||||
#define FP_NORMAL 0x04
|
||||
#define FP_SUBNORMAL 0x08
|
||||
#define FP_ZERO 0x10
|
||||
#define fpclassify(x) \
|
||||
((sizeof (x) == sizeof (float)) ? __fpclassifyf(x) \
|
||||
: (sizeof (x) == sizeof (double)) ? __fpclassifyd(x) \
|
||||
: __fpclassifyl(x))
|
||||
|
||||
#define isfinite(x) \
|
||||
((sizeof (x) == sizeof (float)) ? __isfinitef(x) \
|
||||
: (sizeof (x) == sizeof (double)) ? __isfinite(x) \
|
||||
: __isfinitel(x))
|
||||
#define isinf(x) \
|
||||
((sizeof (x) == sizeof (float)) ? __isinff(x) \
|
||||
: (sizeof (x) == sizeof (double)) ? isinf(x) \
|
||||
: __isinfl(x))
|
||||
#define isnan(x) \
|
||||
((sizeof (x) == sizeof (float)) ? __isnanf(x) \
|
||||
: (sizeof (x) == sizeof (double)) ? isnan(x) \
|
||||
: __isnanl(x))
|
||||
#define isnormal(x) \
|
||||
((sizeof (x) == sizeof (float)) ? __isnormalf(x) \
|
||||
: (sizeof (x) == sizeof (double)) ? __isnormal(x) \
|
||||
: __isnormall(x))
|
||||
#if __STDC_VERSION__ >= 201112L
|
||||
#define __fp_type_select(x, f, d, ld) _Generic((x), \
|
||||
float: f(x), \
|
||||
double: d(x), \
|
||||
long double: ld(x))
|
||||
#elif __GNUC_PREREQ__(5, 1)
|
||||
#define __fp_type_select(x, f, d, ld) __builtin_choose_expr( \
|
||||
__builtin_types_compatible_p(__typeof(x), long double), ld(x), \
|
||||
__builtin_choose_expr( \
|
||||
__builtin_types_compatible_p(__typeof(x), double), d(x), \
|
||||
__builtin_choose_expr( \
|
||||
__builtin_types_compatible_p(__typeof(x), float), f(x), (void)0)))
|
||||
#else
|
||||
#define __fp_type_select(x, f, d, ld) \
|
||||
((sizeof(x) == sizeof(float)) ? f(x) \
|
||||
: (sizeof(x) == sizeof(double)) ? d(x) \
|
||||
: ld(x))
|
||||
#endif
|
||||
|
||||
#define fpclassify(x) \
|
||||
__fp_type_select(x, __fpclassifyf, __fpclassifyd, __fpclassifyd)
|
||||
#define isfinite(x) __fp_type_select(x, __isfinitef, __isfinite, __isfinitel)
|
||||
#define isinf(x) __fp_type_select(x, __isinff, __isinf, __isinfl)
|
||||
#define isnan(x) \
|
||||
__fp_type_select(x, __inline_isnanf, __inline_isnan, __inline_isnanl)
|
||||
#define isnormal(x) __fp_type_select(x, __isnormalf, __isnormal, __isnormall)
|
||||
|
||||
#ifdef __MATH_BUILTIN_RELOPS
|
||||
#define isgreater(x, y) __builtin_isgreater((x), (y))
|
||||
@ -119,10 +125,7 @@ extern const union __nan_un {
|
||||
#define isunordered(x, y) (isnan(x) || isnan(y))
|
||||
#endif /* __MATH_BUILTIN_RELOPS */
|
||||
|
||||
#define signbit(x) \
|
||||
((sizeof (x) == sizeof (float)) ? __signbitf(x) \
|
||||
: (sizeof (x) == sizeof (double)) ? __signbit(x) \
|
||||
: __signbitl(x))
|
||||
#define signbit(x) __fp_type_select(x, __signbitf, __signbit, __signbitl)
|
||||
|
||||
typedef __double_t double_t;
|
||||
typedef __float_t float_t;
|
||||
@ -175,9 +178,8 @@ int __isfinitef(float) __pure2;
|
||||
int __isfinite(double) __pure2;
|
||||
int __isfinitel(long double) __pure2;
|
||||
int __isinff(float) __pure2;
|
||||
int __isinf(double) __pure2;
|
||||
int __isinfl(long double) __pure2;
|
||||
int __isnanf(float) __pure2;
|
||||
int __isnanl(long double) __pure2;
|
||||
int __isnormalf(float) __pure2;
|
||||
int __isnormal(double) __pure2;
|
||||
int __isnormall(long double) __pure2;
|
||||
@ -185,6 +187,27 @@ int __signbit(double) __pure2;
|
||||
int __signbitf(float) __pure2;
|
||||
int __signbitl(long double) __pure2;
|
||||
|
||||
static __inline int
|
||||
__inline_isnan(double __x)
|
||||
{
|
||||
|
||||
return (__x != __x);
|
||||
}
|
||||
|
||||
static __inline int
|
||||
__inline_isnanf(float __x)
|
||||
{
|
||||
|
||||
return (__x != __x);
|
||||
}
|
||||
|
||||
static __inline int
|
||||
__inline_isnanl(long double __x)
|
||||
{
|
||||
|
||||
return (__x != __x);
|
||||
}
|
||||
|
||||
double acos(double);
|
||||
double asin(double);
|
||||
double atan(double);
|
||||
@ -227,8 +250,6 @@ double expm1(double);
|
||||
double fma(double, double, double);
|
||||
double hypot(double, double);
|
||||
int ilogb(double) __pure2;
|
||||
int (isinf)(double) __pure2;
|
||||
int (isnan)(double) __pure2;
|
||||
double lgamma(double);
|
||||
long long llrint(double);
|
||||
long long llround(double);
|
||||
|
Loading…
Reference in New Issue
Block a user