From patchwork Mon Oct 30 16:43:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 23968 Received: (qmail 55322 invoked by alias); 30 Oct 2017 16:43:54 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 55312 invoked by uid 89); 30 Oct 2017 16:43:54 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LOTSOFHASH, RCVD_IN_DNSWL_NONE, SPF_PASS, URIBL_RED autolearn=ham version=3.3.2 spammy=continuing, among X-HELO: relay1.mentorg.com Date: Mon, 30 Oct 2017 16:43:43 +0000 From: Joseph Myers To: Subject: Add _FloatN, _FloatNx M_* constants [committed] Message-ID: User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 X-ClientProxiedBy: svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) To SVR-IES-MBX-03.mgc.mentorg.com (139.181.222.3) Continuing the preparation for additional _FloatN / _FloatNx type support, this patch adds M_* constants for such types. The decimal expansions used are all the same as used for _Float128; there's no need to reduce the precision used. In the case of _Float128x, #error is used because the constants would need additional precision, but how much is needed would depend on the actual _Float128x format used, so it's not possible to add header support simply as part of code that handles all _FloatN / _FloatNx types similarly. Tested for x86_64. Committed. 2017-10-30 Joseph Myers * math/math.h [__HAVE_FLOAT16 && __USE_GNU] (M_Ef16): New macro. [__HAVE_FLOAT16 && __USE_GNU] (M_LOG2Ef16): Likewise. [__HAVE_FLOAT16 && __USE_GNU] (M_LOG10Ef16): Likewise. [__HAVE_FLOAT16 && __USE_GNU] (M_LN2f16): Likewise. [__HAVE_FLOAT16 && __USE_GNU] (M_LN10f16): Likewise. [__HAVE_FLOAT16 && __USE_GNU] (M_PIf16): Likewise. [__HAVE_FLOAT16 && __USE_GNU] (M_PI_2f16): Likewise. [__HAVE_FLOAT16 && __USE_GNU] (M_PI_4f16): Likewise. [__HAVE_FLOAT16 && __USE_GNU] (M_1_PIf16): Likewise. [__HAVE_FLOAT16 && __USE_GNU] (M_2_PIf16): Likewise. [__HAVE_FLOAT16 && __USE_GNU] (M_2_SQRTPIf16): Likewise. [__HAVE_FLOAT16 && __USE_GNU] (M_SQRT2f16): Likewise. [__HAVE_FLOAT16 && __USE_GNU] (M_SQRT1_2f16): Likewise. [__HAVE_FLOAT32 && __USE_GNU] (M_Ef32): Likewise. [__HAVE_FLOAT32 && __USE_GNU] (M_LOG2Ef32): Likewise. [__HAVE_FLOAT32 && __USE_GNU] (M_LOG10Ef32): Likewise. [__HAVE_FLOAT32 && __USE_GNU] (M_LN2f32): Likewise. [__HAVE_FLOAT32 && __USE_GNU] (M_LN10f32): Likewise. [__HAVE_FLOAT32 && __USE_GNU] (M_PIf32): Likewise. [__HAVE_FLOAT32 && __USE_GNU] (M_PI_2f32): Likewise. [__HAVE_FLOAT32 && __USE_GNU] (M_PI_4f32): Likewise. [__HAVE_FLOAT32 && __USE_GNU] (M_1_PIf32): Likewise. [__HAVE_FLOAT32 && __USE_GNU] (M_2_PIf32): Likewise. [__HAVE_FLOAT32 && __USE_GNU] (M_2_SQRTPIf32): Likewise. [__HAVE_FLOAT32 && __USE_GNU] (M_SQRT2f32): Likewise. [__HAVE_FLOAT32 && __USE_GNU] (M_SQRT1_2f32): Likewise. [__HAVE_FLOAT64 && __USE_GNU] (M_Ef64): Likewise. [__HAVE_FLOAT64 && __USE_GNU] (M_LOG2Ef64): Likewise. [__HAVE_FLOAT64 && __USE_GNU] (M_LOG10Ef64): Likewise. [__HAVE_FLOAT64 && __USE_GNU] (M_LN2f64): Likewise. [__HAVE_FLOAT64 && __USE_GNU] (M_LN10f64): Likewise. [__HAVE_FLOAT64 && __USE_GNU] (M_PIf64): Likewise. [__HAVE_FLOAT64 && __USE_GNU] (M_PI_2f64): Likewise. [__HAVE_FLOAT64 && __USE_GNU] (M_PI_4f64): Likewise. [__HAVE_FLOAT64 && __USE_GNU] (M_1_PIf64): Likewise. [__HAVE_FLOAT64 && __USE_GNU] (M_2_PIf64): Likewise. [__HAVE_FLOAT64 && __USE_GNU] (M_2_SQRTPIf64): Likewise. [__HAVE_FLOAT64 && __USE_GNU] (M_SQRT2f64): Likewise. [__HAVE_FLOAT64 && __USE_GNU] (M_SQRT1_2f64): Likewise. [__HAVE_FLOAT32X && __USE_GNU] (M_Ef32x): Likewise. [__HAVE_FLOAT32X && __USE_GNU] (M_LOG2Ef32x): Likewise. [__HAVE_FLOAT32X && __USE_GNU] (M_LOG10Ef32x): Likewise. [__HAVE_FLOAT32X && __USE_GNU] (M_LN2f32x): Likewise. [__HAVE_FLOAT32X && __USE_GNU] (M_LN10f32x): Likewise. [__HAVE_FLOAT32X && __USE_GNU] (M_PIf32x): Likewise. [__HAVE_FLOAT32X && __USE_GNU] (M_PI_2f32x): Likewise. [__HAVE_FLOAT32X && __USE_GNU] (M_PI_4f32x): Likewise. [__HAVE_FLOAT32X && __USE_GNU] (M_1_PIf32x): Likewise. [__HAVE_FLOAT32X && __USE_GNU] (M_2_PIf32x): Likewise. [__HAVE_FLOAT32X && __USE_GNU] (M_2_SQRTPIf32x): Likewise. [__HAVE_FLOAT32X && __USE_GNU] (M_SQRT2f32x): Likewise. [__HAVE_FLOAT32X && __USE_GNU] (M_SQRT1_2f32x): Likewise. [__HAVE_FLOAT64X && __USE_GNU] (M_Ef64x): Likewise. [__HAVE_FLOAT64X && __USE_GNU] (M_LOG2Ef64x): Likewise. [__HAVE_FLOAT64X && __USE_GNU] (M_LOG10Ef64x): Likewise. [__HAVE_FLOAT64X && __USE_GNU] (M_LN2f64x): Likewise. [__HAVE_FLOAT64X && __USE_GNU] (M_LN10f64x): Likewise. [__HAVE_FLOAT64X && __USE_GNU] (M_PIf64x): Likewise. [__HAVE_FLOAT64X && __USE_GNU] (M_PI_2f64x): Likewise. [__HAVE_FLOAT64X && __USE_GNU] (M_PI_4f64x): Likewise. [__HAVE_FLOAT64X && __USE_GNU] (M_1_PIf64x): Likewise. [__HAVE_FLOAT64X && __USE_GNU] (M_2_PIf64x): Likewise. [__HAVE_FLOAT64X && __USE_GNU] (M_2_SQRTPIf64x): Likewise. [__HAVE_FLOAT64X && __USE_GNU] (M_SQRT2f64x): Likewise. [__HAVE_FLOAT64X && __USE_GNU] (M_SQRT1_2f64x): Likewise. [__HAVE_FLOAT128X && __USE_GNU]: Use #error. diff --git a/math/math.h b/math/math.h index 3263042..5683ac9 100644 --- a/math/math.h +++ b/math/math.h @@ -794,6 +794,54 @@ iszero (__T __val) # define M_SQRT1_2l 0.707106781186547524400844362104849039L /* 1/sqrt(2) */ #endif +#if __HAVE_FLOAT16 && defined __USE_GNU +# define M_Ef16 __f16 (2.718281828459045235360287471352662498) /* e */ +# define M_LOG2Ef16 __f16 (1.442695040888963407359924681001892137) /* log_2 e */ +# define M_LOG10Ef16 __f16 (0.434294481903251827651128918916605082) /* log_10 e */ +# define M_LN2f16 __f16 (0.693147180559945309417232121458176568) /* log_e 2 */ +# define M_LN10f16 __f16 (2.302585092994045684017991454684364208) /* log_e 10 */ +# define M_PIf16 __f16 (3.141592653589793238462643383279502884) /* pi */ +# define M_PI_2f16 __f16 (1.570796326794896619231321691639751442) /* pi/2 */ +# define M_PI_4f16 __f16 (0.785398163397448309615660845819875721) /* pi/4 */ +# define M_1_PIf16 __f16 (0.318309886183790671537767526745028724) /* 1/pi */ +# define M_2_PIf16 __f16 (0.636619772367581343075535053490057448) /* 2/pi */ +# define M_2_SQRTPIf16 __f16 (1.128379167095512573896158903121545172) /* 2/sqrt(pi) */ +# define M_SQRT2f16 __f16 (1.414213562373095048801688724209698079) /* sqrt(2) */ +# define M_SQRT1_2f16 __f16 (0.707106781186547524400844362104849039) /* 1/sqrt(2) */ +#endif + +#if __HAVE_FLOAT32 && defined __USE_GNU +# define M_Ef32 __f32 (2.718281828459045235360287471352662498) /* e */ +# define M_LOG2Ef32 __f32 (1.442695040888963407359924681001892137) /* log_2 e */ +# define M_LOG10Ef32 __f32 (0.434294481903251827651128918916605082) /* log_10 e */ +# define M_LN2f32 __f32 (0.693147180559945309417232121458176568) /* log_e 2 */ +# define M_LN10f32 __f32 (2.302585092994045684017991454684364208) /* log_e 10 */ +# define M_PIf32 __f32 (3.141592653589793238462643383279502884) /* pi */ +# define M_PI_2f32 __f32 (1.570796326794896619231321691639751442) /* pi/2 */ +# define M_PI_4f32 __f32 (0.785398163397448309615660845819875721) /* pi/4 */ +# define M_1_PIf32 __f32 (0.318309886183790671537767526745028724) /* 1/pi */ +# define M_2_PIf32 __f32 (0.636619772367581343075535053490057448) /* 2/pi */ +# define M_2_SQRTPIf32 __f32 (1.128379167095512573896158903121545172) /* 2/sqrt(pi) */ +# define M_SQRT2f32 __f32 (1.414213562373095048801688724209698079) /* sqrt(2) */ +# define M_SQRT1_2f32 __f32 (0.707106781186547524400844362104849039) /* 1/sqrt(2) */ +#endif + +#if __HAVE_FLOAT64 && defined __USE_GNU +# define M_Ef64 __f64 (2.718281828459045235360287471352662498) /* e */ +# define M_LOG2Ef64 __f64 (1.442695040888963407359924681001892137) /* log_2 e */ +# define M_LOG10Ef64 __f64 (0.434294481903251827651128918916605082) /* log_10 e */ +# define M_LN2f64 __f64 (0.693147180559945309417232121458176568) /* log_e 2 */ +# define M_LN10f64 __f64 (2.302585092994045684017991454684364208) /* log_e 10 */ +# define M_PIf64 __f64 (3.141592653589793238462643383279502884) /* pi */ +# define M_PI_2f64 __f64 (1.570796326794896619231321691639751442) /* pi/2 */ +# define M_PI_4f64 __f64 (0.785398163397448309615660845819875721) /* pi/4 */ +# define M_1_PIf64 __f64 (0.318309886183790671537767526745028724) /* 1/pi */ +# define M_2_PIf64 __f64 (0.636619772367581343075535053490057448) /* 2/pi */ +# define M_2_SQRTPIf64 __f64 (1.128379167095512573896158903121545172) /* 2/sqrt(pi) */ +# define M_SQRT2f64 __f64 (1.414213562373095048801688724209698079) /* sqrt(2) */ +# define M_SQRT1_2f64 __f64 (0.707106781186547524400844362104849039) /* 1/sqrt(2) */ +#endif + #if __HAVE_FLOAT128 && defined __USE_GNU # define M_Ef128 __f128 (2.718281828459045235360287471352662498) /* e */ # define M_LOG2Ef128 __f128 (1.442695040888963407359924681001892137) /* log_2 e */ @@ -810,6 +858,42 @@ iszero (__T __val) # define M_SQRT1_2f128 __f128 (0.707106781186547524400844362104849039) /* 1/sqrt(2) */ #endif +#if __HAVE_FLOAT32X && defined __USE_GNU +# define M_Ef32x __f32x (2.718281828459045235360287471352662498) /* e */ +# define M_LOG2Ef32x __f32x (1.442695040888963407359924681001892137) /* log_2 e */ +# define M_LOG10Ef32x __f32x (0.434294481903251827651128918916605082) /* log_10 e */ +# define M_LN2f32x __f32x (0.693147180559945309417232121458176568) /* log_e 2 */ +# define M_LN10f32x __f32x (2.302585092994045684017991454684364208) /* log_e 10 */ +# define M_PIf32x __f32x (3.141592653589793238462643383279502884) /* pi */ +# define M_PI_2f32x __f32x (1.570796326794896619231321691639751442) /* pi/2 */ +# define M_PI_4f32x __f32x (0.785398163397448309615660845819875721) /* pi/4 */ +# define M_1_PIf32x __f32x (0.318309886183790671537767526745028724) /* 1/pi */ +# define M_2_PIf32x __f32x (0.636619772367581343075535053490057448) /* 2/pi */ +# define M_2_SQRTPIf32x __f32x (1.128379167095512573896158903121545172) /* 2/sqrt(pi) */ +# define M_SQRT2f32x __f32x (1.414213562373095048801688724209698079) /* sqrt(2) */ +# define M_SQRT1_2f32x __f32x (0.707106781186547524400844362104849039) /* 1/sqrt(2) */ +#endif + +#if __HAVE_FLOAT64X && defined __USE_GNU +# define M_Ef64x __f64x (2.718281828459045235360287471352662498) /* e */ +# define M_LOG2Ef64x __f64x (1.442695040888963407359924681001892137) /* log_2 e */ +# define M_LOG10Ef64x __f64x (0.434294481903251827651128918916605082) /* log_10 e */ +# define M_LN2f64x __f64x (0.693147180559945309417232121458176568) /* log_e 2 */ +# define M_LN10f64x __f64x (2.302585092994045684017991454684364208) /* log_e 10 */ +# define M_PIf64x __f64x (3.141592653589793238462643383279502884) /* pi */ +# define M_PI_2f64x __f64x (1.570796326794896619231321691639751442) /* pi/2 */ +# define M_PI_4f64x __f64x (0.785398163397448309615660845819875721) /* pi/4 */ +# define M_1_PIf64x __f64x (0.318309886183790671537767526745028724) /* 1/pi */ +# define M_2_PIf64x __f64x (0.636619772367581343075535053490057448) /* 2/pi */ +# define M_2_SQRTPIf64x __f64x (1.128379167095512573896158903121545172) /* 2/sqrt(pi) */ +# define M_SQRT2f64x __f64x (1.414213562373095048801688724209698079) /* sqrt(2) */ +# define M_SQRT1_2f64x __f64x (0.707106781186547524400844362104849039) /* 1/sqrt(2) */ +#endif + +#if __HAVE_FLOAT128X && defined __USE_GNU +# error "M_* values needed for _Float128x" +#endif + /* When compiling in strict ISO C compatible mode we must not use the inline functions since they, among other things, do not set the `errno' variable correctly. */