Commit b333e8eb by Jonathan Wakely Committed by Jonathan Wakely

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
parent d5d9703a
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.
......
......@@ -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 =
......
......@@ -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)
......
......@@ -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__
......
// 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
......@@ -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
// 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
......@@ -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
......@@ -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*
......
......@@ -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(); }
......
......@@ -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;
......
......@@ -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)
{ }
......
......@@ -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;
......
// 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
// 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
......@@ -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
// 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
......@@ -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.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment