diff options
Diffstat (limited to 'libstdc++-v3')
-rw-r--r-- | libstdc++-v3/ChangeLog | 9 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/cpp_type_traits.h | 32 | ||||
-rw-r--r-- | libstdc++-v3/include/c_global/cstdlib | 19 | ||||
-rw-r--r-- | libstdc++-v3/include/c_std/cstdlib | 18 | ||||
-rw-r--r-- | libstdc++-v3/include/std/limits | 329 | ||||
-rw-r--r-- | libstdc++-v3/include/std/type_traits | 77 | ||||
-rw-r--r-- | libstdc++-v3/src/c++11/limits.cc | 108 |
7 files changed, 383 insertions, 209 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index a20ae1ccade..cc052f082b5 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,12 @@ +2014-10-14 DJ Delorie <dj@redhat.com> + + * src/c++11/limits.cc: Add support for __intN types. + * include/std/type_traits: Likewise. + * include/std/limits: Likewise. + * include/c_std/cstdlib: Likewise. + * include/bits/cpp_type_traits.h: Likewise. + * include/c_global/cstdlib: Likewise. + 2014-10-14 Jonathan Wakely <jwakely@redhat.com> * testsuite/20_util/align/1.cc: Add dg-require-stdint. diff --git a/libstdc++-v3/include/bits/cpp_type_traits.h b/libstdc++-v3/include/bits/cpp_type_traits.h index 8df81a705ea..46067f18a1e 100644 --- a/libstdc++-v3/include/bits/cpp_type_traits.h +++ b/libstdc++-v3/include/bits/cpp_type_traits.h @@ -141,7 +141,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // Thirteen specializations (yes there are eleven standard integer // types; <em>long long</em> and <em>unsigned long long</em> are - // supported as extensions) + // supported as extensions). Up to four target-specific __int<N> + // types are supported as well. template<> struct __is_integer<bool> { @@ -251,6 +252,35 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION typedef __true_type __type; }; +#define __INT_N(TYPE) \ + template<> \ + struct __is_integer<TYPE> \ + { \ + enum { __value = 1 }; \ + typedef __true_type __type; \ + }; \ + template<> \ + struct __is_integer<unsigned TYPE> \ + { \ + enum { __value = 1 }; \ + typedef __true_type __type; \ + }; + +#ifdef __GLIBCXX_TYPE_INT_N_0 +__INT_N(__GLIBCXX_TYPE_INT_N_0) +#endif +#ifdef __GLIBCXX_TYPE_INT_N_1 +__INT_N(__GLIBCXX_TYPE_INT_N_1) +#endif +#ifdef __GLIBCXX_TYPE_INT_N_2 +__INT_N(__GLIBCXX_TYPE_INT_N_2) +#endif +#ifdef __GLIBCXX_TYPE_INT_N_3 +__INT_N(__GLIBCXX_TYPE_INT_N_3) +#endif + +#undef __INT_N + // // Floating point types // diff --git a/libstdc++-v3/include/c_global/cstdlib b/libstdc++-v3/include/c_global/cstdlib index e98a7262817..f1b36f3db61 100644 --- a/libstdc++-v3/include/c_global/cstdlib +++ b/libstdc++-v3/include/c_global/cstdlib @@ -174,10 +174,23 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION abs(long long __x) { return __builtin_llabs (__x); } #endif -#if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_INT128) - inline __int128 - abs(__int128 __x) { return __x >= 0 ? __x : -__x; } +#if defined(__GLIBCXX_TYPE_INT_N_0) + inline __GLIBCXX_TYPE_INT_N_0 + abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; } #endif +#if defined(__GLIBCXX_TYPE_INT_N_1) + inline __GLIBCXX_TYPE_INT_N_1 + abs(__GLIBCXX_TYPE_INT_N_1 __x) { return __x >= 0 ? __x : -__x; } +#endif +#if defined(__GLIBCXX_TYPE_INT_N_2) + inline __GLIBCXX_TYPE_INT_N_2 + abs(__GLIBCXX_TYPE_INT_N_2 __x) { return __x >= 0 ? __x : -__x; } +#endif +#if defined(__GLIBCXX_TYPE_INT_N_3) + inline __GLIBCXX_TYPE_INT_N_3 + abs(__GLIBCXX_TYPE_INT_N_3 __x) { return __x >= 0 ? __x : -__x; } +#endif + _GLIBCXX_END_NAMESPACE_VERSION } // namespace diff --git a/libstdc++-v3/include/c_std/cstdlib b/libstdc++-v3/include/c_std/cstdlib index 7f0d9b20cd1..38c942a3ceb 100644 --- a/libstdc++-v3/include/c_std/cstdlib +++ b/libstdc++-v3/include/c_std/cstdlib @@ -169,9 +169,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION abs(long long __x) { return __builtin_llabs (__x); } #endif -#if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_INT128) - inline __int128 - abs(__int128 __x) { return __x >= 0 ? __x : -__x; } +#if defined(__GLIBCXX_TYPE_INT_N_0) + inline __GLIBCXX_TYPE_INT_N_0 + abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; } +#endif +#if defined(__GLIBCXX_TYPE_INT_N_1) + inline __GLIBCXX_TYPE_INT_N_1 + abs(__GLIBCXX_TYPE_INT_N_1 __x) { return __x >= 0 ? __x : -__x; } +#endif +#if defined(__GLIBCXX_TYPE_INT_N_2) + inline __GLIBCXX_TYPE_INT_N_2 + abs(__GLIBCXX_TYPE_INT_N_2 __x) { return __x >= 0 ? __x : -__x; } +#endif +#if defined(__GLIBCXX_TYPE_INT_N_3) + inline __GLIBCXX_TYPE_INT_N_3 + abs(__GLIBCXX_TYPE_INT_N_3 __x) { return __x >= 0 ? __x : -__x; } #endif inline ldiv_t diff --git a/libstdc++-v3/include/std/limits b/libstdc++-v3/include/std/limits index f39821eb365..d5add09655a 100644 --- a/libstdc++-v3/include/std/limits +++ b/libstdc++-v3/include/std/limits @@ -125,21 +125,32 @@ // You should not need to define any macros below this point. -#define __glibcxx_signed(T) ((T)(-1) < 0) +#define __glibcxx_signed_b(T,B) ((T)(-1) < 0) -#define __glibcxx_min(T) \ - (__glibcxx_signed (T) ? -__glibcxx_max (T) - 1 : (T)0) +#define __glibcxx_min_b(T,B) \ + (__glibcxx_signed_b (T,B) ? -__glibcxx_max_b (T,B) - 1 : (T)0) -#define __glibcxx_max(T) \ - (__glibcxx_signed (T) ? \ - (((((T)1 << (__glibcxx_digits (T) - 1)) - 1) << 1) + 1) : ~(T)0) +#define __glibcxx_max_b(T,B) \ + (__glibcxx_signed_b (T,B) ? \ + (((((T)1 << (__glibcxx_digits_b (T,B) - 1)) - 1) << 1) + 1) : ~(T)0) -#define __glibcxx_digits(T) \ - (sizeof(T) * __CHAR_BIT__ - __glibcxx_signed (T)) +#define __glibcxx_digits_b(T,B) \ + (B - __glibcxx_signed_b (T,B)) // The fraction 643/2136 approximates log10(2) to 7 significant digits. +#define __glibcxx_digits10_b(T,B) \ + (__glibcxx_digits_b (T,B) * 643L / 2136) + +#define __glibcxx_signed(T) \ + __glibcxx_signed_b (T, sizeof(T) * __CHAR_BIT__) +#define __glibcxx_min(T) \ + __glibcxx_min_b (T, sizeof(T) * __CHAR_BIT__) +#define __glibcxx_max(T) \ + __glibcxx_max_b (T, sizeof(T) * __CHAR_BIT__) +#define __glibcxx_digits(T) \ + __glibcxx_digits_b (T, sizeof(T) * __CHAR_BIT__) #define __glibcxx_digits10(T) \ - (__glibcxx_digits (T) * 643L / 2136) + __glibcxx_digits10_b (T, sizeof(T) * __CHAR_BIT__) #define __glibcxx_max_digits10(T) \ (2 + (T) * 643L / 2136) @@ -1399,153 +1410,181 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION = round_toward_zero; }; -#if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_INT128) - /// numeric_limits<__int128> specialization. - template<> - struct numeric_limits<__int128> - { - static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true; - - static _GLIBCXX_CONSTEXPR __int128 - min() _GLIBCXX_USE_NOEXCEPT { return __glibcxx_min (__int128); } - - static _GLIBCXX_CONSTEXPR __int128 - max() _GLIBCXX_USE_NOEXCEPT { return __glibcxx_max (__int128); } +#if !defined(__STRICT_ANSI__) + +#define __INT_N(TYPE, BITSIZE, EXT, UEXT) \ + template<> \ + struct numeric_limits<TYPE> \ + { \ + static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true; \ + \ + static _GLIBCXX_CONSTEXPR TYPE \ + min() _GLIBCXX_USE_NOEXCEPT { return __glibcxx_min_b (TYPE, BITSIZE); } \ + \ + static _GLIBCXX_CONSTEXPR TYPE \ + max() _GLIBCXX_USE_NOEXCEPT { return __glibcxx_max_b (TYPE, BITSIZE);; } \ + \ + static _GLIBCXX_USE_CONSTEXPR int digits \ + = BITSIZE - 1; \ + static _GLIBCXX_USE_CONSTEXPR int digits10 \ + = (BITSIZE - 1) * 643L / 2136; \ + \ + static _GLIBCXX_USE_CONSTEXPR bool is_signed = true; \ + static _GLIBCXX_USE_CONSTEXPR bool is_integer = true; \ + static _GLIBCXX_USE_CONSTEXPR bool is_exact = true; \ + static _GLIBCXX_USE_CONSTEXPR int radix = 2; \ + \ + static _GLIBCXX_CONSTEXPR TYPE \ + epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; } \ + \ + static _GLIBCXX_CONSTEXPR TYPE \ + round_error() _GLIBCXX_USE_NOEXCEPT { return 0; } \ + \ + EXT \ + \ + static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0; \ + static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0; \ + static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0; \ + static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0; \ + \ + static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false; \ + static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false; \ + static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false; \ + static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm \ + = denorm_absent; \ + static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false; \ + \ + static _GLIBCXX_CONSTEXPR TYPE \ + infinity() _GLIBCXX_USE_NOEXCEPT \ + { return static_cast<TYPE>(0); } \ + \ + static _GLIBCXX_CONSTEXPR TYPE \ + quiet_NaN() _GLIBCXX_USE_NOEXCEPT \ + { return static_cast<TYPE>(0); } \ + \ + static _GLIBCXX_CONSTEXPR TYPE \ + signaling_NaN() _GLIBCXX_USE_NOEXCEPT \ + { return static_cast<TYPE>(0); } \ + \ + static _GLIBCXX_CONSTEXPR TYPE \ + denorm_min() _GLIBCXX_USE_NOEXCEPT \ + { return static_cast<TYPE>(0); } \ + \ + static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false; \ + static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true; \ + static _GLIBCXX_USE_CONSTEXPR bool is_modulo = false; \ + \ + static _GLIBCXX_USE_CONSTEXPR bool traps \ + = __glibcxx_integral_traps; \ + static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false; \ + static _GLIBCXX_USE_CONSTEXPR float_round_style round_style \ + = round_toward_zero; \ + }; \ + \ + template<> \ + struct numeric_limits<unsigned TYPE> \ + { \ + static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true; \ + \ + static _GLIBCXX_CONSTEXPR unsigned TYPE \ + min() _GLIBCXX_USE_NOEXCEPT { return 0; } \ + \ + static _GLIBCXX_CONSTEXPR unsigned TYPE \ + max() _GLIBCXX_USE_NOEXCEPT { return __glibcxx_max_b (TYPE, BITSIZE); } \ + \ + UEXT \ + \ + static _GLIBCXX_USE_CONSTEXPR int digits \ + = BITSIZE; \ + static _GLIBCXX_USE_CONSTEXPR int digits10 \ + = BITSIZE * 643L / 2136; \ + static _GLIBCXX_USE_CONSTEXPR bool is_signed = false; \ + static _GLIBCXX_USE_CONSTEXPR bool is_integer = true; \ + static _GLIBCXX_USE_CONSTEXPR bool is_exact = true; \ + static _GLIBCXX_USE_CONSTEXPR int radix = 2; \ + \ + static _GLIBCXX_CONSTEXPR unsigned TYPE \ + epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; } \ + \ + static _GLIBCXX_CONSTEXPR unsigned TYPE \ + round_error() _GLIBCXX_USE_NOEXCEPT { return 0; } \ + \ + static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0; \ + static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0; \ + static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0; \ + static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0; \ + \ + static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false; \ + static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false; \ + static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false; \ + static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm \ + = denorm_absent; \ + static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false; \ + \ + static _GLIBCXX_CONSTEXPR unsigned TYPE \ + infinity() _GLIBCXX_USE_NOEXCEPT \ + { return static_cast<unsigned TYPE>(0); } \ + \ + static _GLIBCXX_CONSTEXPR unsigned TYPE \ + quiet_NaN() _GLIBCXX_USE_NOEXCEPT \ + { return static_cast<unsigned TYPE>(0); } \ + \ + static _GLIBCXX_CONSTEXPR unsigned TYPE \ + signaling_NaN() _GLIBCXX_USE_NOEXCEPT \ + { return static_cast<unsigned TYPE>(0); } \ + \ + static _GLIBCXX_CONSTEXPR unsigned TYPE \ + denorm_min() _GLIBCXX_USE_NOEXCEPT \ + { return static_cast<unsigned TYPE>(0); } \ + \ + static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false; \ + static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true; \ + static _GLIBCXX_USE_CONSTEXPR bool is_modulo = true; \ + \ + static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps; \ + static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false; \ + static _GLIBCXX_USE_CONSTEXPR float_round_style round_style \ + = round_toward_zero; \ + }; #if __cplusplus >= 201103L - static constexpr __int128 - lowest() noexcept { return min(); } -#endif - static _GLIBCXX_USE_CONSTEXPR int digits - = __glibcxx_digits (__int128); - static _GLIBCXX_USE_CONSTEXPR int digits10 - = __glibcxx_digits10 (__int128); -#if __cplusplus >= 201103L +#define __INT_N_201103(TYPE) \ + static constexpr TYPE \ + lowest() noexcept { return min(); } \ static constexpr int max_digits10 = 0; -#endif - static _GLIBCXX_USE_CONSTEXPR bool is_signed = true; - static _GLIBCXX_USE_CONSTEXPR bool is_integer = true; - static _GLIBCXX_USE_CONSTEXPR bool is_exact = true; - static _GLIBCXX_USE_CONSTEXPR int radix = 2; - - static _GLIBCXX_CONSTEXPR __int128 - epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; } - - static _GLIBCXX_CONSTEXPR __int128 - round_error() _GLIBCXX_USE_NOEXCEPT { return 0; } - - static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0; - static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0; - static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0; - static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0; - - static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false; - static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false; - static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false; - static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm - = denorm_absent; - static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false; - - static _GLIBCXX_CONSTEXPR __int128 - infinity() _GLIBCXX_USE_NOEXCEPT - { return static_cast<__int128>(0); } - - static _GLIBCXX_CONSTEXPR __int128 - quiet_NaN() _GLIBCXX_USE_NOEXCEPT - { return static_cast<__int128>(0); } - - static _GLIBCXX_CONSTEXPR __int128 - signaling_NaN() _GLIBCXX_USE_NOEXCEPT - { return static_cast<__int128>(0); } - - static _GLIBCXX_CONSTEXPR __int128 - denorm_min() _GLIBCXX_USE_NOEXCEPT - { return static_cast<__int128>(0); } - - static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false; - static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true; - static _GLIBCXX_USE_CONSTEXPR bool is_modulo = false; - - static _GLIBCXX_USE_CONSTEXPR bool traps - = __glibcxx_integral_traps; - static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false; - static _GLIBCXX_USE_CONSTEXPR float_round_style round_style - = round_toward_zero; - }; - - /// numeric_limits<unsigned __int128> specialization. - template<> - struct numeric_limits<unsigned __int128> - { - static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true; - - static _GLIBCXX_CONSTEXPR unsigned __int128 - min() _GLIBCXX_USE_NOEXCEPT { return 0; } - static _GLIBCXX_CONSTEXPR unsigned __int128 - max() _GLIBCXX_USE_NOEXCEPT { return __glibcxx_max (unsigned __int128); } +#define __INT_N_U201103(TYPE) \ + static constexpr unsigned TYPE \ + lowest() noexcept { return min(); } \ + static constexpr int max_digits10 = 0; -#if __cplusplus >= 201103L - static constexpr unsigned __int128 - lowest() noexcept { return min(); } +#else +#define __INT_N_201103(TYPE) +#define __INT_N_U201103(TYPE) #endif - static _GLIBCXX_USE_CONSTEXPR int digits - = __glibcxx_digits (unsigned __int128); - static _GLIBCXX_USE_CONSTEXPR int digits10 - = __glibcxx_digits10 (unsigned __int128); -#if __cplusplus >= 201103L - static constexpr int max_digits10 = 0; +#ifdef __GLIBCXX_TYPE_INT_N_0 + __INT_N(__GLIBCXX_TYPE_INT_N_0, __GLIBCXX_BITSIZE_INT_N_0, + __INT_N_201103 (__GLIBCXX_TYPE_INT_N_0), __INT_N_U201103 (__GLIBCXX_TYPE_INT_N_0)) +#endif +#ifdef __GLIBCXX_TYPE_INT_N_1 + __INT_N (__GLIBCXX_TYPE_INT_N_1, __GLIBCXX_BITSIZE_INT_N_1, + __INT_N_201103 (__GLIBCXX_TYPE_INT_N_1), __INT_N_U201103 (__GLIBCXX_TYPE_INT_N_1)) +#endif +#ifdef __GLIBCXX_TYPE_INT_N_2 + __INT_N (__GLIBCXX_TYPE_INT_N_2, __GLIBCXX_BITSIZE_INT_N_2, + __INT_N_201103 (__GLIBCXX_TYPE_INT_N_2), __INT_N_U201103 (__GLIBCXX_TYPE_INT_N_2)) +#endif +#ifdef __GLIBCXX_TYPE_INT_N_3 + __INT_N (__GLIBCXX_TYPE_INT_N_3, __GLIBCXX_BITSIZE_INT_N_3, + __INT_N_201103 (__GLIBCXX_TYPE_INT_N_3), __INT_N_U201103 (__GLIBCXX_TYPE_INT_N_3)) #endif - static _GLIBCXX_USE_CONSTEXPR bool is_signed = false; - static _GLIBCXX_USE_CONSTEXPR bool is_integer = true; - static _GLIBCXX_USE_CONSTEXPR bool is_exact = true; - static _GLIBCXX_USE_CONSTEXPR int radix = 2; - - static _GLIBCXX_CONSTEXPR unsigned __int128 - epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; } - - static _GLIBCXX_CONSTEXPR unsigned __int128 - round_error() _GLIBCXX_USE_NOEXCEPT { return 0; } - - static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0; - static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0; - static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0; - static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0; - - static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false; - static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false; - static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false; - static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm - = denorm_absent; - static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false; - - static _GLIBCXX_CONSTEXPR unsigned __int128 - infinity() _GLIBCXX_USE_NOEXCEPT - { return static_cast<unsigned __int128>(0); } - - static _GLIBCXX_CONSTEXPR unsigned __int128 - quiet_NaN() _GLIBCXX_USE_NOEXCEPT - { return static_cast<unsigned __int128>(0); } - - static _GLIBCXX_CONSTEXPR unsigned __int128 - signaling_NaN() _GLIBCXX_USE_NOEXCEPT - { return static_cast<unsigned __int128>(0); } - - static _GLIBCXX_CONSTEXPR unsigned __int128 - denorm_min() _GLIBCXX_USE_NOEXCEPT - { return static_cast<unsigned __int128>(0); } - static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false; - static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true; - static _GLIBCXX_USE_CONSTEXPR bool is_modulo = true; +#undef __INT_N +#undef __INT_N_201103 +#undef __INT_N_U201103 - static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps; - static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false; - static _GLIBCXX_USE_CONSTEXPR float_round_style round_style - = round_toward_zero; - }; #endif /// numeric_limits<float> specialization. diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index d776efeb68d..b92bbf09287 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -242,13 +242,42 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct __is_integral_helper<unsigned long long> : public true_type { }; -#if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_INT128) + // Conditionalizing on __STRICT_ANSI__ here will break any port that + // uses one of these types for size_t. +#if defined(__GLIBCXX_TYPE_INT_N_0) template<> - struct __is_integral_helper<__int128> + struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_0> : public true_type { }; template<> - struct __is_integral_helper<unsigned __int128> + struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_0> + : public true_type { }; +#endif +#if defined(__GLIBCXX_TYPE_INT_N_1) + template<> + struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_1> + : public true_type { }; + + template<> + struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_1> + : public true_type { }; +#endif +#if defined(__GLIBCXX_TYPE_INT_N_2) + template<> + struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_2> + : public true_type { }; + + template<> + struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_2> + : public true_type { }; +#endif +#if defined(__GLIBCXX_TYPE_INT_N_3) + template<> + struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_3> + : public true_type { }; + + template<> + struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_3> : public true_type { }; #endif @@ -1661,10 +1690,25 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { }; #endif -#if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_INT128) +#if defined(__GLIBCXX_TYPE_INT_N_0) + template<> + struct __make_unsigned<__GLIBCXX_TYPE_INT_N_0> + { typedef unsigned __GLIBCXX_TYPE_INT_N_0 __type; }; +#endif +#if defined(__GLIBCXX_TYPE_INT_N_1) + template<> + struct __make_unsigned<__GLIBCXX_TYPE_INT_N_1> + { typedef unsigned __GLIBCXX_TYPE_INT_N_1 __type; }; +#endif +#if defined(__GLIBCXX_TYPE_INT_N_2) template<> - struct __make_unsigned<__int128> - { typedef unsigned __int128 __type; }; + struct __make_unsigned<__GLIBCXX_TYPE_INT_N_2> + { typedef unsigned __GLIBCXX_TYPE_INT_N_2 __type; }; +#endif +#if defined(__GLIBCXX_TYPE_INT_N_3) + template<> + struct __make_unsigned<__GLIBCXX_TYPE_INT_N_3> + { typedef unsigned __GLIBCXX_TYPE_INT_N_3 __type; }; #endif // Select between integral and enum: not possible to be both. @@ -1758,10 +1802,25 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { }; #endif -#if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_INT128) +#if defined(__GLIBCXX_TYPE_INT_N_0) + template<> + struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_0> + { typedef __GLIBCXX_TYPE_INT_N_0 __type; }; +#endif +#if defined(__GLIBCXX_TYPE_INT_N_1) + template<> + struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_1> + { typedef __GLIBCXX_TYPE_INT_N_1 __type; }; +#endif +#if defined(__GLIBCXX_TYPE_INT_N_2) + template<> + struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_2> + { typedef __GLIBCXX_TYPE_INT_N_2 __type; }; +#endif +#if defined(__GLIBCXX_TYPE_INT_N_3) template<> - struct __make_signed<unsigned __int128> - { typedef __int128 __type; }; + struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_3> + { typedef __GLIBCXX_TYPE_INT_N_3 __type; }; #endif // Select between integral and enum: not possible to be both. diff --git a/libstdc++-v3/src/c++11/limits.cc b/libstdc++-v3/src/c++11/limits.cc index 73335e7dc2b..5cb2b0edf0f 100644 --- a/libstdc++-v3/src/c++11/limits.cc +++ b/libstdc++-v3/src/c++11/limits.cc @@ -388,54 +388,66 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION const bool numeric_limits<unsigned long long>::tinyness_before; const float_round_style numeric_limits<unsigned long long>::round_style; -#if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_INT128) - const bool numeric_limits<__int128>::is_specialized; - const int numeric_limits<__int128>::digits; - const int numeric_limits<__int128>::digits10; - const int numeric_limits<__int128>::max_digits10; - const bool numeric_limits<__int128>::is_signed; - const bool numeric_limits<__int128>::is_integer; - const bool numeric_limits<__int128>::is_exact; - const int numeric_limits<__int128>::radix; - const int numeric_limits<__int128>::min_exponent; - const int numeric_limits<__int128>::min_exponent10; - const int numeric_limits<__int128>::max_exponent; - const int numeric_limits<__int128>::max_exponent10; - const bool numeric_limits<__int128>::has_infinity; - const bool numeric_limits<__int128>::has_quiet_NaN; - const bool numeric_limits<__int128>::has_signaling_NaN; - const float_denorm_style numeric_limits<__int128>::has_denorm; - const bool numeric_limits<__int128>::has_denorm_loss; - const bool numeric_limits<__int128>::is_iec559; - const bool numeric_limits<__int128>::is_bounded; - const bool numeric_limits<__int128>::is_modulo; - const bool numeric_limits<__int128>::traps; - const bool numeric_limits<__int128>::tinyness_before; - const float_round_style numeric_limits<__int128>::round_style; - - const bool numeric_limits<unsigned __int128>::is_specialized; - const int numeric_limits<unsigned __int128>::digits; - const int numeric_limits<unsigned __int128>::digits10; - const int numeric_limits<unsigned __int128>::max_digits10; - const bool numeric_limits<unsigned __int128>::is_signed; - const bool numeric_limits<unsigned __int128>::is_integer; - const bool numeric_limits<unsigned __int128>::is_exact; - const int numeric_limits<unsigned __int128>::radix; - const int numeric_limits<unsigned __int128>::min_exponent; - const int numeric_limits<unsigned __int128>::min_exponent10; - const int numeric_limits<unsigned __int128>::max_exponent; - const int numeric_limits<unsigned __int128>::max_exponent10; - const bool numeric_limits<unsigned __int128>::has_infinity; - const bool numeric_limits<unsigned __int128>::has_quiet_NaN; - const bool numeric_limits<unsigned __int128>::has_signaling_NaN; - const float_denorm_style numeric_limits<unsigned __int128>::has_denorm; - const bool numeric_limits<unsigned __int128>::has_denorm_loss; - const bool numeric_limits<unsigned __int128>::is_iec559; - const bool numeric_limits<unsigned __int128>::is_bounded; - const bool numeric_limits<unsigned __int128>::is_modulo; - const bool numeric_limits<unsigned __int128>::traps; - const bool numeric_limits<unsigned __int128>::tinyness_before; - const float_round_style numeric_limits<unsigned __int128>::round_style; +#define INT_N(__INT_N_TYPE) \ + const bool numeric_limits<__INT_N_TYPE>::is_specialized; \ + const int numeric_limits<__INT_N_TYPE>::digits; \ + const int numeric_limits<__INT_N_TYPE>::digits10; \ + const int numeric_limits<__INT_N_TYPE>::max_digits10; \ + const bool numeric_limits<__INT_N_TYPE>::is_signed; \ + const bool numeric_limits<__INT_N_TYPE>::is_integer; \ + const bool numeric_limits<__INT_N_TYPE>::is_exact; \ + const int numeric_limits<__INT_N_TYPE>::radix; \ + const int numeric_limits<__INT_N_TYPE>::min_exponent; \ + const int numeric_limits<__INT_N_TYPE>::min_exponent10; \ + const int numeric_limits<__INT_N_TYPE>::max_exponent; \ + const int numeric_limits<__INT_N_TYPE>::max_exponent10; \ + const bool numeric_limits<__INT_N_TYPE>::has_infinity; \ + const bool numeric_limits<__INT_N_TYPE>::has_quiet_NaN; \ + const bool numeric_limits<__INT_N_TYPE>::has_signaling_NaN; \ + const float_denorm_style numeric_limits<__INT_N_TYPE>::has_denorm; \ + const bool numeric_limits<__INT_N_TYPE>::has_denorm_loss; \ + const bool numeric_limits<__INT_N_TYPE>::is_iec559; \ + const bool numeric_limits<__INT_N_TYPE>::is_bounded; \ + const bool numeric_limits<__INT_N_TYPE>::is_modulo; \ + const bool numeric_limits<__INT_N_TYPE>::traps; \ + const bool numeric_limits<__INT_N_TYPE>::tinyness_before; \ + const float_round_style numeric_limits<__INT_N_TYPE>::round_style; \ + \ + const bool numeric_limits<unsigned __INT_N_TYPE>::is_specialized; \ + const int numeric_limits<unsigned __INT_N_TYPE>::digits; \ + const int numeric_limits<unsigned __INT_N_TYPE>::digits10; \ + const int numeric_limits<unsigned __INT_N_TYPE>::max_digits10; \ + const bool numeric_limits<unsigned __INT_N_TYPE>::is_signed; \ + const bool numeric_limits<unsigned __INT_N_TYPE>::is_integer; \ + const bool numeric_limits<unsigned __INT_N_TYPE>::is_exact; \ + const int numeric_limits<unsigned __INT_N_TYPE>::radix; \ + const int numeric_limits<unsigned __INT_N_TYPE>::min_exponent; \ + const int numeric_limits<unsigned __INT_N_TYPE>::min_exponent10; \ + const int numeric_limits<unsigned __INT_N_TYPE>::max_exponent; \ + const int numeric_limits<unsigned __INT_N_TYPE>::max_exponent10; \ + const bool numeric_limits<unsigned __INT_N_TYPE>::has_infinity; \ + const bool numeric_limits<unsigned __INT_N_TYPE>::has_quiet_NaN; \ + const bool numeric_limits<unsigned __INT_N_TYPE>::has_signaling_NaN; \ + const float_denorm_style numeric_limits<unsigned __INT_N_TYPE>::has_denorm; \ + const bool numeric_limits<unsigned __INT_N_TYPE>::has_denorm_loss; \ + const bool numeric_limits<unsigned __INT_N_TYPE>::is_iec559; \ + const bool numeric_limits<unsigned __INT_N_TYPE>::is_bounded; \ + const bool numeric_limits<unsigned __INT_N_TYPE>::is_modulo; \ + const bool numeric_limits<unsigned __INT_N_TYPE>::traps; \ + const bool numeric_limits<unsigned __INT_N_TYPE>::tinyness_before; \ + const float_round_style numeric_limits<unsigned __INT_N_TYPE>::round_style; + +#ifdef __GLIBCXX_TYPE_INT_N_0 + INT_N (__GLIBCXX_TYPE_INT_N_0) +#endif +#ifdef __GLIBCXX_TYPE_INT_N_1 + INT_N (__GLIBCXX_TYPE_INT_N_1) +#endif +#ifdef __GLIBCXX_TYPE_INT_N_2 + INT_N (__GLIBCXX_TYPE_INT_N_2) +#endif +#ifdef __GLIBCXX_TYPE_INT_N_3 + INT_N (__GLIBCXX_TYPE_INT_N_3) #endif // float |