From: Jonathan Wakely <jwak...@redhat.com> The char16_t and char32_t types are automatically defined by the compiler and do not depend on support in <stdint.h>. The char_traits specializations depend on uint_leastNN_t but can be made to work anyway by using the predefined macros, or as a last resort make_unsigned.
* include/bits/basic_string.h [!_GLIBCXX_USE_C99_STDINT_TR1] (hash<u16string>, hash<u32string>): Remove dependency on _GLIBCXX_USE_C99_STDINT_TR1. * include/bits/char_traits.h [!_GLIBCXX_USE_C99_STDINT_TR1] (char_traits<char16_t>, char_traits<char32_t>): Remove dependency on _GLIBCXX_USE_C99_STDINT_TR1. Use __UINT_LEAST16_TYPE__ and __UINT_LEAST32_TYPE__ or make_unsigned when <stdint.h> is not usable. * include/bits/codecvt.h [!_GLIBCXX_USE_C99_STDINT_TR1] (codecvt<char16_t, char, mbstate_t>) (codecvt<char32_t, char, mbstate_t>) (codecvt_byname<char16_t, char, mbstate_t>) (codecvt_byname<char32_t, char, mbstate_t>): Remove dependency on _GLIBCXX_USE_C99_STDINT_TR1. * include/bits/locale_facets.h [!_GLIBCXX_USE_C99_STDINT_TR1] (_GLIBCXX_NUM_UNICODE_FACETS): Likewise. * include/bits/stringfwd.h [!_GLIBCXX_USE_C99_STDINT_TR1] (char_traits<char16_t>, char_traits<char32_t>) (basic_string<char16_t>, basic_string<char32_t>): Remove dependency on _GLIBCXX_USE_C99_STDINT_TR1. * include/experimental/string_view [!_GLIBCXX_USE_C99_STDINT_TR1] (u16string_view, u32string_view, hash<u16string_view>) (hash<u32string_view>, operator""sv(const char16_t, size_t)) (operator""sv(const char32_t, size_t)): Likewise. * include/ext/vstring.h [!_GLIBCXX_USE_C99_STDINT_TR1] (hash<__u16vstring>, hash<__u32vstring>): Likewise. * include/ext/vstring_fwd.h [!_GLIBCXX_USE_C99_STDINT_TR1] (__u16vstring, __u16sso_string, __u16rc_string, __u32vstring) (__u32sso_string, __u32rc_string): Likewise. * include/std/codecvt [!_GLIBCXX_USE_C99_STDINT_TR1] (codecvt_mode) (codecvt_utf8, codecvt_utf16, codecvt_utf8_utf16): Likewise. * include/std/string_view [!_GLIBCXX_USE_C99_STDINT_TR1] (u16string_view, u32string_view, hash<u16string_view>) (hash<u32string_view>, operator""sv(const char16_t, size_t)) (operator""sv(const char32_t, size_t)): Likewise. * src/c++11/codecvt.cc: Likewise. * src/c++98/locale_init.cc: Likewise. * src/c++98/localename.cc: Likewise. diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index a3665ee8b6a..10b1496af81 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,43 @@ 2018-07-26 Jonathan Wakely <jwak...@redhat.com> + * include/bits/basic_string.h [!_GLIBCXX_USE_C99_STDINT_TR1] + (hash<u16string>, hash<u32string>): Remove dependency on + _GLIBCXX_USE_C99_STDINT_TR1. + * include/bits/char_traits.h [!_GLIBCXX_USE_C99_STDINT_TR1] + (char_traits<char16_t>, char_traits<char32_t>): Remove dependency on + _GLIBCXX_USE_C99_STDINT_TR1. Use __UINT_LEAST16_TYPE__ and + __UINT_LEAST32_TYPE__ or make_unsigned when <stdint.h> is not usable. + * include/bits/codecvt.h [!_GLIBCXX_USE_C99_STDINT_TR1] + (codecvt<char16_t, char, mbstate_t>) + (codecvt<char32_t, char, mbstate_t>) + (codecvt_byname<char16_t, char, mbstate_t>) + (codecvt_byname<char32_t, char, mbstate_t>): Remove dependency + on _GLIBCXX_USE_C99_STDINT_TR1. + * include/bits/locale_facets.h [!_GLIBCXX_USE_C99_STDINT_TR1] + (_GLIBCXX_NUM_UNICODE_FACETS): Likewise. + * include/bits/stringfwd.h [!_GLIBCXX_USE_C99_STDINT_TR1] + (char_traits<char16_t>, char_traits<char32_t>) + (basic_string<char16_t>, basic_string<char32_t>): Remove dependency + on _GLIBCXX_USE_C99_STDINT_TR1. + * include/experimental/string_view [!_GLIBCXX_USE_C99_STDINT_TR1] + (u16string_view, u32string_view, hash<u16string_view>) + (hash<u32string_view>, operator""sv(const char16_t, size_t)) + (operator""sv(const char32_t, size_t)): Likewise. + * include/ext/vstring.h [!_GLIBCXX_USE_C99_STDINT_TR1] + (hash<__u16vstring>, hash<__u32vstring>): Likewise. + * include/ext/vstring_fwd.h [!_GLIBCXX_USE_C99_STDINT_TR1] + (__u16vstring, __u16sso_string, __u16rc_string, __u32vstring) + (__u32sso_string, __u32rc_string): Likewise. + * include/std/codecvt [!_GLIBCXX_USE_C99_STDINT_TR1] (codecvt_mode) + (codecvt_utf8, codecvt_utf16, codecvt_utf8_utf16): Likewise. + * include/std/string_view [!_GLIBCXX_USE_C99_STDINT_TR1] + (u16string_view, u32string_view, hash<u16string_view>) + (hash<u32string_view>, operator""sv(const char16_t, size_t)) + (operator""sv(const char32_t, size_t)): Likewise. + * src/c++11/codecvt.cc: Likewise. + * src/c++98/locale_init.cc: Likewise. + * src/c++98/localename.cc: Likewise. + * include/bits/atomic_futex.h [!_GLIBCXX_USE_C99_STDINT_TR1] (__atomic_futex_unsigned_base): Remove dependency on _GLIBCXX_USE_C99_STDINT_TR1 macro. diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h index 2d1b9dc6c29..c9463989ddc 100644 --- a/libstdc++-v3/include/bits/basic_string.h +++ b/libstdc++-v3/include/bits/basic_string.h @@ -6662,7 +6662,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #endif #endif /* _GLIBCXX_COMPATIBILITY_CXX0X */ -#ifdef _GLIBCXX_USE_C99_STDINT_TR1 /// std::hash specialization for u16string. template<> struct hash<u16string> @@ -6692,7 +6691,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template<> struct __is_fast_hash<hash<u32string>> : std::false_type { }; -#endif #if __cplusplus > 201103L @@ -6716,7 +6714,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return basic_string<wchar_t>{__str, __len}; } #endif -#ifdef _GLIBCXX_USE_C99_STDINT_TR1 _GLIBCXX_DEFAULT_ABI_TAG inline basic_string<char16_t> operator""s(const char16_t* __str, size_t __len) @@ -6726,7 +6723,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION inline basic_string<char32_t> operator""s(const char32_t* __str, size_t __len) { return basic_string<char32_t>{__str, __len}; } -#endif #pragma GCC diagnostic pop } // inline namespace string_literals diff --git a/libstdc++-v3/include/bits/char_traits.h b/libstdc++-v3/include/bits/char_traits.h index 7cc7c74e8fe..63e810715f8 100644 --- a/libstdc++-v3/include/bits/char_traits.h +++ b/libstdc++-v3/include/bits/char_traits.h @@ -41,7 +41,7 @@ #include <cwchar> // For WEOF, wmemmove, wmemset, etc. #ifndef _GLIBCXX_ALWAYS_INLINE -#define _GLIBCXX_ALWAYS_INLINE inline __attribute__((__always_inline__)) +# define _GLIBCXX_ALWAYS_INLINE inline __attribute__((__always_inline__)) #endif namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) @@ -495,8 +495,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _GLIBCXX_END_NAMESPACE_VERSION } // namespace -#if ((__cplusplus >= 201103L) \ - && defined(_GLIBCXX_USE_C99_STDINT_TR1)) +#if __cplusplus >= 201103L #include <cstdint> @@ -508,7 +507,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct char_traits<char16_t> { typedef char16_t char_type; +#ifdef _GLIBCXX_USE_C99_STDINT_TR1 typedef uint_least16_t int_type; +#elif defined __UINT_LEAST16_TYPE__ + typedef __UINT_LEAST16_TYPE__ int_type; +#else + typedef make_unsigned<char16_t>::type int_type; +#endif typedef streamoff off_type; typedef u16streampos pos_type; typedef mbstate_t state_type; @@ -605,7 +610,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct char_traits<char32_t> { typedef char32_t char_type; +#ifdef _GLIBCXX_USE_C99_STDINT_TR1 typedef uint_least32_t int_type; +#elif defined __UINT_LEAST32_TYPE__ + typedef __UINT_LEAST32_TYPE__ int_type; +#else + typedef make_unsigned<char32_t>::type int_type; +#endif typedef streamoff off_type; typedef u32streampos pos_type; typedef mbstate_t state_type; @@ -701,6 +712,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _GLIBCXX_END_NAMESPACE_VERSION } // namespace -#endif +#endif // C++11 #endif // _CHAR_TRAITS_H diff --git a/libstdc++-v3/include/bits/codecvt.h b/libstdc++-v3/include/bits/codecvt.h index b61df0a7e22..bafa28c3a00 100644 --- a/libstdc++-v3/include/bits/codecvt.h +++ b/libstdc++-v3/include/bits/codecvt.h @@ -459,7 +459,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #endif //_GLIBCXX_USE_WCHAR_T #if __cplusplus >= 201103L -#ifdef _GLIBCXX_USE_C99_STDINT_TR1 /** @brief Class codecvt<char16_t, char, mbstate_t> specialization. * * Converts between UTF-16 and UTF-8. @@ -574,7 +573,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION do_max_length() const throw(); }; -#endif // _GLIBCXX_USE_C99_STDINT_TR1 #endif // C++11 /// class codecvt_byname [22.2.1.6]. @@ -605,7 +603,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ~codecvt_byname() { } }; -#if __cplusplus >= 201103L && defined(_GLIBCXX_USE_C99_STDINT_TR1) +#if __cplusplus >= 201103L template<> class codecvt_byname<char16_t, char, mbstate_t> : public codecvt<char16_t, char, mbstate_t> @@ -641,7 +639,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION virtual ~codecvt_byname() { } }; -#endif +#endif // C++11 // Inhibit implicit instantiations for required instantiations, // which are defined via explicit instantiations elsewhere. @@ -668,7 +666,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION has_facet<codecvt<wchar_t, char, mbstate_t> >(const locale&); #endif -#if __cplusplus >= 201103L && defined(_GLIBCXX_USE_C99_STDINT_TR1) +#if __cplusplus >= 201103L extern template class codecvt_byname<char16_t, char, mbstate_t>; extern template class codecvt_byname<char32_t, char, mbstate_t>; #endif diff --git a/libstdc++-v3/include/bits/locale_facets.h b/libstdc++-v3/include/bits/locale_facets.h index 7bce42232bb..f6e0283fec9 100644 --- a/libstdc++-v3/include/bits/locale_facets.h +++ b/libstdc++-v3/include/bits/locale_facets.h @@ -59,11 +59,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION # define _GLIBCXX_NUM_FACETS 14 # define _GLIBCXX_NUM_CXX11_FACETS 8 #endif -#ifdef _GLIBCXX_USE_C99_STDINT_TR1 -# define _GLIBCXX_NUM_UNICODE_FACETS 2 -#else -# define _GLIBCXX_NUM_UNICODE_FACETS 0 -#endif +#define _GLIBCXX_NUM_UNICODE_FACETS 2 // Convert string to numeric value of type _Tp and store results. // NB: This is specialized for all required types, there is no diff --git a/libstdc++-v3/include/bits/stringfwd.h b/libstdc++-v3/include/bits/stringfwd.h index cf39dbfe048..15eb7183633 100644 --- a/libstdc++-v3/include/bits/stringfwd.h +++ b/libstdc++-v3/include/bits/stringfwd.h @@ -58,8 +58,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template<> struct char_traits<wchar_t>; #endif -#if ((__cplusplus >= 201103L) \ - && defined(_GLIBCXX_USE_C99_STDINT_TR1)) +#if __cplusplus >= 201103L template<> struct char_traits<char16_t>; template<> struct char_traits<char32_t>; #endif @@ -78,8 +77,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 typedef basic_string<wchar_t> wstring; #endif -#if ((__cplusplus >= 201103L) \ - && defined(_GLIBCXX_USE_C99_STDINT_TR1)) +#if __cplusplus >= 201103L /// A string of @c char16_t typedef basic_string<char16_t> u16string; diff --git a/libstdc++-v3/include/experimental/string_view b/libstdc++-v3/include/experimental/string_view index e42d5acde78..b3bc1a9fb4f 100644 --- a/libstdc++-v3/include/experimental/string_view +++ b/libstdc++-v3/include/experimental/string_view @@ -566,10 +566,8 @@ inline namespace fundamentals_v1 #ifdef _GLIBCXX_USE_WCHAR_T using wstring_view = basic_string_view<wchar_t>; #endif -#ifdef _GLIBCXX_USE_C99_STDINT_TR1 using u16string_view = basic_string_view<char16_t>; using u32string_view = basic_string_view<char32_t>; -#endif } // namespace fundamentals_v1 } // namespace experimental @@ -607,7 +605,6 @@ inline namespace fundamentals_v1 { }; #endif -#ifdef _GLIBCXX_USE_C99_STDINT_TR1 template<> struct hash<experimental::u16string_view> : public __hash_base<size_t, experimental::u16string_view> @@ -635,7 +632,6 @@ inline namespace fundamentals_v1 template<> struct __is_fast_hash<hash<experimental::u32string_view>> : std::false_type { }; -#endif namespace experimental { @@ -656,7 +652,6 @@ namespace experimental { return basic_string_view<wchar_t>{__str, __len}; } #endif -#ifdef _GLIBCXX_USE_C99_STDINT_TR1 inline constexpr basic_string_view<char16_t> operator""sv(const char16_t* __str, size_t __len) noexcept { return basic_string_view<char16_t>{__str, __len}; } @@ -664,7 +659,6 @@ namespace experimental inline constexpr basic_string_view<char32_t> operator""sv(const char32_t* __str, size_t __len) noexcept { return basic_string_view<char32_t>{__str, __len}; } -#endif #pragma GCC diagnostic pop } // namespace string_literals } // namespace literals diff --git a/libstdc++-v3/include/ext/vstring.h b/libstdc++-v3/include/ext/vstring.h index 605311e9a28..246684d555f 100644 --- a/libstdc++-v3/include/ext/vstring.h +++ b/libstdc++-v3/include/ext/vstring.h @@ -2933,7 +2933,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION }; #endif -#ifdef _GLIBCXX_USE_C99_STDINT_TR1 /// std::hash specialization for __u16vstring. template<> struct hash<__gnu_cxx::__u16vstring> @@ -2955,7 +2954,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return std::_Hash_impl::hash(__s.data(), __s.length() * sizeof(char32_t)); } }; -#endif _GLIBCXX_END_NAMESPACE_VERSION } // namespace diff --git a/libstdc++-v3/include/ext/vstring_fwd.h b/libstdc++-v3/include/ext/vstring_fwd.h index 7ca79981e3b..f2e6b4bdfa7 100644 --- a/libstdc++-v3/include/ext/vstring_fwd.h +++ b/libstdc++-v3/include/ext/vstring_fwd.h @@ -66,9 +66,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION std::allocator<wchar_t>, __rc_string_base> __wrc_string; #endif -#if ((__cplusplus >= 201103L) \ - && defined(_GLIBCXX_USE_C99_STDINT_TR1)) - +#if __cplusplus >= 201103L typedef __versa_string<char16_t> __u16vstring; typedef __u16vstring __u16sso_string; typedef @@ -80,8 +78,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION typedef __versa_string<char32_t, std::char_traits<char32_t>, std::allocator<char32_t>, __rc_string_base> __u32rc_string; - -#endif +#endif // C++11 _GLIBCXX_END_NAMESPACE_VERSION } // namespace diff --git a/libstdc++-v3/include/std/codecvt b/libstdc++-v3/include/std/codecvt index 2a1bcdb6672..f765c674d78 100644 --- a/libstdc++-v3/include/std/codecvt +++ b/libstdc++-v3/include/std/codecvt @@ -40,8 +40,6 @@ #include <bits/locale_classes.h> #include <bits/codecvt.h> -#ifdef _GLIBCXX_USE_C99_STDINT_TR1 - namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION @@ -174,8 +172,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _GLIBCXX_END_NAMESPACE_VERSION } // namespace -#endif // _GLIBCXX_USE_C99_STDINT_TR1 - -#endif +#endif // C++11 #endif /* _GLIBCXX_CODECVT */ diff --git a/libstdc++-v3/include/std/string_view b/libstdc++-v3/include/std/string_view index f84664ca286..9e0f6a723e4 100644 --- a/libstdc++-v3/include/std/string_view +++ b/libstdc++-v3/include/std/string_view @@ -555,10 +555,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #ifdef _GLIBCXX_USE_WCHAR_T using wstring_view = basic_string_view<wchar_t>; #endif -#ifdef _GLIBCXX_USE_C99_STDINT_TR1 + using u16string_view = basic_string_view<char16_t>; using u32string_view = basic_string_view<char32_t>; -#endif // [string.view.hash], hash support: @@ -594,7 +593,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { }; #endif -#ifdef _GLIBCXX_USE_C99_STDINT_TR1 template<> struct hash<u16string_view> : public __hash_base<size_t, u16string_view> @@ -622,7 +620,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template<> struct __is_fast_hash<hash<u32string_view>> : std::false_type { }; -#endif inline namespace literals { @@ -640,7 +637,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return basic_string_view<wchar_t>{__str, __len}; } #endif -#ifdef _GLIBCXX_USE_C99_STDINT_TR1 inline constexpr basic_string_view<char16_t> operator""sv(const char16_t* __str, size_t __len) noexcept { return basic_string_view<char16_t>{__str, __len}; } @@ -648,7 +644,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION inline constexpr basic_string_view<char32_t> operator""sv(const char32_t* __str, size_t __len) noexcept { return basic_string_view<char32_t>{__str, __len}; } -#endif + #pragma GCC diagnostic pop } // namespace string_literals } // namespace literals diff --git a/libstdc++-v3/src/c++11/codecvt.cc b/libstdc++-v3/src/c++11/codecvt.cc index 3a1a825070c..503f2fe1ff3 100644 --- a/libstdc++-v3/src/c++11/codecvt.cc +++ b/libstdc++-v3/src/c++11/codecvt.cc @@ -26,7 +26,6 @@ #include <cstring> // std::memcpy, std::memcmp #include <bits/stl_algobase.h> // std::min -#ifdef _GLIBCXX_USE_C99_STDINT_TR1 namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION @@ -1639,4 +1638,3 @@ template class codecvt_byname<char32_t, char, mbstate_t>; _GLIBCXX_END_NAMESPACE_VERSION } -#endif // _GLIBCXX_USE_C99_STDINT_TR1 diff --git a/libstdc++-v3/src/c++98/locale_init.cc b/libstdc++-v3/src/c++98/locale_init.cc index fb3d8ab972a..5651c04b9ed 100644 --- a/libstdc++-v3/src/c++98/locale_init.cc +++ b/libstdc++-v3/src/c++98/locale_init.cc @@ -201,7 +201,6 @@ namespace fake_messages_w messages_w; #endif -#ifdef _GLIBCXX_USE_C99_STDINT_TR1 typedef char fake_codecvt_c16[sizeof(codecvt<char16_t, char, mbstate_t>)] __attribute__ ((aligned(__alignof__(codecvt<char16_t, char, mbstate_t>)))); fake_codecvt_c16 codecvt_c16; @@ -209,7 +208,6 @@ namespace typedef char fake_codecvt_c32[sizeof(codecvt<char32_t, char, mbstate_t>)] __attribute__ ((aligned(__alignof__(codecvt<char32_t, char, mbstate_t>)))); fake_codecvt_c32 codecvt_c32; -#endif // Storage for "C" locale caches. typedef char fake_num_cache_c[sizeof(std::__numpunct_cache<char>)] @@ -329,7 +327,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION &std::ctype<wchar_t>::id, &codecvt<wchar_t, char, mbstate_t>::id, #endif -#ifdef _GLIBCXX_USE_C99_STDINT_TR1 +#if _GLIBCXX_NUM_UNICODE_FACETS != 0 &codecvt<char16_t, char, mbstate_t>::id, &codecvt<char32_t, char, mbstate_t>::id, #endif @@ -536,7 +534,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _M_init_facet(new (&messages_w) std::messages<wchar_t>(1)); #endif -#ifdef _GLIBCXX_USE_C99_STDINT_TR1 +#ifdef _GLIBCXX_NUM_UNICODE_FACETS != 0 _M_init_facet(new (&codecvt_c16) codecvt<char16_t, char, mbstate_t>(1)); _M_init_facet(new (&codecvt_c32) codecvt<char32_t, char, mbstate_t>(1)); #endif diff --git a/libstdc++-v3/src/c++98/localename.cc b/libstdc++-v3/src/c++98/localename.cc index 7723f6afbe8..afb43e5cea9 100644 --- a/libstdc++-v3/src/c++98/localename.cc +++ b/libstdc++-v3/src/c++98/localename.cc @@ -269,7 +269,7 @@ const int num_facets = _GLIBCXX_NUM_FACETS + _GLIBCXX_NUM_UNICODE_FACETS _M_init_facet(new std::messages<wchar_t>(__cloc, __s)); #endif -#ifdef _GLIBCXX_USE_C99_STDINT_TR1 +#if _GLIBCXX_NUM_UNICODE_FACETS != 0 _M_init_facet(new codecvt<char16_t, char, mbstate_t>); _M_init_facet(new codecvt<char32_t, char, mbstate_t>); #endif -- 2.14.4