diff options
| author | rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-09-17 01:28:50 +0000 |
|---|---|---|
| committer | rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-09-17 01:28:50 +0000 |
| commit | b0db7939a3a9dbe5cdc3f21b65c7727a0a723fe0 (patch) | |
| tree | 13b37fe93a02d7ab652503bcdc4b3b55cdb5e3d6 /libstdc++-v3/include/std/std_limits.h | |
| parent | 7c4f0b1d149a7f54e531cc148616dd6838816eb2 (diff) | |
| download | ppe42-gcc-b0db7939a3a9dbe5cdc3f21b65c7727a0a723fe0.tar.gz ppe42-gcc-b0db7939a3a9dbe5cdc3f21b65c7727a0a723fe0.zip | |
gcc/
* builtin-types.def (BT_FN_FLOAT_CONST_STRING): New.
(BT_FN_DOUBLE_CONST_STRING, BT_FN_LONG_DOUBLE_CONST_STRING): New.
* builtins.def (__builtin_nan, __builtin_nanf, __builtin_nanl): New.
(__builtin_nans, __builtin_nansf, __builtin_nansl): New.
* builtins.c (fold_builtin_nan): New.
(fold_builtin): Call it.
* real.c (real_nan): Parse a non-empty string.
(round_for_format): Fix NaN significand truncation.
* real.h (real_nan): Return bool.
* doc/extend.texi: Document new builtins.
libstdc++/
* include/std/std_limits.h (__glibcpp_f32_QNaN_bytes,
__glibcpp_f32_has_QNaN, __glibcpp_f32_SNaN_bytes,
__glibcpp_f32_has_SNaN, __glibcpp_f64_QNaN_bytes,
__glibcpp_f64_has_QNaN, __glibcpp_f64_SNaN_bytes,
__glibcpp_f64_has_SNaN, __glibcpp_f80_QNaN_bytes,
__glibcpp_f80_has_QNaN, __glibcpp_f80_SNaN_bytes,
__glibcpp_f80_has_SNaN, __glibcpp_f96_QNaN_bytes,
__glibcpp_f96_has_QNaN, __glibcpp_f96_SNaN_bytes,
__glibcpp_f96_has_SNaN, __glibcpp_f128_QNaN_bytes,
__glibcpp_f128_has_QNaN, __glibcpp_f128_SNaN_bytes,
__glibcpp_f128_has_SNaN, __glibcpp_float_QNaN_bytes,
__glibcpp_float_has_QNaN, __glibcpp_float_SNaN_bytes,
__glibcpp_float_has_SNaN, __glibcpp_double_QNaN_bytes,
__glibcpp_double_has_QNaN, __glibcpp_double_SNaN_bytes,
__glibcpp_double_has_SNaN, __glibcpp_long_double_QNaN_bytes,
__glibcpp_long_double_has_QNaN, __glibcpp_long_double_SNaN_bytes,
__glibcpp_long_double_has_SNaN): Remove.
(__glibcpp_f128_is_iec559): True if IEEE.
(__glibcpp_float_QNaN, __glibcpp_float_SNaN): Remove.
(__glibcpp_double_QNaN, __glibcpp_double_SNaN): Remove.
(__glibcpp_long_double_QNaN, __glibcpp_long_double_SNaN): Remove.
(std::numeric_limits<float>::has_quiet_NaN): Use __builtin_nanf.
(std::numeric_limits<float>::has_signaling_NaN): Mirror has_quiet_NaN.
(std::numeric_limits<float>::quiet_NaN): Use __builtin_nanf.
(std::numeric_limits<float>::signaling_NaN): Use __builtin_nansf.
(std::numeric_limits<double>): Similarly.
(std::numeric_limits<long double>): Similarly.
* src/limits.cc (__glibcpp_float_QNaN, __glibcpp_float_SNaN): Remove.
(__glibcpp_double_QNaN, __glibcpp_double_SNaN): Remove.
(__glibcpp_long_double_QNaN, __glibcpp_long_double_SNaN): Remove.
* testsuite/18_support/numeric_limits.cc (test_infinity): New.
(test_denorm_min, test_qnan, test_is_iec559): New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@57221 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/include/std/std_limits.h')
| -rw-r--r-- | libstdc++-v3/include/std/std_limits.h | 210 |
1 files changed, 16 insertions, 194 deletions
diff --git a/libstdc++-v3/include/std/std_limits.h b/libstdc++-v3/include/std/std_limits.h index 34a3f761387..a1d42244bf8 100644 --- a/libstdc++-v3/include/std/std_limits.h +++ b/libstdc++-v3/include/std/std_limits.h @@ -152,115 +152,32 @@ #define __glibcpp_f32_round_error 1.0F #if __GCC_FLOAT_FORMAT__ == __IEEE_FORMAT__ -# define __glibcpp_f32_QNaN_bytes { 0x7fc00000 } -# define __glibcpp_f32_has_QNaN true -# define __glibcpp_f32_SNaN_bytes { 0x7f800001 } -# define __glibcpp_f32_has_SNaN true # define __glibcpp_f32_is_iec559 true #endif -#ifndef __glibcpp_f32_QNaN_bytes -# define __glibcpp_f32_QNaN_bytes { } -# define __glibcpp_f32_has_QNaN false -#endif -#ifndef __glibcpp_f32_SNaN_bytes -# define __glibcpp_f32_SNaN_bytes { } -# define __glibcpp_f32_has_SNaN false -#endif #ifndef __glibcpp_f32_is_iec559 # define __glibcpp_f32_is_iec559 false #endif #define __glibcpp_f64_round_error 1.0 #if __GCC_FLOAT_FORMAT__ == __IEEE_FORMAT__ -# if __TARGET_FLOAT_WORDS_ORDER__ == __GCC_BIG_ENDIAN__ -# define __glibcpp_f64_QNaN_bytes { 0x7ff80000, 0x0 } -# define __glibcpp_f64_SNaN_bytes { 0x7ff00000, 0x1 } -# else -# define __glibcpp_f64_QNaN_bytes { 0x0, 0x7ff80000 } -# define __glibcpp_f64_SNaN_bytes { 0x1, 0x7ff00000 } -# endif -# define __glibcpp_f64_has_QNaN true -# define __glibcpp_f64_has_SNaN true # define __glibcpp_f64_is_iec559 true #endif -#ifndef __glibcpp_f64_QNaN_bytes -# define __glibcpp_f64_QNaN_bytes { } -# define __glibcpp_f64_has_QNaN false -#endif -#ifndef __glibcpp_f64_SNaN_bytes -# define __glibcpp_f64_SNaN_bytes { } -# define __glibcpp_f64_has_SNaN false -#endif #ifndef __glibcpp_f64_is_iec559 # define __glibcpp_f64_is_iec559 false #endif #define __glibcpp_f80_round_error 1.0L #if __GCC_FLOAT_FORMAT__ == __IEEE_FORMAT__ -# if __TARGET_BYTES_ORDER__ == __GCC_BIG_ENDIAN__ -# define __glibcpp_f80_QNaN_bytes \ - { 0x7f, 0xff, 0xC0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } -# define __glibcpp_f80_SNaN_bytes \ - { 0x7f, 0xff, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1 } -# else -# define __glibcpp_f80_QNaN_bytes \ - { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xC0, 0xff, 0x7f } -# define __glibcpp_f80_SNaN_bytes \ - { 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x80, 0xff, 0x7f } -# endif -# define __glibcpp_f80_has_QNaN true -# define __glibcpp_f80_has_SNaN true # define __glibcpp_f80_is_iec559 true #endif -#ifndef __glibcpp_f80_QNaN_bytes -# define __glibcpp_f80_QNaN_bytes { } -# define __glibcpp_f80_has_QNaN false -#endif -#ifndef __glibcpp_f80_SNaN_bytes -# define __glibcpp_f80_SNaN_bytes { } -# define __glibcpp_f80_has_SNaN false -#endif #ifndef __glibcpp_f80_is_iec559 # define __glibcpp_f80_is_iec559 false #endif #define __glibcpp_f96_round_error 1.0L #if __GCC_FLOAT_FORMAT__ == __IEEE_FORMAT__ -# if __TARGET_BYTES_ORDER__ == __GCC_BIG_ENDIAN__ -# define __glibcpp_f96_QNaN_bytes { 0x7ff80000, 0x0, 0x0 } -# define __glibcpp_f96_SNaN_bytes { 0x7ff00000, 0x0, 0x1 } -# else -# define __glibcpp_f96_QNaN_bytes { 0x0, 0x0, 0x7ff80000 } -# define __glibcpp_f96_SNaN_bytes { 0x1, 0x0, 0x7ff00000 } -# endif -# define __glibcpp_f96_has_QNaN true -# define __glibcpp_f96_has_SNaN true # define __glibcpp_f96_is_iec559 true #endif -#ifndef __glibcpp_f96_QNaN_bytes -# define __glibcpp_f96_QNaN_bytes { } -# define __glibcpp_f96_has_QNaN false -#endif -#ifndef __glibcpp_f96_SNaN_bytes -# define __glibcpp_f96_SNaN_bytes { } -# define __glibcpp_f96_has_SNaN false -#endif #define __glibcpp_f128_round_error 1.0L #if __GCC_FLOAT_FORMAT__ == __IEEE_FORMAT__ -# if __TARGET_FLOAT_WORDS_ORDER__ == __GCC_BIG_ENDIAN__ -# define __glibcpp_f128_QNaN_bytes { 0x7fff0800, 0x0, 0x0, 0x0 } -# define __glibcpp_f128_SNaN_bytes { 0x7fff0000, 0x0, 0x0, 0x1 } -# else -# define __glibcpp_f128_QNaN_bytes { 0x0, 0x0, 0x0, 0x7fff0800 } -# define __glibcpp_f128_SNaN_bytes { 0x1, 0x0, 0x0, 0x7fff0000 } -# endif -# define __glibcpp_f128_has_QNaN true -# define __glibcpp_f128_has_SNaN true -#endif -#ifndef __glibcpp_f128_QNaN_bytes -# define __glibcpp_f128_QNaN_bytes { } -# define __glibcpp_f128_has_QNaN false -#endif -#ifndef __glibcpp_f128_SNaN_bytes -# define __glibcpp_f128_SNaN_bytes { } -# define __glibcpp_f128_has_SNaN false +# define __glibcpp_f128_is_iec559 true #endif #ifndef __glibcpp_f128_is_iec559 # define __glibcpp_f128_is_iec559 false @@ -587,24 +504,12 @@ #if __FLOAT_BIT__ == 32 # define __glibcpp_float_round_error __glibcpp_f32_round_error -# define __glibcpp_float_QNaN_bytes __glibcpp_f32_QNaN_bytes -# define __glibcpp_float_SNaN_bytes __glibcpp_f32_SNaN_bytes -# define __glibcpp_float_has_QNaN __glibcpp_f32_has_QNaN -# define __glibcpp_float_has_SNaN __glibcpp_f32_has_SNaN # define __glibcpp_float_is_iec559 __glibcpp_f32_is_iec559 #elif __FLOAT_BIT__ == 64 # define __glibcpp_float_round_error __glibcpp_f64_round_error -# define __glibcpp_float_QNaN_bytes __glibcpp_f64_QNaN_bytes -# define __glibcpp_float_SNaN_bytes __glibcpp_f64_SNaN_bytes -# define __glibcpp_float_has_QNaN __glibcpp_f64_has_QNaN -# define __glibcpp_float_has_SNaN __glibcpp_f64_has_SNaN # define __glibcpp_float_is_iec559 __glibcpp_f64_is_iec559 #elif __FLOAT_BIT__ == 80 # define __glibcpp_float_round_error __glibcpp_f80_round_error -# define __glibcpp_float_QNaN_bytes __glibcpp_f80_QNaN_bytes -# define __glibcpp_float_SNaN_bytes __glibcpp_f80_SNaN_bytes -# define __glibcpp_float_has_QNaN __glibcpp_f80_has_QNaN -# define __glibcpp_float_has_SNaN __glibcpp_f80_has_SNaN # define __glibcpp_float_is_iec559 __glibcpp_f80_is_iec559 #else // You must define these macros in the configuration file. @@ -612,16 +517,6 @@ // Default values. Should be overriden in configuration files if necessary. -#ifndef __glibcpp_float_QNaN_bytes -# define __glibcpp_float_QNaN_bytes { } -# define __glibcpp_float_has_QNaN false -#endif - -#ifndef __glibcpp_float_SNaN_bytes -# define __glibcpp_float_SNaN_bytes { } -# define __glibcpp_float_has_SNaN false -#endif - #ifndef __glibcpp_float_has_denorm_loss # define __glibcpp_float_has_denorm_loss false #endif @@ -654,24 +549,12 @@ #if __DOUBLE_BIT__ == 32 # define __glibcpp_double_round_error __glibcpp_f32_round_error -# define __glibcpp_double_QNaN_bytes __glibcpp_f32_QNaN_bytes -# define __glibcpp_double_SNaN_bytes __glibcpp_f32_SNaN_bytes -# define __glibcpp_double_has_QNaN __glibcpp_f32_has_QNaN -# define __glibcpp_double_has_SNaN __glibcpp_f32_has_SNaN # define __glibcpp_double_is_iec559 __glibcpp_f32_is_iec559 #elif __DOUBLE_BIT__ == 64 # define __glibcpp_double_round_error __glibcpp_f64_round_error -# define __glibcpp_double_QNaN_bytes __glibcpp_f64_QNaN_bytes -# define __glibcpp_double_SNaN_bytes __glibcpp_f64_SNaN_bytes -# define __glibcpp_double_has_QNaN __glibcpp_f64_has_QNaN -# define __glibcpp_double_has_SNaN __glibcpp_f64_has_SNaN # define __glibcpp_double_is_iec559 __glibcpp_f64_is_iec559 #elif __DOUBLE_BIT__ == 80 # define __glibcpp_double_round_error __glibcpp_f80_round_error -# define __glibcpp_double_QNaN_bytes __glibcpp_f80_QNaN_bytes -# define __glibcpp_double_SNaN_bytes __glibcpp_f80_SNaN_bytes -# define __glibcpp_double_has_QNaN __glibcpp_f80_has_QNaN -# define __glibcpp_double_has_SNaN __glibcpp_f80_has_SNaN # define __glibcpp_double_is_iec559 __glibcpp_f80_is_iec559 #else // You must define these macros in the configuration file. @@ -679,16 +562,6 @@ // Default values. Should be overriden in configuration files if necessary. -#ifndef __glibcpp_double_QNaN_bytes -# define __glibcpp_double_QNaN_bytes { } -# define __glibcpp_double_has_QNaN false -#endif - -#ifndef __glibcpp_double_SNaN_bytes -# define __glibcpp_double_SNaN_bytes { } -# define __glibcpp_double_has_SNaN false -#endif - #ifndef __glibcpp_double_has_denorm_loss # define __glibcpp_double_has_denorm_loss false #endif @@ -721,38 +594,18 @@ #if __LONG_DOUBLE_BIT__ == 32 # define __glibcpp_long_double_round_error __glibcpp_f32_round_error -# define __glibcpp_long_double_QNaN_bytes __glibcpp_f32_QNaN_bytes -# define __glibcpp_long_double_SNaN_bytes __glibcpp_f32_SNaN_bytes -# define __glibcpp_long_double_has_QNaN __glibcpp_f32_has_QNaN -# define __glibcpp_long_double_has_SNaN __glibcpp_f32_has_SNaN # define __glibcpp_long_double_is_iec559 __glibcpp_f32_is_iec559 #elif __LONG_DOUBLE_BIT__ == 64 # define __glibcpp_long_double_round_error __glibcpp_f64_round_error -# define __glibcpp_long_double_QNaN_bytes __glibcpp_f64_QNaN_bytes -# define __glibcpp_long_double_SNaN_bytes __glibcpp_f64_SNaN_bytes -# define __glibcpp_long_double_has_QNaN __glibcpp_f64_has_QNaN -# define __glibcpp_long_double_has_SNaN __glibcpp_f64_has_SNaN # define __glibcpp_long_double_is_iec559 __glibcpp_f64_is_iec559 #elif __LONG_DOUBLE_BIT__ == 80 # define __glibcpp_long_double_round_error __glibcpp_f80_round_error -# define __glibcpp_long_double_QNaN_bytes __glibcpp_f80_QNaN_bytes -# define __glibcpp_long_double_SNaN_bytes __glibcpp_f80_SNaN_bytes -# define __glibcpp_long_double_has_QNaN __glibcpp_f80_has_QNaN -# define __glibcpp_long_double_has_SNaN __glibcpp_f80_has_SNaN # define __glibcpp_long_double_is_iec559 __glibcpp_f80_is_iec559 #elif __LONG_DOUBLE_BIT__ == 96 # define __glibcpp_long_double_round_error __glibcpp_f96_round_error -# define __glibcpp_long_double_QNaN_bytes __glibcpp_f96_QNaN_bytes -# define __glibcpp_long_double_SNaN_bytes __glibcpp_f96_SNaN_bytes -# define __glibcpp_long_double_has_QNaN __glibcpp_f96_has_QNaN -# define __glibcpp_long_double_has_SNaN __glibcpp_f96_has_SNaN # define __glibcpp_long_double_is_iec559 __glibcpp_f96_is_iec559 #elif __LONG_DOUBLE_BIT__ == 128 # define __glibcpp_long_double_round_error __glibcpp_f128_round_error -# define __glibcpp_long_double_QNaN_bytes __glibcpp_f128_QNaN_bytes -# define __glibcpp_long_double_SNaN_bytes __glibcpp_f128_SNaN_bytes -# define __glibcpp_long_double_has_QNaN __glibcpp_f128_has_QNaN -# define __glibcpp_long_double_has_SNaN __glibcpp_f128_has_SNaN # define __glibcpp_long_double_is_iec559 __glibcpp_f128_is_iec559 #else // You must define these macros in the configuration file. @@ -760,16 +613,6 @@ // Default values. Should be overriden in configuration files if necessary. -#ifndef __glibcpp_long_double_QNaN_bytes -# define __glibcpp_long_double_QNaN_bytes { } -# define __glibcpp_long_double_has_QNaN false -#endif - -#ifndef __glibcpp_long_double_SNaN_bytes -# define __glibcpp_long_double_SNaN_bytes { } -# define __glibcpp_long_double_has_SNaN false -#endif - #ifndef __glibcpp_long_double_has_denorm_loss # define __glibcpp_long_double_has_denorm_loss false #endif @@ -843,15 +686,6 @@ namespace std #endif __attribute__((__aligned__(__alignof__(long double)))); - extern const __float_storage __glibcpp_float_QNaN; - extern const __float_storage __glibcpp_float_SNaN; - - extern const __double_storage __glibcpp_double_QNaN; - extern const __double_storage __glibcpp_double_SNaN; - - extern const __long_double_storage __glibcpp_long_double_QNaN; - extern const __long_double_storage __glibcpp_long_double_SNaN; - enum float_round_style { round_indeterminate = -1, @@ -1680,8 +1514,9 @@ namespace std static const bool has_infinity = __builtin_huge_valf () / 2 == __builtin_huge_valf (); - static const bool has_quiet_NaN = __glibcpp_float_has_QNaN; - static const bool has_signaling_NaN = __glibcpp_float_has_SNaN; + static const bool has_quiet_NaN + = __builtin_nanf ("") != __builtin_nanf (""); + static const bool has_signaling_NaN = has_quiet_NaN; static const float_denorm_style has_denorm = __FLT_DENORM_MIN__ ? denorm_present : denorm_absent; static const bool has_denorm_loss = __glibcpp_float_has_denorm_loss; @@ -1689,9 +1524,9 @@ namespace std static float infinity() throw() { return __builtin_huge_valf (); } static float quiet_NaN() throw() - { return *reinterpret_cast<const float*>(__glibcpp_float_QNaN); } + { return __builtin_nanf (""); } static float signaling_NaN() throw() - { return *reinterpret_cast<const float*>(__glibcpp_float_SNaN); } + { return __builtin_nansf (""); } static float denorm_min() throw() { return __FLT_DENORM_MIN__; } @@ -1705,8 +1540,6 @@ namespace std }; #undef __glibcpp_float_round_error -#undef __glibcpp_float_has_QNaN -#undef __glibcpp_float_has_SNaN #undef __glibcpp_float_has_denorm_loss #undef __glibcpp_float_is_iec559 #undef __glibcpp_float_is_bounded @@ -1743,8 +1576,9 @@ namespace std static const bool has_infinity = __builtin_huge_val () / 2 == __builtin_huge_val (); - static const bool has_quiet_NaN = __glibcpp_double_has_QNaN; - static const bool has_signaling_NaN = __glibcpp_double_has_SNaN; + static const bool has_quiet_NaN + = __builtin_nan ("") != __builtin_nan (""); + static const bool has_signaling_NaN = has_quiet_NaN; static const float_denorm_style has_denorm = __DBL_DENORM_MIN__ ? denorm_present : denorm_absent; static const bool has_denorm_loss = __glibcpp_double_has_denorm_loss; @@ -1752,9 +1586,9 @@ namespace std static double infinity() throw() { return __builtin_huge_val(); } static double quiet_NaN() throw() - { return *reinterpret_cast<const double*>(__glibcpp_double_QNaN); } + { return __builtin_nan (""); } static double signaling_NaN() throw() - { return *reinterpret_cast<const double*>(__glibcpp_double_SNaN); } + { return __builtin_nans (""); } static double denorm_min() throw() { return __DBL_DENORM_MIN__; } @@ -1769,8 +1603,6 @@ namespace std }; #undef __glibcpp_double_round_error -#undef __glibcpp_double_has_QNaN -#undef __glibcpp_double_has_SNaN #undef __glibcpp_double_has_denorm_loss #undef __glibcpp_double_is_iec559 #undef __glibcpp_double_is_bounded @@ -1808,8 +1640,9 @@ namespace std static const bool has_infinity = __builtin_huge_vall () / 2 == __builtin_huge_vall (); - static const bool has_quiet_NaN = __glibcpp_long_double_has_SNaN; - static const bool has_signaling_NaN = __glibcpp_long_double_has_SNaN; + static const bool has_quiet_NaN + = __builtin_nanl ("") != __builtin_nanl (""); + static const bool has_signaling_NaN = has_quiet_NaN; static const float_denorm_style has_denorm = __LDBL_DENORM_MIN__ ? denorm_present : denorm_absent; static const bool has_denorm_loss @@ -1817,19 +1650,10 @@ namespace std static long double infinity() throw() { return __builtin_huge_vall (); } - static long double quiet_NaN() throw() - { - return *reinterpret_cast<const long double*> - (__glibcpp_long_double_QNaN); - } - + { return __builtin_nanl (""); } static long double signaling_NaN() throw() - { - return *reinterpret_cast<const long double*> - (__glibcpp_long_double_SNaN); - } - + { return __builtin_nansl (""); } static long double denorm_min() throw() { return __LDBL_DENORM_MIN__; } @@ -1844,8 +1668,6 @@ namespace std }; #undef __glibcpp_long_double_round_error -#undef __glibcpp_long_double_has_QNaN -#undef __glibcpp_long_double_has_SNaN #undef __glibcpp_long_double_has_denorm_loss #undef __glibcpp_long_double_is_iec559 #undef __glibcpp_long_double_is_bounded |

