diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 62bf2e215fa5c28950a5b3766d68dda290ec5f92..89fba85597df42cb74029cb0798486ef959fb74b 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,13 @@
+2013-02-01  François Dumont  <fdumont@gcc.gnu.org>
+
+	* include/bits/hashtable_policy.h
+	(_Prime_rehash_policy::_M_next_bkt)
+	(_Prime_rehash_policy::_M_need_rehash): Move definition...
+	* src/c++11/hashtable_c++0x.cc: ... here.
+	* src/shared/hashtable-aux.cc: Remove c++config.h include.
+	* config/abi/gnu.ver (GLIBCXX_3.4.18): Export _Prime_rehash_policy
+	symbols.
+
 2013-01-29  Jason Merrill  <jason@redhat.com>
 
 	PR libstdc++/54314
diff --git a/libstdc++-v3/config/abi/pre/gnu.ver b/libstdc++-v3/config/abi/pre/gnu.ver
index 71be1c30a279804b94a2d533be722f3b932b6265..2a9d582853ddc29dafe8c80e85301f4fa6d48c25 100644
--- a/libstdc++-v3/config/abi/pre/gnu.ver
+++ b/libstdc++-v3/config/abi/pre/gnu.ver
@@ -1,7 +1,6 @@
 ## Linker script for GNU versioning (GNU ld 2.13.91+ only.)
 ##
-## Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
-## 2011, 2012 Free Software Foundation, Inc.
+## Copyright (C) 2002-2013 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
@@ -1334,6 +1333,7 @@ GLIBCXX_3.4.18 {
     extern "C++"
     {
       std::random_device::*;
+      std::__detail::_Prime_rehash_policy::*;
     };
 
     # std::this_thread::__sleep_for
diff --git a/libstdc++-v3/include/bits/hashtable_policy.h b/libstdc++-v3/include/bits/hashtable_policy.h
index 17c25bc639fc52db01aa1dce2f69bfccebc8aa10..f4d8dc0fbe6c042ab405bcef00b3a368a60cd8fe 100644
--- a/libstdc++-v3/include/bits/hashtable_policy.h
+++ b/libstdc++-v3/include/bits/hashtable_policy.h
@@ -369,7 +369,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
     // Return a bucket count appropriate for n elements
     std::size_t
-    _M_bkt_for_elements(std::size_t __n) const;
+    _M_bkt_for_elements(std::size_t __n) const
+    { return __builtin_ceil(__n / (long double)_M_max_load_factor); }
 
     // __n_bkt is current bucket count, __n_elt is current element count,
     // and __n_ins is number of elements to be inserted.  Do we need to
@@ -397,77 +398,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     mutable std::size_t  _M_next_resize;
   };
 
-  extern const unsigned long __prime_list[];
-
-  // XXX This is a hack.  There's no good reason for any of
-  // _Prime_rehash_policy's member functions to be inline.
-
-  // Return a prime no smaller than n.
-  inline std::size_t
-  _Prime_rehash_policy::
-  _M_next_bkt(std::size_t __n) const
-  {
-    // Optimize lookups involving the first elements of __prime_list.
-    // (useful to speed-up, eg, constructors)
-    static const unsigned char __fast_bkt[12]
-      = { 2, 2, 2, 3, 5, 5, 7, 7, 11, 11, 11, 11 };
-
-    if (__n <= 11)
-      {
-	_M_next_resize
-	  = __builtin_ceil(__fast_bkt[__n]
-			   * (long double)_M_max_load_factor);
-	return __fast_bkt[__n];
-      }
-
-    const unsigned long* __next_bkt
-      = std::lower_bound(__prime_list + 5, __prime_list + _S_n_primes,
-			 __n);
-    _M_next_resize
-      = __builtin_ceil(*__next_bkt * (long double)_M_max_load_factor);
-    return *__next_bkt;
-  }
-
-  // Return the smallest integer p such that alpha p >= n, where alpha
-  // is the load factor.
-  inline std::size_t
-  _Prime_rehash_policy::
-  _M_bkt_for_elements(std::size_t __n) const
-  { return __builtin_ceil(__n / (long double)_M_max_load_factor); }
-
-  // Finds the smallest prime p such that alpha p > __n_elt + __n_ins.
-  // If p > __n_bkt, return make_pair(true, p); otherwise return
-  // make_pair(false, 0).  In principle this isn't very different from
-  // _M_bkt_for_elements.
-
-  // The only tricky part is that we're caching the element count at
-  // which we need to rehash, so we don't have to do a floating-point
-  // multiply for every insertion.
-
-  inline std::pair<bool, std::size_t>
-  _Prime_rehash_policy::
-  _M_need_rehash(std::size_t __n_bkt, std::size_t __n_elt,
-		 std::size_t __n_ins) const
-  {
-    if (__n_elt + __n_ins >= _M_next_resize)
-      {
-	long double __min_bkts = (__n_elt + __n_ins)
-				 / (long double)_M_max_load_factor;
-	if (__min_bkts >= __n_bkt)
-	  return std::make_pair(true,
-	    _M_next_bkt(std::max<std::size_t>(__builtin_floor(__min_bkts) + 1,
-					      __n_bkt * _S_growth_factor)));
-	else
-	  {
-	    _M_next_resize
-	      = __builtin_floor(__n_bkt * (long double)_M_max_load_factor);
-	    return std::make_pair(false, 0);
-	  }
-      }
-    else
-      return std::make_pair(false, 0);
-  }
-
   // Base classes for std::_Hashtable.  We define these base classes
   // because in some cases we want to do different things depending on
   // the value of a policy class.  In some cases the policy class
