On 2013-07-11 19:41, David Chisnall wrote: > Author: theraven > Date: Thu Jul 11 17:41:04 2013 > New Revision: 253215 > URL: http://svnweb.freebsd.org/changeset/base/253215 > > Log: > Cleanups to math.h that prevent namespace conflicts with C++. > > Reviewed by: bde > MFC after: 3 days > > Modified: > head/lib/msun/src/math.h > > Modified: head/lib/msun/src/math.h > ============================================================================== > --- head/lib/msun/src/math.h Thu Jul 11 16:27:11 2013 (r253214) > +++ head/lib/msun/src/math.h Thu Jul 11 17:41:04 2013 (r253215) > @@ -80,27 +80,33 @@ extern const union __nan_un { > #define FP_NORMAL 0x04 > #define FP_SUBNORMAL 0x08 > #define FP_ZERO 0x10 > + > +#if __STDC_VERSION__ >= 201112L > +#define __fp_type_select(x, f, d, ld) _Generic((x), \ > + float: f(x), \ > + double: d(x), \ > + long double: ld(x))
GCC doesn't support _Generic yet for -std=c11. > +#elif __GNUC_PREREQ__(5, 1) GCC 3.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) \ > - ((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)) > + __fp_type_select(x, __fpclassifyf, __fpclassifyd, __fpclassifyd) Last __fpclassifyd should be __fpclassifyl. > @@ -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; I think they should stay for the C90 case.
signature.asc
Description: OpenPGP digital signature