diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 145ea41a4a4813f3a6fbb2c48660340d1a174341..0f653f7d897bd375e9d9d0a4d213eff09a3e5c4b 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,24 @@
+2007-09-08  Benjamin Kosnik  <bkoz@redhat.com>
+
+	* include/bits/functional_hash.h: Add ext/numeric_traits.h.
+	* include/tr1/functional_hash.h Same.
+	* include/tr1/functional: Remove string, ext/type_traits.h includes.
+	* include/tr1_impl/functional_hash.h: Move string, wstring
+	definitions for std::<hash>::operator into separate file.
+	* include/std/functional
+	* src/hash.cc: New, move definitions here.
+	* src/hash_c++0x.cc: Same.
+	* src/Makefile.am: Add new source files.
+	* configure: Regenerate.
+	* Makefile.in: Same.
+	* src/Makefile.in: Same.
+	* po/Makefile.in: Same.
+	* libmath/Makefile.in: Same.
+	* libsupc++/Makefile.in: Same.
+	* testsuite/Makefile.in: Same.
+	* config/abi/pre/gnu.ver: Add symbols.
+	* config/abi/pre/gnu-versioned-namespace.ver: Same, fix.
+	
 2007-09-07  Benjamin Kosnik  <bkoz@redhat.com>
 
 	* testsuite/19_diagnostics/error_category/cons/copy_neg.cc:
diff --git a/libstdc++-v3/Makefile.in b/libstdc++-v3/Makefile.in
index c8ad4694faa0119bd8bfecb0005a1cb93a5ea8ef..ac125e8d6f203d9912f35f2247869878125d9d68 100644
--- a/libstdc++-v3/Makefile.in
+++ b/libstdc++-v3/Makefile.in
@@ -150,6 +150,7 @@ ENABLE_SYMVERS_GNU_TRUE = @ENABLE_SYMVERS_GNU_TRUE@
 ENABLE_SYMVERS_TRUE = @ENABLE_SYMVERS_TRUE@
 ENABLE_VISIBILITY_FALSE = @ENABLE_VISIBILITY_FALSE@
 ENABLE_VISIBILITY_TRUE = @ENABLE_VISIBILITY_TRUE@
+ERROR_CONSTANTS_SRCDIR = @ERROR_CONSTANTS_SRCDIR@
 EXEEXT = @EXEEXT@
 EXTRA_CXX_FLAGS = @EXTRA_CXX_FLAGS@
 FGREP = @FGREP@