diff --git a/libstdc++-v3/src/c++11/hashtable_c++0x.cc b/libstdc++-v3/src/c++11/hashtable_c++0x.cc
index 33911315f5264691f97c3ca305a92b0f88d385b8..7617c58576b3b380b517e9e6786c2f44b7b056a9 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, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+// Copyright (C) 2007-2013 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,13 +22,76 @@
 // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 // <http://www.gnu.org/licenses/>.
 
-#include <bits/c++config.h>
-
 #if __cplusplus < 201103L
 # error "hashtable_c++0x.cc must be compiled with -std=gnu++0x"
 #endif
 
+#include <initializer_list>
+#include <tuple>
+#include <bits/hashtable_policy.h>
+
 namespace std _GLIBCXX_VISIBILITY(default)
 {
 #include "../shared/hashtable-aux.cc"
-} // namespace // namespace std
+
+namespace __detail
+{
+  _GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+  // Return a prime no smaller than n.
+  std::size_t
+  _Prime_rehash_policy::_M_next_bkt(std::size_t __n) const
+  {
+    // Optimize lookups involving the first elements of __prime_list.
+    // (useful to speed-up, eg, constructors)
+    static const unsigned char __fast_bkt[12]
+      = { 2, 2, 2, 3, 5, 5, 7, 7, 11, 11, 11, 11 };
+
+    if (__n <= 11)
+      {
+	_M_next_resize =
+	  __builtin_ceil(__fast_bkt[__n] * (long double)_M_max_load_factor);
+	return __fast_bkt[__n];
+      }
+
+    const unsigned long* __next_bkt =
+      std::lower_bound(__prime_list + 5, __prime_list + _S_n_primes, __n);
+    _M_next_resize =
+      __builtin_ceil(*__next_bkt * (long double)_M_max_load_factor);
+    return *__next_bkt;
+  }
+
+  // Finds the smallest prime p such that alpha p > __n_elt + __n_ins.
+  // If p > __n_bkt, return make_pair(true, p); otherwise return
+  // make_pair(false, 0).  In principle this isn't very different from
+  // _M_bkt_for_elements.
+
+  // The only tricky part is that we're caching the element count at
+  // which we need to rehash, so we don't have to do a floating-point
+  // multiply for every insertion.
+
+  std::pair<bool, std::size_t>
+  _Prime_rehash_policy::
+  _M_need_rehash(std::size_t __n_bkt, std::size_t __n_elt,
+		 std::size_t __n_ins) const
+  {
+    if (__n_elt + __n_ins >= _M_next_resize)
+      {
+	long double __min_bkts = (__n_elt + __n_ins)
+				   / (long double)_M_max_load_factor;
+	if (__min_bkts >= __n_bkt)
+	  return std::make_pair(true,
+	    _M_next_bkt(std::max<std::size_t>(__builtin_floor(__min_bkts) + 1,
+					      __n_bkt * _S_growth_factor)));
+
+	_M_next_resize
+	  = __builtin_floor(__n_bkt * (long double)_M_max_load_factor);
+	return std::make_pair(false, 0);
+      }
+    else
+      return std::make_pair(false, 0);
+  }
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace __detail
+} // namespace std
diff --git a/libstdc++-v3/src/shared/hashtable-aux.cc b/libstdc++-v3/src/shared/hashtable-aux.cc
index 23bb00ec584a47fa4c7cf2bf8f7932d1eba1162e..876ffe1ad0531952e6d89da3560bcd3176231de0 100644
--- a/libstdc++-v3/src/shared/hashtable-aux.cc
+++ b/libstdc++-v3/src/shared/hashtable-aux.cc
@@ -1,6 +1,6 @@
 // std::__detail and std::tr1::__detail definitions -*- C++ -*-
 
-// Copyright (C) 2007, 2009, 2011 Free Software Foundation, Inc.
+// Copyright (C) 2007-2013 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,8 +22,6 @@
 // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 // <http://www.gnu.org/licenses/>.
 
-#include <bits/c++config.h>
-
 namespace __detail
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION