From owner-svn-src-all@FreeBSD.ORG Thu Jul 11 17:41:05 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 4233B656; Thu, 11 Jul 2013 17:41:05 +0000 (UTC) (envelope-from theraven@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 33A821C26; Thu, 11 Jul 2013 17:41:05 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6BHf5Lo060845; Thu, 11 Jul 2013 17:41:05 GMT (envelope-from theraven@svn.freebsd.org) Received: (from theraven@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6BHf5gQ060844; Thu, 11 Jul 2013 17:41:05 GMT (envelope-from theraven@svn.freebsd.org) Message-Id: <201307111741.r6BHf5gQ060844@svn.freebsd.org> From: David Chisnall Date: Thu, 11 Jul 2013 17:41:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r253215 - head/lib/msun/src X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Jul 2013 17:41:05 -0000 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)) +#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) \ - ((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) +#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);