Date: Thu, 11 Jul 2013 20:52:39 +0200 From: Tijl Coosemans <tijl@coosemans.org> To: David Chisnall <theraven@FreeBSD.org> Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r253215 - head/lib/msun/src Message-ID: <51DEFEF7.4080709@coosemans.org> In-Reply-To: <201307111741.r6BHf5gQ060844@svn.freebsd.org> References: <201307111741.r6BHf5gQ060844@svn.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --] 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. [-- Attachment #2 --] -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.20 (FreeBSD) iF4EAREIAAYFAlHe/vwACgkQfoCS2CCgtiv3QwD/USQ3ZRmBJDOZVM/rLceqnkT3 RdTlc2V1NOw0jIiQuQgA/1fZCdFTdAlEmewAxjjPNQDf2iKMBS1Hyu69iBPBszPG =NRg+ -----END PGP SIGNATURE-----
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?51DEFEF7.4080709>
