diff options
author | Tom Honermann <tom@honermann.net> | 2019-02-19 02:54:42 +0000 |
---|---|---|
committer | Jonathan Wakely <redi@gcc.gnu.org> | 2019-02-19 02:54:42 +0000 |
commit | c124af936b6b225eb548ccdd7f01400511d784dc (patch) | |
tree | 5d8d03d00df438331657aa27496f27bc32041eaf /libstdc++-v3/src | |
parent | e8b3c1bc3ba22dcf59b9c743f11d4cb2bc5d7792 (diff) | |
download | gcc-c124af936b6b225eb548ccdd7f01400511d784dc.zip gcc-c124af936b6b225eb548ccdd7f01400511d784dc.tar.gz gcc-c124af936b6b225eb548ccdd7f01400511d784dc.tar.bz2 |
P0482R5 char8_t: Standard library support
gcc/cp:
2019-02-19 Tom Honermann <tom@honermann.net>
* name-lookup.c (get_std_name_hint): Added u8string as a name hint.
libstdc++:
2019-02-19 Tom Honermann <tom@honermann.net>
P0482R5 char8_t: Standard library support
* config/abi/pre/gnu-versioned-namespace.ver (CXXABI_2.0): Add
typeinfo symbols for char8_t.
* config/abi/pre/gnu.ver: Add CXXABI_1.3.12.
(GLIBCXX_3.4.26): Add symbols for specializations of
numeric_limits and codecvt that involve char8_t.
(CXXABI_1.3.12): Add typeinfo symbols for char8_t.
* include/bits/atomic_base.h: Add atomic_char8_t.
* include/bits/basic_string.h: Add std::hash<u8string> and
operator""s(const char8_t*, size_t).
* include/bits/c++config: Define _GLIBCXX_USE_CHAR8_T and
__cpp_lib_char8_t.
* include/bits/char_traits.h: Add char_traits<char8_t>.
* include/bits/codecvt.h: Add
codecvt<char16_t, char8_t, mbstate_t>,
codecvt<char32_t, char8_t, mbstate_t>,
codecvt_byname<char16_t, char8_t, mbstate_t>, and
codecvt_byname<char32_t, char8_t, mbstate_t>.
* include/bits/cpp_type_traits.h: Add __is_integer<char8_t> to
recognize char8_t as an integral type.
* include/bits/fs_path.h: (path::__is_encoded_char): Recognize
char8_t.
(path::u8string): Return std::u8string when char8_t support is
enabled.
(path::generic_u8string): Likewise.
(path::_S_convert): Handle conversion from char8_t input.
(path::_S_str_convert): Likewise.
* include/bits/functional_hash.h: Add hash<char8_t>.
* include/bits/locale_conv.h (__str_codecvt_out): Add overloads for
char8_t.
* include/bits/locale_facets.h (_GLIBCXX_NUM_UNICODE_FACETS): Bump
for new char8_t specializations.
* include/bits/localefwd.h: Add missing declarations of
codecvt<char16_t, char, mbstate_t> and
codecvt<char32_t, char, mbstate_t>. Add char8_t declarations
codecvt<char16_t, char8_t, mbstate_t> and
codecvt<char32_t, char8_t, mbstate_t>.
* include/bits/postypes.h: Add u8streampos
* include/bits/stringfwd.h: Add declarations of
char_traits<char8_t> and u8string.
* include/c_global/cstddef: Add __byte_operand<char8_t>.
* include/experimental/bits/fs_path.h (path::__is_encoded_char):
Recognize char8_t.
(path::u8string): Return std::u8string when char8_t support is
enabled.
(path::generic_u8string): Likewise.
(path::_S_convert): Handle conversion from char8_t input.
(path::_S_str_convert): Likewise.
* include/experimental/string: Add u8string.
* include/experimental/string_view: Add u8string_view,
hash<experimental::u8string_view>, and
operator""sv(const char8_t*, size_t).
* include/std/atomic: Add atomic<char8_t> and atomic_char8_t.
* include/std/charconv (__is_int_to_chars_type): Recognize char8_t
as a character type.
* include/std/limits: Add numeric_limits<char8_t>.
* include/std/string_view: Add u8string_view,
hash<experimental::u8string_view>, and
operator""sv(const char8_t*, size_t).
* include/std/type_traits: Add __is_integral_helper<char8_t>,
__make_unsigned<char8_t>, and __make_signed<char8_t>.
* libsupc++/atomic_lockfree_defines.h: Define
ATOMIC_CHAR8_T_LOCK_FREE.
* src/c++11/Makefile.am: Compile with -fchar8_t when compiling
codecvt.cc and limits.cc so that char8_t specializations of
numeric_limits and codecvt and emitted.
* src/c++11/Makefile.in: Likewise.
* src/c++11/codecvt.cc: Define members of
codecvt<char16_t, char8_t, mbstate_t>,
codecvt<char32_t, char8_t, mbstate_t>,
codecvt_byname<char16_t, char8_t, mbstate_t>, and
codecvt_byname<char32_t, char8_t, mbstate_t>.
* src/c++11/limits.cc: Define members of
numeric_limits<char8_t>.
* src/c++98/Makefile.am: Compile with -fchar8_t when compiling
locale_init.cc and localename.cc.
* src/c++98/Makefile.in: Likewise.
* src/c++98/locale_init.cc: Add initialization for the
codecvt<char16_t, char8_t, mbstate_t> and
codecvt<char32_t, char8_t, mbstate_t> facets.
* src/c++98/localename.cc: Likewise.
* testsuite/util/testsuite_abi.cc: Validate ABI bump.
From-SVN: r269004
Diffstat (limited to 'libstdc++-v3/src')
-rw-r--r-- | libstdc++-v3/src/c++11/Makefile.am | 10 | ||||
-rw-r--r-- | libstdc++-v3/src/c++11/Makefile.in | 10 | ||||
-rw-r--r-- | libstdc++-v3/src/c++11/codecvt.cc | 210 | ||||
-rw-r--r-- | libstdc++-v3/src/c++11/limits.cc | 27 | ||||
-rw-r--r-- | libstdc++-v3/src/c++98/Makefile.am | 8 | ||||
-rw-r--r-- | libstdc++-v3/src/c++98/Makefile.in | 8 | ||||
-rw-r--r-- | libstdc++-v3/src/c++98/locale_init.cc | 20 | ||||
-rw-r--r-- | libstdc++-v3/src/c++98/localename.cc | 6 |
8 files changed, 270 insertions, 29 deletions
diff --git a/libstdc++-v3/src/c++11/Makefile.am b/libstdc++-v3/src/c++11/Makefile.am index 46d31b9..9fc1866 100644 --- a/libstdc++-v3/src/c++11/Makefile.am +++ b/libstdc++-v3/src/c++11/Makefile.am @@ -126,6 +126,16 @@ hashtable_c++0x.lo: hashtable_c++0x.cc hashtable_c++0x.o: hashtable_c++0x.cc $(CXXCOMPILE) -fimplicit-templates -c $< +# Use special rules for source files that require -fchar8_t. +codecvt.lo: codecvt.cc + $(LTCXXCOMPILE) -fchar8_t -c $< +codecvt.o: codecvt.cc + $(CXXCOMPILE) -fchar8_t -c $< +limits.lo: limits.cc + $(LTCXXCOMPILE) -fchar8_t -c $< +limits.o: limits.cc + $(CXXCOMPILE) -fchar8_t -c $< + if ENABLE_DUAL_ABI # Rewrite the type info for __ios_failure. rewrite_ios_failure_typeinfo = sed -e '/^_*_ZTISt13__ios_failure:/,/_ZTVN10__cxxabiv120__si_class_type_infoE/s/_ZTVN10__cxxabiv120__si_class_type_infoE/_ZTVSt19__iosfail_type_info/' diff --git a/libstdc++-v3/src/c++11/Makefile.in b/libstdc++-v3/src/c++11/Makefile.in index 92816c8..a972915 100644 --- a/libstdc++-v3/src/c++11/Makefile.in +++ b/libstdc++-v3/src/c++11/Makefile.in @@ -834,6 +834,16 @@ hashtable_c++0x.lo: hashtable_c++0x.cc hashtable_c++0x.o: hashtable_c++0x.cc $(CXXCOMPILE) -fimplicit-templates -c $< +# Use special rules for source files that require -fchar8_t. +codecvt.lo: codecvt.cc + $(LTCXXCOMPILE) -fchar8_t -c $< +codecvt.o: codecvt.cc + $(CXXCOMPILE) -fchar8_t -c $< +limits.lo: limits.cc + $(LTCXXCOMPILE) -fchar8_t -c $< +limits.o: limits.cc + $(CXXCOMPILE) -fchar8_t -c $< + @ENABLE_DUAL_ABI_TRUE@cxx11-ios_failure-lt.s: cxx11-ios_failure.cc @ENABLE_DUAL_ABI_TRUE@ $(LTCXXCOMPILE) -S $< -o tmp-cxx11-ios_failure-lt.s @ENABLE_DUAL_ABI_TRUE@ -test -f tmp-cxx11-ios_failure-lt.o && mv -f tmp-cxx11-ios_failure-lt.o tmp-cxx11-ios_failure-lt.s diff --git a/libstdc++-v3/src/c++11/codecvt.cc b/libstdc++-v3/src/c++11/codecvt.cc index b2fa375..372aea2 100644 --- a/libstdc++-v3/src/c++11/codecvt.cc +++ b/libstdc++-v3/src/c++11/codecvt.cc @@ -193,8 +193,9 @@ namespace } // If generate_header is set in mode write out UTF-8 BOM. + template<typename C> bool - write_utf8_bom(range<char>& to, codecvt_mode mode) + write_utf8_bom(range<C>& to, codecvt_mode mode) { if (mode & generate_header) return write_bom(to, utf8_bom); @@ -218,8 +219,9 @@ namespace } // If consume_header is set in mode update from.next to after any BOM. + template<typename C> void - read_utf8_bom(range<const char>& from, codecvt_mode mode) + read_utf8_bom(range<const C>& from, codecvt_mode mode) { if (mode & consume_header) read_bom(from, utf8_bom); @@ -245,8 +247,9 @@ namespace // Read a codepoint from a UTF-8 multibyte sequence. // Updates from.next if the codepoint is not greater than maxcode. // Returns invalid_mb_sequence, incomplete_mb_character or the code point. + template<typename C> char32_t - read_utf8_code_point(range<const char>& from, unsigned long maxcode) + read_utf8_code_point(range<const C>& from, unsigned long maxcode) { const size_t avail = from.size(); if (avail == 0) @@ -315,8 +318,9 @@ namespace return invalid_mb_sequence; } + template<typename C> bool - write_utf8_code_point(range<char>& to, char32_t code_point) + write_utf8_code_point(range<C>& to, char32_t code_point) { if (code_point < 0x80) { @@ -445,8 +449,9 @@ namespace } // utf8 -> ucs4 + template<typename C> codecvt_base::result - ucs4_in(range<const char>& from, range<char32_t>& to, + ucs4_in(range<const C>& from, range<char32_t>& to, unsigned long maxcode = max_code_point, codecvt_mode mode = {}) { read_utf8_bom(from, mode); @@ -463,8 +468,9 @@ namespace } // ucs4 -> utf8 + template<typename C> codecvt_base::result - ucs4_out(range<const char32_t>& from, range<char>& to, + ucs4_out(range<const char32_t>& from, range<C>& to, unsigned long maxcode = max_code_point, codecvt_mode mode = {}) { if (!write_utf8_bom(to, mode)) @@ -522,9 +528,9 @@ namespace enum class surrogates { allowed, disallowed }; // utf8 -> utf16 (or utf8 -> ucs2 if s == surrogates::disallowed) - template<typename C> + template<typename C8, typename C16> codecvt_base::result - utf16_in(range<const char>& from, range<C>& to, + utf16_in(range<const C8>& from, range<C16>& to, unsigned long maxcode = max_code_point, codecvt_mode mode = {}, surrogates s = surrogates::allowed) { @@ -552,9 +558,9 @@ namespace } // utf16 -> utf8 (or ucs2 -> utf8 if s == surrogates::disallowed) - template<typename C> + template<typename C16, typename C8> codecvt_base::result - utf16_out(range<const C>& from, range<char>& to, + utf16_out(range<const C16>& from, range<C8>& to, unsigned long maxcode = max_code_point, codecvt_mode mode = {}, surrogates s = surrogates::allowed) { @@ -593,11 +599,12 @@ namespace } // return pos such that [begin,pos) is valid UTF-16 string no longer than max - const char* - utf16_span(const char* begin, const char* end, size_t max, + template<typename C> + const C* + utf16_span(const C* begin, const C* end, size_t max, char32_t maxcode = max_code_point, codecvt_mode mode = {}) { - range<const char> from{ begin, end }; + range<const C> from{ begin, end }; read_utf8_bom(from, mode); size_t count = 0; while (count+1 < max) @@ -615,8 +622,9 @@ namespace } // utf8 -> ucs2 + template<typename C> codecvt_base::result - ucs2_in(range<const char>& from, range<char16_t>& to, + ucs2_in(range<const C>& from, range<char16_t>& to, char32_t maxcode = max_code_point, codecvt_mode mode = {}) { // UCS-2 only supports characters in the BMP, i.e. one UTF-16 code unit: @@ -625,8 +633,9 @@ namespace } // ucs2 -> utf8 + template<typename C> codecvt_base::result - ucs2_out(range<const char16_t>& from, range<char>& to, + ucs2_out(range<const char16_t>& from, range<C>& to, char32_t maxcode = max_code_point, codecvt_mode mode = {}) { // UCS-2 only supports characters in the BMP, i.e. one UTF-16 code unit: @@ -687,11 +696,12 @@ namespace return reinterpret_cast<const char16_t*>(from.next); } - const char* - ucs2_span(const char* begin, const char* end, size_t max, + template<typename C> + const C* + ucs2_span(const C* begin, const C* end, size_t max, char32_t maxcode, codecvt_mode mode) { - range<const char> from{ begin, end }; + range<const C> from{ begin, end }; read_utf8_bom(from, mode); // UCS-2 only supports characters in the BMP, i.e. one UTF-16 code unit: maxcode = std::min(max_single_utf16_unit, maxcode); @@ -702,11 +712,12 @@ namespace } // return pos such that [begin,pos) is valid UCS-4 string no longer than max - const char* - ucs4_span(const char* begin, const char* end, size_t max, + template<typename C> + const C* + ucs4_span(const C* begin, const C* end, size_t max, char32_t maxcode = max_code_point, codecvt_mode mode = {}) { - range<const char> from{ begin, end }; + range<const C> from{ begin, end }; read_utf8_bom(from, mode); char32_t c = 0; while (max-- && c <= maxcode) @@ -875,6 +886,156 @@ codecvt<char32_t, char, mbstate_t>::do_max_length() const throw() return 4; } +#if defined(_GLIBCXX_USE_CHAR8_T) +// Define members of codecvt<char16_t, char8_t, mbstate_t> specialization. +// Converts from UTF-8 to UTF-16. + +locale::id codecvt<char16_t, char8_t, mbstate_t>::id; + +codecvt<char16_t, char8_t, mbstate_t>::~codecvt() { } + +codecvt_base::result +codecvt<char16_t, char8_t, mbstate_t>:: +do_out(state_type&, + const intern_type* __from, + const intern_type* __from_end, const intern_type*& __from_next, + extern_type* __to, extern_type* __to_end, + extern_type*& __to_next) const +{ + range<const char16_t> from{ __from, __from_end }; + range<char8_t> to{ __to, __to_end }; + auto res = utf16_out(from, to); + __from_next = from.next; + __to_next = to.next; + return res; +} + +codecvt_base::result +codecvt<char16_t, char8_t, mbstate_t>:: +do_unshift(state_type&, extern_type* __to, extern_type*, + extern_type*& __to_next) const +{ + __to_next = __to; + return noconv; // we don't use mbstate_t for the unicode facets +} + +codecvt_base::result +codecvt<char16_t, char8_t, mbstate_t>:: +do_in(state_type&, const extern_type* __from, const extern_type* __from_end, + const extern_type*& __from_next, + intern_type* __to, intern_type* __to_end, + intern_type*& __to_next) const +{ + range<const char8_t> from{ __from, __from_end }; + range<char16_t> to{ __to, __to_end }; +#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ + codecvt_mode mode = {}; +#else + codecvt_mode mode = little_endian; +#endif + auto res = utf16_in(from, to, max_code_point, mode); + __from_next = from.next; + __to_next = to.next; + return res; +} + +int +codecvt<char16_t, char8_t, mbstate_t>::do_encoding() const throw() +{ return 0; } // UTF-8 is not a fixed-width encoding + +bool +codecvt<char16_t, char8_t, mbstate_t>::do_always_noconv() const throw() +{ return false; } + +int +codecvt<char16_t, char8_t, mbstate_t>:: +do_length(state_type&, const extern_type* __from, + const extern_type* __end, size_t __max) const +{ + __end = utf16_span(__from, __end, __max); + return __end - __from; +} + +int +codecvt<char16_t, char8_t, mbstate_t>::do_max_length() const throw() +{ + // A single character (one or two UTF-16 code units) requires + // up to four UTF-8 code units. + return 4; +} + +// Define members of codecvt<char32_t, char8_t, mbstate_t> specialization. +// Converts from UTF-8 to UTF-32 (aka UCS-4). + +locale::id codecvt<char32_t, char8_t, mbstate_t>::id; + +codecvt<char32_t, char8_t, mbstate_t>::~codecvt() { } + +codecvt_base::result +codecvt<char32_t, char8_t, mbstate_t>:: +do_out(state_type&, const intern_type* __from, const intern_type* __from_end, + const intern_type*& __from_next, + extern_type* __to, extern_type* __to_end, + extern_type*& __to_next) const +{ + range<const char32_t> from{ __from, __from_end }; + range<char8_t> to{ __to, __to_end }; + auto res = ucs4_out(from, to); + __from_next = from.next; + __to_next = to.next; + return res; +} + +codecvt_base::result +codecvt<char32_t, char8_t, mbstate_t>:: +do_unshift(state_type&, extern_type* __to, extern_type*, + extern_type*& __to_next) const +{ + __to_next = __to; + return noconv; +} + +codecvt_base::result +codecvt<char32_t, char8_t, mbstate_t>:: +do_in(state_type&, const extern_type* __from, const extern_type* __from_end, + const extern_type*& __from_next, + intern_type* __to, intern_type* __to_end, + intern_type*& __to_next) const +{ + range<const char8_t> from{ __from, __from_end }; + range<char32_t> to{ __to, __to_end }; + auto res = ucs4_in(from, to); + __from_next = from.next; + __to_next = to.next; + return res; +} + +int +codecvt<char32_t, char8_t, mbstate_t>::do_encoding() const throw() +{ return 0; } // UTF-8 is not a fixed-width encoding + +bool +codecvt<char32_t, char8_t, mbstate_t>::do_always_noconv() const throw() +{ return false; } + +int +codecvt<char32_t, char8_t, mbstate_t>:: +do_length(state_type&, const extern_type* __from, + const extern_type* __end, size_t __max) const +{ + __end = ucs4_span(__from, __end, __max); + return __end - __from; +} + +int +codecvt<char32_t, char8_t, mbstate_t>::do_max_length() const throw() +{ + // A single character (one UTF-32 code unit) requires + // up to 4 UTF-8 code units. + return 4; +} +#endif // _GLIBCXX_USE_CHAR8_T + // Define members of codecvt_utf8<char16_t> base class implementation. // Converts from UTF-8 to UCS-2. @@ -1636,5 +1797,12 @@ inline template class __codecvt_abstract_base<char32_t, char, mbstate_t>; template class codecvt_byname<char16_t, char, mbstate_t>; template class codecvt_byname<char32_t, char, mbstate_t>; +#if defined(_GLIBCXX_USE_CHAR8_T) +inline template class __codecvt_abstract_base<char16_t, char8_t, mbstate_t>; +inline template class __codecvt_abstract_base<char32_t, char8_t, mbstate_t>; +template class codecvt_byname<char16_t, char8_t, mbstate_t>; +template class codecvt_byname<char32_t, char8_t, mbstate_t>; +#endif + _GLIBCXX_END_NAMESPACE_VERSION } diff --git a/libstdc++-v3/src/c++11/limits.cc b/libstdc++-v3/src/c++11/limits.cc index ed7e631..77b652d 100644 --- a/libstdc++-v3/src/c++11/limits.cc +++ b/libstdc++-v3/src/c++11/limits.cc @@ -525,6 +525,33 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION const bool numeric_limits<long double>::tinyness_before; const float_round_style numeric_limits<long double>::round_style; +#ifdef _GLIBCXX_USE_CHAR8_T + // char8_t + const bool numeric_limits<char8_t>::is_specialized; + const int numeric_limits<char8_t>::digits; + const int numeric_limits<char8_t>::digits10; + const int numeric_limits<char8_t>::max_digits10; + const bool numeric_limits<char8_t>::is_signed; + const bool numeric_limits<char8_t>::is_integer; + const bool numeric_limits<char8_t>::is_exact; + const int numeric_limits<char8_t>::radix; + const int numeric_limits<char8_t>::min_exponent; + const int numeric_limits<char8_t>::min_exponent10; + const int numeric_limits<char8_t>::max_exponent; + const int numeric_limits<char8_t>::max_exponent10; + const bool numeric_limits<char8_t>::has_infinity; + const bool numeric_limits<char8_t>::has_quiet_NaN; + const bool numeric_limits<char8_t>::has_signaling_NaN; + const float_denorm_style numeric_limits<char8_t>::has_denorm; + const bool numeric_limits<char8_t>::has_denorm_loss; + const bool numeric_limits<char8_t>::is_iec559; + const bool numeric_limits<char8_t>::is_bounded; + const bool numeric_limits<char8_t>::is_modulo; + const bool numeric_limits<char8_t>::traps; + const bool numeric_limits<char8_t>::tinyness_before; + const float_round_style numeric_limits<char8_t>::round_style; +#endif // _GLIBCXX_USE_CHAR8_T + // char16_t const bool numeric_limits<char16_t>::is_specialized; const int numeric_limits<char16_t>::digits; diff --git a/libstdc++-v3/src/c++98/Makefile.am b/libstdc++-v3/src/c++98/Makefile.am index b9f59ec..ba88f00 100644 --- a/libstdc++-v3/src/c++98/Makefile.am +++ b/libstdc++-v3/src/c++98/Makefile.am @@ -184,13 +184,13 @@ endif # XXX TODO move locale_init.cc and localename.cc to src/c++11 locale_init.lo: locale_init.cc - $(LTCXXCOMPILE) -std=gnu++11 -c $< + $(LTCXXCOMPILE) -std=gnu++11 -fchar8_t -c $< locale_init.o: locale_init.cc - $(LTCXXCOMPILE) -std=gnu++11 -c $< + $(LTCXXCOMPILE) -std=gnu++11 -fchar8_t -c $< localename.lo: localename.cc - $(LTCXXCOMPILE) -std=gnu++11 -c $< + $(LTCXXCOMPILE) -std=gnu++11 -fchar8_t -c $< localename.o: localename.cc - $(LTCXXCOMPILE) -std=gnu++11 -c $< + $(LTCXXCOMPILE) -std=gnu++11 -fchar8_t -c $< # Use special rules for the deprecated source files so that they find # deprecated include files. diff --git a/libstdc++-v3/src/c++98/Makefile.in b/libstdc++-v3/src/c++98/Makefile.in index 009cb11..8e89c73 100644 --- a/libstdc++-v3/src/c++98/Makefile.in +++ b/libstdc++-v3/src/c++98/Makefile.in @@ -888,13 +888,13 @@ c++locale.o: c++locale.cc # XXX TODO move locale_init.cc and localename.cc to src/c++11 locale_init.lo: locale_init.cc - $(LTCXXCOMPILE) -std=gnu++11 -c $< + $(LTCXXCOMPILE) -std=gnu++11 -fchar8_t -c $< locale_init.o: locale_init.cc - $(LTCXXCOMPILE) -std=gnu++11 -c $< + $(LTCXXCOMPILE) -std=gnu++11 -fchar8_t -c $< localename.lo: localename.cc - $(LTCXXCOMPILE) -std=gnu++11 -c $< + $(LTCXXCOMPILE) -std=gnu++11 -fchar8_t -c $< localename.o: localename.cc - $(LTCXXCOMPILE) -std=gnu++11 -c $< + $(LTCXXCOMPILE) -std=gnu++11 -fchar8_t -c $< strstream.lo: strstream.cc $(LTCXXCOMPILE) -I$(GLIBCXX_INCLUDE_DIR)/backward -Wno-deprecated -c $< strstream.o: strstream.cc diff --git a/libstdc++-v3/src/c++98/locale_init.cc b/libstdc++-v3/src/c++98/locale_init.cc index 0b778de..e5e9d74 100644 --- a/libstdc++-v3/src/c++98/locale_init.cc +++ b/libstdc++-v3/src/c++98/locale_init.cc @@ -209,6 +209,16 @@ namespace __attribute__ ((aligned(__alignof__(codecvt<char32_t, char, mbstate_t>)))); fake_codecvt_c32 codecvt_c32; +#ifdef _GLIBCXX_USE_CHAR8_T + typedef char fake_codecvt_c16_c8[sizeof(codecvt<char16_t, char8_t, mbstate_t>)] + __attribute__ ((aligned(__alignof__(codecvt<char16_t, char8_t, mbstate_t>)))); + fake_codecvt_c16_c8 codecvt_c16_c8; + + typedef char fake_codecvt_c32_c8[sizeof(codecvt<char32_t, char8_t, mbstate_t>)] + __attribute__ ((aligned(__alignof__(codecvt<char32_t, char8_t, mbstate_t>)))); + fake_codecvt_c32_c8 codecvt_c32_c8; +#endif + // Storage for "C" locale caches. typedef char fake_num_cache_c[sizeof(std::__numpunct_cache<char>)] __attribute__ ((aligned(__alignof__(std::__numpunct_cache<char>)))); @@ -329,6 +339,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #if _GLIBCXX_NUM_UNICODE_FACETS != 0 &codecvt<char16_t, char, mbstate_t>::id, &codecvt<char32_t, char, mbstate_t>::id, +#ifdef _GLIBCXX_USE_CHAR8_T + &codecvt<char16_t, char8_t, mbstate_t>::id, + &codecvt<char32_t, char8_t, mbstate_t>::id, +#endif #endif 0 }; @@ -536,6 +550,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #if _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)); + +#ifdef _GLIBCXX_USE_CHAR8_T + _M_init_facet(new (&codecvt_c16_c8) codecvt<char16_t, char8_t, mbstate_t>(1)); + _M_init_facet(new (&codecvt_c32_c8) codecvt<char32_t, char8_t, mbstate_t>(1)); +#endif + #endif #if _GLIBCXX_USE_DUAL_ABI diff --git a/libstdc++-v3/src/c++98/localename.cc b/libstdc++-v3/src/c++98/localename.cc index 38290f0..4e9c5e6 100644 --- a/libstdc++-v3/src/c++98/localename.cc +++ b/libstdc++-v3/src/c++98/localename.cc @@ -272,6 +272,12 @@ const int num_facets = _GLIBCXX_NUM_FACETS + _GLIBCXX_NUM_UNICODE_FACETS #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>); + +#ifdef _GLIBCXX_USE_CHAR8_T + _M_init_facet(new codecvt<char16_t, char8_t, mbstate_t>); + _M_init_facet(new codecvt<char32_t, char8_t, mbstate_t>); +#endif + #endif #if _GLIBCXX_USE_DUAL_ABI |