diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2017-02-03 18:59:05 +0000 |
---|---|---|
committer | Jonathan Wakely <redi@gcc.gnu.org> | 2017-02-03 18:59:05 +0000 |
commit | b333e8ebb0d4b63acd52249b350de410e6f77e5f (patch) | |
tree | a04fd957ad83f6c28b7889bbfda9bd14486ac2be /libstdc++-v3 | |
parent | d5d9703a2caeb411411e02a102756493587073a6 (diff) | |
download | gcc-b333e8ebb0d4b63acd52249b350de410e6f77e5f.zip gcc-b333e8ebb0d4b63acd52249b350de410e6f77e5f.tar.gz gcc-b333e8ebb0d4b63acd52249b350de410e6f77e5f.tar.bz2 |
PR libstdc++/60936 reduce coupling between objects in libstdc++.a
Move explicit instantiation definitions for string I/O functions into
their own files so that iostream and locale definitions are not needed
for uses of strings without I/O. Move functions for throwing C++11
exceptions into the individual files defining the exception types, so
that using any of the functions from functexcept.cc doesn't pull in
large pieces of the C++11 library. Finally, avoid using __int_to_char in
snprintf_lite.cc to avoid pulling in locale-inst.cc for one function.
PR libstdc++/60936
* src/c++11/Makefile.am: Add new files.
* src/c++11/Makefile.in: Regenerate.
* src/c++11/cow-string-inst.cc [!_GLIBCXX_USE_CXX11_ABI]
(operator<<, operator>>, getline): Move explicit instantiations to ...
* src/c++11/cow-string-io-inst.cc: ... new file.
* src/c++11/cow-wstring-inst.cc [!_GLIBCXX_USE_CXX11_ABI]
(operator<<, operator>>, getline): Move explicit instantiations to ...
* src/c++11/cow-wstring-io-inst.cc: ... new file.
* src/c++11/functexcept.cc (__throw_ios_failure, __throw_system_error)
(__throw_future_error, __throw_bad_function_call):
(__throw_regex_error): Move functions for C++11 exceptions to the
files that define the exception types.
* src/c++11/functional.cc (__throw_bad_function_call): Move here.
* src/c++11/future.cc (__throw_future_error): Likewise.
* src/c++11/ios.cc (__throw_ios_failure): Likewise.
* src/c++11/regex.cc (__throw_regex_error): Likewise.
* src/c++11/snprintf_lite.cc (__concat_size_t): Print decimal
representation directly instead of calling __int_to_char.
* src/c++11/sso_string.cc (__sso_string): New file for definition
of __sso_string type.
* src/c++11/string-io-inst.cc [_GLIBCXX_USE_CXX11_ABI]: New file for
explicit instantiations of narrow string I/O functions.
* src/c++11/system_error.cc (__throw_system_error): Move here.
(__sso_string): Move to new file.
* src/c++11/wstring-io-inst.cc [_GLIBCXX_USE_CXX11_ABI]: New file for
explicit instantiations of wide string I/O functions.
* src/c++98/misc-inst.cc [_GLIBCXX_USE_CXX11_ABI] (operator<<)
(operator>>, getline): Remove explicit instantiations from here.
From-SVN: r245162
Diffstat (limited to 'libstdc++-v3')
-rw-r--r-- | libstdc++-v3/ChangeLog | 32 | ||||
-rw-r--r-- | libstdc++-v3/src/c++11/Makefile.am | 9 | ||||
-rw-r--r-- | libstdc++-v3/src/c++11/Makefile.in | 20 | ||||
-rw-r--r-- | libstdc++-v3/src/c++11/cow-string-inst.cc | 25 | ||||
-rw-r--r-- | libstdc++-v3/src/c++11/cow-string-io-inst.cc | 59 | ||||
-rw-r--r-- | libstdc++-v3/src/c++11/cow-wstring-inst.cc | 24 | ||||
-rw-r--r-- | libstdc++-v3/src/c++11/cow-wstring-io-inst.cc | 63 | ||||
-rw-r--r-- | libstdc++-v3/src/c++11/functexcept.cc | 31 | ||||
-rw-r--r-- | libstdc++-v3/src/c++11/functional.cc | 5 | ||||
-rw-r--r-- | libstdc++-v3/src/c++11/future.cc | 5 | ||||
-rw-r--r-- | libstdc++-v3/src/c++11/ios.cc | 16 | ||||
-rw-r--r-- | libstdc++-v3/src/c++11/regex.cc | 6 | ||||
-rw-r--r-- | libstdc++-v3/src/c++11/snprintf_lite.cc | 20 | ||||
-rw-r--r-- | libstdc++-v3/src/c++11/sso_string.cc | 107 | ||||
-rw-r--r-- | libstdc++-v3/src/c++11/string-io-inst.cc | 53 | ||||
-rw-r--r-- | libstdc++-v3/src/c++11/system_error.cc | 74 | ||||
-rw-r--r-- | libstdc++-v3/src/c++11/wstring-io-inst.cc | 55 | ||||
-rw-r--r-- | libstdc++-v3/src/c++98/misc-inst.cc | 28 |
18 files changed, 438 insertions, 194 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 6c10744..045fff2 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,35 @@ +2017-02-03 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/60936 + * src/c++11/Makefile.am: Add new files. + * src/c++11/Makefile.in: Regenerate. + * src/c++11/cow-string-inst.cc [!_GLIBCXX_USE_CXX11_ABI] + (operator<<, operator>>, getline): Move explicit instantiations to ... + * src/c++11/cow-string-io-inst.cc: ... new file. + * src/c++11/cow-wstring-inst.cc [!_GLIBCXX_USE_CXX11_ABI] + (operator<<, operator>>, getline): Move explicit instantiations to ... + * src/c++11/cow-wstring-io-inst.cc: ... new file. + * src/c++11/functexcept.cc (__throw_ios_failure, __throw_system_error) + (__throw_future_error, __throw_bad_function_call): + (__throw_regex_error): Move functions for C++11 exceptions to the + files that define the exception types. + * src/c++11/functional.cc (__throw_bad_function_call): Move here. + * src/c++11/future.cc (__throw_future_error): Likewise. + * src/c++11/ios.cc (__throw_ios_failure): Likewise. + * src/c++11/regex.cc (__throw_regex_error): Likewise. + * src/c++11/snprintf_lite.cc (__concat_size_t): Print decimal + representation directly instead of calling __int_to_char. + * src/c++11/sso_string.cc (__sso_string): New file for definition + of __sso_string type. + * src/c++11/string-io-inst.cc [_GLIBCXX_USE_CXX11_ABI]: New file for + explicit instantiations of narrow string I/O functions. + * src/c++11/system_error.cc (__throw_system_error): Move here. + (__sso_string): Move to new file. + * src/c++11/wstring-io-inst.cc [_GLIBCXX_USE_CXX11_ABI]: New file for + explicit instantiations of wide string I/O functions. + * src/c++98/misc-inst.cc [_GLIBCXX_USE_CXX11_ABI] (operator<<) + (operator>>, getline): Remove explicit instantiations from here. + 2017-02-02 H.J. Lu <hongjiu.lu@intel.com> * config/abi/post/x86_64-linux-gnu/x32/baseline_symbols.txt: Updated. diff --git a/libstdc++-v3/src/c++11/Makefile.am b/libstdc++-v3/src/c++11/Makefile.am index 4b945c0..cf73d4d 100644 --- a/libstdc++-v3/src/c++11/Makefile.am +++ b/libstdc++-v3/src/c++11/Makefile.am @@ -82,9 +82,12 @@ extra_string_inst_sources = \ cow-fstream-inst.cc \ cow-sstream-inst.cc \ cow-string-inst.cc \ + cow-string-io-inst.cc \ cow-wstring-inst.cc \ + cow-wstring-io-inst.cc \ cxx11-locale-inst.cc \ - cxx11-wlocale-inst.cc + cxx11-wlocale-inst.cc \ + sso_string.cc else extra_string_inst_sources = endif @@ -103,8 +106,10 @@ inst_sources = \ sstream-inst.cc \ streambuf-inst.cc \ string-inst.cc \ + string-io-inst.cc \ wlocale-inst.cc \ - wstring-inst.cc + wstring-inst.cc \ + wstring-io-inst.cc else # XTEMPLATE_FLAGS = inst_sources = diff --git a/libstdc++-v3/src/c++11/Makefile.in b/libstdc++-v3/src/c++11/Makefile.in index cd18b82..295d915 100644 --- a/libstdc++-v3/src/c++11/Makefile.in +++ b/libstdc++-v3/src/c++11/Makefile.in @@ -98,15 +98,20 @@ am__objects_3 = chrono.lo codecvt.lo condition_variable.lo \ system_error.lo thread.lo $(am__objects_1) $(am__objects_2) @ENABLE_DUAL_ABI_TRUE@am__objects_4 = cow-fstream-inst.lo \ @ENABLE_DUAL_ABI_TRUE@ cow-sstream-inst.lo cow-string-inst.lo \ -@ENABLE_DUAL_ABI_TRUE@ cow-wstring-inst.lo cxx11-locale-inst.lo \ -@ENABLE_DUAL_ABI_TRUE@ cxx11-wlocale-inst.lo +@ENABLE_DUAL_ABI_TRUE@ cow-string-io-inst.lo \ +@ENABLE_DUAL_ABI_TRUE@ cow-wstring-inst.lo \ +@ENABLE_DUAL_ABI_TRUE@ cow-wstring-io-inst.lo \ +@ENABLE_DUAL_ABI_TRUE@ cxx11-locale-inst.lo \ +@ENABLE_DUAL_ABI_TRUE@ cxx11-wlocale-inst.lo sso_string.lo @ENABLE_EXTERN_TEMPLATE_TRUE@am__objects_5 = $(am__objects_4) \ @ENABLE_EXTERN_TEMPLATE_TRUE@ ext11-inst.lo fstream-inst.lo \ @ENABLE_EXTERN_TEMPLATE_TRUE@ ios-inst.lo iostream-inst.lo \ @ENABLE_EXTERN_TEMPLATE_TRUE@ istream-inst.lo locale-inst.lo \ @ENABLE_EXTERN_TEMPLATE_TRUE@ ostream-inst.lo sstream-inst.lo \ @ENABLE_EXTERN_TEMPLATE_TRUE@ streambuf-inst.lo string-inst.lo \ -@ENABLE_EXTERN_TEMPLATE_TRUE@ wlocale-inst.lo wstring-inst.lo +@ENABLE_EXTERN_TEMPLATE_TRUE@ string-io-inst.lo wlocale-inst.lo \ +@ENABLE_EXTERN_TEMPLATE_TRUE@ wstring-inst.lo \ +@ENABLE_EXTERN_TEMPLATE_TRUE@ wstring-io-inst.lo am_libc__11convenience_la_OBJECTS = $(am__objects_3) $(am__objects_5) libc__11convenience_la_OBJECTS = $(am_libc__11convenience_la_OBJECTS) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) @@ -398,9 +403,12 @@ sources = \ @ENABLE_DUAL_ABI_TRUE@ cow-fstream-inst.cc \ @ENABLE_DUAL_ABI_TRUE@ cow-sstream-inst.cc \ @ENABLE_DUAL_ABI_TRUE@ cow-string-inst.cc \ +@ENABLE_DUAL_ABI_TRUE@ cow-string-io-inst.cc \ @ENABLE_DUAL_ABI_TRUE@ cow-wstring-inst.cc \ +@ENABLE_DUAL_ABI_TRUE@ cow-wstring-io-inst.cc \ @ENABLE_DUAL_ABI_TRUE@ cxx11-locale-inst.cc \ -@ENABLE_DUAL_ABI_TRUE@ cxx11-wlocale-inst.cc +@ENABLE_DUAL_ABI_TRUE@ cxx11-wlocale-inst.cc \ +@ENABLE_DUAL_ABI_TRUE@ sso_string.cc # XTEMPLATE_FLAGS = @ENABLE_EXTERN_TEMPLATE_FALSE@inst_sources = @@ -418,8 +426,10 @@ sources = \ @ENABLE_EXTERN_TEMPLATE_TRUE@ sstream-inst.cc \ @ENABLE_EXTERN_TEMPLATE_TRUE@ streambuf-inst.cc \ @ENABLE_EXTERN_TEMPLATE_TRUE@ string-inst.cc \ +@ENABLE_EXTERN_TEMPLATE_TRUE@ string-io-inst.cc \ @ENABLE_EXTERN_TEMPLATE_TRUE@ wlocale-inst.cc \ -@ENABLE_EXTERN_TEMPLATE_TRUE@ wstring-inst.cc +@ENABLE_EXTERN_TEMPLATE_TRUE@ wstring-inst.cc \ +@ENABLE_EXTERN_TEMPLATE_TRUE@ wstring-io-inst.cc libc__11convenience_la_SOURCES = $(sources) $(inst_sources) diff --git a/libstdc++-v3/src/c++11/cow-string-inst.cc b/libstdc++-v3/src/c++11/cow-string-inst.cc index 6f2e5c4..6d1362f 100644 --- a/libstdc++-v3/src/c++11/cow-string-inst.cc +++ b/libstdc++-v3/src/c++11/cow-string-inst.cc @@ -29,35 +29,10 @@ #define _GLIBCXX_USE_CXX11_ABI 0 #include "string-inst.cc" -#include <istream> -#include <ostream> - #if ! _GLIBCXX_USE_DUAL_ABI # error This file should not be compiled for this configuration. #endif -namespace std _GLIBCXX_VISIBILITY(default) -{ -_GLIBCXX_BEGIN_NAMESPACE_VERSION - - // These came from c++98/misc-inst.cc, repeat them for COW string - // string related to iostreams. - template - basic_istream<char>& - operator>>(basic_istream<char>&, string&); - template - basic_ostream<char>& - operator<<(basic_ostream<char>&, const string&); - template - basic_istream<char>& - getline(basic_istream<char>&, string&, char); - template - basic_istream<char>& - getline(basic_istream<char>&, string&); - -_GLIBCXX_END_NAMESPACE_VERSION -} // namespace - #ifdef _GLIBCXX_USE_C99_STDINT_TR1 #include <random> #if defined __i386__ || defined __x86_64__ diff --git a/libstdc++-v3/src/c++11/cow-string-io-inst.cc b/libstdc++-v3/src/c++11/cow-string-io-inst.cc new file mode 100644 index 0000000..caafd2e --- /dev/null +++ b/libstdc++-v3/src/c++11/cow-string-io-inst.cc @@ -0,0 +1,59 @@ +// Reference-counted COW string instantiations for I/O -*- C++ -*- + +// Copyright (C) 2014-2017 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +// +// ISO C++ 14882: 21 Strings library +// + +#define _GLIBCXX_USE_CXX11_ABI 0 +#include <istream> +#include <ostream> + +#if ! _GLIBCXX_USE_DUAL_ABI +# error This file should not be compiled for this configuration. +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + // The equivalent SSO string instantiations are in c++98/misc-inst.cc, + // repeat them for COW string + + // string related to iostreams. + template + basic_istream<char>& + operator>>(basic_istream<char>&, string&); + template + basic_ostream<char>& + operator<<(basic_ostream<char>&, const string&); + template + basic_istream<char>& + getline(basic_istream<char>&, string&, char); + template + basic_istream<char>& + getline(basic_istream<char>&, string&); + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace diff --git a/libstdc++-v3/src/c++11/cow-wstring-inst.cc b/libstdc++-v3/src/c++11/cow-wstring-inst.cc index 5e4b7ba..3686478 100644 --- a/libstdc++-v3/src/c++11/cow-wstring-inst.cc +++ b/libstdc++-v3/src/c++11/cow-wstring-inst.cc @@ -33,32 +33,8 @@ #define C wchar_t #include "string-inst.cc" -#include <ostream> -#include <istream> - #if ! _GLIBCXX_USE_DUAL_ABI # error This file should not be compiled for this configuration. #endif -namespace std _GLIBCXX_VISIBILITY(default) -{ -_GLIBCXX_BEGIN_NAMESPACE_VERSION - - // XXX these came from c++98/misc-inst.cc, repeat them for COW string - // string related to iostreams - template - basic_istream<wchar_t>& - operator>>(basic_istream<wchar_t>&, wstring&); - template - basic_ostream<wchar_t>& - operator<<(basic_ostream<wchar_t>&, const wstring&); - template - basic_istream<wchar_t>& - getline(basic_istream<wchar_t>&, wstring&, wchar_t); - template - basic_istream<wchar_t>& - getline(basic_istream<wchar_t>&, wstring&); - -_GLIBCXX_END_NAMESPACE_VERSION -} // namespace #endif diff --git a/libstdc++-v3/src/c++11/cow-wstring-io-inst.cc b/libstdc++-v3/src/c++11/cow-wstring-io-inst.cc new file mode 100644 index 0000000..b174d20 --- /dev/null +++ b/libstdc++-v3/src/c++11/cow-wstring-io-inst.cc @@ -0,0 +1,63 @@ +// Reference-counted COW wide string instantiations for I/O -*- C++ -*- + +// Copyright (C) 2014-2017 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +// +// ISO C++ 14882: 21 Strings library +// + +#define _GLIBCXX_USE_CXX11_ABI 0 +#include <bits/c++config.h> + +#ifdef _GLIBCXX_USE_WCHAR_T +#include <ostream> +#include <istream> + +#if ! _GLIBCXX_USE_DUAL_ABI +# error This file should not be compiled for this configuration. +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + // The equivalent SSO wstring instantiations are in c++98/misc-inst.cc, + // repeat them for COW wstring + + // string related to iostreams + template + basic_istream<wchar_t>& + operator>>(basic_istream<wchar_t>&, wstring&); + template + basic_ostream<wchar_t>& + operator<<(basic_ostream<wchar_t>&, const wstring&); + template + basic_istream<wchar_t>& + getline(basic_istream<wchar_t>&, wstring&, wchar_t); + template + basic_istream<wchar_t>& + getline(basic_istream<wchar_t>&, wstring&); + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace +#endif diff --git a/libstdc++-v3/src/c++11/functexcept.cc b/libstdc++-v3/src/c++11/functexcept.cc index 6281534..d2c154c 100644 --- a/libstdc++-v3/src/c++11/functexcept.cc +++ b/libstdc++-v3/src/c++11/functexcept.cc @@ -20,21 +20,12 @@ // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. -// Determines the version of ios_base::failure thrown by __throw_ios_failure. -// If !_GLIBCXX_USE_DUAL_ABI this will get undefined automatically. -#define _GLIBCXX_USE_CXX11_ABI 1 - #include <bits/functexcept.h> #include <cstdlib> #include <exception> #include <stdexcept> #include <new> #include <typeinfo> -#include <ios> -#include <system_error> -#include <future> -#include <functional> -#include <bits/regex_error.h> #include <stdarg.h> #ifdef _GLIBCXX_USE_NLS @@ -122,27 +113,5 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __throw_underflow_error(const char* __s __attribute__((unused))) { _GLIBCXX_THROW_OR_ABORT(underflow_error(_(__s))); } - void - __throw_ios_failure(const char* __s __attribute__((unused))) - { _GLIBCXX_THROW_OR_ABORT(ios_base::failure(_(__s))); } - - void - __throw_system_error(int __i __attribute__((unused))) - { _GLIBCXX_THROW_OR_ABORT(system_error(error_code(__i, - generic_category()))); } - - void - __throw_future_error(int __i __attribute__((unused))) - { _GLIBCXX_THROW_OR_ABORT(future_error(make_error_code(future_errc(__i)))); } - - void - __throw_bad_function_call() - { _GLIBCXX_THROW_OR_ABORT(bad_function_call()); } - - void - __throw_regex_error(regex_constants::error_type __ecode - __attribute__((unused))) - { _GLIBCXX_THROW_OR_ABORT(regex_error(__ecode)); } - _GLIBCXX_END_NAMESPACE_VERSION } // namespace diff --git a/libstdc++-v3/src/c++11/functional.cc b/libstdc++-v3/src/c++11/functional.cc index 4c304bc..8ac87b9 100644 --- a/libstdc++-v3/src/c++11/functional.cc +++ b/libstdc++-v3/src/c++11/functional.cc @@ -23,11 +23,16 @@ // <http://www.gnu.org/licenses/>. #include <functional> +#include <bits/functexcept.h> namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION + void + __throw_bad_function_call() + { _GLIBCXX_THROW_OR_ABORT(bad_function_call()); } + bad_function_call::~bad_function_call() noexcept = default; const char* diff --git a/libstdc++-v3/src/c++11/future.cc b/libstdc++-v3/src/c++11/future.cc index e138567..d25ea4a 100644 --- a/libstdc++-v3/src/c++11/future.cc +++ b/libstdc++-v3/src/c++11/future.cc @@ -23,6 +23,7 @@ // <http://www.gnu.org/licenses/>. #include <future> +#include <bits/functexcept.h> namespace { @@ -70,6 +71,10 @@ namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION + void + __throw_future_error(int __i __attribute__((unused))) + { _GLIBCXX_THROW_OR_ABORT(future_error(make_error_code(future_errc(__i)))); } + const error_category& future_category() noexcept { return __future_category_instance(); } diff --git a/libstdc++-v3/src/c++11/ios.cc b/libstdc++-v3/src/c++11/ios.cc index ef0da96..9061989 100644 --- a/libstdc++-v3/src/c++11/ios.cc +++ b/libstdc++-v3/src/c++11/ios.cc @@ -26,13 +26,29 @@ // ISO C++ 14882: 27.4 Iostreams base classes // +// Determines the version of ios_base::failure thrown by __throw_ios_failure. +// If !_GLIBCXX_USE_DUAL_ABI this will get undefined automatically. +#define _GLIBCXX_USE_CXX11_ABI 1 + #include <ios> #include <limits> +#include <bits/functexcept.h> + +#ifdef _GLIBCXX_USE_NLS +# include <libintl.h> +# define _(msgid) gettext (msgid) +#else +# define _(msgid) (msgid) +#endif namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION + void + __throw_ios_failure(const char* __s __attribute__((unused))) + { _GLIBCXX_THROW_OR_ABORT(ios_base::failure(_(__s))); } + // Definitions for static const members of ios_base. const ios_base::fmtflags ios_base::boolalpha; const ios_base::fmtflags ios_base::dec; diff --git a/libstdc++-v3/src/c++11/regex.cc b/libstdc++-v3/src/c++11/regex.cc index 122572f..cd2e489 100644 --- a/libstdc++-v3/src/c++11/regex.cc +++ b/libstdc++-v3/src/c++11/regex.cc @@ -24,11 +24,17 @@ #include <stdexcept> #include <bits/regex_error.h> +#include <bits/functexcept.h> namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION + void + __throw_regex_error(regex_constants::error_type __ecode + __attribute__((unused))) + { _GLIBCXX_THROW_OR_ABORT(regex_error(__ecode)); } + regex_error::regex_error(regex_constants::error_type __ecode) : std::runtime_error("regex_error"), _M_code(__ecode) { } diff --git a/libstdc++-v3/src/c++11/snprintf_lite.cc b/libstdc++-v3/src/c++11/snprintf_lite.cc index d97b31e..6144ecf 100644 --- a/libstdc++-v3/src/c++11/snprintf_lite.cc +++ b/libstdc++-v3/src/c++11/snprintf_lite.cc @@ -71,19 +71,17 @@ namespace __gnu_cxx { // Returns number of characters appended, or -1 if BUFSIZE is too small. int __concat_size_t(char *__buf, size_t __bufsize, size_t __val) { - // __int_to_char is explicitly instantiated and available only for - // some, but not all, types. See locale-inst.cc. -#ifdef _GLIBCXX_USE_LONG_LONG - unsigned long long __val2 = __val; -#else - unsigned long __val2 = __val; -#endif // Long enough for decimal representation. - int __ilen = 3 * sizeof(__val2); + int __ilen = 3 * sizeof(__val); char *__cs = static_cast<char*>(__builtin_alloca(__ilen)); - size_t __len = std::__int_to_char(__cs + __ilen, __val2, - std::__num_base::_S_atoms_out, - std::ios_base::dec, true); + char* __out = __cs + __ilen; + do + { + *--__out = "0123456789"[__val % 10]; + __val /= 10; + } + while (__val != 0); + size_t __len = __out - __cs; if (__bufsize < __len) return -1; diff --git a/libstdc++-v3/src/c++11/sso_string.cc b/libstdc++-v3/src/c++11/sso_string.cc new file mode 100644 index 0000000..a59db1a --- /dev/null +++ b/libstdc++-v3/src/c++11/sso_string.cc @@ -0,0 +1,107 @@ +// Helper for accessing __cxx11::string from the ABI -*- C++ -*- + +// Copyright (C) 2014-2017 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + + +#define _GLIBCXX_USE_CXX11_ABI 1 +#define __sso_string __sso_stringxxx +#include <string> +#include <stdexcept> +#undef __sso_string + +#if ! _GLIBCXX_USE_DUAL_ABI +# error This file should not be compiled for this configuration. +#endif + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wabi-tag" + // Redefine __sso_string so that we can define and export its members + // in terms of the SSO std::string. + struct __sso_string + { + struct __str + { + const char* _M_p; + size_t _M_string_length; + char _M_local_buf[16]; + }; + + union { + __str _M_s; + char _M_bytes[sizeof(_M_s)]; + std::string _M_str; + }; + + __sso_string(); + __sso_string(const std::string& s); + __sso_string(const char*, size_t n); + __sso_string(const __sso_string&) noexcept; + __sso_string& operator=(const __sso_string&) noexcept; + ~__sso_string(); + __sso_string(__sso_string&&) noexcept; + __sso_string& operator=(__sso_string&&) noexcept; + }; +#pragma GCC diagnostic pop + + __sso_string::__sso_string() : _M_str() { } + +#if _GLIBCXX_USE_CXX11_ABI + static_assert(sizeof(__sso_string) == sizeof(std::string), + "sizeof(std::string) has changed"); + static_assert(alignof(__sso_string) == alignof(std::string), + "alignof(std::string) has changed"); + + // This constructor is defined in src/c++11/cow-stdexcept.cc for COW strings + __sso_string::__sso_string(const std::string& s) : _M_str(s) { } +#endif + + __sso_string::__sso_string(const char* s, size_t n) : _M_str(s, n) { } + + __sso_string::__sso_string(const __sso_string& s) noexcept + : _M_str(s._M_str) { } + + __sso_string& + __sso_string::operator=(const __sso_string& s) noexcept + { + _M_str = s._M_str; + return *this; + } + + __sso_string::~__sso_string() { _M_str.~basic_string(); } + + __sso_string::__sso_string(__sso_string&& s) noexcept + : _M_str(std::move(s._M_str)) { } + + __sso_string& + __sso_string::operator=(__sso_string&& s) noexcept + { + _M_str = std::move(s._M_str); + return *this; + } + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace diff --git a/libstdc++-v3/src/c++11/string-io-inst.cc b/libstdc++-v3/src/c++11/string-io-inst.cc new file mode 100644 index 0000000..7c063d4 --- /dev/null +++ b/libstdc++-v3/src/c++11/string-io-inst.cc @@ -0,0 +1,53 @@ +// SSO string instantiations for I/O -*- C++ -*- + +// Copyright (C) 1997-2017 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +// +// ISO C++ 14882: +// + +#define _GLIBCXX_USE_CXX11_ABI 1 +#include <string> +#include <istream> +#include <ostream> + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + // string related to iostreams + template + basic_istream<char>& + operator>>(basic_istream<char>&, string&); + template + basic_ostream<char>& + operator<<(basic_ostream<char>&, const string&); + template + basic_istream<char>& + getline(basic_istream<char>&, string&, char); + template + basic_istream<char>& + getline(basic_istream<char>&, string&); + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace diff --git a/libstdc++-v3/src/c++11/system_error.cc b/libstdc++-v3/src/c++11/system_error.cc index c5065dd..61dbc3f 100644 --- a/libstdc++-v3/src/c++11/system_error.cc +++ b/libstdc++-v3/src/c++11/system_error.cc @@ -75,6 +75,12 @@ namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION + void + __throw_system_error(int __i __attribute__((unused))) + { + _GLIBCXX_THROW_OR_ABORT(system_error(error_code(__i, generic_category()))); + } + error_category::~error_category() noexcept = default; const error_category& @@ -112,73 +118,5 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } #endif -#if _GLIBCXX_USE_DUAL_ABI -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wabi-tag" - // Redefine __sso_string so that we can define and export its members - // in terms of the SSO std::string. - struct __sso_string - { - struct __str - { - const char* _M_p; - size_t _M_string_length; - char _M_local_buf[16]; - }; - - union { - __str _M_s; - char _M_bytes[sizeof(_M_s)]; - std::string _M_str; - }; - - __sso_string(); - __sso_string(const std::string& s); - __sso_string(const char*, size_t n); - __sso_string(const __sso_string&) noexcept; - __sso_string& operator=(const __sso_string&) noexcept; - ~__sso_string(); - __sso_string(__sso_string&&) noexcept; - __sso_string& operator=(__sso_string&&) noexcept; - }; -#pragma GCC diagnostic pop - - __sso_string::__sso_string() : _M_str() { } - -#if _GLIBCXX_USE_CXX11_ABI - static_assert(sizeof(__sso_string) == sizeof(std::string), - "sizeof(std::string) has changed"); - static_assert(alignof(__sso_string) == alignof(std::string), - "alignof(std::string) has changed"); - - // This constructor is defined in src/c++11/cow-stdexcept.cc for COW strings - __sso_string::__sso_string(const std::string& s) : _M_str(s) { } -#endif - - __sso_string::__sso_string(const char* s, size_t n) : _M_str(s, n) { } - - __sso_string::__sso_string(const __sso_string& s) noexcept - : _M_str(s._M_str) { } - - __sso_string& - __sso_string::operator=(const __sso_string& s) noexcept - { - _M_str = s._M_str; - return *this; - } - - __sso_string::~__sso_string() { _M_str.~basic_string(); } - - __sso_string::__sso_string(__sso_string&& s) noexcept - : _M_str(std::move(s._M_str)) { } - - __sso_string& - __sso_string::operator=(__sso_string&& s) noexcept - { - _M_str = std::move(s._M_str); - return *this; - } -#endif // _GLIBCXX_USE_DUAL_ABI - _GLIBCXX_END_NAMESPACE_VERSION } // namespace diff --git a/libstdc++-v3/src/c++11/wstring-io-inst.cc b/libstdc++-v3/src/c++11/wstring-io-inst.cc new file mode 100644 index 0000000..0fae821 --- /dev/null +++ b/libstdc++-v3/src/c++11/wstring-io-inst.cc @@ -0,0 +1,55 @@ +// SSO string instantiations for I/O -*- C++ -*- + +// Copyright (C) 1997-2017 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +// +// ISO C++ 14882: +// + +#define _GLIBCXX_USE_CXX11_ABI 1 +#include <string> +#include <istream> +#include <ostream> + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + // string related to iostreams +#ifdef _GLIBCXX_USE_WCHAR_T + template + basic_istream<wchar_t>& + operator>>(basic_istream<wchar_t>&, wstring&); + template + basic_ostream<wchar_t>& + operator<<(basic_ostream<wchar_t>&, const wstring&); + template + basic_istream<wchar_t>& + getline(basic_istream<wchar_t>&, wstring&, wchar_t); + template + basic_istream<wchar_t>& + getline(basic_istream<wchar_t>&, wstring&); +#endif + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace diff --git a/libstdc++-v3/src/c++98/misc-inst.cc b/libstdc++-v3/src/c++98/misc-inst.cc index 91c02bf..a0c5912 100644 --- a/libstdc++-v3/src/c++98/misc-inst.cc +++ b/libstdc++-v3/src/c++98/misc-inst.cc @@ -36,34 +36,6 @@ namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION - // string related to iostreams - template - basic_istream<char>& - operator>>(basic_istream<char>&, string&); - template - basic_ostream<char>& - operator<<(basic_ostream<char>&, const string&); - template - basic_istream<char>& - getline(basic_istream<char>&, string&, char); - template - basic_istream<char>& - getline(basic_istream<char>&, string&); -#ifdef _GLIBCXX_USE_WCHAR_T - template - basic_istream<wchar_t>& - operator>>(basic_istream<wchar_t>&, wstring&); - template - basic_ostream<wchar_t>& - operator<<(basic_ostream<wchar_t>&, const wstring&); - template - basic_istream<wchar_t>& - getline(basic_istream<wchar_t>&, wstring&, wchar_t); - template - basic_istream<wchar_t>& - getline(basic_istream<wchar_t>&, wstring&); -#endif - #if _GLIBCXX_USE_CXX11_ABI // C++98 members that are not instantiated by src/c++11/string-inst.cc // because they changed in C++11 to take const_iterator parameters. |