diff options
author | Joseph Myers <joseph@codesourcery.com> | 2017-10-30 16:42:28 +0000 |
---|---|---|
committer | Joseph Myers <joseph@codesourcery.com> | 2017-10-30 16:42:28 +0000 |
commit | ce12269fac8cb873df1a8785e4a6cde870855590 (patch) | |
tree | e6a54819f72d08d032acfe9e590eaa12213ef2de /math | |
parent | 4484b9e29656980f18bb0fc8cdb6b1bbe5364f21 (diff) | |
download | glibc-ce12269fac8cb873df1a8785e4a6cde870855590.tar.gz glibc-ce12269fac8cb873df1a8785e4a6cde870855590.tar.xz glibc-ce12269fac8cb873df1a8785e4a6cde870855590.zip |
Add _FloatN, _FloatNx M_* constants.
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. * 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.
Diffstat (limited to 'math')
-rw-r--r-- | math/math.h | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/math/math.h b/math/math.h index 326304202a..5683ac96fe 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. */ |