summaryrefslogtreecommitdiff
path: root/libstdc++-v3/src/c++11
diff options
context:
space:
mode:
authorbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2015-01-21 22:01:24 +0000
committerbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2015-01-21 22:01:24 +0000
commitffde65b31066f17eef243be882bb89a6e19370aa (patch)
treeea876d041c0a63eefccdac5416a8678e75da4cfc /libstdc++-v3/src/c++11
parenta8c7acc4db08ce7c8ac3ddcb943f9219e2893792 (diff)
downloadgcc-ffde65b31066f17eef243be882bb89a6e19370aa.tar.gz
[.]
2015-01-21 Basile Starynkevitch <basile@starynkevitch.net> {{merged with trunk -i.e. GCC5.0 in stage4- using svn merge -r209216:219879 svn+ssh://bstarynk@gcc.gnu.org/svn/gcc/trunk but should probably have used svn merge -r209216:219879 ^/trunk we don't use svnmerge.py anymore since our svn is version 1.8.10 }} VERY UNSTABLE 2015-01-20 Basile Starynkevitch <basile@starynkevitch.net> Move previous topdir ChangeLog.MELT to ChangeLog.MELT.2008-2014 [contrib/] 2015-01-21 Basile Starynkevitch <basile@starynkevitch.net> * MELT-Plugin-Makefile: Able to make upgrade-melt as a plugin. Works for GCC 5.0. Remove GCC 4.7 old stuff. Move previous contrib/ChangeLog.MELT to ChangeLog.MELT.2008-2014 [gcc/] 2015-01-21 Basile Starynkevitch <basile@starynkevitch.net> {{merged with trunk -i.e. GCC5.0 in stage4- using svn merge -r209216:219879 svn+ssh://bstarynk@gcc.gnu.org/svn/gcc/trunk but should probably have used svn merge -r209216:219879 ^/trunk **@@@ UNSTABLE since libmelt-ana-gimple.melt not compiling, but translator painfully bootstrapping!!@@@@ }} * toplev.c: Merged manually by keeping MELT extra stuff. * toplev.h: Likewise. * gengtype.c: Add "melt-runtime.h" in list, but merged with trunk. * melt-runtime.h (MELT_VERSION_STRING): Bump to "1.2-pre-merged". (meltgc_walk_gimple_seq): Remove. (gt_ggc_mx_gimple_statement_d): Same for GCC 4.9 & 5.0 * melt-runtime.cc: Update copyright year. (ggc_alloc_cleared_melt_valuevector_st, melt_resize_scangcvect): Call ggc_internal_cleared_alloc. (melt_val2passflag): Skip TODO_verify_ssa, TODO_verify_flow, TODO_verify_stmts, TODO_verify_rtl_sharing for GCC 5.0. (meltgc_walkstmt_cb, meltgc_walktree_cb) (melt_tree_walk_frame_size, meltgc_walk_gimple_seq): Remove. (melt_gt_ggc_mx_gimple_seq_d): Call gt_ggc_mx_gimple_statement_base. * melt-build-script.tpl: Update copyright year. Don't symlink meltrunsup.h anymore. * melt-build-script.sh: Regenerate. * melt/warmelt-base.melt: Update copyright year. (valdesc_object, valdesc_mapobjects, valdesc_mapstrings) (valdesc_multiple, valdesc_closure, valdesc_routine, valdesc_hook) (valdesc_bucketlongs, valdesc_jsonobject, valdesc_string) (valdesc_strbuf, valdesc_pair, valdesc_list, valdesc_int) (valdesc_double, valdesc_mixint, valdesc_mixloc) (valdesc_mixbigint, valdesc_real, valdesc_special_data): Use ggc_internal_alloc & ggc_internal_cleared_alloc for GCC 5.0. (json_canonical_name): Use ISUPPER, ISALPHA, TOUPPER instead of their standard <ctype.h> lowercase macros. * melt/warmelt-modes.melt: Update copyright year. (generate_runtypesupport_forwcopy_fun): Emit both GCC 4.9 & 5.0 compatible code. * melt/libmelt-ana-base.melt: Update copyright year. * melt/libmelt-ana-gimple.melt: TO BE IMPROVED * melt/generated/*: Painfully regenerated several times thru GCC 4.9 MELT plugin. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@219975 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/src/c++11')
-rw-r--r--libstdc++-v3/src/c++11/Makefile.am57
-rw-r--r--libstdc++-v3/src/c++11/Makefile.in82
-rw-r--r--libstdc++-v3/src/c++11/chrono.cc2
-rw-r--r--libstdc++-v3/src/c++11/codecvt.cc1408
-rw-r--r--libstdc++-v3/src/c++11/compatibility-atomic-c++0x.cc2
-rw-r--r--libstdc++-v3/src/c++11/compatibility-c++0x.cc130
-rw-r--r--libstdc++-v3/src/c++11/compatibility-chrono.cc2
-rw-r--r--libstdc++-v3/src/c++11/compatibility-condvar.cc2
-rw-r--r--libstdc++-v3/src/c++11/compatibility-thread-c++0x.cc2
-rw-r--r--libstdc++-v3/src/c++11/condition_variable.cc77
-rw-r--r--libstdc++-v3/src/c++11/cow-fstream-inst.cc78
-rw-r--r--libstdc++-v3/src/c++11/cow-locale_init.cc194
-rw-r--r--libstdc++-v3/src/c++11/cow-shim_facets.cc35
-rw-r--r--libstdc++-v3/src/c++11/cow-sstream-inst.cc34
-rw-r--r--libstdc++-v3/src/c++11/cow-stdexcept.cc153
-rw-r--r--libstdc++-v3/src/c++11/cow-string-inst.cc120
-rw-r--r--libstdc++-v3/src/c++11/cow-wstring-inst.cc64
-rw-r--r--libstdc++-v3/src/c++11/ctype.cc133
-rw-r--r--libstdc++-v3/src/c++11/cxx11-hash_tr1.cc59
-rw-r--r--libstdc++-v3/src/c++11/cxx11-ios_failure.cc94
-rw-r--r--libstdc++-v3/src/c++11/cxx11-locale-inst.cc39
-rw-r--r--libstdc++-v3/src/c++11/cxx11-shim_facets.cc837
-rw-r--r--libstdc++-v3/src/c++11/cxx11-stdexcept.cc78
-rw-r--r--libstdc++-v3/src/c++11/cxx11-wlocale-inst.cc32
-rw-r--r--libstdc++-v3/src/c++11/debug.cc12
-rw-r--r--libstdc++-v3/src/c++11/ext11-inst.cc40
-rw-r--r--libstdc++-v3/src/c++11/fstream-inst.cc3
-rw-r--r--libstdc++-v3/src/c++11/functexcept.cc5
-rw-r--r--libstdc++-v3/src/c++11/functional.cc2
-rw-r--r--libstdc++-v3/src/c++11/futex.cc96
-rw-r--r--libstdc++-v3/src/c++11/future.cc25
-rw-r--r--libstdc++-v3/src/c++11/hash_c++0x.cc2
-rw-r--r--libstdc++-v3/src/c++11/hashtable_c++0x.cc2
-rw-r--r--libstdc++-v3/src/c++11/ios-inst.cc42
-rw-r--r--libstdc++-v3/src/c++11/ios.cc259
-rw-r--r--libstdc++-v3/src/c++11/iostream-inst.cc47
-rw-r--r--libstdc++-v3/src/c++11/istream-inst.cc114
-rw-r--r--libstdc++-v3/src/c++11/limits.cc110
-rw-r--r--libstdc++-v3/src/c++11/locale-inst.cc413
-rw-r--r--libstdc++-v3/src/c++11/mutex.cc2
-rw-r--r--libstdc++-v3/src/c++11/ostream-inst.cc117
-rw-r--r--libstdc++-v3/src/c++11/placeholders.cc2
-rw-r--r--libstdc++-v3/src/c++11/random.cc3
-rw-r--r--libstdc++-v3/src/c++11/regex.cc2
-rw-r--r--libstdc++-v3/src/c++11/shared_ptr.cc60
-rw-r--r--libstdc++-v3/src/c++11/snprintf_lite.cc2
-rw-r--r--libstdc++-v3/src/c++11/sstream-inst.cc53
-rw-r--r--libstdc++-v3/src/c++11/streambuf-inst.cc63
-rw-r--r--libstdc++-v3/src/c++11/string-inst.cc31
-rw-r--r--libstdc++-v3/src/c++11/system_error.cc84
-rw-r--r--libstdc++-v3/src/c++11/thread.cc10
-rw-r--r--libstdc++-v3/src/c++11/wlocale-inst.cc77
-rw-r--r--libstdc++-v3/src/c++11/wstring-inst.cc3
53 files changed, 5301 insertions, 94 deletions
diff --git a/libstdc++-v3/src/c++11/Makefile.am b/libstdc++-v3/src/c++11/Makefile.am
index cf1e3beaa83..90697d044dd 100644
--- a/libstdc++-v3/src/c++11/Makefile.am
+++ b/libstdc++-v3/src/c++11/Makefile.am
@@ -1,6 +1,6 @@
## Makefile for the C++03 sources of the GNU C++ Standard library.
##
-## Copyright (C) 1997-2014 Free Software Foundation, Inc.
+## Copyright (C) 1997-2015 Free Software Foundation, Inc.
##
## This file is part of the libstdc++ version 3 distribution.
## Process this file with automake to produce Makefile.in.
@@ -27,15 +27,44 @@ noinst_LTLIBRARIES = libc++11convenience.la
headers =
+# Source files linked in via configuration/make substitution for a
+# particular host.
+host_sources = \
+ ctype_configure_char.cc \
+ ctype_members.cc
+
+ctype_configure_char.cc: ${glibcxx_srcdir}/$(OS_INC_SRCDIR)/ctype_configure_char.cc
+ $(LN_S) ${glibcxx_srcdir}/$(OS_INC_SRCDIR)/ctype_configure_char.cc . || true
+
+ctype_members.cc: ${glibcxx_srcdir}/$(CCTYPE_CC)
+ $(LN_S) ${glibcxx_srcdir}/$(CCTYPE_CC) . || true
+
+if ENABLE_DUAL_ABI
+cxx11_abi_sources = \
+ cow-locale_init.cc \
+ cow-shim_facets.cc \
+ cxx11-hash_tr1.cc \
+ cxx11-ios_failure.cc \
+ cxx11-shim_facets.cc \
+ cxx11-stdexcept.cc
+else
+cxx11_abi_sources =
+endif
+
sources = \
chrono.cc \
+ codecvt.cc \
condition_variable.cc \
+ cow-stdexcept.cc \
+ ctype.cc \
debug.cc \
functexcept.cc \
functional.cc \
+ futex.cc \
future.cc \
hash_c++0x.cc \
hashtable_c++0x.cc \
+ ios.cc \
limits.cc \
mutex.cc \
placeholders.cc \
@@ -44,13 +73,37 @@ sources = \
shared_ptr.cc \
snprintf_lite.cc \
system_error.cc \
- thread.cc
+ thread.cc \
+ ${cxx11_abi_sources} \
+ ${host_sources}
+
+if ENABLE_DUAL_ABI
+extra_string_inst_sources = \
+ cow-fstream-inst.cc \
+ cow-sstream-inst.cc \
+ cow-string-inst.cc \
+ cow-wstring-inst.cc \
+ cxx11-locale-inst.cc \
+ cxx11-wlocale-inst.cc
+else
+extra_string_inst_sources =
+endif
if ENABLE_EXTERN_TEMPLATE
# XTEMPLATE_FLAGS = -fno-implicit-templates
inst_sources = \
+ $(extra_string_inst_sources) \
+ ext11-inst.cc \
fstream-inst.cc \
+ ios-inst.cc \
+ iostream-inst.cc \
+ istream-inst.cc \
+ locale-inst.cc \
+ ostream-inst.cc \
+ sstream-inst.cc \
+ streambuf-inst.cc \
string-inst.cc \
+ wlocale-inst.cc \
wstring-inst.cc
else
# XTEMPLATE_FLAGS =
diff --git a/libstdc++-v3/src/c++11/Makefile.in b/libstdc++-v3/src/c++11/Makefile.in
index d2ccd9ca430..61c23578136 100644
--- a/libstdc++-v3/src/c++11/Makefile.in
+++ b/libstdc++-v3/src/c++11/Makefile.in
@@ -84,14 +84,29 @@ CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
LTLIBRARIES = $(noinst_LTLIBRARIES)
libc__11convenience_la_LIBADD =
-am__objects_1 = chrono.lo condition_variable.lo debug.lo \
- functexcept.lo functional.lo future.lo hash_c++0x.lo \
- hashtable_c++0x.lo limits.lo mutex.lo placeholders.lo \
- random.lo regex.lo shared_ptr.lo snprintf_lite.lo \
- system_error.lo thread.lo
-@ENABLE_EXTERN_TEMPLATE_TRUE@am__objects_2 = fstream-inst.lo \
-@ENABLE_EXTERN_TEMPLATE_TRUE@ string-inst.lo wstring-inst.lo
-am_libc__11convenience_la_OBJECTS = $(am__objects_1) $(am__objects_2)
+@ENABLE_DUAL_ABI_TRUE@am__objects_1 = cow-locale_init.lo \
+@ENABLE_DUAL_ABI_TRUE@ cow-shim_facets.lo cxx11-hash_tr1.lo \
+@ENABLE_DUAL_ABI_TRUE@ cxx11-ios_failure.lo \
+@ENABLE_DUAL_ABI_TRUE@ cxx11-shim_facets.lo cxx11-stdexcept.lo
+am__objects_2 = ctype_configure_char.lo ctype_members.lo
+am__objects_3 = chrono.lo codecvt.lo condition_variable.lo \
+ cow-stdexcept.lo ctype.lo debug.lo functexcept.lo \
+ functional.lo futex.lo future.lo hash_c++0x.lo hashtable_c++0x.lo \
+ ios.lo limits.lo mutex.lo placeholders.lo random.lo regex.lo \
+ shared_ptr.lo snprintf_lite.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_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
+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)
depcomp =
@@ -256,6 +271,7 @@ glibcxx_POFILES = @glibcxx_POFILES@
glibcxx_builddir = @glibcxx_builddir@
glibcxx_compiler_pic_flag = @glibcxx_compiler_pic_flag@
glibcxx_compiler_shared_flag = @glibcxx_compiler_shared_flag@
+glibcxx_cxx98_abi = @glibcxx_cxx98_abi@
glibcxx_localedir = @glibcxx_localedir@
glibcxx_lt_pic_flag = @glibcxx_lt_pic_flag@
glibcxx_prefixdir = @glibcxx_prefixdir@
@@ -332,15 +348,36 @@ AM_CPPFLAGS = $(GLIBCXX_INCLUDES)
# Convenience library for C++11 runtime.
noinst_LTLIBRARIES = libc++11convenience.la
headers =
+
+# Source files linked in via configuration/make substitution for a
+# particular host.
+host_sources = \
+ ctype_configure_char.cc \
+ ctype_members.cc
+
+@ENABLE_DUAL_ABI_FALSE@cxx11_abi_sources =
+@ENABLE_DUAL_ABI_TRUE@cxx11_abi_sources = \
+@ENABLE_DUAL_ABI_TRUE@ cow-locale_init.cc \
+@ENABLE_DUAL_ABI_TRUE@ cow-shim_facets.cc \
+@ENABLE_DUAL_ABI_TRUE@ cxx11-hash_tr1.cc \
+@ENABLE_DUAL_ABI_TRUE@ cxx11-ios_failure.cc \
+@ENABLE_DUAL_ABI_TRUE@ cxx11-shim_facets.cc \
+@ENABLE_DUAL_ABI_TRUE@ cxx11-stdexcept.cc
+
sources = \
chrono.cc \
+ codecvt.cc \
condition_variable.cc \
+ cow-stdexcept.cc \
+ ctype.cc \
debug.cc \
functexcept.cc \
functional.cc \
+ futex.cc \
future.cc \
hash_c++0x.cc \
hashtable_c++0x.cc \
+ ios.cc \
limits.cc \
mutex.cc \
placeholders.cc \
@@ -349,15 +386,36 @@ sources = \
shared_ptr.cc \
snprintf_lite.cc \
system_error.cc \
- thread.cc
+ thread.cc \
+ ${cxx11_abi_sources} \
+ ${host_sources}
+
+@ENABLE_DUAL_ABI_FALSE@extra_string_inst_sources =
+@ENABLE_DUAL_ABI_TRUE@extra_string_inst_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-wstring-inst.cc \
+@ENABLE_DUAL_ABI_TRUE@ cxx11-locale-inst.cc \
+@ENABLE_DUAL_ABI_TRUE@ cxx11-wlocale-inst.cc
# XTEMPLATE_FLAGS =
@ENABLE_EXTERN_TEMPLATE_FALSE@inst_sources =
# XTEMPLATE_FLAGS = -fno-implicit-templates
@ENABLE_EXTERN_TEMPLATE_TRUE@inst_sources = \
+@ENABLE_EXTERN_TEMPLATE_TRUE@ $(extra_string_inst_sources) \
+@ENABLE_EXTERN_TEMPLATE_TRUE@ ext11-inst.cc \
@ENABLE_EXTERN_TEMPLATE_TRUE@ fstream-inst.cc \
+@ENABLE_EXTERN_TEMPLATE_TRUE@ ios-inst.cc \
+@ENABLE_EXTERN_TEMPLATE_TRUE@ iostream-inst.cc \
+@ENABLE_EXTERN_TEMPLATE_TRUE@ istream-inst.cc \
+@ENABLE_EXTERN_TEMPLATE_TRUE@ locale-inst.cc \
+@ENABLE_EXTERN_TEMPLATE_TRUE@ ostream-inst.cc \
+@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@ wlocale-inst.cc \
@ENABLE_EXTERN_TEMPLATE_TRUE@ wstring-inst.cc
libc__11convenience_la_SOURCES = $(sources) $(inst_sources)
@@ -662,6 +720,12 @@ uninstall-am:
pdf pdf-am ps ps-am tags uninstall uninstall-am
+ctype_configure_char.cc: ${glibcxx_srcdir}/$(OS_INC_SRCDIR)/ctype_configure_char.cc
+ $(LN_S) ${glibcxx_srcdir}/$(OS_INC_SRCDIR)/ctype_configure_char.cc . || true
+
+ctype_members.cc: ${glibcxx_srcdir}/$(CCTYPE_CC)
+ $(LN_S) ${glibcxx_srcdir}/$(CCTYPE_CC) . || true
+
vpath % $(top_srcdir)/src/c++11
# Use special rules for the hashtable.cc file so that all
diff --git a/libstdc++-v3/src/c++11/chrono.cc b/libstdc++-v3/src/c++11/chrono.cc
index bc03b57df0c..a2c105f1e38 100644
--- a/libstdc++-v3/src/c++11/chrono.cc
+++ b/libstdc++-v3/src/c++11/chrono.cc
@@ -1,6 +1,6 @@
// chrono -*- C++ -*-
-// Copyright (C) 2008-2014 Free Software Foundation, Inc.
+// Copyright (C) 2008-2015 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
diff --git a/libstdc++-v3/src/c++11/codecvt.cc b/libstdc++-v3/src/c++11/codecvt.cc
new file mode 100644
index 00000000000..7eed903bc0c
--- /dev/null
+++ b/libstdc++-v3/src/c++11/codecvt.cc
@@ -0,0 +1,1408 @@
+// Locale support (codecvt) -*- C++ -*-
+
+// Copyright (C) 2015 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/>.
+
+#include <codecvt>
+#include <cstring> // std::memcpy, std::memcmp
+#include <bits/stl_algobase.h> // std::max
+
+#ifdef _GLIBCXX_USE_C99_STDINT_TR1
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+namespace
+{
+ // Largest code point that fits in a single UTF-16 code unit.
+ const char32_t max_single_utf16_unit = 0xFFFF;
+ const char32_t max_code_point = 0x10FFFF;
+
+ template<typename Elem>
+ struct range
+ {
+ Elem* next;
+ Elem* end;
+
+ Elem operator*() const { return *next; }
+
+ range& operator++() { ++next; return *this; }
+
+ size_t size() const { return end - next; }
+ };
+
+ // Multibyte sequences can have "header" consisting of Byte Order Mark
+ const unsigned char utf8_bom[3] = { 0xEF, 0xBB, 0xBF };
+ const unsigned char utf16_bom[4] = { 0xFE, 0xFF };
+ const unsigned char utf16le_bom[4] = { 0xFF, 0xFE };
+
+ template<size_t N>
+ inline bool
+ write_bom(range<char>& to, const unsigned char (&bom)[N])
+ {
+ if (to.size() < N)
+ return false;
+ memcpy(to.next, bom, N);
+ to.next += N;
+ return true;
+ }
+
+ // If generate_header is set in mode write out UTF-8 BOM.
+ bool
+ write_utf8_bom(range<char>& to, codecvt_mode mode)
+ {
+ if (mode & generate_header)
+ return write_bom(to, utf8_bom);
+ return true;
+ }
+
+ // If generate_header is set in mode write out the UTF-16 BOM indicated
+ // by whether little_endian is set in mode.
+ bool
+ write_utf16_bom(range<char16_t>& to, codecvt_mode mode)
+ {
+ if (mode & generate_header)
+ {
+ if (!to.size())
+ return false;
+ auto* bom = (mode & little_endian) ? utf16le_bom : utf16_bom;
+ std::memcpy(to.next, bom, 2);
+ ++to.next;
+ }
+ return true;
+ }
+
+ template<size_t N>
+ inline bool
+ read_bom(range<const char>& from, const unsigned char (&bom)[N])
+ {
+ if (from.size() >= N && !memcmp(from.next, bom, N))
+ {
+ from.next += N;
+ return true;
+ }
+ return false;
+ }
+
+ // If consume_header is set in mode update from.next to after any BOM.
+ void
+ read_utf8_bom(range<const char>& from, codecvt_mode mode)
+ {
+ if (mode & consume_header)
+ read_bom(from, utf8_bom);
+ }
+
+ // If consume_header is set in mode update from.next to after any BOM.
+ // Return little_endian iff the UTF-16LE BOM was present.
+ codecvt_mode
+ read_utf16_bom(range<const char16_t>& from, codecvt_mode mode)
+ {
+ if (mode & consume_header && from.size())
+ {
+ if (*from.next == 0xFEFF)
+ ++from.next;
+ else if (*from.next == 0xFFFE)
+ {
+ ++from.next;
+ return little_endian;
+ }
+ }
+ return {};
+ }
+
+ // Read a codepoint from a UTF-8 multibyte sequence.
+ // Updates from.next if the codepoint is not greater than maxcode.
+ // Returns -1 if there is an invalid or incomplete multibyte character.
+ char32_t
+ read_utf8_code_point(range<const char>& from, unsigned long maxcode)
+ {
+ size_t avail = from.size();
+ if (avail == 0)
+ return -1;
+ unsigned char c1 = from.next[0];
+ // https://en.wikipedia.org/wiki/UTF-8#Sample_code
+ if (c1 < 0x80)
+ {
+ ++from.next;
+ return c1;
+ }
+ else if (c1 < 0xC2) // continuation or overlong 2-byte sequence
+ return -1;
+ else if (c1 < 0xE0) // 2-byte sequence
+ {
+ if (avail < 2)
+ return -1;
+ unsigned char c2 = from.next[1];
+ if ((c2 & 0xC0) != 0x80)
+ return -1;
+ char32_t c = (c1 << 6) + c2 - 0x3080;
+ if (c <= maxcode)
+ from.next += 2;
+ return c;
+ }
+ else if (c1 < 0xF0) // 3-byte sequence
+ {
+ if (avail < 3)
+ return -1;
+ unsigned char c2 = from.next[1];
+ if ((c2 & 0xC0) != 0x80)
+ return -1;
+ if (c1 == 0xE0 && c2 < 0xA0) // overlong
+ return -1;
+ unsigned char c3 = from.next[2];
+ if ((c3 & 0xC0) != 0x80)
+ return -1;
+ char32_t c = (c1 << 12) + (c2 << 6) + c3 - 0xE2080;
+ if (c <= maxcode)
+ from.next += 3;
+ return c;
+ }
+ else if (c1 < 0xF5) // 4-byte sequence
+ {
+ if (avail < 4)
+ return -1;
+ unsigned char c2 = from.next[1];
+ if ((c2 & 0xC0) != 0x80)
+ return -1;
+ if (c1 == 0xF0 && c2 < 0x90) // overlong
+ return -1;
+ if (c1 == 0xF4 && c2 >= 0x90) // > U+10FFFF
+ return -1;
+ unsigned char c3 = from.next[2];
+ if ((c3 & 0xC0) != 0x80)
+ return -1;
+ unsigned char c4 = from.next[3];
+ if ((c4 & 0xC0) != 0x80)
+ return -1;
+ char32_t c = (c1 << 18) + (c2 << 12) + (c3 << 6) + c4 - 0x3C82080;
+ if (c <= maxcode)
+ from.next += 4;
+ return c;
+ }
+ else // > U+10FFFF
+ return -1;
+ }
+
+ bool
+ write_utf8_code_point(range<char>& to, char32_t code_point)
+ {
+ if (code_point < 0x80)
+ {
+ if (to.size() < 1)
+ return false;
+ *to.next++ = code_point;
+ }
+ else if (code_point <= 0x7FF)
+ {
+ if (to.size() < 2)
+ return false;
+ *to.next++ = (code_point >> 6) + 0xC0;
+ *to.next++ = (code_point & 0x3F) + 0x80;
+ }
+ else if (code_point <= 0xFFFF)
+ {
+ if (to.size() < 3)
+ return false;
+ *to.next++ = (code_point >> 12) + 0xE0;
+ *to.next++ = ((code_point >> 6) & 0x3F) + 0x80;
+ *to.next++ = (code_point & 0x3F) + 0x80;
+ }
+ else if (code_point <= 0x10FFFF)
+ {
+ if (to.size() < 4)
+ return false;
+ *to.next++ = (code_point >> 18) + 0xF0;
+ *to.next++ = ((code_point >> 12) & 0x3F) + 0x80;
+ *to.next++ = ((code_point >> 6) & 0x3F) + 0x80;
+ *to.next++ = (code_point & 0x3F) + 0x80;
+ }
+ else
+ return false;
+ return true;
+ }
+
+ inline char16_t
+ adjust_byte_order(char16_t c, codecvt_mode mode)
+ {
+#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+ return (mode & little_endian) ? __builtin_bswap16(c) : c;
+#else
+ return (mode & little_endian) ? c : __builtin_bswap16(c);
+#endif
+ }
+
+ // Read a codepoint from a UTF-16 multibyte sequence.
+ // The sequence's endianness is indicated by (mode & little_endian).
+ // Updates from.next if the codepoint is not greater than maxcode.
+ // Returns -1 if there is an incomplete multibyte character.
+ char32_t
+ read_utf16_code_point(range<const char16_t>& from, unsigned long maxcode,
+ codecvt_mode mode)
+ {
+ int inc = 1;
+ char32_t c = adjust_byte_order(from.next[0], mode);
+ if (c >= 0xD800 && c <= 0xDBFF)
+ {
+ if (from.size() < 2)
+ return -1;
+ const char16_t c2 = adjust_byte_order(from.next[1], mode);
+ if (c2 >= 0xDC00 && c2 <= 0xDFFF)
+ {
+ c = (c << 10) + c2 - 0x35FDC00;
+ inc = 2;
+ }
+ }
+ if (c <= maxcode)
+ from.next += inc;
+ return c;
+ }
+
+ template<typename C>
+ bool
+ write_utf16_code_point(range<C>& to, char32_t codepoint, codecvt_mode mode)
+ {
+ static_assert(sizeof(C) >= 2, "a code unit must be at least 16-bit");
+
+ if (codepoint < max_single_utf16_unit)
+ {
+ if (to.size() > 0)
+ {
+ *to.next = codepoint;
+ ++to.next;
+ return true;
+ }
+ }
+ else if (to.size() > 1)
+ {
+ // Algorithm from http://www.unicode.org/faq/utf_bom.html#utf16-4
+ const char32_t LEAD_OFFSET = 0xD800 - (0x10000 >> 10);
+ const char32_t SURROGATE_OFFSET = 0x10000 - (0xD800 << 10) - 0xDC00;
+ char16_t lead = LEAD_OFFSET + (codepoint >> 10);
+ char16_t trail = 0xDC00 + (codepoint & 0x3FF);
+ char32_t utf16bytes = (lead << 10) + trail + SURROGATE_OFFSET;
+
+ to.next[0] = adjust_byte_order(utf16bytes >> 16, mode);
+ to.next[1] = adjust_byte_order(utf16bytes & 0xFFFF, mode);
+ to.next += 2;
+ return true;
+ }
+ return false;
+ }
+
+ // utf8 -> ucs4
+ codecvt_base::result
+ ucs4_in(range<const char>& from, range<char32_t>& to,
+ unsigned long maxcode = max_code_point, codecvt_mode mode = {})
+ {
+ read_utf8_bom(from, mode);
+ while (from.size() && to.size())
+ {
+ const char32_t codepoint = read_utf8_code_point(from, maxcode);
+ if (codepoint == char32_t(-1))
+ break;
+ if (codepoint > maxcode)
+ return codecvt_base::error;
+ *to.next++ = codepoint;
+ }
+ return from.size() ? codecvt_base::partial : codecvt_base::ok;
+ }
+
+ // ucs4 -> utf8
+ codecvt_base::result
+ ucs4_out(range<const char32_t>& from, range<char>& to,
+ unsigned long maxcode = max_code_point, codecvt_mode mode = {})
+ {
+ if (!write_utf8_bom(to, mode))
+ return codecvt_base::partial;
+ while (from.size())
+ {
+ const char32_t c = from.next[0];
+ if (c > maxcode)
+ return codecvt_base::error;
+ if (!write_utf8_code_point(to, c))
+ return codecvt_base::partial;
+ ++from.next;
+ }
+ return codecvt_base::ok;
+ }
+
+ // utf16 -> ucs4
+ codecvt_base::result
+ ucs4_in(range<const char16_t>& from, range<char32_t>& to,
+ unsigned long maxcode = max_code_point, codecvt_mode mode = {})
+ {
+ if (read_utf16_bom(from, mode) == little_endian)
+ mode = codecvt_mode(mode & little_endian);
+ while (from.size() && to.size())
+ {
+ const char32_t codepoint = read_utf16_code_point(from, maxcode, mode);
+ if (codepoint == char32_t(-1))
+ break;
+ if (codepoint > maxcode)
+ return codecvt_base::error;
+ *to.next++ = codepoint;
+ }
+ return from.size() ? codecvt_base::partial : codecvt_base::ok;
+ }
+
+ // ucs4 -> utf16
+ codecvt_base::result
+ ucs4_out(range<const char32_t>& from, range<char16_t>& to,
+ unsigned long maxcode = max_code_point, codecvt_mode mode = {})
+ {
+ if (!write_utf16_bom(to, mode))
+ return codecvt_base::partial;
+ while (from.size())
+ {
+ const char32_t c = from.next[0];
+ if (c > maxcode)
+ return codecvt_base::error;
+ if (!write_utf16_code_point(to, c, mode))
+ return codecvt_base::partial;
+ ++from.next;
+ }
+ return codecvt_base::ok;
+ }
+
+ // utf8 -> utf16
+ template<typename C>
+ codecvt_base::result
+ utf16_in(range<const char>& from, range<C>& to,
+ unsigned long maxcode = max_code_point, codecvt_mode mode = {})
+ {
+ read_utf8_bom(from, mode);
+ while (from.size() && to.size())
+ {
+ const char* first = from.next;
+ if ((unsigned char)*first >= 0xF0 && to.size() < 2)
+ return codecvt_base::partial;
+ const char32_t codepoint = read_utf8_code_point(from, maxcode);
+ if (codepoint == char32_t(-1))
+ return codecvt_base::partial;
+ if (codepoint > maxcode)
+ return codecvt_base::error;
+ if (!write_utf16_code_point(to, codepoint, {}))
+ {
+ from.next = first;
+ return codecvt_base::partial;
+ }
+ }
+ return codecvt_base::ok;
+ }
+
+ // utf16 -> utf8
+ template<typename C>
+ codecvt_base::result
+ utf16_out(range<const C>& from, range<char>& to,
+ unsigned long maxcode = max_code_point, codecvt_mode mode = {})
+ {
+ if (!write_utf8_bom(to, mode))
+ return codecvt_base::partial;
+ while (from.size())
+ {
+ char32_t c = from.next[0];
+ int inc = 1;
+ if (c >= 0xD800 && c <= 0xDBFF) // start of surrogate pair
+ {
+ if (from.size() < 2)
+ return codecvt_base::ok; // stop converting at this point
+
+ const char32_t c2 = from.next[1];
+ if (c2 >= 0xDC00 && c2 <= 0xDFFF)
+ {
+ inc = 2;
+ c = (c << 10) + c2 - 0x35FDC00;
+ }
+ else
+ return codecvt_base::error;
+ }
+ if (c > maxcode)
+ return codecvt_base::error;
+ if (!write_utf8_code_point(to, c))
+ return codecvt_base::partial;
+ from.next += inc;
+ }
+ return codecvt_base::ok;
+ }
+
+ // 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,
+ char32_t maxcode = max_code_point, codecvt_mode mode = {})
+ {
+ range<const char> from{ begin, end };
+ read_utf8_bom(from, mode);
+ size_t count = 0;
+ while (count+1 < max)
+ {
+ char32_t c = read_utf8_code_point(from, maxcode);
+ if (c == char32_t(-1))
+ break;
+ else if (c > max_single_utf16_unit)
+ ++count;
+ ++count;
+ }
+ if (count+1 == max) // take one more character if it fits in a single unit
+ read_utf8_code_point(from, std::max(max_single_utf16_unit, maxcode));
+ return from.next;
+ }
+
+ // utf8 -> ucs2
+ codecvt_base::result
+ ucs2_in(range<const char>& from, range<char16_t>& to,
+ char32_t maxcode = max_code_point, codecvt_mode mode = {})
+ {
+ return utf16_in(from, to, std::max(max_single_utf16_unit, maxcode), mode);
+ }
+
+ // ucs2 -> utf8
+ codecvt_base::result
+ ucs2_out(range<const char16_t>& from, range<char>& to,
+ char32_t maxcode = max_code_point, codecvt_mode mode = {})
+ {
+ return utf16_out(from, to, std::max(max_single_utf16_unit, maxcode), mode);
+ }
+
+ // ucs2 -> utf16
+ codecvt_base::result
+ ucs2_out(range<const char16_t>& from, range<char16_t>& to,
+ char32_t maxcode = max_code_point, codecvt_mode mode = {})
+ {
+ if (!write_utf16_bom(to, mode))
+ return codecvt_base::partial;
+ while (from.size() && to.size())
+ {
+ char16_t c = from.next[0];
+ if (c >= 0xD800 && c <= 0xDBFF) // start of surrogate pair
+ return codecvt_base::error;
+ if (c > maxcode)
+ return codecvt_base::error;
+ *to.next++ = adjust_byte_order(c, mode);
+ ++from.next;
+ }
+ return from.size() == 0 ? codecvt_base::ok : codecvt_base::partial;
+ }
+
+ // utf16 -> ucs2
+ codecvt_base::result
+ ucs2_in(range<const char16_t>& from, range<char16_t>& to,
+ char32_t maxcode = max_code_point, codecvt_mode mode = {})
+ {
+ if (read_utf16_bom(from, mode) == little_endian)
+ mode = codecvt_mode(mode & little_endian);
+ maxcode = std::max(max_single_utf16_unit, maxcode);
+ while (from.size() && to.size())
+ {
+ const char32_t c = read_utf16_code_point(from, maxcode, mode);
+ if (c == char32_t(-1))
+ break;
+ if (c >= maxcode)
+ return codecvt_base::error;
+ *to.next++ = c;
+ }
+ return from.size() == 0 ? codecvt_base::ok : codecvt_base::partial;
+ }
+
+ const char16_t*
+ ucs2_span(const char16_t* begin, const char16_t* end, size_t max,
+ char32_t maxcode, codecvt_mode mode)
+ {
+ range<const char16_t> from{ begin, end };
+ if (read_utf16_bom(from, mode) == little_endian)
+ mode = codecvt_mode(mode & little_endian);
+ maxcode = std::max(max_single_utf16_unit, maxcode);
+ char32_t c = 0;
+ while (max-- && c <= maxcode)
+ c = read_utf16_code_point(from, maxcode, mode);
+ return from.next;
+ }
+
+ const char*
+ ucs2_span(const char* begin, const char* end, size_t max,
+ char32_t maxcode, codecvt_mode mode)
+ {
+ range<const char> from{ begin, end };
+ read_utf8_bom(from, mode);
+ maxcode = std::max(max_single_utf16_unit, maxcode);
+ char32_t c = 0;
+ while (max-- && c <= maxcode)
+ c = read_utf8_code_point(from, maxcode);
+ return from.next;
+ }
+
+ // 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,
+ char32_t maxcode = max_code_point, codecvt_mode mode = {})
+ {
+ range<const char> from{ begin, end };
+ read_utf8_bom(from, mode);
+ char32_t c = 0;
+ while (max-- && c <= maxcode)
+ c = read_utf8_code_point(from, maxcode);
+ return from.next;
+ }
+
+ // return pos such that [begin,pos) is valid UCS-4 string no longer than max
+ const char16_t*
+ ucs4_span(const char16_t* begin, const char16_t* end, size_t max,
+ char32_t maxcode = max_code_point, codecvt_mode mode = {})
+ {
+ range<const char16_t> from{ begin, end };
+ if (read_utf16_bom(from, mode) == little_endian)
+ mode = codecvt_mode(mode & little_endian);
+ char32_t c = 0;
+ while (max-- && c <= maxcode)
+ c = read_utf16_code_point(from, maxcode, mode);
+ return from.next;
+ }
+}
+
+// Define members of codecvt<char16_t, char, mbstate_t> specialization.
+// Converts from UTF-8 to UTF-16.
+
+locale::id codecvt<char16_t, char, mbstate_t>::id;
+
+codecvt<char16_t, char, mbstate_t>::~codecvt() { }
+
+codecvt_base::result
+codecvt<char16_t, char, 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<char> 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, char, 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, char, 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 char> from{ __from, __from_end };
+ range<char16_t> to{ __to, __to_end };
+ auto res = utf16_in(from, to);
+ __from_next = from.next;
+ __to_next = to.next;
+ return res;
+}
+
+int
+codecvt<char16_t, char, mbstate_t>::do_encoding() const throw()
+{ return 0; }
+
+bool
+codecvt<char16_t, char, mbstate_t>::do_always_noconv() const throw()
+{ return false; }
+
+int
+codecvt<char16_t, char, 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, char, mbstate_t>::do_max_length() const throw()
+{
+ // Any valid UTF-8 sequence of 3 bytes fits in a single 16-bit code unit,
+ // whereas 4 byte sequences require two 16-bit code units.
+ return 3;
+}
+
+// Define members of codecvt<char32_t, char, mbstate_t> specialization.
+// Converts from UTF-8 to UTF-32 (aka UCS-4).
+
+locale::id codecvt<char32_t, char, mbstate_t>::id;
+
+codecvt<char32_t, char, mbstate_t>::~codecvt() { }
+
+codecvt_base::result
+codecvt<char32_t, char, 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<char> 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, char, 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, char, 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 char> 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, char, mbstate_t>::do_encoding() const throw()
+{ return 0; }
+
+bool
+codecvt<char32_t, char, mbstate_t>::do_always_noconv() const throw()
+{ return false; }
+
+int
+codecvt<char32_t, char, 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, char, mbstate_t>::do_max_length() const throw()
+{ return 4; }
+
+// Define members of codecvt_utf8<char16_t> base class implementation.
+// Converts from UTF-8 to UCS-2.
+
+__codecvt_utf8_base<char16_t>::~__codecvt_utf8_base() { }
+
+codecvt_base::result
+__codecvt_utf8_base<char16_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<char> to{ __to, __to_end };
+ auto res = ucs2_out(from, to, _M_maxcode, _M_mode);
+ __from_next = from.next;
+ __to_next = to.next;
+ return res;
+}
+
+codecvt_base::result
+__codecvt_utf8_base<char16_t>::
+do_unshift(state_type&, extern_type* __to, extern_type*,
+ extern_type*& __to_next) const
+{
+ __to_next = __to;
+ return noconv;
+}
+
+codecvt_base::result
+__codecvt_utf8_base<char16_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 char> from{ __from, __from_end };
+ range<char16_t> to{ __to, __to_end };
+ auto res = ucs2_in(from, to, _M_maxcode, _M_mode);
+ __from_next = from.next;
+ __to_next = to.next;
+ return res;
+}
+
+int
+__codecvt_utf8_base<char16_t>::do_encoding() const throw()
+{ return 0; }
+
+bool
+__codecvt_utf8_base<char16_t>::do_always_noconv() const throw()
+{ return false; }
+
+int
+__codecvt_utf8_base<char16_t>::
+do_length(state_type&, const extern_type* __from,
+ const extern_type* __end, size_t __max) const
+{
+ __end = ucs2_span(__from, __end, __max, _M_maxcode, _M_mode);
+ return __end - __from;
+}
+
+int
+__codecvt_utf8_base<char16_t>::do_max_length() const throw()
+{ return 3; }
+
+// Define members of codecvt_utf8<char32_t> base class implementation.
+// Converts from UTF-8 to UTF-32 (aka UCS-4).
+
+__codecvt_utf8_base<char32_t>::~__codecvt_utf8_base() { }
+
+codecvt_base::result
+__codecvt_utf8_base<char32_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<char> to{ __to, __to_end };
+ auto res = ucs4_out(from, to, _M_maxcode, _M_mode);
+ __from_next = from.next;
+ __to_next = to.next;
+ return res;
+}
+
+codecvt_base::result
+__codecvt_utf8_base<char32_t>::
+do_unshift(state_type&, extern_type* __to, extern_type*,
+ extern_type*& __to_next) const
+{
+ __to_next = __to;
+ return noconv;
+}
+
+codecvt_base::result
+__codecvt_utf8_base<char32_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 char> from{ __from, __from_end };
+ range<char32_t> to{ __to, __to_end };
+ auto res = ucs4_in(from, to, _M_maxcode, _M_mode);
+ __from_next = from.next;
+ __to_next = to.next;
+ return res;
+}
+
+int
+__codecvt_utf8_base<char32_t>::do_encoding() const throw()
+{ return 0; }
+
+bool
+__codecvt_utf8_base<char32_t>::do_always_noconv() const throw()
+{ return false; }
+
+int
+__codecvt_utf8_base<char32_t>::
+do_length(state_type&, const extern_type* __from,
+ const extern_type* __end, size_t __max) const
+{
+ __end = ucs4_span(__from, __end, __max, _M_maxcode, _M_mode);
+ return __end - __from;
+}
+
+int
+__codecvt_utf8_base<char32_t>::do_max_length() const throw()
+{ return 4; }
+
+#ifdef _GLIBCXX_USE_WCHAR_T
+// Define members of codecvt_utf8<wchar_t> base class implementation.
+// Converts from UTF-8 to UCS-2 or UCS-4 depending on sizeof(wchar_t).
+
+__codecvt_utf8_base<wchar_t>::~__codecvt_utf8_base() { }
+
+codecvt_base::result
+__codecvt_utf8_base<wchar_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<char> to{ __to, __to_end };
+#if __SIZEOF_WCHAR_T__ == 2
+ range<const char16_t> from{
+ reinterpret_cast<const char16_t*>(__from),
+ reinterpret_cast<const char16_t*>(__from_end)
+ };
+ auto res = ucs2_out(from, to, _M_maxcode, _M_mode);
+#elif __SIZEOF_WCHAR_T__ == 4
+ range<const char32_t> from{
+ reinterpret_cast<const char32_t*>(__from),
+ reinterpret_cast<const char32_t*>(__from_end)
+ };
+ auto res = ucs4_out(from, to, _M_maxcode, _M_mode);
+#else
+ return codecvt_base::error;
+#endif
+ __from_next = reinterpret_cast<const wchar_t*>(from.next);
+ __to_next = to.next;
+ return res;
+}
+
+codecvt_base::result
+__codecvt_utf8_base<wchar_t>::
+do_unshift(state_type&, extern_type* __to, extern_type*,
+ extern_type*& __to_next) const
+{
+ __to_next = __to;
+ return noconv;
+}
+
+codecvt_base::result
+__codecvt_utf8_base<wchar_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 char> from{ __from, __from_end };
+#if __SIZEOF_WCHAR_T__ == 2
+ range<char16_t> to{
+ reinterpret_cast<char16_t*>(__to),
+ reinterpret_cast<char16_t*>(__to_end)
+ };
+ auto res = ucs2_in(from, to, _M_maxcode, _M_mode);
+#elif __SIZEOF_WCHAR_T__ == 4
+ range<char32_t> to{
+ reinterpret_cast<char32_t*>(__to),
+ reinterpret_cast<char32_t*>(__to_end)
+ };
+ auto res = ucs4_in(from, to, _M_maxcode, _M_mode);
+#else
+ return codecvt_base::error;
+#endif
+ __from_next = from.next;
+ __to_next = reinterpret_cast<wchar_t*>(to.next);
+ return res;
+}
+
+int
+__codecvt_utf8_base<wchar_t>::do_encoding() const throw()
+{ return 0; }
+
+bool
+__codecvt_utf8_base<wchar_t>::do_always_noconv() const throw()
+{ return false; }
+
+int
+__codecvt_utf8_base<wchar_t>::
+do_length(state_type&, const extern_type* __from,
+ const extern_type* __end, size_t __max) const
+{
+#if __SIZEOF_WCHAR_T__ == 2
+ __end = ucs2_span(__from, __end, __max, _M_maxcode, _M_mode);
+#elif __SIZEOF_WCHAR_T__ == 4
+ __end = ucs4_span(__from, __end, __max, _M_maxcode, _M_mode);
+#else
+ __end = __from;
+#endif
+ return __end - __from;
+}
+
+int
+__codecvt_utf8_base<wchar_t>::do_max_length() const throw()
+{ return 4; }
+#endif
+
+// Define members of codecvt_utf16<char16_t> base class implementation.
+// Converts from UTF-16 to UCS-2.
+
+__codecvt_utf16_base<char16_t>::~__codecvt_utf16_base() { }
+
+codecvt_base::result
+__codecvt_utf16_base<char16_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<char16_t> to{
+ reinterpret_cast<char16_t*>(__to),
+ reinterpret_cast<char16_t*>(__to_end)
+ };
+ auto res = ucs2_out(from, to, _M_maxcode, _M_mode);
+ __from_next = from.next;
+ __to_next = reinterpret_cast<char*>(to.next);
+ return res;
+}
+
+codecvt_base::result
+__codecvt_utf16_base<char16_t>::
+do_unshift(state_type&, extern_type* __to, extern_type*,
+ extern_type*& __to_next) const
+{
+ __to_next = __to;
+ return noconv;
+}
+
+codecvt_base::result
+__codecvt_utf16_base<char16_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 char16_t> from{
+ reinterpret_cast<const char16_t*>(__from),
+ reinterpret_cast<const char16_t*>(__from_end)
+ };
+ range<char16_t> to{ __to, __to_end };
+ auto res = ucs2_in(from, to, _M_maxcode, _M_mode);
+ __from_next = reinterpret_cast<const char*>(from.next);
+ __to_next = to.next;
+ return res;
+}
+
+int
+__codecvt_utf16_base<char16_t>::do_encoding() const throw()
+{ return 1; }
+
+bool
+__codecvt_utf16_base<char16_t>::do_always_noconv() const throw()
+{ return false; }
+
+int
+__codecvt_utf16_base<char16_t>::
+do_length(state_type&, const extern_type* __from,
+ const extern_type* __end, size_t __max) const
+{
+ auto next = reinterpret_cast<const char16_t*>(__from);
+ next = ucs2_span(next, reinterpret_cast<const char16_t*>(__end), __max,
+ _M_maxcode, _M_mode);
+ return reinterpret_cast<const char*>(next) - __from;
+}
+
+int
+__codecvt_utf16_base<char16_t>::do_max_length() const throw()
+{ return 3; }
+
+// Define members of codecvt_utf16<char32_t> base class implementation.
+// Converts from UTF-16 to UTF-32 (aka UCS-4).
+
+__codecvt_utf16_base<char32_t>::~__codecvt_utf16_base() { }
+
+codecvt_base::result
+__codecvt_utf16_base<char32_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<char16_t> to{
+ reinterpret_cast<char16_t*>(__to),
+ reinterpret_cast<char16_t*>(__to_end)
+ };
+ auto res = ucs4_out(from, to, _M_maxcode, _M_mode);
+ __from_next = from.next;
+ __to_next = reinterpret_cast<char*>(to.next);
+ return res;
+}
+
+codecvt_base::result
+__codecvt_utf16_base<char32_t>::
+do_unshift(state_type&, extern_type* __to, extern_type*,
+ extern_type*& __to_next) const
+{
+ __to_next = __to;
+ return noconv;
+}
+
+codecvt_base::result
+__codecvt_utf16_base<char32_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 char16_t> from{
+ reinterpret_cast<const char16_t*>(__from),
+ reinterpret_cast<const char16_t*>(__from_end)
+ };
+ range<char32_t> to{ __to, __to_end };
+ auto res = ucs4_in(from, to, _M_maxcode, _M_mode);
+ __from_next = reinterpret_cast<const char*>(from.next);
+ __to_next = to.next;
+ return res;
+}
+
+int
+__codecvt_utf16_base<char32_t>::do_encoding() const throw()
+{ return 0; }
+
+bool
+__codecvt_utf16_base<char32_t>::do_always_noconv() const throw()
+{ return false; }
+
+int
+__codecvt_utf16_base<char32_t>::
+do_length(state_type&, const extern_type* __from,
+ const extern_type* __end, size_t __max) const
+{
+ auto next = reinterpret_cast<const char16_t*>(__from);
+ next = ucs4_span(next, reinterpret_cast<const char16_t*>(__end), __max,
+ _M_maxcode, _M_mode);
+ return reinterpret_cast<const char*>(next) - __from;
+}
+
+int
+__codecvt_utf16_base<char32_t>::do_max_length() const throw()
+{ return 3; }
+
+#ifdef _GLIBCXX_USE_WCHAR_T
+// Define members of codecvt_utf16<wchar_t> base class implementation.
+// Converts from UTF-8 to UCS-2 or UCS-4 depending on sizeof(wchar_t).
+
+__codecvt_utf16_base<wchar_t>::~__codecvt_utf16_base() { }
+
+codecvt_base::result
+__codecvt_utf16_base<wchar_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<char> to{ __to, __to_end };
+#if __SIZEOF_WCHAR_T__ == 2
+ range<const char16_t> from{
+ reinterpret_cast<const char16_t*>(__from),
+ reinterpret_cast<const char16_t*>(__from_end)
+ };
+ auto res = ucs2_out(from, to, _M_maxcode, _M_mode);
+#elif __SIZEOF_WCHAR_T__ == 4
+ range<const char32_t> from{
+ reinterpret_cast<const char32_t*>(__from),
+ reinterpret_cast<const char32_t*>(__from_end)
+ };
+ auto res = ucs4_out(from, to, _M_maxcode, _M_mode);
+#else
+ return codecvt_base::error;
+#endif
+ __from_next = reinterpret_cast<const wchar_t*>(from.next);
+ __to_next = to.next;
+ return res;
+}
+
+codecvt_base::result
+__codecvt_utf16_base<wchar_t>::
+do_unshift(state_type&, extern_type* __to, extern_type*,
+ extern_type*& __to_next) const
+{
+ __to_next = __to;
+ return noconv;
+}
+
+codecvt_base::result
+__codecvt_utf16_base<wchar_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 char> from{ __from, __from_end };
+#if __SIZEOF_WCHAR_T__ == 2
+ range<char16_t> to{
+ reinterpret_cast<char16_t*>(__to),
+ reinterpret_cast<char16_t*>(__to_end)
+ };
+ auto res = ucs2_in(from, to, _M_maxcode, _M_mode);
+#elif __SIZEOF_WCHAR_T__ == 4
+ range<char32_t> to{
+ reinterpret_cast<char32_t*>(__to),
+ reinterpret_cast<char32_t*>(__to_end)
+ };
+ auto res = ucs4_in(from, to, _M_maxcode, _M_mode);
+#else
+ return codecvt_base::error;
+#endif
+ __from_next = from.next;
+ __to_next = reinterpret_cast<wchar_t*>(to.next);
+ return res;
+}
+
+int
+__codecvt_utf16_base<wchar_t>::do_encoding() const throw()
+{ return 0; }
+
+bool
+__codecvt_utf16_base<wchar_t>::do_always_noconv() const throw()
+{ return false; }
+
+int
+__codecvt_utf16_base<wchar_t>::
+do_length(state_type&, const extern_type* __from,
+ const extern_type* __end, size_t __max) const
+{
+ auto next = reinterpret_cast<const char16_t*>(__from);
+#if __SIZEOF_WCHAR_T__ == 2
+ next = ucs2_span(next, reinterpret_cast<const char16_t*>(__end), __max,
+ _M_maxcode, _M_mode);
+#elif __SIZEOF_WCHAR_T__ == 4
+ next = ucs4_span(next, reinterpret_cast<const char16_t*>(__end), __max,
+ _M_maxcode, _M_mode);
+#endif
+ return reinterpret_cast<const char*>(next) - __from;
+}
+
+int
+__codecvt_utf16_base<wchar_t>::do_max_length() const throw()
+{ return 4; }
+#endif
+
+// Define members of codecvt_utf8_utf16<char16_t> base class implementation.
+// Converts from UTF-8 to UTF-16.
+
+__codecvt_utf8_utf16_base<char16_t>::~__codecvt_utf8_utf16_base() { }
+
+codecvt_base::result
+__codecvt_utf8_utf16_base<char16_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<char> to{ __to, __to_end };
+ auto res = utf16_out(from, to, _M_maxcode, _M_mode);
+ __from_next = from.next;
+ __to_next = to.next;
+ return res;
+}
+
+codecvt_base::result
+__codecvt_utf8_utf16_base<char16_t>::
+do_unshift(state_type&, extern_type* __to, extern_type*,
+ extern_type*& __to_next) const
+{
+ __to_next = __to;
+ return noconv;
+}
+
+codecvt_base::result
+__codecvt_utf8_utf16_base<char16_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 char> from{ __from, __from_end };
+ range<char16_t> to{ __to, __to_end };
+ auto res = utf16_in(from, to, _M_maxcode, _M_mode);
+ __from_next = from.next;
+ __to_next = to.next;
+ return res;
+}
+
+int
+__codecvt_utf8_utf16_base<char16_t>::do_encoding() const throw()
+{ return 0; }
+
+bool
+__codecvt_utf8_utf16_base<char16_t>::do_always_noconv() const throw()
+{ return false; }
+
+int
+__codecvt_utf8_utf16_base<char16_t>::
+do_length(state_type&, const extern_type* __from,
+ const extern_type* __end, size_t __max) const
+{
+ __end = utf16_span(__from, __end, __max, _M_maxcode, _M_mode);
+ return __end - __from;
+}
+
+int
+__codecvt_utf8_utf16_base<char16_t>::do_max_length() const throw()
+{
+ // Any valid UTF-8 sequence of 3 bytes fits in a single 16-bit code unit,
+ // whereas 4 byte sequences require two 16-bit code units.
+ return 3;
+}
+
+// Define members of codecvt_utf8_utf16<char32_t> base class implementation.
+// Converts from UTF-8 to UTF-16.
+
+__codecvt_utf8_utf16_base<char32_t>::~__codecvt_utf8_utf16_base() { }
+
+codecvt_base::result
+__codecvt_utf8_utf16_base<char32_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<char> to{ __to, __to_end };
+ auto res = utf16_out(from, to, _M_maxcode, _M_mode);
+ __from_next = from.next;
+ __to_next = to.next;
+ return res;
+}
+
+codecvt_base::result
+__codecvt_utf8_utf16_base<char32_t>::
+do_unshift(state_type&, extern_type* __to, extern_type*,
+ extern_type*& __to_next) const
+{
+ __to_next = __to;
+ return noconv;
+}
+
+codecvt_base::result
+__codecvt_utf8_utf16_base<char32_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 char> from{ __from, __from_end };
+ range<char32_t> to{ __to, __to_end };
+ auto res = utf16_in(from, to, _M_maxcode, _M_mode);
+ __from_next = from.next;
+ __to_next = to.next;
+ return res;
+}
+
+int
+__codecvt_utf8_utf16_base<char32_t>::do_encoding() const throw()
+{ return 0; }
+
+bool
+__codecvt_utf8_utf16_base<char32_t>::do_always_noconv() const throw()
+{ return false; }
+
+int
+__codecvt_utf8_utf16_base<char32_t>::
+do_length(state_type&, const extern_type* __from,
+ const extern_type* __end, size_t __max) const
+{
+ __end = utf16_span(__from, __end, __max, _M_maxcode, _M_mode);
+ return __end - __from;
+}
+
+int
+__codecvt_utf8_utf16_base<char32_t>::do_max_length() const throw()
+{
+ // Any valid UTF-8 sequence of 3 bytes fits in a single 16-bit code unit,
+ // whereas 4 byte sequences require two 16-bit code units.
+ return 3;
+}
+
+#ifdef _GLIBCXX_USE_WCHAR_T
+// Define members of codecvt_utf8_utf16<wchar_t> base class implementation.
+// Converts from UTF-8 to UTF-16.
+
+__codecvt_utf8_utf16_base<wchar_t>::~__codecvt_utf8_utf16_base() { }
+
+codecvt_base::result
+__codecvt_utf8_utf16_base<wchar_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 wchar_t> from{ __from, __from_end };
+ range<char> to{ __to, __to_end };
+ auto res = utf16_out(from, to, _M_maxcode, _M_mode);
+ __from_next = from.next;
+ __to_next = to.next;
+ return res;
+}
+
+codecvt_base::result
+__codecvt_utf8_utf16_base<wchar_t>::
+do_unshift(state_type&, extern_type* __to, extern_type*,
+ extern_type*& __to_next) const
+{
+ __to_next = __to;
+ return noconv;
+}
+
+codecvt_base::result
+__codecvt_utf8_utf16_base<wchar_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 char> from{ __from, __from_end };
+ range<wchar_t> to{ __to, __to_end };
+ auto res = utf16_in(from, to, _M_maxcode, _M_mode);
+ __from_next = from.next;
+ __to_next = to.next;
+ return res;
+}
+
+int
+__codecvt_utf8_utf16_base<wchar_t>::do_encoding() const throw()
+{ return 0; }
+
+bool
+__codecvt_utf8_utf16_base<wchar_t>::do_always_noconv() const throw()
+{ return false; }
+
+int
+__codecvt_utf8_utf16_base<wchar_t>::
+do_length(state_type&, const extern_type* __from,
+ const extern_type* __end, size_t __max) const
+{
+ __end = utf16_span(__from, __end, __max, _M_maxcode, _M_mode);
+ return __end - __from;
+}
+
+int
+__codecvt_utf8_utf16_base<wchar_t>::do_max_length() const throw()
+{
+ // Any valid UTF-8 sequence of 3 bytes fits in a single 16-bit code unit,
+ // whereas 4 byte sequences require two 16-bit code units.
+ return 3;
+}
+#endif
+
+inline template class __codecvt_abstract_base<char16_t, char, mbstate_t>;
+inline template class __codecvt_abstract_base<char32_t, char, mbstate_t>;
+
+_GLIBCXX_END_NAMESPACE_VERSION
+}
+#endif // _GLIBCXX_USE_C99_STDINT_TR1
diff --git a/libstdc++-v3/src/c++11/compatibility-atomic-c++0x.cc b/libstdc++-v3/src/c++11/compatibility-atomic-c++0x.cc
index 4d92cdfcb01..84230254090 100644
--- a/libstdc++-v3/src/c++11/compatibility-atomic-c++0x.cc
+++ b/libstdc++-v3/src/c++11/compatibility-atomic-c++0x.cc
@@ -1,6 +1,6 @@
// <atomic> compatibility -*- C++ -*-
-// Copyright (C) 2008-2014 Free Software Foundation, Inc.
+// Copyright (C) 2008-2015 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
diff --git a/libstdc++-v3/src/c++11/compatibility-c++0x.cc b/libstdc++-v3/src/c++11/compatibility-c++0x.cc
index 3c83561e703..9ed367b3ace 100644
--- a/libstdc++-v3/src/c++11/compatibility-c++0x.cc
+++ b/libstdc++-v3/src/c++11/compatibility-c++0x.cc
@@ -1,6 +1,6 @@
// Compatibility symbols for previous versions, C++0x bits -*- C++ -*-
-// Copyright (C) 2009-2014 Free Software Foundation, Inc.
+// Copyright (C) 2009-2015 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
@@ -23,8 +23,18 @@
// <http://www.gnu.org/licenses/>.
#define _GLIBCXX_COMPATIBILITY_CXX0X
+#define _GLIBCXX_USE_CXX11_ABI 0
+#define error_category error_categoryxx
+#define system_category system_categoryxx
+#define generic_category generic_categoryxx
+#define _V2 _V2xx
#include <string>
#include <system_error>
+#include <cstring>
+#undef error_category
+#undef system_category
+#undef generic_category
+#undef _V2
#if __cplusplus < 201103L
# error "compatibility-c++0x.cc must be compiled with -std=gnu++0x"
@@ -120,9 +130,125 @@ namespace std _GLIBCXX_VISIBILITY(default)
constexpr bool system_clock::is_monotonic;
} // namespace chrono
+ // gcc-5 replaces this with _V2::error_category
+ class error_category
+ {
+ public:
+ error_category() noexcept;
+
+ virtual ~error_category();
+
+ error_category(const error_category&) = delete;
+ error_category& operator=(const error_category&) = delete;
+
+ virtual const char*
+ name() const noexcept = 0;
+
+ virtual string
+ message(int) const = 0;
+
+ virtual error_condition
+ default_error_condition(int __i) const noexcept;
+
+ virtual bool
+ equivalent(int __i, const error_condition& __cond) const noexcept;
+
+ virtual bool
+ equivalent(const error_code& __code, int __i) const noexcept;
+
+ bool
+ operator<(const error_category& __other) const noexcept
+ { return less<const error_category*>()(this, &__other); }
+
+ bool
+ operator==(const error_category& __other) const noexcept
+ { return this == &__other; }
+
+ bool
+ operator!=(const error_category& __other) const noexcept
+ { return this != &__other; }
+ };
+
// gcc-4.9.0
// LWG 2145 changes this constructor to constexpr i.e. inline
error_category::error_category() noexcept = default;
-}
+ error_category::~error_category() noexcept = default;
+
+ namespace
+ {
+ using std::string;
+
+ struct generic_error_category : public std::error_category
+ {
+ virtual const char*
+ name() const noexcept
+ { return "generic"; }
+
+ virtual string
+ message(int i) const
+ {
+ // XXX locale issues: how does one get or set loc.
+ // _GLIBCXX_HAVE_STRERROR_L, strerror_l(i, cloc)
+ return string(strerror(i));
+ }
+ };
+
+ struct system_error_category : public std::error_category
+ {
+ virtual const char*
+ name() const noexcept
+ { return "system"; }
+
+ virtual string
+ message(int i) const
+ {
+ // XXX locale issues: how does one get or set loc.
+ // _GLIBCXX_HAVE_STRERROR_L, strerror_l(i, cloc)
+ return string(strerror(i));
+ }
+ };
+
+ const generic_error_category generic_category_instance{};
+ const system_error_category system_category_instance{};
+ }
+
+ const error_category&
+ system_category() noexcept { return system_category_instance; }
+
+ const error_category&
+ generic_category() noexcept { return generic_category_instance; }
+
+ namespace _V2
+ {
+ _GLIBCXX_CONST const error_categoryxx& system_category() noexcept;
+ _GLIBCXX_CONST const error_categoryxx& generic_category() noexcept;
+ }
+
+ error_condition
+ error_category::default_error_condition(int __i) const noexcept
+ {
+ if (*this == system_category())
+ return error_condition(__i, _V2::system_category());
+ return error_condition(__i, _V2::generic_category());
+ }
+
+ bool
+ error_category::equivalent(int __i,
+ const error_condition& __cond) const noexcept
+ { return default_error_condition(__i) == __cond; }
+
+ bool
+ error_category::equivalent(const error_code& __code, int __i) const noexcept
+ {
+ if (*this == system_category()
+ && __code.category() == _V2::system_category())
+ return __code.value() == __i;
+ if (*this == generic_category()
+ && __code.category() == _V2::generic_category())
+ return __code.value() == __i;
+ return false;
+ }
+
+}
#endif
diff --git a/libstdc++-v3/src/c++11/compatibility-chrono.cc b/libstdc++-v3/src/c++11/compatibility-chrono.cc
index 9e5060fa42e..91a9c4a1160 100644
--- a/libstdc++-v3/src/c++11/compatibility-chrono.cc
+++ b/libstdc++-v3/src/c++11/compatibility-chrono.cc
@@ -1,6 +1,6 @@
// Compatibility symbols for previous versions, C++0x bits -*- C++ -*-
-// Copyright (C) 2013-2014 Free Software Foundation, Inc.
+// Copyright (C) 2013-2015 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
diff --git a/libstdc++-v3/src/c++11/compatibility-condvar.cc b/libstdc++-v3/src/c++11/compatibility-condvar.cc
index dd92c4d37f6..d4c15f13c7d 100644
--- a/libstdc++-v3/src/c++11/compatibility-condvar.cc
+++ b/libstdc++-v3/src/c++11/compatibility-condvar.cc
@@ -1,6 +1,6 @@
// Compatibility symbols for previous versions, C++0x bits -*- C++ -*-
-// Copyright (C) 2013-2014 Free Software Foundation, Inc.
+// Copyright (C) 2013-2015 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
diff --git a/libstdc++-v3/src/c++11/compatibility-thread-c++0x.cc b/libstdc++-v3/src/c++11/compatibility-thread-c++0x.cc
index e074bc4ba39..21d875914e5 100644
--- a/libstdc++-v3/src/c++11/compatibility-thread-c++0x.cc
+++ b/libstdc++-v3/src/c++11/compatibility-thread-c++0x.cc
@@ -1,6 +1,6 @@
// Compatibility symbols for previous versions, C++0x bits -*- C++ -*-
-// Copyright (C) 2009-2014 Free Software Foundation, Inc.
+// Copyright (C) 2009-2015 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
diff --git a/libstdc++-v3/src/c++11/condition_variable.cc b/libstdc++-v3/src/c++11/condition_variable.cc
index 7f78c39b03d..cc0f6e4506a 100644
--- a/libstdc++-v3/src/c++11/condition_variable.cc
+++ b/libstdc++-v3/src/c++11/condition_variable.cc
@@ -1,6 +1,6 @@
// condition_variable -*- C++ -*-
-// Copyright (C) 2008-2014 Free Software Foundation, Inc.
+// Copyright (C) 2008-2015 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
@@ -23,6 +23,7 @@
// <http://www.gnu.org/licenses/>.
#include <condition_variable>
+#include <cstdlib>
#if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1)
@@ -77,6 +78,80 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
__throw_system_error(__e);
}
+ extern void
+ __at_thread_exit(__at_thread_exit_elt*);
+
+ namespace
+ {
+ __gthread_key_t key;
+
+ void run(void* p)
+ {
+ auto elt = (__at_thread_exit_elt*)p;
+ while (elt)
+ {
+ auto next = elt->_M_next;
+ elt->_M_cb(elt);
+ elt = next;
+ }
+ }
+
+ void run()
+ {
+ auto elt = (__at_thread_exit_elt*)__gthread_getspecific(key);
+ __gthread_setspecific(key, nullptr);
+ run(elt);
+ }
+
+ struct notifier final : __at_thread_exit_elt
+ {
+ notifier(condition_variable& cv, unique_lock<mutex>& l)
+ : cv(&cv), mx(l.release())
+ {
+ _M_cb = &notifier::run;
+ __at_thread_exit(this);
+ }
+
+ ~notifier()
+ {
+ mx->unlock();
+ cv->notify_all();
+ }
+
+ condition_variable* cv;
+ mutex* mx;
+
+ static void run(void* p) { delete static_cast<notifier*>(p); }
+ };
+
+
+ void key_init() {
+ struct key_s {
+ key_s() { __gthread_key_create (&key, run); }
+ ~key_s() { __gthread_key_delete (key); }
+ };
+ static key_s ks;
+ // Also make sure the callbacks are run by std::exit.
+ std::atexit (run);
+ }
+ }
+
+ void
+ __at_thread_exit(__at_thread_exit_elt* elt)
+ {
+ static __gthread_once_t once = __GTHREAD_ONCE_INIT;
+ __gthread_once (&once, key_init);
+
+ elt->_M_next = (__at_thread_exit_elt*)__gthread_getspecific(key);
+ __gthread_setspecific(key, elt);
+ }
+
+ void
+ notify_all_at_thread_exit(condition_variable& cv, unique_lock<mutex> l)
+ {
+ (void) new notifier{cv, l};
+ }
+
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
diff --git a/libstdc++-v3/src/c++11/cow-fstream-inst.cc b/libstdc++-v3/src/c++11/cow-fstream-inst.cc
new file mode 100644
index 00000000000..e29593e236f
--- /dev/null
+++ b/libstdc++-v3/src/c++11/cow-fstream-inst.cc
@@ -0,0 +1,78 @@
+// Explicit instantiation file.
+
+// Copyright (C) 2014-2015 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 0
+#include <fstream>
+
+#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
+
+ template basic_filebuf<char>*
+ basic_filebuf<char>::open(const std::string&, ios_base::openmode);
+ template
+ basic_ifstream<char>::
+ basic_ifstream(const std::string&, ios_base::openmode);
+ template void
+ basic_ifstream<char>::open(const std::string&, ios_base::openmode);
+ template
+ basic_ofstream<char>::
+ basic_ofstream(const std::string&, ios_base::openmode);
+ template void
+ basic_ofstream<char>::open(const std::string&, ios_base::openmode);
+ template
+ basic_fstream<char>::basic_fstream(const std::string&, ios_base::openmode);
+ template void
+ basic_fstream<char>::open(const std::string&, ios_base::openmode);
+
+#ifdef _GLIBCXX_USE_WCHAR_T
+ template basic_filebuf<wchar_t>*
+ basic_filebuf<wchar_t>::open(const std::string&, ios_base::openmode);
+ template
+ basic_ifstream<wchar_t>::
+ basic_ifstream(const std::string&, ios_base::openmode);
+ template void
+ basic_ifstream<wchar_t>::open(const std::string&, ios_base::openmode);
+ template
+ basic_ofstream<wchar_t>::
+ basic_ofstream(const std::string&, ios_base::openmode);
+ template void
+ basic_ofstream<wchar_t>::open(const std::string&, ios_base::openmode);
+ template
+ basic_fstream<wchar_t>::
+ basic_fstream(const std::string&, ios_base::openmode);
+ template void
+ basic_fstream<wchar_t>::open(const std::string&, ios_base::openmode);
+#endif
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace
diff --git a/libstdc++-v3/src/c++11/cow-locale_init.cc b/libstdc++-v3/src/c++11/cow-locale_init.cc
new file mode 100644
index 00000000000..14355c1bed0
--- /dev/null
+++ b/libstdc++-v3/src/c++11/cow-locale_init.cc
@@ -0,0 +1,194 @@
+// Copyright (C) 2014-2015 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/>.
+
+// Instantiate the facets using old std::string ABI.
+#define _GLIBCXX_USE_CXX11_ABI 0
+#include <locale>
+
+#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
+
+namespace
+{
+ typedef char fake_collate_c[sizeof(std::collate<char>)]
+ __attribute__ ((aligned(__alignof__(std::collate<char>))));
+ fake_collate_c collate_c;
+
+ typedef char fake_numpunct_c[sizeof(numpunct<char>)]
+ __attribute__ ((aligned(__alignof__(numpunct<char>))));
+ fake_numpunct_c numpunct_c;
+
+ typedef char fake_moneypunct_c[sizeof(moneypunct<char, true>)]
+ __attribute__ ((aligned(__alignof__(moneypunct<char, true>))));
+ fake_moneypunct_c moneypunct_ct;
+ fake_moneypunct_c moneypunct_cf;
+
+ typedef char fake_money_get_c[sizeof(money_get<char>)]
+ __attribute__ ((aligned(__alignof__(money_get<char>))));
+ fake_money_get_c money_get_c;
+
+ typedef char fake_money_put_c[sizeof(money_put<char>)]
+ __attribute__ ((aligned(__alignof__(money_put<char>))));
+ fake_money_put_c money_put_c;
+
+ typedef char fake_time_get_c[sizeof(time_get<char>)]
+ __attribute__ ((aligned(__alignof__(time_get<char>))));
+ fake_time_get_c time_get_c;
+
+ typedef char fake_messages_c[sizeof(messages<char>)]
+ __attribute__ ((aligned(__alignof__(messages<char>))));
+ fake_messages_c messages_c;
+
+#ifdef _GLIBCXX_USE_WCHAR_T
+ typedef char fake_wollate_w[sizeof(std::collate<wchar_t>)]
+ __attribute__ ((aligned(__alignof__(std::collate<wchar_t>))));
+ fake_wollate_w collate_w;
+
+ typedef char fake_numpunct_w[sizeof(numpunct<wchar_t>)]
+ __attribute__ ((aligned(__alignof__(numpunct<wchar_t>))));
+ fake_numpunct_w numpunct_w;
+
+ typedef char fake_moneypunct_w[sizeof(moneypunct<wchar_t, true>)]
+ __attribute__ ((aligned(__alignof__(moneypunct<wchar_t, true>))));
+ fake_moneypunct_w moneypunct_wt;
+ fake_moneypunct_w moneypunct_wf;
+
+ typedef char fake_money_get_w[sizeof(money_get<wchar_t>)]
+ __attribute__ ((aligned(__alignof__(money_get<wchar_t>))));
+ fake_money_get_w money_get_w;
+
+ typedef char fake_money_put_w[sizeof(money_put<wchar_t>)]
+ __attribute__ ((aligned(__alignof__(money_put<wchar_t>))));
+ fake_money_put_w money_put_w;
+
+ typedef char fake_time_get_w[sizeof(time_get<wchar_t>)]
+ __attribute__ ((aligned(__alignof__(time_get<wchar_t>))));
+ fake_time_get_w time_get_w;
+
+ typedef char fake_messages_w[sizeof(messages<wchar_t>)]
+ __attribute__ ((aligned(__alignof__(messages<wchar_t>))));
+ fake_messages_w messages_w;
+#endif
+} // anonymous namespace
+
+ void
+ locale::_Impl::_M_init_extra(facet** caches)
+ {
+ auto __npc = static_cast<__numpunct_cache<char>*>(caches[0]);
+ auto __mpcf = static_cast<__moneypunct_cache<char, false>*>(caches[1]);
+ auto __mpct = static_cast<__moneypunct_cache<char, true>*>(caches[2]);
+
+ _M_init_facet_unchecked(new (&numpunct_c) numpunct<char>(__npc, 1));
+ _M_init_facet_unchecked(new (&collate_c) std::collate<char>(1));
+ _M_init_facet_unchecked(new (&moneypunct_cf) moneypunct<char, false>(__mpcf, 1));
+ _M_init_facet_unchecked(new (&moneypunct_ct) moneypunct<char, true>(__mpct, 1));
+ _M_init_facet_unchecked(new (&money_get_c) money_get<char>(1));
+ _M_init_facet_unchecked(new (&money_put_c) money_put<char>(1));
+ _M_init_facet_unchecked(new (&time_get_c) time_get<char>(1));
+ _M_init_facet_unchecked(new (&messages_c) std::messages<char>(1));
+#ifdef _GLIBCXX_USE_WCHAR_T
+ auto __npw = static_cast<__numpunct_cache<wchar_t>*>(caches[3]);
+ auto __mpwf = static_cast<__moneypunct_cache<wchar_t, false>*>(caches[4]);
+ auto __mpwt = static_cast<__moneypunct_cache<wchar_t, true>*>(caches[5]);
+
+ _M_init_facet_unchecked(new (&numpunct_w) numpunct<wchar_t>(__npw, 1));
+ _M_init_facet_unchecked(new (&collate_w) std::collate<wchar_t>(1));
+ _M_init_facet_unchecked(new (&moneypunct_wf) moneypunct<wchar_t, false>(__mpwf, 1));
+ _M_init_facet_unchecked(new (&moneypunct_wt) moneypunct<wchar_t, true>(__mpwt, 1));
+ _M_init_facet_unchecked(new (&money_get_w) money_get<wchar_t>(1));
+ _M_init_facet_unchecked(new (&money_put_w) money_put<wchar_t>(1));
+ _M_init_facet_unchecked(new (&time_get_w) time_get<wchar_t>(1));
+ _M_init_facet_unchecked(new (&messages_w) std::messages<wchar_t>(1));
+#endif
+
+ _M_caches[numpunct<char>::id._M_id()] = __npc;
+ _M_caches[moneypunct<char, false>::id._M_id()] = __mpcf;
+ _M_caches[moneypunct<char, true>::id._M_id()] = __mpct;
+#ifdef _GLIBCXX_USE_WCHAR_T
+ _M_caches[numpunct<wchar_t>::id._M_id()] = __npw;
+ _M_caches[moneypunct<wchar_t, false>::id._M_id()] = __mpwf;
+ _M_caches[moneypunct<wchar_t, true>::id._M_id()] = __mpwt;
+#endif
+ }
+
+ void
+ locale::_Impl::_M_init_extra(void* cloc, void* clocm,
+ const char* __s, const char* __smon)
+ {
+ auto& __cloc = *static_cast<__c_locale*>(cloc);
+
+ _M_init_facet_unchecked(new numpunct<char>(__cloc));
+ _M_init_facet_unchecked(new std::collate<char>(__cloc));
+ _M_init_facet_unchecked(new moneypunct<char, false>(__cloc, 0));
+ _M_init_facet_unchecked(new moneypunct<char, true>(__cloc, 0));
+ _M_init_facet_unchecked(new money_get<char>);
+ _M_init_facet_unchecked(new money_put<char>);
+ _M_init_facet_unchecked(new time_get<char>);
+ _M_init_facet_unchecked(new std::messages<char>(__cloc, __s));
+
+#ifdef _GLIBCXX_USE_WCHAR_T
+ auto& __clocm = *static_cast<__c_locale*>(clocm);
+
+ _M_init_facet_unchecked(new numpunct<wchar_t>(__cloc));
+ _M_init_facet_unchecked(new std::collate<wchar_t>(__cloc));
+ _M_init_facet_unchecked(new moneypunct<wchar_t, false>(__clocm, __smon));
+ _M_init_facet_unchecked(new moneypunct<wchar_t, true>(__clocm, __smon));
+ _M_init_facet_unchecked(new money_get<wchar_t>);
+ _M_init_facet_unchecked(new money_put<wchar_t>);
+ _M_init_facet_unchecked(new time_get<wchar_t>);
+ _M_init_facet_unchecked(new std::messages<wchar_t>(__cloc, __s));
+#endif
+ }
+
+// TODO should be in another file
+ string
+ locale::name() const
+ {
+ string __ret;
+ if (!_M_impl->_M_names[0])
+ __ret = '*';
+ else if (_M_impl->_M_check_same_name())
+ __ret = _M_impl->_M_names[0];
+ else
+ {
+ __ret.reserve(128);
+ __ret += _S_categories[0];
+ __ret += '=';
+ __ret += _M_impl->_M_names[0];
+ for (size_t __i = 1; __i < _S_categories_size; ++__i)
+ {
+ __ret += ';';
+ __ret += _S_categories[__i];
+ __ret += '=';
+ __ret += _M_impl->_M_names[__i];
+ }
+ }
+ return __ret;
+ }
+
+_GLIBCXX_END_NAMESPACE_VERSION
+}
diff --git a/libstdc++-v3/src/c++11/cow-shim_facets.cc b/libstdc++-v3/src/c++11/cow-shim_facets.cc
new file mode 100644
index 00000000000..43cacb92b23
--- /dev/null
+++ b/libstdc++-v3/src/c++11/cow-shim_facets.cc
@@ -0,0 +1,35 @@
+// Locale support -*- C++ -*-
+
+// Copyright (C) 2014-2015 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/>.
+
+/** @file bits/locale_classes.tcc
+ * This is an internal header file, included by other library headers.
+ * Do not attempt to use it directly. @headername{locale}
+ */
+
+//
+// ISO C++ 14882: 22.1 Locales
+//
+
+#define _GLIBCXX_USE_CXX11_ABI 0
+#include "cxx11-shim_facets.cc"
diff --git a/libstdc++-v3/src/c++11/cow-sstream-inst.cc b/libstdc++-v3/src/c++11/cow-sstream-inst.cc
new file mode 100644
index 00000000000..fc05239d685
--- /dev/null
+++ b/libstdc++-v3/src/c++11/cow-sstream-inst.cc
@@ -0,0 +1,34 @@
+// Explicit instantiation file.
+
+// Copyright (C) 2014-2015 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 0
+#include "sstream-inst.cc"
+
+#if ! _GLIBCXX_USE_DUAL_ABI
+# error This file should not be compiled for this configuration.
+#endif
diff --git a/libstdc++-v3/src/c++11/cow-stdexcept.cc b/libstdc++-v3/src/c++11/cow-stdexcept.cc
new file mode 100644
index 00000000000..d24dfe68477
--- /dev/null
+++ b/libstdc++-v3/src/c++11/cow-stdexcept.cc
@@ -0,0 +1,153 @@
+// Methods for Exception Support for -*- C++ -*-
+
+// Copyright (C) 2014-2015 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: 19.1 Exception classes
+//
+
+// All exception classes still use the classic COW std::string.
+#define _GLIBCXX_USE_CXX11_ABI 0
+#define _GLIBCXX_DEFINE_STDEXCEPT_COPY_OPS 1
+#define __cow_string __cow_stringxxx
+#include <stdexcept>
+#include <system_error>
+#undef __cow_string
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ // Copy constructors and assignment operators defined using COW std::string
+
+ logic_error::logic_error(const logic_error& e) noexcept
+ : _M_msg(e._M_msg) { }
+
+ logic_error& logic_error::operator=(const logic_error& e) noexcept
+ { _M_msg = e._M_msg; return *this; }
+
+ runtime_error::runtime_error(const runtime_error& e) noexcept
+ : _M_msg(e._M_msg) { }
+
+ runtime_error&
+ runtime_error::operator=(const runtime_error& e) noexcept
+ { _M_msg = e._M_msg; return *this; }
+
+ // New C++11 constructors:
+
+ logic_error::logic_error(const char* __arg)
+ : exception(), _M_msg(__arg) { }
+
+ domain_error::domain_error(const char* __arg)
+ : logic_error(__arg) { }
+
+ invalid_argument::invalid_argument(const char* __arg)
+ : logic_error(__arg) { }
+
+ length_error::length_error(const char* __arg)
+ : logic_error(__arg) { }
+
+ out_of_range::out_of_range(const char* __arg)
+ : logic_error(__arg) { }
+
+ runtime_error::runtime_error(const char* __arg)
+ : exception(), _M_msg(__arg) { }
+
+ range_error::range_error(const char* __arg)
+ : runtime_error(__arg) { }
+
+ overflow_error::overflow_error(const char* __arg)
+ : runtime_error(__arg) { }
+
+ underflow_error::underflow_error(const char* __arg)
+ : runtime_error(__arg) { }
+
+#if _GLIBCXX_USE_DUAL_ABI
+ // Converting constructor from COW std::string to SSO string.
+ __sso_string::__sso_string(const string& s)
+ : __sso_string(s.c_str(), s.length()) { }
+
+ // Redefine __cow_string so that we can define and export its members
+ // in terms of the COW std::string.
+ struct __cow_string
+ {
+ union {
+ const char* _M_p;
+ char _M_bytes[sizeof(_M_p)];
+ std::string _M_str;
+ };
+
+ __cow_string();
+ __cow_string(const std::string& s);
+ __cow_string(const char*, size_t n);
+ __cow_string(const __cow_string&) noexcept;
+ __cow_string& operator=(const __cow_string&) noexcept;
+ ~__cow_string();
+ __cow_string(__cow_string&&) noexcept;
+ __cow_string& operator=(__cow_string&&) noexcept;
+ };
+
+ __cow_string::__cow_string() : _M_str() { }
+
+ __cow_string::__cow_string(const std::string& s) : _M_str(s) { }
+
+ __cow_string::__cow_string(const char* s, size_t n) : _M_str(s, n) { }
+
+ __cow_string::__cow_string(const __cow_string& s) noexcept
+ : _M_str(s._M_str) { }
+
+ __cow_string&
+ __cow_string::operator=(const __cow_string& s) noexcept
+ {
+ _M_str = s._M_str;
+ return *this;
+ }
+
+ __cow_string::~__cow_string() { _M_str.~basic_string(); }
+
+ __cow_string::__cow_string(__cow_string&& s) noexcept
+ : _M_str(std::move(s._M_str)) { }
+
+ __cow_string&
+ __cow_string::operator=(__cow_string&& s) noexcept
+ {
+ _M_str = std::move(s._M_str);
+ return *this;
+ }
+
+ static_assert(sizeof(__cow_string) == sizeof(std::string),
+ "sizeof(std::string) has changed");
+ static_assert(alignof(__cow_string) == alignof(std::string),
+ "alignof(std::string) has changed");
+#endif
+
+ // Return error_category::message() as an SSO string
+ __sso_string
+ error_category::_M_message(int i) const
+ {
+ string msg = this->message(i);
+ return {msg.c_str(), msg.length()};
+ }
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace
diff --git a/libstdc++-v3/src/c++11/cow-string-inst.cc b/libstdc++-v3/src/c++11/cow-string-inst.cc
new file mode 100644
index 00000000000..b51ffa7289d
--- /dev/null
+++ b/libstdc++-v3/src/c++11/cow-string-inst.cc
@@ -0,0 +1,120 @@
+// Reference-counted COW string instantiations -*- C++ -*-
+
+// Copyright (C) 2014-2015 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 "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__
+# include <cpuid.h>
+#endif
+#include <cstdio>
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+ void
+ random_device::_M_init(const std::string& token)
+ {
+ const char *fname = token.c_str();
+
+ if (token == "default")
+ {
+#if (defined __i386__ || defined __x86_64__) && defined _GLIBCXX_X86_RDRAND
+ unsigned int eax, ebx, ecx, edx;
+ // Check availability of cpuid and, for now at least, also the
+ // CPU signature for Intel's
+ if (__get_cpuid_max(0, &ebx) > 0 && ebx == signature_INTEL_ebx)
+ {
+ __cpuid(1, eax, ebx, ecx, edx);
+ if (ecx & bit_RDRND)
+ {
+ _M_file = nullptr;
+ return;
+ }
+ }
+#endif
+
+ fname = "/dev/urandom";
+ }
+ else if (token != "/dev/urandom" && token != "/dev/random")
+ fail:
+ std::__throw_runtime_error(__N("random_device::"
+ "random_device(const std::string&)"));
+
+ _M_file = static_cast<void*>(std::fopen(fname, "rb"));
+ if (!_M_file)
+ goto fail;
+ }
+
+ void
+ random_device::_M_init_pretr1(const std::string& token)
+ {
+ unsigned long __seed = 5489UL;
+ if (token != "mt19937")
+ {
+ const char* __nptr = token.c_str();
+ char* __endptr;
+ __seed = std::strtoul(__nptr, &__endptr, 0);
+ if (*__nptr == '\0' || *__endptr != '\0')
+ std::__throw_runtime_error(__N("random_device::random_device"
+ "(const std::string&)"));
+ }
+ _M_mt.seed(__seed);
+ }
+} // namespace
+#endif
diff --git a/libstdc++-v3/src/c++11/cow-wstring-inst.cc b/libstdc++-v3/src/c++11/cow-wstring-inst.cc
new file mode 100644
index 00000000000..171d3a6ee12
--- /dev/null
+++ b/libstdc++-v3/src/c++11/cow-wstring-inst.cc
@@ -0,0 +1,64 @@
+// Reference-counted COW wide string instantiations -*- C++ -*-
+
+// Copyright (C) 2014-2015 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
+#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/ctype.cc b/libstdc++-v3/src/c++11/ctype.cc
new file mode 100644
index 00000000000..17c84ceaae5
--- /dev/null
+++ b/libstdc++-v3/src/c++11/ctype.cc
@@ -0,0 +1,133 @@
+// Copyright (C) 1997-2015 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/>.
+
+#include <locale>
+#include <cstdlib>
+#include <cstring>
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ // Definitions for static const data members of ctype_base.
+ const ctype_base::mask ctype_base::space;
+ const ctype_base::mask ctype_base::print;
+ const ctype_base::mask ctype_base::cntrl;
+ const ctype_base::mask ctype_base::upper;
+ const ctype_base::mask ctype_base::lower;
+ const ctype_base::mask ctype_base::alpha;
+ const ctype_base::mask ctype_base::digit;
+ const ctype_base::mask ctype_base::punct;
+ const ctype_base::mask ctype_base::xdigit;
+ const ctype_base::mask ctype_base::alnum;
+ const ctype_base::mask ctype_base::graph;
+ const ctype_base::mask ctype_base::blank;
+
+ // Definitions for locale::id of standard facets that are specialized.
+ locale::id ctype<char>::id;
+
+#ifdef _GLIBCXX_USE_WCHAR_T
+ locale::id ctype<wchar_t>::id;
+#endif
+
+ const size_t ctype<char>::table_size;
+
+ ctype<char>::~ctype()
+ {
+ _S_destroy_c_locale(_M_c_locale_ctype);
+ if (_M_del)
+ delete[] this->table();
+ }
+
+ // Fill in the narrowing cache and flag whether all values are
+ // valid or not. _M_narrow_ok is set to 2 if memcpy can't
+ // be used.
+ void
+ ctype<char>::
+ _M_narrow_init() const
+ {
+ char __tmp[sizeof(_M_narrow)];
+ for (size_t __i = 0; __i < sizeof(_M_narrow); ++__i)
+ __tmp[__i] = __i;
+ do_narrow(__tmp, __tmp + sizeof(__tmp), 0, _M_narrow);
+
+ _M_narrow_ok = 1;
+ if (__builtin_memcmp(__tmp, _M_narrow, sizeof(_M_narrow)))
+ _M_narrow_ok = 2;
+ else
+ {
+ // Deal with the special case of zero: renarrow with a
+ // different default and compare.
+ char __c;
+ do_narrow(__tmp, __tmp + 1, 1, &__c);
+ if (__c == 1)
+ _M_narrow_ok = 2;
+ }
+ }
+
+ void
+ ctype<char>::
+ _M_widen_init() const
+ {
+ char __tmp[sizeof(_M_widen)];
+ for (size_t __i = 0; __i < sizeof(_M_widen); ++__i)
+ __tmp[__i] = __i;
+ do_widen(__tmp, __tmp + sizeof(__tmp), _M_widen);
+
+ _M_widen_ok = 1;
+ // Set _M_widen_ok to 2 if memcpy can't be used.
+ if (__builtin_memcmp(__tmp, _M_widen, sizeof(_M_widen)))
+ _M_widen_ok = 2;
+ }
+
+#ifdef _GLIBCXX_USE_WCHAR_T
+ ctype<wchar_t>::ctype(size_t __refs)
+ : __ctype_abstract_base<wchar_t>(__refs),
+ _M_c_locale_ctype(_S_get_c_locale()), _M_narrow_ok(false)
+ { _M_initialize_ctype(); }
+
+ ctype<wchar_t>::ctype(__c_locale __cloc, size_t __refs)
+ : __ctype_abstract_base<wchar_t>(__refs),
+ _M_c_locale_ctype(_S_clone_c_locale(__cloc)), _M_narrow_ok(false)
+ { _M_initialize_ctype(); }
+
+ ctype<wchar_t>::~ctype()
+ { _S_destroy_c_locale(_M_c_locale_ctype); }
+
+ ctype_byname<wchar_t>::ctype_byname(const char* __s, size_t __refs)
+ : ctype<wchar_t>(__refs)
+ {
+ if (std::strcmp(__s, "C") != 0 && std::strcmp(__s, "POSIX") != 0)
+ {
+ this->_S_destroy_c_locale(this->_M_c_locale_ctype);
+ this->_S_create_c_locale(this->_M_c_locale_ctype, __s);
+ this->_M_initialize_ctype();
+ }
+ }
+
+ ctype_byname<wchar_t>::~ctype_byname()
+ { }
+
+#endif
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace
diff --git a/libstdc++-v3/src/c++11/cxx11-hash_tr1.cc b/libstdc++-v3/src/c++11/cxx11-hash_tr1.cc
new file mode 100644
index 00000000000..33793563ab3
--- /dev/null
+++ b/libstdc++-v3/src/c++11/cxx11-hash_tr1.cc
@@ -0,0 +1,59 @@
+// std::tr1::hash definitions with new string -*- C++ -*-
+
+// Copyright (C) 2014-2015 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
+#include <string>
+
+#if ! _GLIBCXX_USE_DUAL_ABI
+# error This file should not be compiled for this configuration.
+#endif
+
+#include <tr1/functional>
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+ namespace tr1
+ {
+ template<>
+ size_t
+ hash<string>::operator()(string __s) const
+ { return _Fnv_hash::hash(__s.data(), __s.length()); }
+
+ template<>
+ size_t
+ hash<const string&>::operator()(const string& __s) const
+ { return _Fnv_hash::hash(__s.data(), __s.length()); }
+
+#ifdef _GLIBCXX_USE_WCHAR_T
+ template<>
+ size_t
+ hash<wstring>::operator()(wstring __s) const
+ { return _Fnv_hash::hash(__s.data(), __s.length() * sizeof(wchar_t)); }
+
+ template<>
+ size_t
+ hash<const wstring&>::operator()(const wstring& __s) const
+ { return _Fnv_hash::hash(__s.data(), __s.length() * sizeof(wchar_t)); }
+#endif
+ }
+}
diff --git a/libstdc++-v3/src/c++11/cxx11-ios_failure.cc b/libstdc++-v3/src/c++11/cxx11-ios_failure.cc
new file mode 100644
index 00000000000..e1c8d4e0139
--- /dev/null
+++ b/libstdc++-v3/src/c++11/cxx11-ios_failure.cc
@@ -0,0 +1,94 @@
+// Iostreams base classes -*- C++ -*-
+
+// Copyright (C) 2014-2015 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:2011: 27.5.3.1.1 Class ios_base::failure
+//
+
+#define _GLIBCXX_USE_CXX11_ABI 1
+#include <ios>
+
+#if ! _GLIBCXX_USE_DUAL_ABI
+# error This file should not be compiled for this configuration.
+#endif
+
+namespace
+{
+ struct io_error_category : std::error_category
+ {
+ virtual const char*
+ name() const noexcept
+ { return "iostream"; }
+
+ virtual std::string message(int __ec) const
+ {
+ std::string __msg;
+ switch (std::io_errc(__ec))
+ {
+ case std::io_errc::stream:
+ __msg = "iostream error";
+ break;
+ default:
+ __msg = "Unknown error";
+ break;
+ }
+ return __msg;
+ }
+ };
+
+ const io_error_category&
+ __io_category_instance() noexcept
+ {
+ static const io_error_category __ec{};
+ return __ec;
+ }
+
+} // namespace
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ const error_category&
+ iostream_category() noexcept
+ { return __io_category_instance(); }
+
+ ios_base::failure::failure(const string& __str)
+ : system_error(io_errc::stream, __str) { }
+
+ ios_base::failure::failure(const string& __str, const error_code& __ec)
+ : system_error(__ec, __str) { }
+
+ ios_base::failure::failure(const char* __str, const error_code& __ec)
+ : system_error(__ec, __str) { }
+
+ ios_base::failure::~failure()
+ { }
+
+ const char*
+ ios_base::failure::what() const throw()
+ { return runtime_error::what(); }
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace
diff --git a/libstdc++-v3/src/c++11/cxx11-locale-inst.cc b/libstdc++-v3/src/c++11/cxx11-locale-inst.cc
new file mode 100644
index 00000000000..75c8cd311c7
--- /dev/null
+++ b/libstdc++-v3/src/c++11/cxx11-locale-inst.cc
@@ -0,0 +1,39 @@
+// Copyright (C) 2014-2015 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: 22.1 Locales
+//
+
+// Facet instantiations using new ABI strings.
+
+#define _GLIBCXX_USE_CXX11_ABI 1
+#include <bits/c++config.h>
+#if ! _GLIBCXX_USE_DUAL_ABI
+# error This file should not be compiled for this configuration.
+#endif
+
+#ifndef C
+# define C char
+# define C_is_char
+#endif
+# include "locale-inst.cc"
diff --git a/libstdc++-v3/src/c++11/cxx11-shim_facets.cc b/libstdc++-v3/src/c++11/cxx11-shim_facets.cc
new file mode 100644
index 00000000000..407b7b9f921
--- /dev/null
+++ b/libstdc++-v3/src/c++11/cxx11-shim_facets.cc
@@ -0,0 +1,837 @@
+// Locale support -*- C++ -*-
+
+// Copyright (C) 2014-2015 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: 22.1 Locales
+//
+
+// This file defines classes that behave like the standard predefined locale
+// facets (collate, money_get etc.) except that they forward all virtual
+// functions to another facet which uses a different std::string ABI,
+// converting between string types as needed.
+// When a user replaces one of the relevant facets the corresponding shim in
+// this file is used so that the replacement facet can be used (via the shim)
+// in code that uses the other std::string ABI from the replacing code.
+
+#ifndef _GLIBCXX_USE_CXX11_ABI
+# define _GLIBCXX_USE_CXX11_ABI 1
+#endif
+#include <locale>
+
+#if ! _GLIBCXX_USE_DUAL_ABI
+# error This file should not be compiled for this configuration.
+#endif
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+ // Base class of facet shims, holds a reference to the underlying facet
+ // that the shim forwards to.
+ class locale::facet::__shim
+ {
+ public:
+ const facet* _M_get() const { return _M_facet; }
+
+ __shim(const __shim&) = delete;
+ __shim& operator=(const __shim&) = delete;
+
+ protected:
+ explicit
+ __shim(const facet* __f) : _M_facet(__f) { __f->_M_add_reference(); }
+
+ ~__shim() { _M_facet->_M_remove_reference(); }
+
+ private:
+ const facet* _M_facet;
+ };
+
+namespace __facet_shims
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ namespace // unnamed
+ {
+ template<typename C>
+ void __destroy_string(void* p)
+ {
+ static_cast<std::basic_string<C>*>(p)->~basic_string();
+ }
+ } // namespace
+
+ // Manages a buffer of uninitialized memory that can store a std::string
+ // or std::wstring, using either ABI, and convert to the other ABI.
+ class __any_string
+ {
+ struct __attribute__((may_alias)) __str_rep
+ {
+ union {
+ const void* _M_p;
+ char* _M_pc;
+#ifdef _GLIBCXX_USE_WCHAR_T
+ wchar_t* _M_pwc;
+#endif
+ };
+ size_t _M_len;
+ char _M_unused[16];
+
+ operator const char*() const { return _M_pc; }
+#ifdef _GLIBCXX_USE_WCHAR_T
+ operator const wchar_t*() const { return _M_pwc; }
+#endif
+ };
+ union {
+ __str_rep _M_str;
+ char _M_bytes[sizeof(__str_rep)];
+ };
+ using __dtor_func = void(*)(void*);
+ __dtor_func _M_dtor = nullptr;
+
+#if _GLIBCXX_USE_CXX11_ABI
+ // SSO strings overlay the entire __str_rep structure.
+ static_assert(sizeof(std::string) == sizeof(__str_rep),
+ "std::string changed size!");
+#else
+ // COW strings overlay just the pointer, the length is stored manually.
+ static_assert(sizeof(std::string) == sizeof(__str_rep::_M_p),
+ "std::string changed size!");
+#endif
+# ifdef _GLIBCXX_USE_WCHAR_T
+ static_assert(sizeof(std::wstring) == sizeof(std::string),
+ "std::wstring and std::string are different sizes!");
+# endif
+
+ public:
+ __any_string() = default;
+ ~__any_string() { if (_M_dtor) _M_dtor(_M_bytes); }
+
+ __any_string(const __any_string&) = delete;
+ __any_string& operator=(const __any_string&) = delete;
+
+ // Store a string (and its length if needed) in the buffer and
+ // set _M_dtor to the function that runs the right destructor.
+ template<typename C>
+ __any_string&
+ operator=(const basic_string<C>& s)
+ {
+ if (_M_dtor)
+ _M_dtor(_M_bytes);
+ ::new(_M_bytes) basic_string<C>(s);
+#if ! _GLIBCXX_USE_CXX11_ABI
+ _M_str._M_len = s.length();
+#endif
+ _M_dtor = __destroy_string<C>;
+ return *this;
+ }
+
+ // Create a new string with a copy of the characters in the stored string.
+ // The returned object will match the caller's string ABI, even when the
+ // stored string doesn't.
+ template<typename C>
+ operator basic_string<C>() const
+ {
+ if (!_M_dtor)
+ __throw_logic_error("uninitialized __any_string");
+ return basic_string<C>(static_cast<const C*>(_M_str), _M_str._M_len);
+ }
+ };
+
+ // This file is compiled twice, with and without this macro defined.
+ // Define tag types to distinguish between the two cases and to allow
+ // overloading on the tag.
+ using current_abi = __bool_constant<_GLIBCXX_USE_CXX11_ABI>;
+ using other_abi = __bool_constant<!_GLIBCXX_USE_CXX11_ABI>;
+
+ using facet = locale::facet;
+
+ // Declare the functions that shims defined in this file will call to
+ // perform work in the context of the other ABI.
+ // These will be defined when this file is recompiled for the other ABI
+ // (at which point what is now "current_abi" will become "other_abi").
+
+ template<typename C>
+ void
+ __numpunct_fill_cache(other_abi, const facet*, __numpunct_cache<C>*,
+ const char*&, size_t&);
+
+ template<typename C>
+ int
+ __collate_compare(other_abi, const facet*, const C*, const C*,
+ const C*, const C*);
+
+ template<typename C>
+ void
+ __collate_transform(other_abi, const facet*, __any_string&,
+ const C*, const C*);
+
+ template<typename C>
+ time_base::dateorder
+ __time_get_dateorder(other_abi, const facet* f);
+
+ template<typename C>
+ istreambuf_iterator<C>
+ __time_get(other_abi, const facet* f,
+ istreambuf_iterator<C> beg, istreambuf_iterator<C> end,
+ ios_base& io, ios_base::iostate& err, tm* t, char which);
+
+ template<typename C, bool Intl>
+ void
+ __moneypunct_fill_cache(other_abi, const facet*,
+ __moneypunct_cache<C, Intl>*);
+
+ template<typename C>
+ istreambuf_iterator<C>
+ __money_get(other_abi, const facet*,
+ istreambuf_iterator<C>, istreambuf_iterator<C>,
+ bool, ios_base&, ios_base::iostate&,
+ long double*, __any_string*);
+
+ template<typename C>
+ ostreambuf_iterator<C>
+ __money_put(other_abi, const facet*, ostreambuf_iterator<C>, bool,
+ ios_base&, C, long double, const __any_string*);
+
+ template<typename C>
+ messages_base::catalog
+ __messages_open(other_abi, const facet*, const char*, size_t,
+ const locale&);
+
+ template<typename C>
+ void
+ __messages_get(other_abi, const facet*, __any_string&,
+ messages_base::catalog, int, int, const C*, size_t);
+
+ template<typename C>
+ void
+ __messages_close(other_abi, const facet*, messages_base::catalog);
+
+ namespace // unnamed
+ {
+ template<typename _CharT>
+ struct numpunct_shim : std::numpunct<_CharT>, facet::__shim
+ {
+ typedef typename numpunct<_CharT>::__cache_type __cache_type;
+
+ // f must point to a type derived from numpunct<C>[abi:other]
+ numpunct_shim(const facet* f, __cache_type* c = new __cache_type)
+ : std::numpunct<_CharT>(c), __shim(f), _M_cache(c)
+ {
+ __numpunct_fill_cache(other_abi{}, f, c, _M_grouping,
+ _M_grouping_size);
+ }
+
+ ~numpunct_shim() { delete[] _M_grouping; }
+
+ virtual string
+ do_grouping() const
+ { return string(_M_grouping, _M_grouping_size); }
+
+ // No need to override other virtual functions, the base definitions
+ // will return the cached data.
+
+ __cache_type* _M_cache;
+ // numpunct uses __numpunct_cache<C>::_M_grouping for its own purposes
+ // so we can't store that in the cache
+ const char* _M_grouping;
+ size_t _M_grouping_size;
+ };
+
+ template<typename _CharT>
+ struct collate_shim : std::collate<_CharT>, facet::__shim
+ {
+ typedef basic_string<_CharT> string_type;
+
+ // f must point to a type derived from collate<C>[abi:other]
+ collate_shim(const facet* f) : __shim(f) { }
+
+ virtual int
+ do_compare(const _CharT* lo1, const _CharT* hi1,
+ const _CharT* lo2, const _CharT* hi2) const
+ {
+ return __collate_compare(other_abi{}, _M_get(),
+ lo1, hi1, lo2, hi2);
+ }
+
+ virtual string_type
+ do_transform(const _CharT* lo, const _CharT* hi) const
+ {
+ __any_string st;
+ __collate_transform(other_abi{}, _M_get(), st, lo, hi);
+ return st;
+ }
+ };
+
+ template<typename _CharT>
+ struct time_get_shim : std::time_get<_CharT>, facet::__shim
+ {
+ typedef typename std::time_get<_CharT>::iter_type iter_type;
+ typedef typename std::time_get<_CharT>::char_type char_type;
+
+ // f must point to a type derived from time_get<C>[abi:other]
+ time_get_shim(const facet* f) : __shim(f) { }
+
+ virtual time_base::dateorder
+ do_date_order() const
+ { return __time_get_dateorder<_CharT>(other_abi{}, _M_get()); }
+
+ virtual iter_type
+ do_get_time(iter_type beg, iter_type end, ios_base& io,
+ ios_base::iostate& err, tm* t) const
+ {
+ return __time_get(other_abi{}, _M_get(), beg, end, io, err, t,
+ 't');
+ }
+
+ virtual iter_type
+ do_get_date(iter_type beg, iter_type end, ios_base& io,
+ ios_base::iostate& err, tm* t) const
+ {
+ return __time_get(other_abi{}, _M_get(), beg, end, io, err, t,
+ 'd');
+ }
+
+ virtual iter_type
+ do_get_weekday(iter_type beg, iter_type end, ios_base& io,
+ ios_base::iostate& err, tm* t) const
+ {
+ return __time_get(other_abi{}, _M_get(), beg, end, io, err, t,
+ 'w');
+ }
+
+ virtual iter_type
+ do_get_monthname(iter_type beg, iter_type end, ios_base& io,
+ ios_base::iostate& err, tm* t) const
+ {
+ return __time_get(other_abi{}, _M_get(), beg, end, io, err, t,
+ 'm');
+ }
+
+ virtual iter_type
+ do_get_year(iter_type beg, iter_type end, ios_base& io,
+ ios_base::iostate& err, tm* t) const
+ {
+ return __time_get(other_abi{}, _M_get(), beg, end, io, err, t,
+ 'y');
+ }
+ };
+
+ template<typename _CharT, bool _Intl>
+ struct moneypunct_shim : std::moneypunct<_CharT, _Intl>, facet::__shim
+ {
+ typedef typename moneypunct<_CharT, _Intl>::__cache_type __cache_type;
+
+ // f must point to a type derived from moneypunct<C>[abi:other]
+ moneypunct_shim(const facet* f, __cache_type* c = new __cache_type)
+ : std::moneypunct<_CharT, _Intl>(c), __shim(f), _M_cache(c)
+ {
+ __moneypunct_fill_cache(other_abi{}, f, c);
+ }
+
+ ~moneypunct_shim()
+ {
+ // stop GNU locale's ~moneypunct() from freeing these strings
+ _M_cache->_M_grouping_size = 0;
+ _M_cache->_M_curr_symbol_size = 0;
+ _M_cache->_M_positive_sign_size = 0;
+ _M_cache->_M_negative_sign_size = 0;
+ }
+
+ // No need to override any virtual functions, the base definitions
+ // will return the cached data.
+
+ __cache_type* _M_cache;
+ };
+
+ template<typename _CharT>
+ struct money_get_shim : std::money_get<_CharT>, facet::__shim
+ {
+ typedef typename std::money_get<_CharT>::iter_type iter_type;
+ typedef typename std::money_get<_CharT>::char_type char_type;
+ typedef typename std::money_get<_CharT>::string_type string_type;
+
+ // f must point to a type derived from money_get<C>[abi:other]
+ money_get_shim(const facet* f) : __shim(f) { }
+
+ virtual iter_type
+ do_get(iter_type s, iter_type end, bool intl, ios_base& io,
+ ios_base::iostate& err, long double& units) const
+ {
+ ios_base::iostate err2 = ios_base::goodbit;
+ long double units2;
+ s = __money_get(other_abi{}, _M_get(), s, end, intl, io, err2,
+ &units2, nullptr);
+ if (err2 == ios_base::goodbit)
+ units = units2;
+ else
+ err = err2;
+ return s;
+ }
+
+ virtual iter_type
+ do_get(iter_type s, iter_type end, bool intl, ios_base& io,
+ ios_base::iostate& err, string_type& digits) const
+ {
+ __any_string st;
+ ios_base::iostate err2 = ios_base::goodbit;
+ s = __money_get(other_abi{}, _M_get(), s, end, intl, io, err2,
+ nullptr, &st);
+ if (err2 == ios_base::goodbit)
+ digits = st;
+ else
+ err = err2;
+ return s;
+ }
+ };
+
+ template<typename _CharT>
+ struct money_put_shim : std::money_put<_CharT>, facet::__shim
+ {
+ typedef typename std::money_put<_CharT>::iter_type iter_type;
+ typedef typename std::money_put<_CharT>::char_type char_type;
+ typedef typename std::money_put<_CharT>::string_type string_type;
+
+ // f must point to a type derived from money_put<C>[abi:other]
+ money_put_shim(const facet* f) : __shim(f) { }
+
+ virtual iter_type
+ do_put(iter_type s, bool intl, ios_base& io,
+ char_type fill, long double units) const
+ {
+ return __money_put(other_abi{}, _M_get(), s, intl, io, fill, units,
+ nullptr);
+ }
+
+ virtual iter_type
+ do_put(iter_type s, bool intl, ios_base& io,
+ char_type fill, const string_type& digits) const
+ {
+ __any_string st;
+ st = digits;
+ return __money_put(other_abi{}, _M_get(), s, intl, io, fill, 0.L,
+ &st);
+ }
+ };
+
+ template<typename _CharT>
+ struct messages_shim : std::messages<_CharT>, facet::__shim
+ {
+ typedef messages_base::catalog catalog;
+ typedef basic_string<_CharT> string_type;
+
+ // f must point to a type derived from messages<C>[abi:other]
+ messages_shim(const facet* f) : __shim(f) { }
+
+ virtual catalog
+ do_open(const basic_string<char>& s, const locale& l) const
+ {
+ return __messages_open<_CharT>(other_abi{}, _M_get(),
+ s.c_str(), s.size(), l);
+ }
+
+ virtual string_type
+ do_get(catalog c, int set, int msgid, const string_type& dfault) const
+ {
+ __any_string st;
+ __messages_get(other_abi{}, _M_get(), st, c, set, msgid,
+ dfault.c_str(), dfault.size());
+ return st;
+ }
+
+ virtual void
+ do_close(catalog c) const
+ {
+ __messages_close<_CharT>(other_abi{}, _M_get(), c);
+ }
+ };
+
+ template class numpunct_shim<char>;
+ template class collate_shim<char>;
+ template class moneypunct_shim<char, true>;
+ template class moneypunct_shim<char, false>;
+ template class money_get_shim<char>;
+ template class money_put_shim<char>;
+ template class messages_shim<char>;
+#ifdef _GLIBCXX_USE_WCHAR_T
+ template class numpunct_shim<wchar_t>;
+ template class collate_shim<wchar_t>;
+ template class moneypunct_shim<wchar_t, true>;
+ template class moneypunct_shim<wchar_t, false>;
+ template class money_get_shim<wchar_t>;
+ template class money_put_shim<wchar_t>;
+ template class messages_shim<wchar_t>;
+#endif
+
+ template<typename C>
+ inline size_t
+ __copy(const C*& dest, const basic_string<C>& s)
+ {
+ auto len = s.length();
+ C* p = new C[len+1];
+ s.copy(p, len);
+ p[len] = '\0';
+ dest = p;
+ return len;
+ }
+
+ } // namespace
+
+ // Now define and instantiate the functions that will be called by the
+ // shim facets defined when this file is recompiled for the other ABI.
+
+ template<typename C>
+ void
+ __numpunct_fill_cache(current_abi, const facet* f, __numpunct_cache<C>* c,
+ const char*& grouping, size_t& grouping_size)
+ {
+ auto* m = static_cast<const numpunct<C>*>(f);
+
+ c->_M_decimal_point = m->decimal_point();
+ c->_M_thousands_sep = m->thousands_sep();
+
+ c->_M_truename = nullptr;
+ c->_M_falsename = nullptr;
+ // set _M_allocated so that if any allocation fails the previously
+ // allocated strings will be deleted in ~__numpunct_c()
+ c->_M_allocated = true;
+
+ c->_M_truename_size = __copy(c->_M_truename, m->truename());
+ c->_M_falsename_size = __copy(c->_M_falsename, m->falsename());
+ // Set grouping last as it is only deleted by ~numpunct_shim() which
+ // won't run if this function throws an exception.
+ grouping_size = __copy(grouping, m->grouping());
+ }
+
+ template void
+ __numpunct_fill_cache(current_abi, const facet*, __numpunct_cache<char>*,
+ const char*&, size_t&);
+
+#ifdef _GLIBCXX_USE_WCHAR_T
+ template void
+ __numpunct_fill_cache(current_abi, const facet*, __numpunct_cache<wchar_t>*,
+ const char*&, size_t&);
+#endif
+
+ template<typename C>
+ int
+ __collate_compare(current_abi, const facet* f, const C* lo1, const C* hi1,
+ const C* lo2, const C* hi2)
+ {
+ return static_cast<const collate<C>*>(f)->compare(lo1, hi1, lo2, hi2);
+ }
+
+ template int
+ __collate_compare(current_abi, const facet*, const char*, const char*,
+ const char*, const char*);
+
+#ifdef _GLIBCXX_USE_WCHAR_T
+ template int
+ __collate_compare(current_abi, const facet*, const wchar_t*, const wchar_t*,
+ const wchar_t*, const wchar_t*);
+#endif
+
+ template<typename C>
+ void
+ __collate_transform(current_abi, const facet* f, __any_string& st,
+ const C* __lo, const C* __hi)
+ {
+ auto* c = static_cast<const collate<C>*>(f);
+ st = c->transform(__lo, __hi);
+ }
+
+ template void
+ __collate_transform(current_abi, const facet*, __any_string&,
+ const char*, const char*);
+
+#ifdef _GLIBCXX_USE_WCHAR_T
+ template void
+ __collate_transform(current_abi, const facet*, __any_string&,
+ const wchar_t*, const wchar_t*);
+#endif
+
+ template<typename C, bool Intl>
+ void
+ __moneypunct_fill_cache(current_abi, const facet* f,
+ __moneypunct_cache<C, Intl>* c)
+ {
+ auto* m = static_cast<const moneypunct<C, Intl>*>(f);
+
+ c->_M_decimal_point = m->decimal_point();
+ c->_M_thousands_sep = m->thousands_sep();
+ c->_M_frac_digits = m->frac_digits();
+
+ c->_M_grouping = nullptr;
+ c->_M_curr_symbol = nullptr;
+ c->_M_positive_sign = nullptr;
+ c->_M_negative_sign = nullptr;
+ // set _M_allocated so that if any allocation fails the previously
+ // allocated strings will be deleted in ~__moneypunct_c()
+ c->_M_allocated = true;
+
+ c->_M_grouping_size = __copy(c->_M_grouping, m->grouping());
+ c->_M_curr_symbol_size = __copy(c->_M_curr_symbol, m->curr_symbol());
+ c->_M_positive_sign_size
+ = __copy(c->_M_positive_sign, m->positive_sign());
+ c->_M_negative_sign_size
+ = __copy(c->_M_negative_sign, m->negative_sign());
+
+ c->_M_pos_format = m->pos_format();
+ c->_M_neg_format = m->neg_format();
+ }
+
+ template void
+ __moneypunct_fill_cache(current_abi, const facet*,
+ __moneypunct_cache<char, true>*);
+
+ template void
+ __moneypunct_fill_cache(current_abi, const facet*,
+ __moneypunct_cache<char, false>*);
+
+#ifdef _GLIBCXX_USE_WCHAR_T
+ template void
+ __moneypunct_fill_cache(current_abi, const facet*,
+ __moneypunct_cache<wchar_t, true>*);
+
+ template void
+ __moneypunct_fill_cache(current_abi, const facet*,
+ __moneypunct_cache<wchar_t, false>*);
+#endif
+
+ template<typename C>
+ messages_base::catalog
+ __messages_open(current_abi, const facet* f, const char* s, size_t n,
+ const locale& l)
+ {
+ auto* m = static_cast<const messages<C>*>(f);
+ string str(s, n);
+ return m->open(str, l);
+ }
+
+ template messages_base::catalog
+ __messages_open<char>(current_abi, const facet*, const char*, size_t,
+ const locale&);
+
+#ifdef _GLIBCXX_USE_WCHAR_T
+ template messages_base::catalog
+ __messages_open<wchar_t>(current_abi, const facet*, const char*, size_t,
+ const locale&);
+#endif
+
+ template<typename C>
+ void
+ __messages_get(current_abi, const facet* f, __any_string& st,
+ messages_base::catalog c, int set, int msgid,
+ const C* s, size_t n)
+ {
+ auto* m = static_cast<const messages<C>*>(f);
+ st = m->get(c, set, msgid, basic_string<C>(s, n));
+ }
+
+ template void
+ __messages_get(current_abi, const facet*, __any_string&,
+ messages_base::catalog, int, int, const char*, size_t);
+
+#ifdef _GLIBCXX_USE_WCHAR_T
+ template void
+ __messages_get(current_abi, const facet*, __any_string&,
+ messages_base::catalog, int, int, const wchar_t*, size_t);
+#endif
+
+ template<typename C>
+ void
+ __messages_close(current_abi, const facet* f, messages_base::catalog c)
+ {
+ static_cast<const messages<C>*>(f)->close(c);
+ }
+
+ template void
+ __messages_close<char>(current_abi, const facet*, messages_base::catalog c);
+
+#ifdef _GLIBCXX_USE_WCHAR_T
+ template void
+ __messages_close<wchar_t>(current_abi, const facet*,
+ messages_base::catalog c);
+#endif
+
+ template<typename C>
+ time_base::dateorder
+ __time_get_dateorder(current_abi, const facet* f)
+ { return static_cast<const time_get<C>*>(f)->date_order(); }
+
+ template time_base::dateorder
+ __time_get_dateorder<char>(current_abi, const facet*);
+
+#ifdef _GLIBCXX_USE_WCHAR_T
+ template time_base::dateorder
+ __time_get_dateorder<wchar_t>(current_abi, const facet*);
+#endif
+
+ template<typename C>
+ istreambuf_iterator<C>
+ __time_get(current_abi, const facet* f,
+ istreambuf_iterator<C> beg, istreambuf_iterator<C> end,
+ ios_base& io, ios_base::iostate& err, tm* t, char which)
+ {
+ auto* g = static_cast<const time_get<C>*>(f);
+ switch(which)
+ {
+ case 't':
+ return g->get_time(beg, end, io, err, t);
+ case 'd':
+ return g->get_date(beg, end, io, err, t);
+ case 'w':
+ return g->get_weekday(beg, end, io, err, t);
+ case 'm':
+ return g->get_monthname(beg, end, io, err, t);
+ case 'y':
+ return g->get_year(beg, end, io, err, t);
+ default:
+ __builtin_unreachable();
+ }
+ }
+
+ template istreambuf_iterator<char>
+ __time_get(current_abi, const facet*,
+ istreambuf_iterator<char>, istreambuf_iterator<char>,
+ ios_base&, ios_base::iostate&, tm*, char);
+
+#ifdef _GLIBCXX_USE_WCHAR_T
+ template istreambuf_iterator<wchar_t>
+ __time_get(current_abi, const facet*,
+ istreambuf_iterator<wchar_t>, istreambuf_iterator<wchar_t>,
+ ios_base&, ios_base::iostate&, tm*, char);
+#endif
+
+ template<typename C>
+ istreambuf_iterator<C>
+ __money_get(current_abi, const facet* f,
+ istreambuf_iterator<C> s, istreambuf_iterator<C> end,
+ bool intl, ios_base& str, ios_base::iostate& err,
+ long double* units, __any_string* digits)
+ {
+ auto* m = static_cast<const money_get<C>*>(f);
+ if (units)
+ return m->get(s, end, intl, str, err, *units);
+ basic_string<C> digits2;
+ s = m->get(s, end, intl, str, err, digits2);
+ if (err == ios_base::goodbit)
+ *digits = digits2;
+ return s;
+ }
+
+ template istreambuf_iterator<char>
+ __money_get(current_abi, const facet*,
+ istreambuf_iterator<char>, istreambuf_iterator<char>,
+ bool, ios_base&, ios_base::iostate&,
+ long double*, __any_string*);
+
+#ifdef _GLIBCXX_USE_WCHAR_T
+ template istreambuf_iterator<wchar_t>
+ __money_get(current_abi, const facet*,
+ istreambuf_iterator<wchar_t>, istreambuf_iterator<wchar_t>,
+ bool, ios_base&, ios_base::iostate&,
+ long double*, __any_string*);
+#endif
+
+ template<typename C>
+ ostreambuf_iterator<C>
+ __money_put(current_abi, const facet* f, ostreambuf_iterator<C> s,
+ bool intl, ios_base& io, C fill, long double units,
+ const __any_string* digits)
+ {
+ auto* m = static_cast<const money_put<C>*>(f);
+ if (digits)
+ return m->put(s, intl, io, fill, *digits);
+ else
+ return m->put(s, intl, io, fill, units);
+ }
+
+ template ostreambuf_iterator<char>
+ __money_put(current_abi, const facet*, ostreambuf_iterator<char>,
+ bool, ios_base&, char, long double, const __any_string*);
+
+#ifdef _GLIBCXX_USE_WCHAR_T
+ template ostreambuf_iterator<wchar_t>
+ __money_put(current_abi, const facet*, ostreambuf_iterator<wchar_t>,
+ bool, ios_base&, wchar_t, long double, const __any_string*);
+#endif
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace __facet_shims
+
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+ // Create a new shim facet of type WHICH that forwards calls to F.
+ // F is the replacement facet provided by the user, WHICH is the ID of
+ // F's "other ABI twin" which we are replacing with a shim.
+ const locale::facet*
+#if _GLIBCXX_USE_CXX11_ABI
+ locale::facet::_M_sso_shim(const locale::id* which) const
+#else
+ locale::facet::_M_cow_shim(const locale::id* which) const
+#endif
+ {
+ using namespace __facet_shims;
+
+#if __cpp_rtti
+ // If this is already a shim just use its underlying facet.
+ if (auto* p = dynamic_cast<const __shim*>(this))
+ return p->_M_get();
+#endif
+
+ if (which == &numpunct<char>::id)
+ return new numpunct_shim<char>{this};
+ if (which == &std::collate<char>::id)
+ return new collate_shim<char>{this};
+ if (which == &time_get<char>::id)
+ return new time_get_shim<char>{this};
+ if (which == &money_get<char>::id)
+ return new money_get_shim<char>{this};
+ if (which == &money_put<char>::id)
+ return new money_put_shim<char>{this};
+ if (which == &moneypunct<char, true>::id)
+ return new moneypunct_shim<char, true>{this};
+ if (which == &moneypunct<char, false>::id)
+ return new moneypunct_shim<char, false>{this};
+ if (which == &std::messages<char>::id)
+ return new messages_shim<char>{this};
+#ifdef _GLIBCXX_USE_WCHAR_T
+ if (which == &numpunct<wchar_t>::id)
+ return new numpunct_shim<wchar_t>{this};
+ if (which == &std::collate<wchar_t>::id)
+ return new collate_shim<wchar_t>{this};
+ if (which == &time_get<wchar_t>::id)
+ return new time_get_shim<wchar_t>{this};
+ if (which == &money_get<wchar_t>::id)
+ return new money_get_shim<wchar_t>{this};
+ if (which == &money_put<wchar_t>::id)
+ return new money_put_shim<wchar_t>{this};
+ if (which == &moneypunct<wchar_t, true>::id)
+ return new moneypunct_shim<wchar_t, true>{this};
+ if (which == &moneypunct<wchar_t, false>::id)
+ return new moneypunct_shim<wchar_t, false>{this};
+ if (which == &std::messages<wchar_t>::id)
+ return new messages_shim<wchar_t>{this};
+#endif
+ __throw_logic_error("cannot create shim for unknown locale::facet");
+ }
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace std
diff --git a/libstdc++-v3/src/c++11/cxx11-stdexcept.cc b/libstdc++-v3/src/c++11/cxx11-stdexcept.cc
new file mode 100644
index 00000000000..328c157b4f7
--- /dev/null
+++ b/libstdc++-v3/src/c++11/cxx11-stdexcept.cc
@@ -0,0 +1,78 @@
+// Methods for Exception Support for -*- C++ -*-
+
+// Copyright (C) 2014-2015 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: 19.1 Exception classes
+//
+
+#define _GLIBCXX_USE_CXX11_ABI 1
+#include <stdexcept>
+
+#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 constructors take an abi-tagged std::string and use it to
+ // initialize an untagged COW std::string in _M_msg.
+
+ logic_error::logic_error(const string& __arg)
+ : _M_msg(__arg) { }
+
+ runtime_error::runtime_error(const string& __arg)
+ : _M_msg(__arg) { }
+
+ // These constructors take an abi-tagged std::string and pass it to the
+ // base class constructors defined above.
+
+ domain_error::domain_error(const string& __arg)
+ : logic_error(__arg) { }
+
+ invalid_argument::invalid_argument(const string& __arg)
+ : logic_error(__arg) { }
+
+ length_error::length_error(const string& __arg)
+ : logic_error(__arg) { }
+
+ out_of_range::out_of_range(const string& __arg)
+ : logic_error(__arg) { }
+
+ range_error::range_error(const string& __arg)
+ : runtime_error(__arg) { }
+
+ overflow_error::overflow_error(const string& __arg)
+ : runtime_error(__arg) { }
+
+ underflow_error::underflow_error(const string& __arg)
+ : runtime_error(__arg) { }
+
+ // Converting constructor from ABI-tagged std::string to COW string.
+ __cow_string::__cow_string(const string& s)
+ : __cow_string(s.c_str(), s.length()) { }
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace
diff --git a/libstdc++-v3/src/c++11/cxx11-wlocale-inst.cc b/libstdc++-v3/src/c++11/cxx11-wlocale-inst.cc
new file mode 100644
index 00000000000..e750a52272f
--- /dev/null
+++ b/libstdc++-v3/src/c++11/cxx11-wlocale-inst.cc
@@ -0,0 +1,32 @@
+// Copyright (C) 2014-2015 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: 22.1 Locales
+//
+
+#define _GLIBCXX_USE_CXX11_ABI 1
+#include <bits/c++config.h>
+#ifdef _GLIBCXX_USE_WCHAR_T
+#define C wchar_t
+#include "cxx11-locale-inst.cc"
+#endif
diff --git a/libstdc++-v3/src/c++11/debug.cc b/libstdc++-v3/src/c++11/debug.cc
index c5dc6fba620..5041c9218dc 100644
--- a/libstdc++-v3/src/c++11/debug.cc
+++ b/libstdc++-v3/src/c++11/debug.cc
@@ -1,6 +1,6 @@
// Debugging mode support code -*- C++ -*-
-// Copyright (C) 2003-2014 Free Software Foundation, Inc.
+// Copyright (C) 2003-2015 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
@@ -23,8 +23,8 @@
// <http://www.gnu.org/licenses/>.
#include <debug/debug.h>
-#include <debug/safe_sequence.h>
-#include <debug/safe_unordered_container.h>
+#include <debug/safe_base.h>
+#include <debug/safe_unordered_base.h>
#include <debug/safe_iterator.h>
#include <debug/safe_local_iterator.h>
#include <algorithm>
@@ -235,7 +235,7 @@ namespace __gnu_debug
void
_Safe_sequence_base::
- _M_swap(_Safe_sequence_base& __x)
+ _M_swap(_Safe_sequence_base& __x) noexcept
{
// We need to lock both sequences to swap
using namespace __gnu_cxx;
@@ -382,7 +382,7 @@ namespace __gnu_debug
_Safe_unordered_container_base*
_Safe_local_iterator_base::
- _M_get_container() const _GLIBCXX_NOEXCEPT
+ _M_get_container() const noexcept
{ return static_cast<_Safe_unordered_container_base*>(_M_sequence); }
void
@@ -455,7 +455,7 @@ namespace __gnu_debug
void
_Safe_unordered_container_base::
- _M_swap(_Safe_unordered_container_base& __x)
+ _M_swap(_Safe_unordered_container_base& __x) noexcept
{
// We need to lock both containers to swap
using namespace __gnu_cxx;
diff --git a/libstdc++-v3/src/c++11/ext11-inst.cc b/libstdc++-v3/src/c++11/ext11-inst.cc
new file mode 100644
index 00000000000..0d9ebc206e2
--- /dev/null
+++ b/libstdc++-v3/src/c++11/ext11-inst.cc
@@ -0,0 +1,40 @@
+// Explicit instantiation file.
+
+// Copyright (C) 2014-2015 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/>.
+
+#include <ext/stdio_filebuf.h>
+#include <ext/stdio_sync_filebuf.h>
+
+namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ template class stdio_filebuf<char>;
+ template class stdio_sync_filebuf<char>;
+#ifdef _GLIBCXX_USE_WCHAR_T
+ template class stdio_filebuf<wchar_t>;
+ template class stdio_sync_filebuf<wchar_t>;
+#endif
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace
diff --git a/libstdc++-v3/src/c++11/fstream-inst.cc b/libstdc++-v3/src/c++11/fstream-inst.cc
index 0ef5fc47e94..8653e623a73 100644
--- a/libstdc++-v3/src/c++11/fstream-inst.cc
+++ b/libstdc++-v3/src/c++11/fstream-inst.cc
@@ -1,6 +1,6 @@
// Explicit instantiation file.
-// Copyright (C) 1997-2014 Free Software Foundation, Inc.
+// Copyright (C) 1997-2015 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
@@ -26,6 +26,7 @@
// ISO C++ 14882:
//
+#define _GLIBCXX_USE_CXX11_ABI 1
#include <fstream>
namespace std _GLIBCXX_VISIBILITY(default)
diff --git a/libstdc++-v3/src/c++11/functexcept.cc b/libstdc++-v3/src/c++11/functexcept.cc
index d184bfc0b6c..b47b4179335 100644
--- a/libstdc++-v3/src/c++11/functexcept.cc
+++ b/libstdc++-v3/src/c++11/functexcept.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2001-2014 Free Software Foundation, Inc.
+// Copyright (C) 2001-2015 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
@@ -20,6 +20,9 @@
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
+// We don't want to change the type thrown by __throw_ios_failure (yet?)
+#define _GLIBCXX_USE_CXX11_ABI 0
+
#include <bits/functexcept.h>
#include <cstdlib>
#include <exception>
diff --git a/libstdc++-v3/src/c++11/functional.cc b/libstdc++-v3/src/c++11/functional.cc
index 13a104ab1be..86cf54157f4 100644
--- a/libstdc++-v3/src/c++11/functional.cc
+++ b/libstdc++-v3/src/c++11/functional.cc
@@ -1,6 +1,6 @@
// Support for <functional> -*- C++ -*-
-// Copyright (C) 2011-2014 Free Software Foundation, Inc.
+// Copyright (C) 2011-2015 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
diff --git a/libstdc++-v3/src/c++11/futex.cc b/libstdc++-v3/src/c++11/futex.cc
new file mode 100644
index 00000000000..1336779dfb7
--- /dev/null
+++ b/libstdc++-v3/src/c++11/futex.cc
@@ -0,0 +1,96 @@
+// futex -*- C++ -*-
+
+// Copyright (C) 2015 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/>.
+
+#include <bits/atomic_futex.h>
+#if defined(_GLIBCXX_HAVE_LINUX_FUTEX) && ATOMIC_INT_LOCK_FREE > 1
+#include <chrono>
+#include <climits>
+#include <syscall.h>
+#include <unistd.h>
+#include <sys/time.h>
+#include <errno.h>
+#include <debug/debug.h>
+
+// Constants for the wait/wake futex syscall operations
+const unsigned futex_wait_op = 0;
+const unsigned futex_wake_op = 1;
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ bool
+ __atomic_futex_unsigned_base::_M_futex_wait_until(unsigned *__addr,
+ unsigned __val,
+ bool __has_timeout, chrono::seconds __s, chrono::nanoseconds __ns)
+ {
+ if (!__has_timeout)
+ {
+ // Ignore whether we actually succeeded to block because at worst,
+ // we will fall back to spin-waiting. The only thing we could do
+ // here on errors is abort.
+ int ret __attribute__((unused));
+ ret = syscall (SYS_futex, __addr, futex_wait_op, __val);
+ _GLIBCXX_DEBUG_ASSERT(ret == 0 || errno == EINTR || errno == EAGAIN);
+ return true;
+ }
+ else
+ {
+ struct timeval tv;
+ gettimeofday (&tv, NULL);
+ // Convert the absolute timeout value to a relative timeout
+ struct timespec rt;
+ rt.tv_sec = __s.count() - tv.tv_sec;
+ rt.tv_nsec = __ns.count() - tv.tv_usec * 1000;
+ if (rt.tv_nsec < 0)
+ {
+ rt.tv_nsec += 1000000000;
+ --rt.tv_sec;
+ }
+ // Did we already time out?
+ if (rt.tv_sec < 0)
+ return false;
+
+ if (syscall (SYS_futex, __addr, futex_wait_op, __val, &rt) == -1)
+ {
+ _GLIBCXX_DEBUG_ASSERT(errno == EINTR || errno == EAGAIN
+ || errno == ETIMEDOUT);
+ if (errno == ETIMEDOUT)
+ return false;
+ }
+ return true;
+ }
+ }
+
+ void
+ __atomic_futex_unsigned_base::_M_futex_notify_all(unsigned* __addr)
+ {
+ // This syscall can fail for various reasons, including in situations
+ // in which there is no real error. Thus, we don't bother checking
+ // the error codes. See the futex documentation and glibc for background.
+ syscall (SYS_futex, __addr, futex_wake_op, INT_MAX);
+ }
+
+}
+#endif
diff --git a/libstdc++-v3/src/c++11/future.cc b/libstdc++-v3/src/c++11/future.cc
index 6ffab18d4d4..c711a5fe823 100644
--- a/libstdc++-v3/src/c++11/future.cc
+++ b/libstdc++-v3/src/c++11/future.cc
@@ -1,6 +1,6 @@
// future -*- C++ -*-
-// Copyright (C) 2009-2014 Free Software Foundation, Inc.
+// Copyright (C) 2009-2015 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
@@ -82,6 +82,29 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
__future_base::_Result_base::_Result_base() = default;
__future_base::_Result_base::~_Result_base() = default;
+
+ void
+ __future_base::_State_baseV2::_Make_ready::_S_run(void* p)
+ {
+ unique_ptr<_Make_ready> mr{static_cast<_Make_ready*>(p)};
+ if (auto state = mr->_M_shared_state.lock())
+ {
+ // Use release MO to synchronize with observers of the ready state.
+ state->_M_status._M_store_notify_all(_Status::__ready,
+ memory_order_release);
+ }
+ }
+
+ // defined in src/c++11/condition_variable.cc
+ extern void
+ __at_thread_exit(__at_thread_exit_elt* elt);
+
+ void
+ __future_base::_State_baseV2::_Make_ready::_M_set()
+ {
+ _M_cb = &_Make_ready::_S_run;
+ __at_thread_exit(this);
+ }
#endif
_GLIBCXX_END_NAMESPACE_VERSION
diff --git a/libstdc++-v3/src/c++11/hash_c++0x.cc b/libstdc++-v3/src/c++11/hash_c++0x.cc
index defd38977eb..1d68f7ecac8 100644
--- a/libstdc++-v3/src/c++11/hash_c++0x.cc
+++ b/libstdc++-v3/src/c++11/hash_c++0x.cc
@@ -1,6 +1,6 @@
// std::hash definitions -*- C++ -*-
-// Copyright (C) 2010-2014 Free Software Foundation, Inc.
+// Copyright (C) 2010-2015 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
diff --git a/libstdc++-v3/src/c++11/hashtable_c++0x.cc b/libstdc++-v3/src/c++11/hashtable_c++0x.cc
index c95742d5f5e..22de51bba0f 100644
--- a/libstdc++-v3/src/c++11/hashtable_c++0x.cc
+++ b/libstdc++-v3/src/c++11/hashtable_c++0x.cc
@@ -1,6 +1,6 @@
// std::__detail definitions -*- C++ -*-
-// Copyright (C) 2007-2014 Free Software Foundation, Inc.
+// Copyright (C) 2007-2015 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
diff --git a/libstdc++-v3/src/c++11/ios-inst.cc b/libstdc++-v3/src/c++11/ios-inst.cc
new file mode 100644
index 00000000000..809e828c5ad
--- /dev/null
+++ b/libstdc++-v3/src/c++11/ios-inst.cc
@@ -0,0 +1,42 @@
+// Explicit instantiation file.
+
+// Copyright (C) 1997-2015 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:
+//
+
+#include <ios>
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ template class basic_ios<char>;
+
+#ifdef _GLIBCXX_USE_WCHAR_T
+ template class basic_ios<wchar_t>;
+#endif
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace
diff --git a/libstdc++-v3/src/c++11/ios.cc b/libstdc++-v3/src/c++11/ios.cc
new file mode 100644
index 00000000000..4adc7019293
--- /dev/null
+++ b/libstdc++-v3/src/c++11/ios.cc
@@ -0,0 +1,259 @@
+// Iostreams base classes -*- C++ -*-
+
+// Copyright (C) 1997-2015 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: 27.4 Iostreams base classes
+//
+
+#include <ios>
+#include <limits>
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ // Definitions for static const members of ios_base.
+ const ios_base::fmtflags ios_base::boolalpha;
+ const ios_base::fmtflags ios_base::dec;
+ const ios_base::fmtflags ios_base::fixed;
+ const ios_base::fmtflags ios_base::hex;
+ const ios_base::fmtflags ios_base::internal;
+ const ios_base::fmtflags ios_base::left;
+ const ios_base::fmtflags ios_base::oct;
+ const ios_base::fmtflags ios_base::right;
+ const ios_base::fmtflags ios_base::scientific;
+ const ios_base::fmtflags ios_base::showbase;
+ const ios_base::fmtflags ios_base::showpoint;
+ const ios_base::fmtflags ios_base::showpos;
+ const ios_base::fmtflags ios_base::skipws;
+ const ios_base::fmtflags ios_base::unitbuf;
+ const ios_base::fmtflags ios_base::uppercase;
+ const ios_base::fmtflags ios_base::adjustfield;
+ const ios_base::fmtflags ios_base::basefield;
+ const ios_base::fmtflags ios_base::floatfield;
+
+ const ios_base::iostate ios_base::badbit;
+ const ios_base::iostate ios_base::eofbit;
+ const ios_base::iostate ios_base::failbit;
+ const ios_base::iostate ios_base::goodbit;
+
+ const ios_base::openmode ios_base::app;
+ const ios_base::openmode ios_base::ate;
+ const ios_base::openmode ios_base::binary;
+ const ios_base::openmode ios_base::in;
+ const ios_base::openmode ios_base::out;
+ const ios_base::openmode ios_base::trunc;
+
+ const ios_base::seekdir ios_base::beg;
+ const ios_base::seekdir ios_base::cur;
+ const ios_base::seekdir ios_base::end;
+
+ _Atomic_word ios_base::Init::_S_refcount;
+
+ bool ios_base::Init::_S_synced_with_stdio = true;
+
+ ios_base::ios_base() throw()
+ : _M_precision(), _M_width(), _M_flags(), _M_exception(),
+ _M_streambuf_state(), _M_callbacks(0), _M_word_zero(),
+ _M_word_size(_S_local_word_size), _M_word(_M_local_word), _M_ios_locale()
+ {
+ // Do nothing: basic_ios::init() does it.
+ // NB: _M_callbacks and _M_word must be zero for non-initialized
+ // ios_base to go through ~ios_base gracefully.
+ }
+
+ // 27.4.2.7 ios_base constructors/destructors
+ ios_base::~ios_base()
+ {
+ _M_call_callbacks(erase_event);
+ _M_dispose_callbacks();
+ if (_M_word != _M_local_word)
+ {
+ delete [] _M_word;
+ _M_word = 0;
+ }
+ }
+
+ // 27.4.2.5 ios_base storage functions
+ int
+ ios_base::xalloc() throw()
+ {
+ // Implementation note: Initialize top to zero to ensure that
+ // initialization occurs before main() is started.
+ static _Atomic_word _S_top = 0;
+ return __gnu_cxx::__exchange_and_add_dispatch(&_S_top, 1) + 4;
+ }
+
+ void
+ ios_base::register_callback(event_callback __fn, int __index)
+ { _M_callbacks = new _Callback_list(__fn, __index, _M_callbacks); }
+
+ // 27.4.2.5 iword/pword storage
+ ios_base::_Words&
+ ios_base::_M_grow_words(int __ix, bool __iword)
+ {
+ // Precondition: _M_word_size <= __ix
+ int __newsize = _S_local_word_size;
+ _Words* __words = _M_local_word;
+ if (__ix > _S_local_word_size - 1)
+ {
+ if (__ix < numeric_limits<int>::max())
+ {
+ __newsize = __ix + 1;
+ __try
+ { __words = new _Words[__newsize]; }
+ __catch(const std::bad_alloc&)
+ {
+ _M_streambuf_state |= badbit;
+ if (_M_streambuf_state & _M_exception)
+ __throw_ios_failure(__N("ios_base::_M_grow_words "
+ "allocation failed"));
+ if (__iword)
+ _M_word_zero._M_iword = 0;
+ else
+ _M_word_zero._M_pword = 0;
+ return _M_word_zero;
+ }
+ for (int __i = 0; __i < _M_word_size; __i++)
+ __words[__i] = _M_word[__i];
+ if (_M_word && _M_word != _M_local_word)
+ {
+ delete [] _M_word;
+ _M_word = 0;
+ }
+ }
+ else
+ {
+ _M_streambuf_state |= badbit;
+ if (_M_streambuf_state & _M_exception)
+ __throw_ios_failure(__N("ios_base::_M_grow_words is not valid"));
+ if (__iword)
+ _M_word_zero._M_iword = 0;
+ else
+ _M_word_zero._M_pword = 0;
+ return _M_word_zero;
+ }
+ }
+ _M_word = __words;
+ _M_word_size = __newsize;
+ return _M_word[__ix];
+ }
+
+ void
+ ios_base::_M_call_callbacks(event __e) throw()
+ {
+ _Callback_list* __p = _M_callbacks;
+ while (__p)
+ {
+ __try
+ { (*__p->_M_fn) (__e, *this, __p->_M_index); }
+ __catch(...)
+ { }
+ __p = __p->_M_next;
+ }
+ }
+
+ void
+ ios_base::_M_dispose_callbacks(void) throw()
+ {
+ _Callback_list* __p = _M_callbacks;
+ while (__p && __p->_M_remove_reference() == 0)
+ {
+ _Callback_list* __next = __p->_M_next;
+ delete __p;
+ __p = __next;
+ }
+ _M_callbacks = 0;
+ }
+
+ void
+ ios_base::_M_move(ios_base& __rhs) noexcept
+ {
+ _M_precision = __rhs._M_precision;
+ _M_width = __rhs._M_width;
+ _M_flags = __rhs._M_flags;
+ _M_exception = __rhs._M_exception;
+ _M_streambuf_state = __rhs._M_streambuf_state;
+ _M_callbacks = std::__exchange(__rhs._M_callbacks, nullptr);
+ if (_M_word != _M_local_word)
+ delete[] _M_word;
+ if (__rhs._M_word == __rhs._M_local_word)
+ {
+ _M_word = _M_local_word;
+ _M_word_size = _S_local_word_size;
+ for (int __i = 0; __i < _S_local_word_size; __i++)
+ _M_word[__i] = std::__exchange(__rhs._M_word[__i], {});
+ }
+ else
+ {
+ _M_word = std::__exchange(__rhs._M_word, __rhs._M_local_word);
+ _M_word_size
+ = std::__exchange(__rhs._M_word_size, _S_local_word_size);
+ }
+ _M_ios_locale = __rhs._M_ios_locale;
+ }
+
+ void
+ ios_base::_M_swap(ios_base& __rhs) noexcept
+ {
+ std::swap(_M_precision, __rhs._M_precision);
+ std::swap(_M_width, __rhs._M_width);
+ std::swap(_M_flags, __rhs._M_flags);
+ std::swap(_M_exception, __rhs._M_exception);
+ std::swap(_M_streambuf_state, __rhs._M_streambuf_state);
+ std::swap(_M_callbacks, __rhs._M_callbacks);
+ const bool __lhs_local = _M_word == _M_local_word;
+ const bool __rhs_local = __rhs._M_word == __rhs._M_local_word;
+ if (__lhs_local && __rhs_local)
+ std::swap(_M_local_word, __rhs._M_local_word); // array swap
+ else
+ {
+ if (!__lhs_local && !__rhs_local)
+ std::swap(_M_word, __rhs._M_word);
+ else
+ {
+ ios_base* __local;
+ ios_base* __allocated;
+ if (__lhs_local)
+ {
+ __local = this;
+ __allocated = &__rhs;
+ }
+ else
+ {
+ __local = &__rhs;
+ __allocated= this;
+ }
+ for (int __i = 0; __i < _S_local_word_size; __i++)
+ __allocated->_M_local_word[__i] = __local->_M_local_word[__i];
+ __local->_M_word = __allocated->_M_word;
+ __allocated->_M_word = __allocated->_M_local_word;
+ }
+ std::swap(_M_word_size, __rhs._M_word_size);
+ }
+ std::swap(_M_ios_locale, __rhs._M_ios_locale);
+ }
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace
diff --git a/libstdc++-v3/src/c++11/iostream-inst.cc b/libstdc++-v3/src/c++11/iostream-inst.cc
new file mode 100644
index 00000000000..2ac59cab414
--- /dev/null
+++ b/libstdc++-v3/src/c++11/iostream-inst.cc
@@ -0,0 +1,47 @@
+// Explicit instantiation file.
+
+// Copyright (C) 1997-2015 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:
+//
+
+#include <iomanip>
+#include <istream>
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ template class _Setfill<char>;
+ template _Setfill<char> setfill(char);
+ template class basic_iostream<char>;
+
+#ifdef _GLIBCXX_USE_WCHAR_T
+ template class _Setfill<wchar_t>;
+ template _Setfill<wchar_t> setfill(wchar_t);
+ template class basic_iostream<wchar_t>;
+#endif
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace
diff --git a/libstdc++-v3/src/c++11/istream-inst.cc b/libstdc++-v3/src/c++11/istream-inst.cc
new file mode 100644
index 00000000000..a209a01ca63
--- /dev/null
+++ b/libstdc++-v3/src/c++11/istream-inst.cc
@@ -0,0 +1,114 @@
+// Explicit instantiation file.
+
+// Copyright (C) 1997-2015 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:
+//
+
+#include <istream>
+#include <iomanip>
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ template class basic_istream<char>;
+ template istream& ws(istream&);
+ template istream& operator>>(istream&, char&);
+ template istream& operator>>(istream&, unsigned char&);
+ template istream& operator>>(istream&, signed char&);
+ template istream& operator>>(istream&, char*);
+ template istream& operator>>(istream&, unsigned char*);
+ template istream& operator>>(istream&, signed char*);
+
+ template istream& operator>>(istream&, _Setfill<char>);
+ template istream& operator>>(istream&, _Setiosflags);
+ template istream& operator>>(istream&, _Resetiosflags);
+ template istream& operator>>(istream&, _Setbase);
+ template istream& operator>>(istream&, _Setprecision);
+ template istream& operator>>(istream&, _Setw);
+
+ template istream& istream::_M_extract(unsigned short&);
+ template istream& istream::_M_extract(unsigned int&);
+ template istream& istream::_M_extract(long&);
+ template istream& istream::_M_extract(unsigned long&);
+ template istream& istream::_M_extract(bool&);
+#ifdef _GLIBCXX_USE_LONG_LONG
+ template istream& istream::_M_extract(long long&);
+ template istream& istream::_M_extract(unsigned long long&);
+#endif
+ template istream& istream::_M_extract(float&);
+ template istream& istream::_M_extract(double&);
+ template istream& istream::_M_extract(long double&);
+ template istream& istream::_M_extract(void*&);
+
+#ifdef _GLIBCXX_USE_WCHAR_T
+ template class basic_istream<wchar_t>;
+ template wistream& ws(wistream&);
+ template wistream& operator>>(wistream&, wchar_t&);
+ template wistream& operator>>(wistream&, wchar_t*);
+
+ template wistream& operator>>(wistream&, _Setfill<wchar_t>);
+ template wistream& operator>>(wistream&, _Setiosflags);
+ template wistream& operator>>(wistream&, _Resetiosflags);
+ template wistream& operator>>(wistream&, _Setbase);
+ template wistream& operator>>(wistream&, _Setprecision);
+ template wistream& operator>>(wistream&, _Setw);
+
+ template wistream& wistream::_M_extract(unsigned short&);
+ template wistream& wistream::_M_extract(unsigned int&);
+ template wistream& wistream::_M_extract(long&);
+ template wistream& wistream::_M_extract(unsigned long&);
+ template wistream& wistream::_M_extract(bool&);
+#ifdef _GLIBCXX_USE_LONG_LONG
+ template wistream& wistream::_M_extract(long long&);
+ template wistream& wistream::_M_extract(unsigned long long&);
+#endif
+ template wistream& wistream::_M_extract(float&);
+ template wistream& wistream::_M_extract(double&);
+ template wistream& wistream::_M_extract(long double&);
+ template wistream& wistream::_M_extract(void*&);
+#endif
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace
+
+// XXX GLIBCXX_ABI Deprecated
+#ifdef _GLIBCXX_LONG_DOUBLE_COMPAT
+
+#define _GLIBCXX_LDBL_COMPAT(dbl, ldbl) \
+ extern "C" void ldbl (void) __attribute__ ((alias (#dbl), weak))
+_GLIBCXX_LDBL_COMPAT (_ZNSirsERd, _ZNSirsERe);
+#ifdef _GLIBCXX_USE_WCHAR_T
+_GLIBCXX_LDBL_COMPAT (_ZNSt13basic_istreamIwSt11char_traitsIwEErsERd,
+ _ZNSt13basic_istreamIwSt11char_traitsIwEErsERe);
+#endif
+_GLIBCXX_LDBL_COMPAT (_ZNSi10_M_extractIdEERSiRT_,
+ _ZNSi10_M_extractIeEERSiRT_);
+#ifdef _GLIBCXX_USE_WCHAR_T
+_GLIBCXX_LDBL_COMPAT (_ZNSt13basic_istreamIwSt11char_traitsIwEE10_M_extractIdEERS2_RT_,
+ _ZNSt13basic_istreamIwSt11char_traitsIwEE10_M_extractIeEERS2_RT_);
+#endif
+
+#endif // _GLIBCXX_LONG_DOUBLE_COMPAT
diff --git a/libstdc++-v3/src/c++11/limits.cc b/libstdc++-v3/src/c++11/limits.cc
index 73335e7dc2b..5866a5a7d48 100644
--- a/libstdc++-v3/src/c++11/limits.cc
+++ b/libstdc++-v3/src/c++11/limits.cc
@@ -1,6 +1,6 @@
// Static data members of -*- C++ -*- numeric_limits classes
-// Copyright (C) 1999-2014 Free Software Foundation, Inc.
+// Copyright (C) 1999-2015 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
@@ -388,54 +388,66 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
const bool numeric_limits<unsigned long long>::tinyness_before;
const float_round_style numeric_limits<unsigned long long>::round_style;
-#if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_INT128)
- const bool numeric_limits<__int128>::is_specialized;
- const int numeric_limits<__int128>::digits;
- const int numeric_limits<__int128>::digits10;
- const int numeric_limits<__int128>::max_digits10;
- const bool numeric_limits<__int128>::is_signed;
- const bool numeric_limits<__int128>::is_integer;
- const bool numeric_limits<__int128>::is_exact;
- const int numeric_limits<__int128>::radix;
- const int numeric_limits<__int128>::min_exponent;
- const int numeric_limits<__int128>::min_exponent10;
- const int numeric_limits<__int128>::max_exponent;
- const int numeric_limits<__int128>::max_exponent10;
- const bool numeric_limits<__int128>::has_infinity;
- const bool numeric_limits<__int128>::has_quiet_NaN;
- const bool numeric_limits<__int128>::has_signaling_NaN;
- const float_denorm_style numeric_limits<__int128>::has_denorm;
- const bool numeric_limits<__int128>::has_denorm_loss;
- const bool numeric_limits<__int128>::is_iec559;
- const bool numeric_limits<__int128>::is_bounded;
- const bool numeric_limits<__int128>::is_modulo;
- const bool numeric_limits<__int128>::traps;
- const bool numeric_limits<__int128>::tinyness_before;
- const float_round_style numeric_limits<__int128>::round_style;
-
- const bool numeric_limits<unsigned __int128>::is_specialized;
- const int numeric_limits<unsigned __int128>::digits;
- const int numeric_limits<unsigned __int128>::digits10;
- const int numeric_limits<unsigned __int128>::max_digits10;
- const bool numeric_limits<unsigned __int128>::is_signed;
- const bool numeric_limits<unsigned __int128>::is_integer;
- const bool numeric_limits<unsigned __int128>::is_exact;
- const int numeric_limits<unsigned __int128>::radix;
- const int numeric_limits<unsigned __int128>::min_exponent;
- const int numeric_limits<unsigned __int128>::min_exponent10;
- const int numeric_limits<unsigned __int128>::max_exponent;
- const int numeric_limits<unsigned __int128>::max_exponent10;
- const bool numeric_limits<unsigned __int128>::has_infinity;
- const bool numeric_limits<unsigned __int128>::has_quiet_NaN;
- const bool numeric_limits<unsigned __int128>::has_signaling_NaN;
- const float_denorm_style numeric_limits<unsigned __int128>::has_denorm;
- const bool numeric_limits<unsigned __int128>::has_denorm_loss;
- const bool numeric_limits<unsigned __int128>::is_iec559;
- const bool numeric_limits<unsigned __int128>::is_bounded;
- const bool numeric_limits<unsigned __int128>::is_modulo;
- const bool numeric_limits<unsigned __int128>::traps;
- const bool numeric_limits<unsigned __int128>::tinyness_before;
- const float_round_style numeric_limits<unsigned __int128>::round_style;
+#define INT_N(__INT_N_TYPE) \
+ const bool numeric_limits<__INT_N_TYPE>::is_specialized; \
+ const int numeric_limits<__INT_N_TYPE>::digits; \
+ const int numeric_limits<__INT_N_TYPE>::digits10; \
+ const int numeric_limits<__INT_N_TYPE>::max_digits10; \
+ const bool numeric_limits<__INT_N_TYPE>::is_signed; \
+ const bool numeric_limits<__INT_N_TYPE>::is_integer; \
+ const bool numeric_limits<__INT_N_TYPE>::is_exact; \
+ const int numeric_limits<__INT_N_TYPE>::radix; \
+ const int numeric_limits<__INT_N_TYPE>::min_exponent; \
+ const int numeric_limits<__INT_N_TYPE>::min_exponent10; \
+ const int numeric_limits<__INT_N_TYPE>::max_exponent; \
+ const int numeric_limits<__INT_N_TYPE>::max_exponent10; \
+ const bool numeric_limits<__INT_N_TYPE>::has_infinity; \
+ const bool numeric_limits<__INT_N_TYPE>::has_quiet_NaN; \
+ const bool numeric_limits<__INT_N_TYPE>::has_signaling_NaN; \
+ const float_denorm_style numeric_limits<__INT_N_TYPE>::has_denorm; \
+ const bool numeric_limits<__INT_N_TYPE>::has_denorm_loss; \
+ const bool numeric_limits<__INT_N_TYPE>::is_iec559; \
+ const bool numeric_limits<__INT_N_TYPE>::is_bounded; \
+ const bool numeric_limits<__INT_N_TYPE>::is_modulo; \
+ const bool numeric_limits<__INT_N_TYPE>::traps; \
+ const bool numeric_limits<__INT_N_TYPE>::tinyness_before; \
+ const float_round_style numeric_limits<__INT_N_TYPE>::round_style; \
+ \
+ const bool numeric_limits<unsigned __INT_N_TYPE>::is_specialized; \
+ const int numeric_limits<unsigned __INT_N_TYPE>::digits; \
+ const int numeric_limits<unsigned __INT_N_TYPE>::digits10; \
+ const int numeric_limits<unsigned __INT_N_TYPE>::max_digits10; \
+ const bool numeric_limits<unsigned __INT_N_TYPE>::is_signed; \
+ const bool numeric_limits<unsigned __INT_N_TYPE>::is_integer; \
+ const bool numeric_limits<unsigned __INT_N_TYPE>::is_exact; \
+ const int numeric_limits<unsigned __INT_N_TYPE>::radix; \
+ const int numeric_limits<unsigned __INT_N_TYPE>::min_exponent; \
+ const int numeric_limits<unsigned __INT_N_TYPE>::min_exponent10; \
+ const int numeric_limits<unsigned __INT_N_TYPE>::max_exponent; \
+ const int numeric_limits<unsigned __INT_N_TYPE>::max_exponent10; \
+ const bool numeric_limits<unsigned __INT_N_TYPE>::has_infinity; \
+ const bool numeric_limits<unsigned __INT_N_TYPE>::has_quiet_NaN; \
+ const bool numeric_limits<unsigned __INT_N_TYPE>::has_signaling_NaN; \
+ const float_denorm_style numeric_limits<unsigned __INT_N_TYPE>::has_denorm; \
+ const bool numeric_limits<unsigned __INT_N_TYPE>::has_denorm_loss; \
+ const bool numeric_limits<unsigned __INT_N_TYPE>::is_iec559; \
+ const bool numeric_limits<unsigned __INT_N_TYPE>::is_bounded; \
+ const bool numeric_limits<unsigned __INT_N_TYPE>::is_modulo; \
+ const bool numeric_limits<unsigned __INT_N_TYPE>::traps; \
+ const bool numeric_limits<unsigned __INT_N_TYPE>::tinyness_before; \
+ const float_round_style numeric_limits<unsigned __INT_N_TYPE>::round_style;
+
+#ifdef __GLIBCXX_TYPE_INT_N_0
+ INT_N (__GLIBCXX_TYPE_INT_N_0)
+#endif
+#ifdef __GLIBCXX_TYPE_INT_N_1
+ INT_N (__GLIBCXX_TYPE_INT_N_1)
+#endif
+#ifdef __GLIBCXX_TYPE_INT_N_2
+ INT_N (__GLIBCXX_TYPE_INT_N_2)
+#endif
+#ifdef __GLIBCXX_TYPE_INT_N_3
+ INT_N (__GLIBCXX_TYPE_INT_N_3)
#endif
// float
diff --git a/libstdc++-v3/src/c++11/locale-inst.cc b/libstdc++-v3/src/c++11/locale-inst.cc
new file mode 100644
index 00000000000..573da4d433e
--- /dev/null
+++ b/libstdc++-v3/src/c++11/locale-inst.cc
@@ -0,0 +1,413 @@
+// Locale support -*- C++ -*-
+
+// Copyright (C) 1999-2015 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: 22.1 Locales
+//
+
+#ifndef _GLIBCXX_USE_CXX11_ABI
+// Instantiations in this file use the old COW std::string ABI unless included
+// by another file which defines _GLIBCXX_USE_CXX11_ABI=1. Some instantiations
+// are guarded by a check for !_GLIBCXX_USE_CXX11_ABI so that they are only
+// instantiated once, because they are not tagged with abi_tag so should not
+// be instantiated twice.
+# define _GLIBCXX_USE_CXX11_ABI 0
+#endif
+
+#include <locale>
+
+// Instantiation configuration.
+#ifndef C
+# define C char
+# define C_is_char
+#endif
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ // moneypunct, money_get, and money_put
+#if ! _GLIBCXX_USE_CXX11_ABI
+ template struct __moneypunct_cache<C, false>;
+ template struct __moneypunct_cache<C, true>;
+#endif
+_GLIBCXX_BEGIN_NAMESPACE_CXX11
+ template class moneypunct<C, false>;
+ template class moneypunct<C, true>;
+ template class moneypunct_byname<C, false>;
+ template class moneypunct_byname<C, true>;
+_GLIBCXX_END_NAMESPACE_CXX11
+_GLIBCXX_BEGIN_NAMESPACE_LDBL_OR_CXX11
+ template class money_get<C, istreambuf_iterator<C> >;
+ template class money_put<C, ostreambuf_iterator<C> >;
+ template
+ istreambuf_iterator<C>
+ money_get<C, istreambuf_iterator<C> >::
+ _M_extract<true>(istreambuf_iterator<C>, istreambuf_iterator<C>,
+ ios_base&, ios_base::iostate&, string&) const;
+
+ template
+ istreambuf_iterator<C>
+ money_get<C, istreambuf_iterator<C> >::
+ _M_extract<false>(istreambuf_iterator<C>, istreambuf_iterator<C>,
+ ios_base&, ios_base::iostate&, string&) const;
+
+ template
+ ostreambuf_iterator<C>
+ money_put<C, ostreambuf_iterator<C> >::
+ _M_insert<true>(ostreambuf_iterator<C>, ios_base&, C,
+ const string_type&) const;
+
+ template
+ ostreambuf_iterator<C>
+ money_put<C, ostreambuf_iterator<C> >::
+ _M_insert<false>(ostreambuf_iterator<C>, ios_base&, C,
+ const string_type&) const;
+_GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
+
+ // numpunct, numpunct_byname, num_get, and num_put
+#if ! _GLIBCXX_USE_CXX11_ABI
+ template struct __numpunct_cache<C>;
+#endif
+_GLIBCXX_BEGIN_NAMESPACE_CXX11
+ template class numpunct<C>;
+ template class numpunct_byname<C>;
+_GLIBCXX_END_NAMESPACE_CXX11
+_GLIBCXX_BEGIN_NAMESPACE_LDBL
+#if ! _GLIBCXX_USE_CXX11_ABI
+ template class num_get<C, istreambuf_iterator<C> >;
+#endif
+
+ template
+ istreambuf_iterator<C>
+ num_get<C, istreambuf_iterator<C> >::
+ _M_extract_int(istreambuf_iterator<C>, istreambuf_iterator<C>,
+ ios_base&, ios_base::iostate&,
+ long&) const;
+
+ template
+ istreambuf_iterator<C>
+ num_get<C, istreambuf_iterator<C> >::
+ _M_extract_int(istreambuf_iterator<C>, istreambuf_iterator<C>,
+ ios_base&, ios_base::iostate&,
+ unsigned short&) const;
+
+ template
+ istreambuf_iterator<C>
+ num_get<C, istreambuf_iterator<C> >::
+ _M_extract_int(istreambuf_iterator<C>, istreambuf_iterator<C>,
+ ios_base&, ios_base::iostate&,
+ unsigned int&) const;
+
+ template
+ istreambuf_iterator<C>
+ num_get<C, istreambuf_iterator<C> >::
+ _M_extract_int(istreambuf_iterator<C>, istreambuf_iterator<C>,
+ ios_base&, ios_base::iostate&,
+ unsigned long&) const;
+
+#ifdef _GLIBCXX_USE_LONG_LONG
+ template
+ istreambuf_iterator<C>
+ num_get<C, istreambuf_iterator<C> >::
+ _M_extract_int(istreambuf_iterator<C>, istreambuf_iterator<C>,
+ ios_base&, ios_base::iostate&,
+ long long&) const;
+
+ template
+ istreambuf_iterator<C>
+ num_get<C, istreambuf_iterator<C> >::
+ _M_extract_int(istreambuf_iterator<C>, istreambuf_iterator<C>,
+ ios_base&, ios_base::iostate&,
+ unsigned long long&) const;
+#endif
+
+#if ! _GLIBCXX_USE_CXX11_ABI
+ template class num_put<C, ostreambuf_iterator<C> >;
+
+ template
+ ostreambuf_iterator<C>
+ num_put<C, ostreambuf_iterator<C> >::
+ _M_insert_int(ostreambuf_iterator<C>, ios_base&, C,
+ long) const;
+
+ template
+ ostreambuf_iterator<C>
+ num_put<C, ostreambuf_iterator<C> >::
+ _M_insert_int(ostreambuf_iterator<C>, ios_base&, C,
+ unsigned long) const;
+
+#ifdef _GLIBCXX_USE_LONG_LONG
+ template
+ ostreambuf_iterator<C>
+ num_put<C, ostreambuf_iterator<C> >::
+ _M_insert_int(ostreambuf_iterator<C>, ios_base&, C,
+ long long) const;
+
+ template
+ ostreambuf_iterator<C>
+ num_put<C, ostreambuf_iterator<C> >::
+ _M_insert_int(ostreambuf_iterator<C>, ios_base&, C,
+ unsigned long long) const;
+#endif
+
+ template
+ ostreambuf_iterator<C>
+ num_put<C, ostreambuf_iterator<C> >::
+ _M_insert_float(ostreambuf_iterator<C>, ios_base&, C, char,
+ double) const;
+
+ template
+ ostreambuf_iterator<C>
+ num_put<C, ostreambuf_iterator<C> >::
+ _M_insert_float(ostreambuf_iterator<C>, ios_base&, C, char,
+ long double) const;
+#endif
+_GLIBCXX_END_NAMESPACE_LDBL
+
+ // time_get and time_put
+#if ! _GLIBCXX_USE_CXX11_ABI
+ template class __timepunct<C>;
+ template struct __timepunct_cache<C>;
+ template class time_put<C, ostreambuf_iterator<C> >;
+ template class time_put_byname<C, ostreambuf_iterator<C> >;
+#endif
+_GLIBCXX_BEGIN_NAMESPACE_CXX11
+ template class time_get<C, istreambuf_iterator<C> >;
+ template class time_get_byname<C, istreambuf_iterator<C> >;
+_GLIBCXX_END_NAMESPACE_CXX11
+
+ // messages
+_GLIBCXX_BEGIN_NAMESPACE_CXX11
+ template class messages<C>;
+ template class messages_byname<C>;
+_GLIBCXX_END_NAMESPACE_CXX11
+
+ // ctype
+#if ! _GLIBCXX_USE_CXX11_ABI
+ inline template class __ctype_abstract_base<C>;
+ template class ctype_byname<C>;
+#endif
+
+ // codecvt
+#if ! _GLIBCXX_USE_CXX11_ABI
+ inline template class __codecvt_abstract_base<C, char, mbstate_t>;
+ template class codecvt_byname<C, char, mbstate_t>;
+#endif
+
+ // collate
+_GLIBCXX_BEGIN_NAMESPACE_CXX11
+ template class collate<C>;
+ template class collate_byname<C>;
+_GLIBCXX_END_NAMESPACE_CXX11
+
+ // use_facet
+#if ! _GLIBCXX_USE_CXX11_ABI
+ template
+ const ctype<C>&
+ use_facet<ctype<C> >(const locale&);
+
+ template
+ const codecvt<C, char, mbstate_t>&
+ use_facet<codecvt<C, char, mbstate_t> >(const locale&);
+#endif
+
+ template
+ const collate<C>&
+ use_facet<collate<C> >(const locale&);
+
+ template
+ const numpunct<C>&
+ use_facet<numpunct<C> >(const locale&);
+
+#if ! _GLIBCXX_USE_CXX11_ABI
+ template
+ const num_put<C>&
+ use_facet<num_put<C> >(const locale&);
+
+ template
+ const num_get<C>&
+ use_facet<num_get<C> >(const locale&);
+#endif
+
+ template
+ const moneypunct<C, true>&
+ use_facet<moneypunct<C, true> >(const locale&);
+
+ template
+ const moneypunct<C, false>&
+ use_facet<moneypunct<C, false> >(const locale&);
+
+ template
+ const money_put<C>&
+ use_facet<money_put<C> >(const locale&);
+
+ template
+ const money_get<C>&
+ use_facet<money_get<C> >(const locale&);
+
+#if ! _GLIBCXX_USE_CXX11_ABI
+ template
+ const __timepunct<C>&
+ use_facet<__timepunct<C> >(const locale&);
+
+ template
+ const time_put<C>&
+ use_facet<time_put<C> >(const locale&);
+#endif
+
+ template
+ const time_get<C>&
+ use_facet<time_get<C> >(const locale&);
+
+ template
+ const messages<C>&
+ use_facet<messages<C> >(const locale&);
+
+ // has_facet
+#if ! _GLIBCXX_USE_CXX11_ABI
+ template
+ bool
+ has_facet<ctype<C> >(const locale&);
+
+ template
+ bool
+ has_facet<codecvt<C, char, mbstate_t> >(const locale&);
+#endif
+
+ template
+ bool
+ has_facet<collate<C> >(const locale&);
+
+ template
+ bool
+ has_facet<numpunct<C> >(const locale&);
+
+#if ! _GLIBCXX_USE_CXX11_ABI
+ template
+ bool
+ has_facet<num_put<C> >(const locale&);
+
+ template
+ bool
+ has_facet<num_get<C> >(const locale&);
+#endif
+
+ template
+ bool
+ has_facet<moneypunct<C> >(const locale&);
+
+ template
+ bool
+ has_facet<money_put<C> >(const locale&);
+
+ template
+ bool
+ has_facet<money_get<C> >(const locale&);
+
+#if ! _GLIBCXX_USE_CXX11_ABI
+ template
+ bool
+ has_facet<__timepunct<C> >(const locale&);
+
+ template
+ bool
+ has_facet<time_put<C> >(const locale&);
+#endif
+
+ template
+ bool
+ has_facet<time_get<C> >(const locale&);
+
+ template
+ bool
+ has_facet<messages<C> >(const locale&);
+
+
+#if ! _GLIBCXX_USE_CXX11_ABI
+ // locale functions.
+ template
+ C*
+ __add_grouping<C>(C*, C, char const*, size_t,
+ C const*, C const*);
+
+ template class __pad<C, char_traits<C> >;
+
+ template
+ int
+ __int_to_char(C*, unsigned long, const C*,
+ ios_base::fmtflags, bool);
+
+#ifdef _GLIBCXX_USE_LONG_LONG
+ template
+ int
+ __int_to_char(C*, unsigned long long, const C*,
+ ios_base::fmtflags, bool);
+#endif
+#endif
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace
+
+// XXX GLIBCXX_ABI Deprecated
+#if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined C_is_char \
+ && _GLIBCXX_USE_CXX11_ABI == 0
+
+#define _GLIBCXX_LDBL_COMPAT(dbl, ldbl) \
+ extern "C" void ldbl (void) __attribute__ ((alias (#dbl), weak))
+
+_GLIBCXX_LDBL_COMPAT(_ZNKSt17__gnu_cxx_ldbl1287num_getIcSt19istreambuf_iteratorIcSt11char_traitsIcEEE14_M_extract_intIjEES4_S4_S4_RSt8ios_baseRSt12_Ios_IostateRT_,
+ _ZNKSt7num_getIcSt19istreambuf_iteratorIcSt11char_traitsIcEEE14_M_extract_intIjEES3_S3_S3_RSt8ios_baseRSt12_Ios_IostateRT_);
+_GLIBCXX_LDBL_COMPAT(_ZNKSt17__gnu_cxx_ldbl1287num_getIcSt19istreambuf_iteratorIcSt11char_traitsIcEEE14_M_extract_intIlEES4_S4_S4_RSt8ios_baseRSt12_Ios_IostateRT_,
+ _ZNKSt7num_getIcSt19istreambuf_iteratorIcSt11char_traitsIcEEE14_M_extract_intIlEES3_S3_S3_RSt8ios_baseRSt12_Ios_IostateRT_);
+_GLIBCXX_LDBL_COMPAT(_ZNKSt17__gnu_cxx_ldbl1287num_getIcSt19istreambuf_iteratorIcSt11char_traitsIcEEE14_M_extract_intImEES4_S4_S4_RSt8ios_baseRSt12_Ios_IostateRT_,
+ _ZNKSt7num_getIcSt19istreambuf_iteratorIcSt11char_traitsIcEEE14_M_extract_intImEES3_S3_S3_RSt8ios_baseRSt12_Ios_IostateRT_);
+_GLIBCXX_LDBL_COMPAT(_ZNKSt17__gnu_cxx_ldbl1287num_getIcSt19istreambuf_iteratorIcSt11char_traitsIcEEE14_M_extract_intItEES4_S4_S4_RSt8ios_baseRSt12_Ios_IostateRT_,
+ _ZNKSt7num_getIcSt19istreambuf_iteratorIcSt11char_traitsIcEEE14_M_extract_intItEES3_S3_S3_RSt8ios_baseRSt12_Ios_IostateRT_);
+_GLIBCXX_LDBL_COMPAT(_ZNKSt17__gnu_cxx_ldbl1287num_getIcSt19istreambuf_iteratorIcSt11char_traitsIcEEE14_M_extract_intIxEES4_S4_S4_RSt8ios_baseRSt12_Ios_IostateRT_,
+ _ZNKSt7num_getIcSt19istreambuf_iteratorIcSt11char_traitsIcEEE14_M_extract_intIxEES3_S3_S3_RSt8ios_baseRSt12_Ios_IostateRT_);
+_GLIBCXX_LDBL_COMPAT(_ZNKSt17__gnu_cxx_ldbl1287num_getIcSt19istreambuf_iteratorIcSt11char_traitsIcEEE14_M_extract_intIyEES4_S4_S4_RSt8ios_baseRSt12_Ios_IostateRT_,
+ _ZNKSt7num_getIcSt19istreambuf_iteratorIcSt11char_traitsIcEEE14_M_extract_intIyEES3_S3_S3_RSt8ios_baseRSt12_Ios_IostateRT_);
+_GLIBCXX_LDBL_COMPAT(_ZNKSt17__gnu_cxx_ldbl1287num_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE13_M_insert_intIlEES4_S4_RSt8ios_basecT_,
+ _ZNKSt7num_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE13_M_insert_intIlEES3_S3_RSt8ios_basecT_);
+_GLIBCXX_LDBL_COMPAT(_ZNKSt17__gnu_cxx_ldbl1287num_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE13_M_insert_intImEES4_S4_RSt8ios_basecT_,
+ _ZNKSt7num_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE13_M_insert_intImEES3_S3_RSt8ios_basecT_);
+_GLIBCXX_LDBL_COMPAT(_ZNKSt17__gnu_cxx_ldbl1287num_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE13_M_insert_intIxEES4_S4_RSt8ios_basecT_,
+ _ZNKSt7num_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE13_M_insert_intIxEES3_S3_RSt8ios_basecT_);
+_GLIBCXX_LDBL_COMPAT(_ZNKSt17__gnu_cxx_ldbl1287num_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE13_M_insert_intIyEES4_S4_RSt8ios_basecT_,
+ _ZNKSt7num_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE13_M_insert_intIyEES3_S3_RSt8ios_basecT_);
+_GLIBCXX_LDBL_COMPAT(_ZNKSt17__gnu_cxx_ldbl1287num_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE15_M_insert_floatIdEES4_S4_RSt8ios_baseccT_,
+ _ZNKSt7num_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE15_M_insert_floatIdEES3_S3_RSt8ios_baseccT_);
+_GLIBCXX_LDBL_COMPAT(_ZNKSt7num_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE15_M_insert_floatIdEES3_S3_RSt8ios_baseccT_,
+ _ZNKSt7num_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE15_M_insert_floatIeEES3_S3_RSt8ios_baseccT_);
+_GLIBCXX_LDBL_COMPAT(_ZNKSt17__gnu_cxx_ldbl1289money_getIcSt19istreambuf_iteratorIcSt11char_traitsIcEEE10_M_extractILb0EEES4_S4_S4_RSt8ios_baseRSt12_Ios_IostateRSs,
+ _ZNKSt9money_getIcSt19istreambuf_iteratorIcSt11char_traitsIcEEE10_M_extractILb0EEES3_S3_S3_RSt8ios_baseRSt12_Ios_IostateRSs);
+_GLIBCXX_LDBL_COMPAT(_ZNKSt17__gnu_cxx_ldbl1289money_getIcSt19istreambuf_iteratorIcSt11char_traitsIcEEE10_M_extractILb1EEES4_S4_S4_RSt8ios_baseRSt12_Ios_IostateRSs,
+ _ZNKSt9money_getIcSt19istreambuf_iteratorIcSt11char_traitsIcEEE10_M_extractILb1EEES3_S3_S3_RSt8ios_baseRSt12_Ios_IostateRSs);
+_GLIBCXX_LDBL_COMPAT(_ZNKSt17__gnu_cxx_ldbl1289money_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE9_M_insertILb0EEES4_S4_RSt8ios_basecRKSs,
+ _ZNKSt9money_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE9_M_insertILb0EEES3_S3_RSt8ios_basecRKSs);
+_GLIBCXX_LDBL_COMPAT(_ZNKSt17__gnu_cxx_ldbl1289money_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE9_M_insertILb1EEES4_S4_RSt8ios_basecRKSs,
+ _ZNKSt9money_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE9_M_insertILb1EEES3_S3_RSt8ios_basecRKSs);
+
+#endif // _GLIBCXX_LONG_DOUBLE_COMPAT
diff --git a/libstdc++-v3/src/c++11/mutex.cc b/libstdc++-v3/src/c++11/mutex.cc
index ed787e7bc28..eadcd971213 100644
--- a/libstdc++-v3/src/c++11/mutex.cc
+++ b/libstdc++-v3/src/c++11/mutex.cc
@@ -1,6 +1,6 @@
// mutex -*- C++ -*-
-// Copyright (C) 2008-2014 Free Software Foundation, Inc.
+// Copyright (C) 2008-2015 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
diff --git a/libstdc++-v3/src/c++11/ostream-inst.cc b/libstdc++-v3/src/c++11/ostream-inst.cc
new file mode 100644
index 00000000000..fff5559c367
--- /dev/null
+++ b/libstdc++-v3/src/c++11/ostream-inst.cc
@@ -0,0 +1,117 @@
+// Explicit instantiation file.
+
+// Copyright (C) 1997-2015 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:
+//
+
+#include <ostream>
+#include <iomanip>
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ // ostream
+ template class basic_ostream<char>;
+ template ostream& endl(ostream&);
+ template ostream& ends(ostream&);
+ template ostream& flush(ostream&);
+ template ostream& operator<<(ostream&, char);
+ template ostream& operator<<(ostream&, unsigned char);
+ template ostream& operator<<(ostream&, signed char);
+ template ostream& operator<<(ostream&, const char*);
+ template ostream& operator<<(ostream&, const unsigned char*);
+ template ostream& operator<<(ostream&, const signed char*);
+
+ template ostream& operator<<(ostream&, _Setfill<char>);
+ template ostream& operator<<(ostream&, _Setiosflags);
+ template ostream& operator<<(ostream&, _Resetiosflags);
+ template ostream& operator<<(ostream&, _Setbase);
+ template ostream& operator<<(ostream&, _Setprecision);
+ template ostream& operator<<(ostream&, _Setw);
+ template ostream& __ostream_insert(ostream&, const char*, streamsize);
+
+ template ostream& ostream::_M_insert(long);
+ template ostream& ostream::_M_insert(unsigned long);
+ template ostream& ostream::_M_insert(bool);
+#ifdef _GLIBCXX_USE_LONG_LONG
+ template ostream& ostream::_M_insert(long long);
+ template ostream& ostream::_M_insert(unsigned long long);
+#endif
+ template ostream& ostream::_M_insert(double);
+ template ostream& ostream::_M_insert(long double);
+ template ostream& ostream::_M_insert(const void*);
+
+#ifdef _GLIBCXX_USE_WCHAR_T
+ template class basic_ostream<wchar_t>;
+ template wostream& endl(wostream&);
+ template wostream& ends(wostream&);
+ template wostream& flush(wostream&);
+ template wostream& operator<<(wostream&, wchar_t);
+ template wostream& operator<<(wostream&, char);
+ template wostream& operator<<(wostream&, const wchar_t*);
+ template wostream& operator<<(wostream&, const char*);
+
+ template wostream& operator<<(wostream&, _Setfill<wchar_t>);
+ template wostream& operator<<(wostream&, _Setiosflags);
+ template wostream& operator<<(wostream&, _Resetiosflags);
+ template wostream& operator<<(wostream&, _Setbase);
+ template wostream& operator<<(wostream&, _Setprecision);
+ template wostream& operator<<(wostream&, _Setw);
+ template wostream& __ostream_insert(wostream&, const wchar_t*, streamsize);
+
+ template wostream& wostream::_M_insert(long);
+ template wostream& wostream::_M_insert(unsigned long);
+ template wostream& wostream::_M_insert(bool);
+#ifdef _GLIBCXX_USE_LONG_LONG
+ template wostream& wostream::_M_insert(long long);
+ template wostream& wostream::_M_insert(unsigned long long);
+#endif
+ template wostream& wostream::_M_insert(double);
+ template wostream& wostream::_M_insert(long double);
+ template wostream& wostream::_M_insert(const void*);
+#endif
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace
+
+// XXX GLIBCXX_ABI Deprecated
+#ifdef _GLIBCXX_LONG_DOUBLE_COMPAT
+
+#define _GLIBCXX_LDBL_COMPAT(dbl, ldbl) \
+ extern "C" void ldbl (void) __attribute__ ((alias (#dbl), weak))
+_GLIBCXX_LDBL_COMPAT (_ZNSolsEd, _ZNSolsEe);
+#ifdef _GLIBCXX_USE_WCHAR_T
+_GLIBCXX_LDBL_COMPAT (_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEd,
+ _ZNSt13basic_ostreamIwSt11char_traitsIwEElsEe);
+#endif
+_GLIBCXX_LDBL_COMPAT (_ZNSo9_M_insertIdEERSoT_,
+ _ZNSo9_M_insertIeEERSoT_);
+#ifdef _GLIBCXX_USE_WCHAR_T
+_GLIBCXX_LDBL_COMPAT (_ZNSt13basic_ostreamIwSt11char_traitsIwEE9_M_insertIdEERS2_T_,
+ _ZNSt13basic_ostreamIwSt11char_traitsIwEE9_M_insertIeEERS2_T_);
+#endif
+
+#endif // _GLIBCXX_LONG_DOUBLE_COMPAT
diff --git a/libstdc++-v3/src/c++11/placeholders.cc b/libstdc++-v3/src/c++11/placeholders.cc
index adbfd45c012..5e7376d0bf5 100644
--- a/libstdc++-v3/src/c++11/placeholders.cc
+++ b/libstdc++-v3/src/c++11/placeholders.cc
@@ -1,6 +1,6 @@
// std::placeholders -*- C++ -*-
-// Copyright (C) 2011-2014 Free Software Foundation, Inc.
+// Copyright (C) 2011-2015 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
diff --git a/libstdc++-v3/src/c++11/random.cc b/libstdc++-v3/src/c++11/random.cc
index f61daeacb50..edf900f6bb7 100644
--- a/libstdc++-v3/src/c++11/random.cc
+++ b/libstdc++-v3/src/c++11/random.cc
@@ -1,6 +1,6 @@
// random -*- C++ -*-
-// Copyright (C) 2012-2014 Free Software Foundation, Inc.
+// Copyright (C) 2012-2015 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
@@ -22,6 +22,7 @@
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
+#define _GLIBCXX_USE_CXX11_ABI 1
#include <random>
#ifdef _GLIBCXX_USE_C99_STDINT_TR1
diff --git a/libstdc++-v3/src/c++11/regex.cc b/libstdc++-v3/src/c++11/regex.cc
index a0ad374bcea..69f4d836fef 100644
--- a/libstdc++-v3/src/c++11/regex.cc
+++ b/libstdc++-v3/src/c++11/regex.cc
@@ -1,6 +1,6 @@
// regex -*- C++ -*-
-// Copyright (C) 2011-2014 Free Software Foundation, Inc.
+// Copyright (C) 2011-2015 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
diff --git a/libstdc++-v3/src/c++11/shared_ptr.cc b/libstdc++-v3/src/c++11/shared_ptr.cc
index 53b3452f093..306492d5a48 100644
--- a/libstdc++-v3/src/c++11/shared_ptr.cc
+++ b/libstdc++-v3/src/c++11/shared_ptr.cc
@@ -1,6 +1,6 @@
// Support for pointer abstractions -*- C++ -*-
-// Copyright (C) 2011-2014 Free Software Foundation, Inc.
+// Copyright (C) 2011-2015 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
@@ -34,5 +34,63 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
bad_weak_ptr::what() const noexcept
{ return "bad_weak_ptr"; }
+#ifdef __GTHREADS
+ namespace
+ {
+ const unsigned char mask = 0xf;
+ const unsigned char invalid = mask + 1;
+
+ inline unsigned char key(const void* addr)
+ { return _Hash_impl::hash(addr) & mask; }
+
+ /* Returns different instances of __mutex depending on the passed address
+ * in order to limit contention.
+ */
+ __gnu_cxx::__mutex&
+ get_mutex(unsigned char i)
+ {
+ static __gnu_cxx::__mutex m[mask + 1];
+ return m[i];
+ }
+ }
+
+ _Sp_locker::_Sp_locker(const void* p)
+ {
+ if (__gthread_active_p())
+ {
+ _M_key1 = _M_key2 = key(p);
+ get_mutex(_M_key1).lock();
+ }
+ else
+ _M_key1 = _M_key2 = invalid;
+ }
+
+ _Sp_locker::_Sp_locker(const void* p1, const void* p2)
+ {
+ if (__gthread_active_p())
+ {
+ _M_key1 = key(p1);
+ _M_key2 = key(p2);
+ if (_M_key2 < _M_key1)
+ get_mutex(_M_key2).lock();
+ get_mutex(_M_key1).lock();
+ if (_M_key2 > _M_key1)
+ get_mutex(_M_key2).lock();
+ }
+ else
+ _M_key1 = _M_key2 = invalid;
+ }
+
+ _Sp_locker::~_Sp_locker()
+ {
+ if (_M_key1 != invalid)
+ {
+ get_mutex(_M_key1).unlock();
+ if (_M_key2 != _M_key1)
+ get_mutex(_M_key2).unlock();
+ }
+ }
+#endif
+
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
diff --git a/libstdc++-v3/src/c++11/snprintf_lite.cc b/libstdc++-v3/src/c++11/snprintf_lite.cc
index 087b1ab70ff..a700041aec1 100644
--- a/libstdc++-v3/src/c++11/snprintf_lite.cc
+++ b/libstdc++-v3/src/c++11/snprintf_lite.cc
@@ -1,6 +1,6 @@
// Debugging support -*- C++ -*-
-// Copyright (C) 2013-2014 Free Software Foundation, Inc.
+// Copyright (C) 2013-2015 Free Software Foundation, Inc.
//
// This file is part of GCC.
//
diff --git a/libstdc++-v3/src/c++11/sstream-inst.cc b/libstdc++-v3/src/c++11/sstream-inst.cc
new file mode 100644
index 00000000000..b17c50d6eb8
--- /dev/null
+++ b/libstdc++-v3/src/c++11/sstream-inst.cc
@@ -0,0 +1,53 @@
+// Explicit instantiation file.
+
+// Copyright (C) 1997-2015 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:
+//
+
+#ifndef _GLIBCXX_USE_CXX11_ABI
+// Instantiations in this file use the new SSO std::string ABI unless included
+// by another file which defines _GLIBCXX_USE_CXX11_ABI=0.
+# define _GLIBCXX_USE_CXX11_ABI 1
+#endif
+#include <sstream>
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ template class basic_stringbuf<char>;
+ template class basic_istringstream<char>;
+ template class basic_ostringstream<char>;
+ template class basic_stringstream<char>;
+
+#ifdef _GLIBCXX_USE_WCHAR_T
+ template class basic_stringbuf<wchar_t>;
+ template class basic_istringstream<wchar_t>;
+ template class basic_ostringstream<wchar_t>;
+ template class basic_stringstream<wchar_t>;
+#endif
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace
diff --git a/libstdc++-v3/src/c++11/streambuf-inst.cc b/libstdc++-v3/src/c++11/streambuf-inst.cc
new file mode 100644
index 00000000000..763c5e014f5
--- /dev/null
+++ b/libstdc++-v3/src/c++11/streambuf-inst.cc
@@ -0,0 +1,63 @@
+// Explicit instantiation file.
+
+// Copyright (C) 1997-2015 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:
+//
+
+#include <ios>
+#include <streambuf>
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+ // streambuf
+ template class basic_streambuf<char>;
+
+ template
+ streamsize
+ __copy_streambufs(basic_streambuf<char>*, basic_streambuf<char>*);
+
+ template
+ streamsize
+ __copy_streambufs_eof(basic_streambuf<char>*,
+ basic_streambuf<char>*, bool&);
+
+#ifdef _GLIBCXX_USE_WCHAR_T
+ // wstreambuf
+ template class basic_streambuf<wchar_t>;
+
+ template
+ streamsize
+ __copy_streambufs(basic_streambuf<wchar_t>*, basic_streambuf<wchar_t>*);
+
+ template
+ streamsize
+ __copy_streambufs_eof(basic_streambuf<wchar_t>*,
+ basic_streambuf<wchar_t>*, bool&);
+#endif
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace
diff --git a/libstdc++-v3/src/c++11/string-inst.cc b/libstdc++-v3/src/c++11/string-inst.cc
index f19a0b0e9d6..8c26be1ef32 100644
--- a/libstdc++-v3/src/c++11/string-inst.cc
+++ b/libstdc++-v3/src/c++11/string-inst.cc
@@ -1,6 +1,6 @@
// Components for manipulating sequences of characters -*- C++ -*-
-// Copyright (C) 1997-2014 Free Software Foundation, Inc.
+// Copyright (C) 1997-2015 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
@@ -29,6 +29,12 @@
// Written by Jason Merrill based upon the specification by Takanori Adachi
// in ANSI X3J16/94-0013R2. Rewritten by Nathan Myers.
+#ifndef _GLIBCXX_USE_CXX11_ABI
+// Instantiations in this file use the new SSO std::string ABI unless included
+// by another file which defines _GLIBCXX_USE_CXX11_ABI=0.
+# define _GLIBCXX_USE_CXX11_ABI 1
+#endif
+
#include <string>
// Instantiation configuration.
@@ -49,7 +55,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// Only one template keyword allowed here.
// See core issue #46 (NAD)
- // http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/cwg_closed.html#46
+ // http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#46
template
S::basic_string(C*, C*, const allocator<C>&);
@@ -59,6 +65,26 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template
S::basic_string(S::iterator, S::iterator, const allocator<C>&);
+#if _GLIBCXX_USE_CXX11_ABI
+ template
+ void
+ S::_M_construct(S::iterator, S::iterator, forward_iterator_tag);
+
+ template
+ void
+ S::_M_construct(S::const_iterator, S::const_iterator,
+ forward_iterator_tag);
+
+ template
+ void
+ S::_M_construct(C*, C*, forward_iterator_tag);
+
+ template
+ void
+ S::_M_construct(const C*, const C*, forward_iterator_tag);
+
+#else // !_GLIBCXX_USE_CXX11_ABI
+
template
C*
S::_S_construct(S::iterator, S::iterator,
@@ -72,6 +98,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
C*
S::_S_construct(const C*, const C*, const allocator<C>&,
forward_iterator_tag);
+#endif
_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 5bd59f0e6bb..71f5c8b652d 100644
--- a/libstdc++-v3/src/c++11/system_error.cc
+++ b/libstdc++-v3/src/c++11/system_error.cc
@@ -1,6 +1,6 @@
// <system_error> implementation file
-// Copyright (C) 2007-2014 Free Software Foundation, Inc.
+// Copyright (C) 2007-2015 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
@@ -23,10 +23,13 @@
// <http://www.gnu.org/licenses/>.
+#define _GLIBCXX_USE_CXX11_ABI 1
+#define __sso_string __sso_stringxxx
#include <cstring>
#include <system_error>
#include <bits/functexcept.h>
#include <limits>
+#undef __sso_string
namespace
{
@@ -73,10 +76,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
error_category::~error_category() noexcept = default;
const error_category&
- system_category() noexcept { return system_category_instance; }
+ _V2::system_category() noexcept { return system_category_instance; }
const error_category&
- generic_category() noexcept { return generic_category_instance; }
+ _V2::generic_category() noexcept { return generic_category_instance; }
system_error::~system_error() noexcept = default;
@@ -97,5 +100,80 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
error_code::default_error_condition() const noexcept
{ return category().default_error_condition(value()); }
+#if _GLIBCXX_USE_CXX11_ABI
+ // Return error_category::message() as a COW string
+ __cow_string
+ error_category::_M_message(int i) const
+ {
+ string msg = this->message(i);
+ return {msg.c_str(), msg.length()};
+ }
+#endif
+
+#if _GLIBCXX_USE_DUAL_ABI
+ // 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;
+ };
+
+ __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/thread.cc b/libstdc++-v3/src/c++11/thread.cc
index 49aacb5a96d..954f2676aa1 100644
--- a/libstdc++-v3/src/c++11/thread.cc
+++ b/libstdc++-v3/src/c++11/thread.cc
@@ -1,6 +1,6 @@
// thread -*- C++ -*-
-// Copyright (C) 2008-2014 Free Software Foundation, Inc.
+// Copyright (C) 2008-2015 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
@@ -130,13 +130,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
thread::_M_start_thread(__shared_base_type __b)
{
if (!__gthread_active_p())
-#if __EXCEPTIONS
+#if __cpp_exceptions
throw system_error(make_error_code(errc::operation_not_permitted),
"Enable multithreading to use std::thread");
#else
__throw_system_error(int(errc::operation_not_permitted));
#endif
+ _M_start_thread(__b, nullptr);
+ }
+
+ void
+ thread::_M_start_thread(__shared_base_type __b, void (*)())
+ {
__b->_M_this_ptr = __b;
int __e = __gthread_create(&_M_id._M_thread,
&execute_native_thread_routine, __b.get());
diff --git a/libstdc++-v3/src/c++11/wlocale-inst.cc b/libstdc++-v3/src/c++11/wlocale-inst.cc
new file mode 100644
index 00000000000..2c1b444e145
--- /dev/null
+++ b/libstdc++-v3/src/c++11/wlocale-inst.cc
@@ -0,0 +1,77 @@
+// Locale support -*- C++ -*-
+
+// Copyright (C) 1999-2015 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: 22.1 Locales
+//
+
+// Instantiate locales using COW std::wstring ABI
+#define _GLIBCXX_USE_CXX11_ABI 0
+#include <bits/c++config.h>
+
+#ifdef _GLIBCXX_USE_WCHAR_T
+#define C wchar_t
+#include "locale-inst.cc"
+
+// XXX GLIBCXX_ABI Deprecated
+#if defined _GLIBCXX_LONG_DOUBLE_COMPAT
+
+#define _GLIBCXX_LDBL_COMPAT(dbl, ldbl) \
+ extern "C" void ldbl (void) __attribute__ ((alias (#dbl), weak))
+
+_GLIBCXX_LDBL_COMPAT(_ZNKSt17__gnu_cxx_ldbl1287num_getIwSt19istreambuf_iteratorIwSt11char_traitsIwEEE14_M_extract_intIjEES4_S4_S4_RSt8ios_baseRSt12_Ios_IostateRT_,
+ _ZNKSt7num_getIwSt19istreambuf_iteratorIwSt11char_traitsIwEEE14_M_extract_intIjEES3_S3_S3_RSt8ios_baseRSt12_Ios_IostateRT_);
+_GLIBCXX_LDBL_COMPAT(_ZNKSt17__gnu_cxx_ldbl1287num_getIwSt19istreambuf_iteratorIwSt11char_traitsIwEEE14_M_extract_intIlEES4_S4_S4_RSt8ios_baseRSt12_Ios_IostateRT_,
+ _ZNKSt7num_getIwSt19istreambuf_iteratorIwSt11char_traitsIwEEE14_M_extract_intIlEES3_S3_S3_RSt8ios_baseRSt12_Ios_IostateRT_);
+_GLIBCXX_LDBL_COMPAT(_ZNKSt17__gnu_cxx_ldbl1287num_getIwSt19istreambuf_iteratorIwSt11char_traitsIwEEE14_M_extract_intImEES4_S4_S4_RSt8ios_baseRSt12_Ios_IostateRT_,
+ _ZNKSt7num_getIwSt19istreambuf_iteratorIwSt11char_traitsIwEEE14_M_extract_intImEES3_S3_S3_RSt8ios_baseRSt12_Ios_IostateRT_);
+_GLIBCXX_LDBL_COMPAT(_ZNKSt17__gnu_cxx_ldbl1287num_getIwSt19istreambuf_iteratorIwSt11char_traitsIwEEE14_M_extract_intItEES4_S4_S4_RSt8ios_baseRSt12_Ios_IostateRT_,
+ _ZNKSt7num_getIwSt19istreambuf_iteratorIwSt11char_traitsIwEEE14_M_extract_intItEES3_S3_S3_RSt8ios_baseRSt12_Ios_IostateRT_);
+_GLIBCXX_LDBL_COMPAT(_ZNKSt17__gnu_cxx_ldbl1287num_getIwSt19istreambuf_iteratorIwSt11char_traitsIwEEE14_M_extract_intIxEES4_S4_S4_RSt8ios_baseRSt12_Ios_IostateRT_,
+ _ZNKSt7num_getIwSt19istreambuf_iteratorIwSt11char_traitsIwEEE14_M_extract_intIxEES3_S3_S3_RSt8ios_baseRSt12_Ios_IostateRT_);
+_GLIBCXX_LDBL_COMPAT(_ZNKSt17__gnu_cxx_ldbl1287num_getIwSt19istreambuf_iteratorIwSt11char_traitsIwEEE14_M_extract_intIyEES4_S4_S4_RSt8ios_baseRSt12_Ios_IostateRT_,
+ _ZNKSt7num_getIwSt19istreambuf_iteratorIwSt11char_traitsIwEEE14_M_extract_intIyEES3_S3_S3_RSt8ios_baseRSt12_Ios_IostateRT_);
+_GLIBCXX_LDBL_COMPAT(_ZNKSt17__gnu_cxx_ldbl1287num_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEE13_M_insert_intIlEES4_S4_RSt8ios_basewT_,
+ _ZNKSt7num_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEE13_M_insert_intIlEES3_S3_RSt8ios_basewT_);
+_GLIBCXX_LDBL_COMPAT(_ZNKSt17__gnu_cxx_ldbl1287num_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEE13_M_insert_intImEES4_S4_RSt8ios_basewT_,
+ _ZNKSt7num_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEE13_M_insert_intImEES3_S3_RSt8ios_basewT_);
+_GLIBCXX_LDBL_COMPAT(_ZNKSt17__gnu_cxx_ldbl1287num_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEE13_M_insert_intIxEES4_S4_RSt8ios_basewT_,
+ _ZNKSt7num_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEE13_M_insert_intIxEES3_S3_RSt8ios_basewT_);
+_GLIBCXX_LDBL_COMPAT(_ZNKSt17__gnu_cxx_ldbl1287num_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEE13_M_insert_intIyEES4_S4_RSt8ios_basewT_,
+ _ZNKSt7num_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEE13_M_insert_intIyEES3_S3_RSt8ios_basewT_);
+_GLIBCXX_LDBL_COMPAT(_ZNKSt17__gnu_cxx_ldbl1287num_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEE15_M_insert_floatIdEES4_S4_RSt8ios_basewcT_,
+ _ZNKSt7num_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEE15_M_insert_floatIdEES3_S3_RSt8ios_basewcT_);
+_GLIBCXX_LDBL_COMPAT(_ZNKSt7num_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEE15_M_insert_floatIdEES3_S3_RSt8ios_basewcT_,
+ _ZNKSt7num_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEE15_M_insert_floatIeEES3_S3_RSt8ios_basewcT_);
+_GLIBCXX_LDBL_COMPAT(_ZNKSt17__gnu_cxx_ldbl1289money_getIwSt19istreambuf_iteratorIwSt11char_traitsIwEEE10_M_extractILb0EEES4_S4_S4_RSt8ios_baseRSt12_Ios_IostateRSs,
+ _ZNKSt9money_getIwSt19istreambuf_iteratorIwSt11char_traitsIwEEE10_M_extractILb0EEES3_S3_S3_RSt8ios_baseRSt12_Ios_IostateRSs);
+_GLIBCXX_LDBL_COMPAT(_ZNKSt17__gnu_cxx_ldbl1289money_getIwSt19istreambuf_iteratorIwSt11char_traitsIwEEE10_M_extractILb1EEES4_S4_S4_RSt8ios_baseRSt12_Ios_IostateRSs,
+ _ZNKSt9money_getIwSt19istreambuf_iteratorIwSt11char_traitsIwEEE10_M_extractILb1EEES3_S3_S3_RSt8ios_baseRSt12_Ios_IostateRSs);
+_GLIBCXX_LDBL_COMPAT(_ZNKSt17__gnu_cxx_ldbl1289money_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEE9_M_insertILb0EEES4_S4_RSt8ios_basewRKSbIwS3_SaIwEE,
+ _ZNKSt9money_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEE9_M_insertILb0EEES3_S3_RSt8ios_basewRKSbIwS2_SaIwEE);
+_GLIBCXX_LDBL_COMPAT(_ZNKSt17__gnu_cxx_ldbl1289money_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEE9_M_insertILb1EEES4_S4_RSt8ios_basewRKSbIwS3_SaIwEE,
+ _ZNKSt9money_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEE9_M_insertILb1EEES3_S3_RSt8ios_basewRKSbIwS2_SaIwEE);
+
+#endif // _GLIBCXX_LONG_DOUBLE_COMPAT
+#endif
diff --git a/libstdc++-v3/src/c++11/wstring-inst.cc b/libstdc++-v3/src/c++11/wstring-inst.cc
index 8c9f9017ad2..42cb3f610fb 100644
--- a/libstdc++-v3/src/c++11/wstring-inst.cc
+++ b/libstdc++-v3/src/c++11/wstring-inst.cc
@@ -1,6 +1,6 @@
// wide string support -*- C++ -*-
-// Copyright (C) 1999-2014 Free Software Foundation, Inc.
+// Copyright (C) 1999-2015 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
@@ -26,6 +26,7 @@
// ISO C++ 14882: 21 Strings library
//
+#define _GLIBCXX_USE_CXX11_ABI 1
#include <bits/c++config.h>
#ifdef _GLIBCXX_USE_WCHAR_T