diff --git a/libstdc++-v3/config/abi/pre/gnu-versioned-namespace.ver b/libstdc++-v3/config/abi/pre/gnu-versioned-namespace.ver
index 4613f4e53d4a6f9da55f164e62c04438788d15f0..4661512fe05e93b667d6dfba6473a4ef32c1e9f2 100644
--- a/libstdc++-v3/config/abi/pre/gnu-versioned-namespace.ver
+++ b/libstdc++-v3/config/abi/pre/gnu-versioned-namespace.ver
@@ -66,7 +66,8 @@ GLIBCXX_3.7 {
     _ZNSt2_614__convert_to_v*;
 
     # std::__copy_streambufs
-    _ZNSt2_617__copy_streambufsI[cw]NS_11char_traitsI[cw]EEEEiPNS_15basic_streambufIT_T0_EES7_;
+    _ZNSt2_617__copy_streambufsI*;
+    _ZNSt2_621__copy_streambufs_eofI*;
 
     # __gnu_cxx::__atomic_add
     # __gnu_cxx::__exchange_and_add
@@ -87,6 +88,40 @@ GLIBCXX_3.7 {
     _ZN9__gnu_cxx2_69free_list6_M_getE[jm];
     _ZN9__gnu_cxx2_69free_list8_M_clearEv;
 
+    # debug mode
+    _ZN10__gnu_norm15_List_node_base4hook*;
+    _ZN10__gnu_norm15_List_node_base4swap*;
+    _ZN10__gnu_norm15_List_node_base6unhookEv;
+    _ZN10__gnu_norm15_List_node_base7reverseEv;
+    _ZN10__gnu_norm15_List_node_base8transfer*;
+
+    _ZNSt6__norm15_List_node_base4hook*;
+    _ZNSt6__norm15_List_node_base4swap*;
+    _ZNSt6__norm15_List_node_base6unhookEv;
+    _ZNSt6__norm15_List_node_base7reverseEv;
+    _ZNSt6__norm15_List_node_base8transfer*;
+
+    _ZN11__gnu_debug19_Safe_sequence_base12_M_get_mutexEv;
+    _ZN11__gnu_debug19_Safe_sequence_base13_M_detach_allEv;
+    _ZN11__gnu_debug19_Safe_sequence_base18_M_detach_singularEv;
+    _ZN11__gnu_debug19_Safe_sequence_base22_M_revalidate_singularEv;
+    _ZN11__gnu_debug19_Safe_sequence_base7_M_swapERS0_;
+
+    _ZN11__gnu_debug19_Safe_iterator_base9_M_attachEPNS_19_Safe_sequence_baseEb;
+    _ZN11__gnu_debug19_Safe_iterator_base16_M_attach_singleEPNS_19_Safe_sequence_baseEb;
+    _ZN11__gnu_debug19_Safe_iterator_base9_M_detachEv;
+    _ZN11__gnu_debug19_Safe_iterator_base16_M_detach_singleEv;
+    _ZN11__gnu_debug19_Safe_iterator_base12_M_get_mutexEv;
+    _ZNK11__gnu_debug19_Safe_iterator_base11_M_singularEv;
+    _ZNK11__gnu_debug19_Safe_iterator_base14_M_can_compareERKS0_;
+
+    _ZNK11__gnu_debug16_Error_formatter10_M_message*;
+    _ZNK11__gnu_debug16_Error_formatter10_Parameter*;
+    _ZNK11__gnu_debug16_Error_formatter13_M_print_word*;
+    _ZNK11__gnu_debug16_Error_formatter15_M_print_string*;
+    _ZNK11__gnu_debug16_Error_formatter8_M_error*;
+    _ZNK11__gnu_debug16_Error_formatter17_M_get_max_lengthEv;
+
   local:
     *;
 };
@@ -164,7 +199,7 @@ CXXABI_1.7 {
     _ZTVN10__cxxabiv120__si_class_type_infoE;
     _ZTVN10__cxxabiv121__vmi_class_type_infoE;
 
-    # typeinfo structure (and some names)
+    # typeinfo structure
     _ZTI[a-z];
     _ZTIP[a-z];
     _ZTIPK[a-z];
@@ -178,6 +213,8 @@ CXXABI_1.7 {
     _ZTIN10__cxxabiv119__pointer_type_infoE;
     _ZTIN10__cxxabiv120__si_class_type_infoE;
     _ZTIN10__cxxabiv121__vmi_class_type_infoE;
+    _ZTIN10__cxxabiv115__forced_unwindE;
+    _ZTIN10__cxxabiv119__foreign_exceptionE;
 
     # typeinfo name
     _ZTS[a-z];
@@ -200,11 +237,3 @@ CXXABI_1.7 {
   local:
     *;
 };
-
-CXXABI_1.7.1 {
-
-    # typeinfo structures
-    _ZTIN10__cxxabiv115__forced_unwindE;
-    _ZTIN10__cxxabiv119__foreign_exceptionE;
-
-} CXXABI_1.7;
diff --git a/libstdc++-v3/config/abi/pre/gnu.ver b/libstdc++-v3/config/abi/pre/gnu.ver
index 059d20a19e99348309741abfdbf543952b18eeef..12d21f1c8ec4047da88f8e35c52de7a52985ba38 100644
--- a/libstdc++-v3/config/abi/pre/gnu.ver
+++ b/libstdc++-v3/config/abi/pre/gnu.ver
@@ -60,7 +60,8 @@ GLIBCXX_3.4 {
 #     std::c[i-z]*;
       std::c[i-s]*;
       std::c[u-z]*;
-      std::[d-h]*;
+      std::[d-g]*;
+      std::h[^a]*;
       std::i[a-n]*;
       std::ios_base::[A-Ha-z]*;
       std::ios_base::_M_grow_words*;
@@ -107,7 +108,10 @@ GLIBCXX_3.4 {
 #     std::string
       std::strstream*;
       std::strstreambuf*;
-      std::[A-Zt-z]*;
+      std::t[a-q]*;
+      std::tr1::h[^a]*;
+      std::t[s-z]*;
+      std::[A-Zu-z]*;
       std::_List_node_base::hook*;
       std::_List_node_base::swap*;
       std::_List_node_base::unhook*;
@@ -753,6 +757,18 @@ GLIBCXX_3.4.10 {
     _ZTISt12system_error;
     _ZTVSt12system_error;
     _ZNSt12system_errorD*Ev;
+    _ZNSt12system_errorC*;
+
+    _ZNKSt3tr14hashIRKSbIwSt11char_traitsIwESaIwEEEclES6_;
+    _ZNKSt3tr14hashIRKSsEclES2_;
+    _ZNKSt3tr14hashISbIwSt11char_traitsIwESaIwEEEclES4_;
+    _ZNKSt3tr14hashISsEclESs;
+
+    _ZNKSt4hashIRKSbIwSt11char_traitsIwESaIwEEEclES5_;
+    _ZNKSt4hashIRKSsEclES1_;
+    _ZNKSt4hashISbIwSt11char_traitsIwESaIwEEEclES3_;
+    _ZNKSt4hashISsEclESs;
+    _ZNKSt4hashISt10error_codeEclES0_;
 
 } GLIBCXX_3.4.9;
 
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index e2371b936c28c88270856c1c7dfe8e53f20abd51..3651176e1720d773afada6c98fbbd11563d175f5 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -93844,6 +93844,7 @@ ABI_TWEAKS_SRCDIR=config/${abi_tweaks_dir}
 
 
 
+
 # Determine cross-compile flags and AM_CONDITIONALs.
 #AC_SUBST(GLIBCXX_IS_NATIVE)
 #AM_CONDITIONAL(CANADIAN, test $CANADIAN = yes)
diff --git a/libstdc++-v3/include/bits/functional_hash.h b/libstdc++-v3/include/bits/functional_hash.h
index d5658fe4c50e56aa37ae25ff77957c9ec5e410f2..7b0d81cc6e876ce4169688a56cd924bb3dd60033 100644
--- a/libstdc++-v3/include/bits/functional_hash.h
+++ b/libstdc++-v3/include/bits/functional_hash.h
@@ -27,7 +27,7 @@
 // invalidate any other reasons why the executable file might be covered by
 // the GNU General Public License.
 
-/** @file functional_hash.h
+/** @file bits/functional_hash.h
  *  This is an internal header file, included by other library headers.
  *  You should not attempt to use it directly.
  */
@@ -45,6 +45,8 @@
 #  error C++0x header cannot be included from TR1 header
 #endif
 
+#include <ext/numeric_traits.h>
+
 #if defined(_GLIBCXX_INCLUDE_AS_CXX0X)
 #  include <tr1_impl/functional_hash.h>
 #else
@@ -59,20 +61,14 @@
 #  undef _GLIBCXX_INCLUDE_AS_CXX0X
 #endif
 
-#include <system_error>
 
 namespace std
 {
+  struct error_code;
+
   template<>
-    struct hash<error_code> : public unary_function<error_code, size_t>
-    {      
-      size_t
-      operator()(error_code __e) const
-      { 
-	const char* __p = reinterpret_cast<const char*>(&__e);
-	return _Fnv_hash<>::hash(__p, sizeof(__e));
-      }
-    };
+    size_t
+    hash<error_code>::operator()(error_code) const;
 }
 
 #endif // _FUNCTIONAL_HASH_H
diff --git a/libstdc++-v3/include/std/functional b/libstdc++-v3/include/std/functional
index 27e88176400640438ffcf3b133ca227af4d60862..83bf85aef292ea110f094b920192d50368cfde12 100644
--- a/libstdc++-v3/include/std/functional
+++ b/libstdc++-v3/include/std/functional
@@ -59,11 +59,10 @@
 #    error C++0x header cannot be included from TR1 header
 #  endif
 #  include <cmath>
-#  include <string>
 #  include <typeinfo>
-#  include <ext/type_traits.h>
 #  include <tuple>
 #  include <type_traits>
+#  include <bits/stringfwd.h>
 #  include <bits/functional_hash.h>
 #  if defined(_GLIBCXX_INCLUDE_AS_CXX0X)
 #    include <tr1_impl/functional>
diff --git a/libstdc++-v3/include/tr1/functional b/libstdc++-v3/include/tr1/functional
index d3afe76409b0d86fcabf3a40b31e750278d3d3ba..78f6b925eee14e5c6e54864a61a34d1e4a3fe3d2 100644
--- a/libstdc++-v3/include/tr1/functional
+++ b/libstdc++-v3/include/tr1/functional
@@ -44,11 +44,10 @@
 #include <bits/stl_function.h>
 
 #include <cmath>
-#include <string>
 #include <typeinfo>
-#include <ext/type_traits.h>
 #include <tr1/tuple>
 #include <tr1/type_traits>
+#include <bits/stringfwd.h>
 #include <tr1/functional_hash.h>
 
 #if defined(_GLIBCXX_INCLUDE_AS_TR1)
diff --git a/libstdc++-v3/include/tr1/functional_hash.h b/libstdc++-v3/include/tr1/functional_hash.h
index a41b232d67b9b2d8dbac921396ea825192e53c81..946c966f3d3df84505a0e8797cd99dfb66b48f7b 100644
--- a/libstdc++-v3/include/tr1/functional_hash.h
+++ b/libstdc++-v3/include/tr1/functional_hash.h
@@ -41,6 +41,8 @@
 #  error TR1 header cannot be included from C++0x header
 #endif
 
+#include <ext/numeric_traits.h>
+
 #if defined(_GLIBCXX_INCLUDE_AS_TR1)
 #  include <tr1_impl/functional_hash.h>
 #else
diff --git a/libstdc++-v3/include/tr1_impl/functional_hash.h b/libstdc++-v3/include/tr1_impl/functional_hash.h
index 3b1a758338333cffe1a58a4e19d84f6e5d7b0abf..2ac1a45f6ba5bf621c2d83bf39ffaf8940d9a476 100644
--- a/libstdc++-v3/include/tr1_impl/functional_hash.h
+++ b/libstdc++-v3/include/tr1_impl/functional_hash.h
@@ -36,20 +36,31 @@ namespace std
 {
 _GLIBCXX_BEGIN_NAMESPACE_TR1
 
-  // Definition of default hash function std::tr1::hash<>.  The types for
-  // which std::tr1::hash<T> is defined is in clause 6.3.3. of the PDTR.
+  // Class template hash.
+  // Declaration of default hash functor std::tr1::hash.  The types for
+  // which std::tr1::hash<T> is well-defined is in clause 6.3.3. of the PDTR.
   template<typename _Tp>
-    struct hash;
-
-#define _TR1_hashtable_define_trivial_hash(_Tp)         \
-  template<>                                            \
-    struct hash<_Tp>                                    \
-    : public std::unary_function<_Tp, std::size_t>      \
-    {                                                   \
-      std::size_t                                       \
-      operator()(_Tp __val) const                       \
-      { return static_cast<std::size_t>(__val); }       \
-    }                                                     
+    struct hash : public std::unary_function<_Tp, size_t>
+    {
+      size_t
+      operator()(_Tp __val) const;
+    };
+
+  // Partial specializations for pointer types.
+  template<typename _Tp>
+    struct hash<_Tp*> : public std::unary_function<_Tp*, size_t>
+    {
+      size_t
+      operator()(_Tp* __p) const
+      { return reinterpret_cast<size_t>(__p); }
+    };
+
+  // Explicit specializations for integer types.
+#define _TR1_hashtable_define_trivial_hash(_Tp) 	\
+  template<>						\
+    inline size_t					\
+    hash<_Tp>::operator()(_Tp __val) const		\
+    { return static_cast<size_t>(__val); }
 
   _TR1_hashtable_define_trivial_hash(bool);
   _TR1_hashtable_define_trivial_hash(char);
@@ -67,26 +78,17 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1
 
 #undef _TR1_hashtable_define_trivial_hash
 
-  template<typename _Tp>
-    struct hash<_Tp*>
-    : public std::unary_function<_Tp*, std::size_t>
-    {
-      std::size_t
-      operator()(_Tp* __p) const
-      { return reinterpret_cast<std::size_t>(__p); }
-    };
-
   // Fowler / Noll / Vo (FNV) Hash (type FNV-1a)
-  // (used by the next specializations of std::tr1::hash<>)
+  // (Used by the next specializations of std::tr1::hash.)
 
   // Dummy generic implementation (for sizeof(size_t) != 4, 8).
-  template<std::size_t = sizeof(std::size_t)>
+  template<size_t = sizeof(size_t)>
     struct _Fnv_hash
     {
-      static std::size_t
-      hash(const char* __first, std::size_t __length)
+      static size_t
+      hash(const char* __first, size_t __length)
       {
-	std::size_t __result = 0;
+	size_t __result = 0;
 	for (; __length > 0; --__length)
 	  __result = (__result * 131) + *__first++;
 	return __result;
@@ -96,14 +98,14 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1
   template<>
     struct _Fnv_hash<4>
     {
-      static std::size_t
-      hash(const char* __first, std::size_t __length)
+      static size_t
+      hash(const char* __first, size_t __length)
       {
-	std::size_t __result = static_cast<std::size_t>(2166136261UL);
+	size_t __result = static_cast<size_t>(2166136261UL);
 	for (; __length > 0; --__length)
 	  {
-	    __result ^= static_cast<std::size_t>(*__first++);
-	    __result *= static_cast<std::size_t>(16777619UL);
+	    __result ^= static_cast<size_t>(*__first++);
+	    __result *= static_cast<size_t>(16777619UL);
 	  }
 	return __result;
       }
@@ -112,112 +114,94 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1
   template<>
     struct _Fnv_hash<8>
     {
-      static std::size_t
-      hash(const char* __first, std::size_t __length)
+      static size_t
+      hash(const char* __first, size_t __length)
       {
-	std::size_t __result =
-	  static_cast<std::size_t>(14695981039346656037ULL);
+	size_t __result =
+	  static_cast<size_t>(14695981039346656037ULL);
 	for (; __length > 0; --__length)
 	  {
-	    __result ^= static_cast<std::size_t>(*__first++);
-	    __result *= static_cast<std::size_t>(1099511628211ULL);
+	    __result ^= static_cast<size_t>(*__first++);
+	    __result *= static_cast<size_t>(1099511628211ULL);
 	  }
 	return __result;
       }
     };
 
-  // XXX String and floating point hashes probably shouldn't be inline
-  // member functions, since are nontrivial.  Once we have the framework
-  // for TR1 .cc files, these should go in one.
-  template<>
-    struct hash<std::string>
-    : public std::unary_function<std::string, std::size_t>
-    {      
-      std::size_t
-      operator()(const std::string& __s) const
-      { return _Fnv_hash<>::hash(__s.data(), __s.length()); }
-    };
-
-#ifdef _GLIBCXX_USE_WCHAR_T
-  template<>
-    struct hash<std::wstring>
-    : public std::unary_function<std::wstring, std::size_t>
-    {
-      std::size_t
-      operator()(const std::wstring& __s) const
-      {
-	return _Fnv_hash<>::hash(reinterpret_cast<const char*>(__s.data()),
-				 __s.length() * sizeof(wchar_t));
-      }
-    };
-#endif
-
+  // Explicit specializations for floating point types.
   template<>
-    struct hash<float>
-    : public std::unary_function<float, std::size_t>
+    inline size_t
+    hash<float>::operator()(float __val) const
     {
-      std::size_t
-      operator()(float __fval) const
-      {
-	std::size_t __result = 0;
-
-	// 0 and -0 both hash to zero.
-	if (__fval != 0.0f)
-	  __result = _Fnv_hash<>::hash(reinterpret_cast<const char*>(&__fval),
-				       sizeof(__fval));
-	return __result;
-      }
+      size_t __result = 0;
+      
+      // 0 and -0 both hash to zero.
+      if (__val != 0.0f)
+	__result = _Fnv_hash<>::hash(reinterpret_cast<const char*>(&__val),
+				     sizeof(__val));
+      return __result;
     };
 
   template<>
-    struct hash<double>
-    : public std::unary_function<double, std::size_t>
+    inline size_t
+    hash<double>::operator()(double __val) const
     {
-      std::size_t
-      operator()(double __dval) const
-      {
-	std::size_t __result = 0;
+	size_t __result = 0;
 
 	// 0 and -0 both hash to zero.
-	if (__dval != 0.0)
-	  __result = _Fnv_hash<>::hash(reinterpret_cast<const char*>(&__dval),
-				       sizeof(__dval));
+	if (__val != 0.0)
+	  __result = _Fnv_hash<>::hash(reinterpret_cast<const char*>(&__val),
+				       sizeof(__val));
 	return __result;
-      }
     };
 
   // For long double, careful with random padding bits (e.g., on x86,
   // 10 bytes -> 12 bytes) and resort to frexp.
   template<>
-    struct hash<long double>
-    : public std::unary_function<long double, std::size_t>
+    inline size_t
+    hash<long double>::operator()(long double __val) const
     {
-      std::size_t
-      operator()(long double __ldval) const
-      {
-	std::size_t __result = 0;
-
-	int __exponent;
-	__ldval = std::frexp(__ldval, &__exponent);
-	__ldval = __ldval < 0.0l ? -(__ldval + 0.5l) : __ldval;
-
-	const long double __mult =
-	  __gnu_cxx::__numeric_traits<std::size_t>::__max + 1.0l;
-	__ldval *= __mult;
-
+      size_t __result = 0;
+
+      int __exponent;
+      __val = std::frexp(__val, &__exponent);
+      __val = __val < 0.0l ? -(__val + 0.5l) : __val;
+      
+      const long double __mult =
+      __gnu_cxx::__numeric_traits<size_t>::__max + 1.0l;
+      __val *= __mult;
+      
 	// Try to use all the bits of the mantissa (really necessary only
 	// on 32-bit targets, at least for 80-bit floating point formats).
-	const std::size_t __hibits = (std::size_t)__ldval;
-	__ldval = (__ldval - (long double)__hibits) * __mult;
+      const size_t __hibits = (size_t)__val;
+      __val = (__val - (long double)__hibits) * __mult;
+      
+      const size_t __coeff =
+	__gnu_cxx::__numeric_traits<size_t>::__max / __LDBL_MAX_EXP__;
+      
+      __result = __hibits + (size_t)__val + __coeff * __exponent;
+      
+      return __result;
+    };
 
-	const std::size_t __coeff =
-	  __gnu_cxx::__numeric_traits<std::size_t>::__max / __LDBL_MAX_EXP__;
+  // Explicit specialization of member operator for types that are not builtin.
+  template<>
+    size_t
+    hash<string>::operator()(string) const;
 
-	__result = __hibits + (std::size_t)__ldval + __coeff * __exponent;
+  template<>
+    size_t
+    hash<const string&>::operator()(const string&) const;
 
-	return __result;
-      }
-    };
+#ifdef _GLIBCXX_USE_WCHAR_T
+  template<>
+    size_t
+    hash<wstring>::operator()(wstring) const;
+
+  template<>
+    size_t
+    hash<const wstring&>::operator()(const wstring&) const;
+#endif
 
 _GLIBCXX_END_NAMESPACE_TR1
 }
diff --git a/libstdc++-v3/libmath/Makefile.in b/libstdc++-v3/libmath/Makefile.in
index e0cd3a2e0ee3df152017690b1a3a199dd6ac7de9..f72792aebce6c5db2273dd0877a2e22e93b163cd 100644
--- a/libstdc++-v3/libmath/Makefile.in
+++ b/libstdc++-v3/libmath/Makefile.in
@@ -133,6 +133,7 @@ ENABLE_SYMVERS_GNU_TRUE = @ENABLE_SYMVERS_GNU_TRUE@
 ENABLE_SYMVERS_TRUE = @ENABLE_SYMVERS_TRUE@
 ENABLE_VISIBILITY_FALSE = @ENABLE_VISIBILITY_FALSE@
 ENABLE_VISIBILITY_TRUE = @ENABLE_VISIBILITY_TRUE@
+ERROR_CONSTANTS_SRCDIR = @ERROR_CONSTANTS_SRCDIR@
 EXEEXT = @EXEEXT@
 EXTRA_CXX_FLAGS = @EXTRA_CXX_FLAGS@
 FGREP = @FGREP@
diff --git a/libstdc++-v3/libsupc++/Makefile.in b/libstdc++-v3/libsupc++/Makefile.in
index 5074f0f0ade3cd7e373bf5fcc40dc2ff5d9d85d0..3e714743a24fcf1094256ad99e031b83a044558b 100644
--- a/libstdc++-v3/libsupc++/Makefile.in
+++ b/libstdc++-v3/libsupc++/Makefile.in
@@ -188,6 +188,7 @@ ENABLE_SYMVERS_GNU_TRUE = @ENABLE_SYMVERS_GNU_TRUE@
 ENABLE_SYMVERS_TRUE = @ENABLE_SYMVERS_TRUE@
 ENABLE_VISIBILITY_FALSE = @ENABLE_VISIBILITY_FALSE@
 ENABLE_VISIBILITY_TRUE = @ENABLE_VISIBILITY_TRUE@
+ERROR_CONSTANTS_SRCDIR = @ERROR_CONSTANTS_SRCDIR@
 EXEEXT = @EXEEXT@
 EXTRA_CXX_FLAGS = @EXTRA_CXX_FLAGS@
 FGREP = @FGREP@
diff --git a/libstdc++-v3/po/Makefile.in b/libstdc++-v3/po/Makefile.in
index 8fae1a6725dfb577da2a39ec8f05832391351524..f9ec7e38ece553a8aa8bd45c32147a292ff328b4 100644
--- a/libstdc++-v3/po/Makefile.in
+++ b/libstdc++-v3/po/Makefile.in
@@ -118,6 +118,7 @@ ENABLE_SYMVERS_GNU_TRUE = @ENABLE_SYMVERS_GNU_TRUE@
 ENABLE_SYMVERS_TRUE = @ENABLE_SYMVERS_TRUE@
 ENABLE_VISIBILITY_FALSE = @ENABLE_VISIBILITY_FALSE@
 ENABLE_VISIBILITY_TRUE = @ENABLE_VISIBILITY_TRUE@
+ERROR_CONSTANTS_SRCDIR = @ERROR_CONSTANTS_SRCDIR@
 EXEEXT = @EXEEXT@
 EXTRA_CXX_FLAGS = @EXTRA_CXX_FLAGS@
 FGREP = @FGREP@
diff --git a/libstdc++-v3/src/Makefile.am b/libstdc++-v3/src/Makefile.am
index cd2aad64b65f2dac944ee2a409bd0519f6ecef59..419580190c5f0725b44a800f50007da9b36d5444 100644
--- a/libstdc++-v3/src/Makefile.am
+++ b/libstdc++-v3/src/Makefile.am
@@ -139,6 +139,8 @@ sources = \
 	debug.cc \
 	debug_list.cc \
 	functexcept.cc \
+	hash.cc \
+	hash_c++0x.cc \
 	globals_io.cc \
 	ios.cc \
 	ios_failure.cc \
@@ -211,6 +213,11 @@ system_error.lo: system_error.cc
 system_error.o: system_error.cc
 	$(CXXCOMPILE) -std=gnu++0x -c $<
 
+hash_c++0x.lo: hash_c++0x.cc
+	$(LTCXXCOMPILE) -std=gnu++0x -c $<
+hash_c++0x.o: hash_c++0x.cc
+	$(CXXCOMPILE) -std=gnu++0x -c $<
+
 if GLIBCXX_LDBL_COMPAT
 # Use special rules for compatibility-ldbl.cc compilation, as we need to
 # pass -mlong-double-64.
@@ -276,7 +283,7 @@ endif
 
 debugdir = debug
 
-# Build parallel set of debug objects here.
+# Build a set of debug objects here.
 stamp-debug:
 	if test ! -d ${debugdir}; then \
 	  mkdir -p ${debugdir}; \
diff --git a/libstdc++-v3/src/Makefile.in b/libstdc++-v3/src/Makefile.in
index 184b903b6e9090e8e67e57ba423cd58de813354e..eb6e72353589c9ff6032d9ff6100d7e0f633a87f 100644
--- a/libstdc++-v3/src/Makefile.in
+++ b/libstdc++-v3/src/Makefile.in
@@ -69,19 +69,19 @@ toolexeclibLTLIBRARIES_INSTALL = $(INSTALL)
 LTLIBRARIES = $(toolexeclib_LTLIBRARIES)
 am__libstdc___la_SOURCES_DIST = bitmap_allocator.cc pool_allocator.cc \
 	mt_allocator.cc codecvt.cc compatibility.cc complex_io.cc \
-	ctype.cc debug.cc debug_list.cc functexcept.cc globals_io.cc \
-	ios.cc ios_failure.cc ios_init.cc ios_locale.cc limits.cc \
-	list.cc locale.cc locale_init.cc locale_facets.cc \
-	localename.cc stdexcept.cc strstream.cc system_error.cc \
-	tree.cc allocator-inst.cc concept-inst.cc fstream-inst.cc \
-	ext-inst.cc ios-inst.cc iostream-inst.cc istream-inst.cc \
-	istream.cc locale-inst.cc misc-inst.cc ostream-inst.cc \
-	sstream-inst.cc streambuf-inst.cc streambuf.cc string-inst.cc \
-	valarray-inst.cc wlocale-inst.cc wstring-inst.cc atomicity.cc \
-	codecvt_members.cc collate_members.cc ctype_members.cc \
-	messages_members.cc monetary_members.cc numeric_members.cc \
-	time_members.cc basic_file.cc c++locale.cc \
-	compatibility-ldbl.cc
+	ctype.cc debug.cc debug_list.cc functexcept.cc hash.cc \
+	hash_c++0x.cc globals_io.cc ios.cc ios_failure.cc ios_init.cc \
+	ios_locale.cc limits.cc list.cc locale.cc locale_init.cc \
+	locale_facets.cc localename.cc stdexcept.cc strstream.cc \
+	system_error.cc tree.cc allocator-inst.cc concept-inst.cc \
+	fstream-inst.cc ext-inst.cc ios-inst.cc iostream-inst.cc \
+	istream-inst.cc istream.cc locale-inst.cc misc-inst.cc \
+	ostream-inst.cc sstream-inst.cc streambuf-inst.cc streambuf.cc \
+	string-inst.cc valarray-inst.cc wlocale-inst.cc \
+	wstring-inst.cc atomicity.cc codecvt_members.cc \
+	collate_members.cc ctype_members.cc messages_members.cc \
+	monetary_members.cc numeric_members.cc time_members.cc \
+	basic_file.cc c++locale.cc compatibility-ldbl.cc
 am__objects_1 = atomicity.lo codecvt_members.lo collate_members.lo \
 	ctype_members.lo messages_members.lo monetary_members.lo \
 	numeric_members.lo time_members.lo
@@ -89,16 +89,16 @@ am__objects_2 = basic_file.lo c++locale.lo
 @GLIBCXX_LDBL_COMPAT_TRUE@am__objects_3 = compatibility-ldbl.lo
 am__objects_4 = bitmap_allocator.lo pool_allocator.lo mt_allocator.lo \
 	codecvt.lo compatibility.lo complex_io.lo ctype.lo debug.lo \
-	debug_list.lo functexcept.lo globals_io.lo ios.lo \
-	ios_failure.lo ios_init.lo ios_locale.lo limits.lo list.lo \
-	locale.lo locale_init.lo locale_facets.lo localename.lo \
-	stdexcept.lo strstream.lo system_error.lo tree.lo \
-	allocator-inst.lo concept-inst.lo fstream-inst.lo ext-inst.lo \
-	ios-inst.lo iostream-inst.lo istream-inst.lo istream.lo \
-	locale-inst.lo misc-inst.lo ostream-inst.lo sstream-inst.lo \
-	streambuf-inst.lo streambuf.lo string-inst.lo valarray-inst.lo \
-	wlocale-inst.lo wstring-inst.lo $(am__objects_1) \
-	$(am__objects_2) $(am__objects_3)
+	debug_list.lo functexcept.lo hash.lo hash_c++0x.lo \
+	globals_io.lo ios.lo ios_failure.lo ios_init.lo ios_locale.lo \
+	limits.lo list.lo locale.lo locale_init.lo locale_facets.lo \
+	localename.lo stdexcept.lo strstream.lo system_error.lo \
+	tree.lo allocator-inst.lo concept-inst.lo fstream-inst.lo \
+	ext-inst.lo ios-inst.lo iostream-inst.lo istream-inst.lo \
+	istream.lo locale-inst.lo misc-inst.lo ostream-inst.lo \
+	sstream-inst.lo streambuf-inst.lo streambuf.lo string-inst.lo \
+	valarray-inst.lo wlocale-inst.lo wstring-inst.lo \
+	$(am__objects_1) $(am__objects_2) $(am__objects_3)
 am_libstdc___la_OBJECTS = $(am__objects_4)
 libstdc___la_OBJECTS = $(am_libstdc___la_OBJECTS)
 DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
@@ -168,6 +168,7 @@ ENABLE_SYMVERS_GNU_TRUE = @ENABLE_SYMVERS_GNU_TRUE@
 ENABLE_SYMVERS_TRUE = @ENABLE_SYMVERS_TRUE@
 ENABLE_VISIBILITY_FALSE = @ENABLE_VISIBILITY_FALSE@
 ENABLE_VISIBILITY_TRUE = @ENABLE_VISIBILITY_TRUE@
+ERROR_CONSTANTS_SRCDIR = @ERROR_CONSTANTS_SRCDIR@
 EXEEXT = @EXEEXT@
 EXTRA_CXX_FLAGS = @EXTRA_CXX_FLAGS@
 FGREP = @FGREP@
@@ -365,6 +366,8 @@ sources = \
 	debug.cc \
 	debug_list.cc \
 	functexcept.cc \
+	hash.cc \
+	hash_c++0x.cc \
 	globals_io.cc \
 	ios.cc \
 	ios_failure.cc \
@@ -793,6 +796,11 @@ system_error.lo: system_error.cc
 system_error.o: system_error.cc
 	$(CXXCOMPILE) -std=gnu++0x -c $<
 
+hash_c++0x.lo: hash_c++0x.cc
+	$(LTCXXCOMPILE) -std=gnu++0x -c $<
+hash_c++0x.o: hash_c++0x.cc
+	$(CXXCOMPILE) -std=gnu++0x -c $<
+
 # Use special rules for compatibility-ldbl.cc compilation, as we need to
 # pass -mlong-double-64.
 @GLIBCXX_LDBL_COMPAT_TRUE@compatibility-ldbl.lo: compatibility-ldbl.cc
@@ -806,7 +814,7 @@ system_error.o: system_error.cc
 @GLIBCXX_BUILD_DEBUG_FALSE@all-local:
 @GLIBCXX_BUILD_DEBUG_FALSE@install-data-local:
 
-# Build parallel set of debug objects here.
+# Build a set of debug objects here.
 stamp-debug:
 	if test ! -d ${debugdir}; then \
 	  mkdir -p ${debugdir}; \
diff --git a/libstdc++-v3/src/hash.cc b/libstdc++-v3/src/hash.cc
new file mode 100644
index 0000000000000000000000000000000000000000..60554dd2a92b571798bac5f460a21aea61826fca
--- /dev/null
+++ b/libstdc++-v3/src/hash.cc
@@ -0,0 +1,77 @@
+//  std::hash and std::tr1::hash definitions -*- C++ -*-
+
+// Copyright (C) 2007 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 2, 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.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING.  If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02110-1301, USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <cstddef>
+#include <string>
+
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+#include <functional>
+#  define _GLIBCXX_BEGIN_NAMESPACE_TR1 
+#  define _GLIBCXX_END_NAMESPACE_TR1 
+#else
+#include <tr1/functional>
+#  define _GLIBCXX_INCLUDE_AS_TR1
+#  define _GLIBCXX_BEGIN_NAMESPACE_TR1 namespace tr1 {
+#  define _GLIBCXX_END_NAMESPACE_TR1 }
+#endif
+
+namespace std
+{
+_GLIBCXX_BEGIN_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
+    {
+      const char* __p = reinterpret_cast<const char*>(__s.data());
+      return _Fnv_hash<>::hash(__p, __s.length() * sizeof(wchar_t));
+    }
+
+  template<>
+    size_t
+    hash<const wstring&>::operator()(const wstring& __s) const
+    {
+      const char* __p = reinterpret_cast<const char*>(__s.data());
+      return _Fnv_hash<>::hash(__p, __s.length() * sizeof(wchar_t));
+    }
+#endif
+
+_GLIBCXX_END_NAMESPACE_TR1
+}
diff --git a/libstdc++-v3/src/hash_c++0x.cc b/libstdc++-v3/src/hash_c++0x.cc
new file mode 100644
index 0000000000000000000000000000000000000000..528ffafb3e7eebe06e618e6cefad04f8900f8225
--- /dev/null
+++ b/libstdc++-v3/src/hash_c++0x.cc
@@ -0,0 +1,42 @@
+// std::hash definitions -*- C++ -*-
+
+// Copyright (C) 2007 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 2, 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.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include "hash.cc"
+#include <system_error>
+
+namespace std
+{
+  template<>
+    size_t
+    hash<error_code>::operator()(error_code __e) const
+    { 
+      const char* __p = reinterpret_cast<const char*>(&__e);
+      return _Fnv_hash<>::hash(__p, sizeof(__e));
+    }
+}
diff --git a/libstdc++-v3/testsuite/Makefile.in b/libstdc++-v3/testsuite/Makefile.in
index f700c5b524dbd1cb1f7c0a0f71b88e13135be979..d943b3f836d4ff36e0e52e5e54e88b928673bff8 100644
--- a/libstdc++-v3/testsuite/Makefile.in
+++ b/libstdc++-v3/testsuite/Makefile.in
@@ -122,6 +122,7 @@ ENABLE_SYMVERS_GNU_TRUE = @ENABLE_SYMVERS_GNU_TRUE@
 ENABLE_SYMVERS_TRUE = @ENABLE_SYMVERS_TRUE@
 ENABLE_VISIBILITY_FALSE = @ENABLE_VISIBILITY_FALSE@
 ENABLE_VISIBILITY_TRUE = @ENABLE_VISIBILITY_TRUE@
+ERROR_CONSTANTS_SRCDIR = @ERROR_CONSTANTS_SRCDIR@
 EXEEXT = @EXEEXT@
 EXTRA_CXX_FLAGS = @EXTRA_CXX_FLAGS@
 FGREP = @FGREP@