2011-11-18 Paolo Carlini <paolo.carlini@oracle.com>
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 18 Nov 2011 12:37:06 +0000 (12:37 +0000)
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 18 Nov 2011 12:37:06 +0000 (12:37 +0000)
* src/hash-long-double-aux.cc: Rename to...
* src/hash-long-double-tr1-aux.cc: ... this.
* src/compatibility-ldbl.cc: Adjust.
* src/hash_tr1.cc: Likewise.
* src/hash_c++0x.cc: Don't use src/hash-long-double-aux.cc.
* include/bits/functional_hash.h (hash<_Tp*>::operator(), specs
for integer types, hash<float>::operator(), hash<double>::operator(),
hash<long double>::operator()): Declare noexcept.
* include/debug/bitset (hash<__debug::bitset>::operator()): Likewise.
* include/debug/vector (hash<__debug::vector>::operator()): Likewise.
* include/std/system_error (hash<error_code>::operator()): Likewise.
* include/std/thread (hash<thread::id>::operator()): Likewise.
* include/std/bitset (hash<bitset>::operator()): Likewise.
* include/std/typeindex (hash<type_index>::operator()): Likewise.
* include/profile/bitset (hash<__profile::vector>::operator()):
Likewise.
* include/profile/vector (hash<__profile::vector>::operator()):
Likewise.
* include/ext/vstring.h (hash<__vstring>::operator(),
hash<__wvstring>::operator(), hash<__u16vstring>::operator(),
hash<__u32vstring>::operator()): Likewise.
* include/bits/shared_ptr.h (hash<shared_ptr>::operator()): Likewise.
* include/bits/shared_ptr_base.h (hash<__shared_ptr>::operator()):
Likewise.
* include/bits/unique_ptr.h (hash<unique_ptr>::operator()): Likewise.
* include/bits/basic_string.h (hash<string>::operator(),
hash<wstring>::operator(), hash<u16string>::operator(),
hash<u32string>::operator()): Likewise.
* include/bits/vector.tcc (hash<vector>::operator()): Likewise.
* include/bits/stl_bvector.h (hash<vector>::operator()): Likewise.
* libsupc++/typeinfo (type_info::hash_code): Use noexcept instead of
throw().

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@181473 138bc75d-0d04-0410-961f-82ee72b054a4

23 files changed:
libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/basic_string.h
libstdc++-v3/include/bits/functional_hash.h
libstdc++-v3/include/bits/shared_ptr.h
libstdc++-v3/include/bits/shared_ptr_base.h
libstdc++-v3/include/bits/stl_bvector.h
libstdc++-v3/include/bits/unique_ptr.h
libstdc++-v3/include/bits/vector.tcc
libstdc++-v3/include/debug/bitset
libstdc++-v3/include/debug/vector
libstdc++-v3/include/ext/vstring.h
libstdc++-v3/include/profile/bitset
libstdc++-v3/include/profile/vector
libstdc++-v3/include/std/bitset
libstdc++-v3/include/std/system_error
libstdc++-v3/include/std/thread
libstdc++-v3/include/std/typeindex
libstdc++-v3/libsupc++/typeinfo
libstdc++-v3/src/compatibility-ldbl.cc
libstdc++-v3/src/hash-long-double-aux.cc [deleted file]
libstdc++-v3/src/hash-long-double-tr1-aux.cc [new file with mode: 0644]
libstdc++-v3/src/hash_c++0x.cc
libstdc++-v3/src/hash_tr1.cc

index c52db38..0d68464 100644 (file)
@@ -1,3 +1,38 @@
+2011-11-18  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       * src/hash-long-double-aux.cc: Rename to...
+       * src/hash-long-double-tr1-aux.cc: ... this.
+       * src/compatibility-ldbl.cc: Adjust.
+       * src/hash_tr1.cc: Likewise.
+       * src/hash_c++0x.cc: Don't use src/hash-long-double-aux.cc.
+       * include/bits/functional_hash.h (hash<_Tp*>::operator(), specs
+       for integer types, hash<float>::operator(), hash<double>::operator(),
+       hash<long double>::operator()): Declare noexcept.
+       * include/debug/bitset (hash<__debug::bitset>::operator()): Likewise.
+       * include/debug/vector (hash<__debug::vector>::operator()): Likewise.
+       * include/std/system_error (hash<error_code>::operator()): Likewise.
+       * include/std/thread (hash<thread::id>::operator()): Likewise.
+       * include/std/bitset (hash<bitset>::operator()): Likewise.
+       * include/std/typeindex (hash<type_index>::operator()): Likewise.
+       * include/profile/bitset (hash<__profile::vector>::operator()):
+       Likewise.
+       * include/profile/vector (hash<__profile::vector>::operator()):
+       Likewise.
+       * include/ext/vstring.h (hash<__vstring>::operator(),
+       hash<__wvstring>::operator(), hash<__u16vstring>::operator(),
+       hash<__u32vstring>::operator()): Likewise.
+       * include/bits/shared_ptr.h (hash<shared_ptr>::operator()): Likewise.
+       * include/bits/shared_ptr_base.h (hash<__shared_ptr>::operator()):
+       Likewise.
+       * include/bits/unique_ptr.h (hash<unique_ptr>::operator()): Likewise.
+       * include/bits/basic_string.h (hash<string>::operator(),
+       hash<wstring>::operator(), hash<u16string>::operator(),
+       hash<u32string>::operator()): Likewise.
+       * include/bits/vector.tcc (hash<vector>::operator()): Likewise.
+       * include/bits/stl_bvector.h (hash<vector>::operator()): Likewise.
+       * libsupc++/typeinfo (type_info::hash_code): Use noexcept instead of
+       throw().
+
 2011-11-17  Richard Henderson  <rth@redhat.com>
 
        PR libstdc++/51181
index 00f9bcc..169daf5 100644 (file)
@@ -3044,7 +3044,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     : public __hash_base<size_t, string>
     {
       size_t
-      operator()(const string& __s) const
+      operator()(const string& __s) const noexcept
       { return std::_Hash_impl::hash(__s.data(), __s.length()); }
     };
 
@@ -3055,7 +3055,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     : public __hash_base<size_t, wstring>
     {
       size_t
-      operator()(const wstring& __s) const
+      operator()(const wstring& __s) const noexcept
       { return std::_Hash_impl::hash(__s.data(),
                                      __s.length() * sizeof(wchar_t)); }
     };
@@ -3069,7 +3069,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     : public __hash_base<size_t, u16string>
     {
       size_t
-      operator()(const u16string& __s) const
+      operator()(const u16string& __s) const noexcept
       { return std::_Hash_impl::hash(__s.data(),
                                      __s.length() * sizeof(char16_t)); }
     };
@@ -3080,7 +3080,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     : public __hash_base<size_t, u32string>
     {
       size_t
-      operator()(const u32string& __s) const
+      operator()(const u32string& __s) const noexcept
       { return std::_Hash_impl::hash(__s.data(),
                                      __s.length() * sizeof(char32_t)); }
     };
index e77cb4e..2b82b21 100644 (file)
@@ -66,61 +66,64 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     struct hash<_Tp*> : public __hash_base<size_t, _Tp*>
     {
       size_t
-      operator()(_Tp* __p) const
+      operator()(_Tp* __p) const noexcept
       { return reinterpret_cast<size_t>(__p); }
     };
 
   // Explicit specializations for integer types.
 #define _Cxx_hashtable_define_trivial_hash(_Tp)        \
   template<>                                           \
-    inline size_t                                      \
-    hash<_Tp>::operator()(_Tp __val) const             \
-    { return static_cast<size_t>(__val); }
+    struct hash<_Tp> : public __hash_base<size_t, _Tp>  \
+    {                                                   \
+      size_t                                            \
+      operator()(_Tp __val) const noexcept              \
+      { return static_cast<size_t>(__val); }            \
+    };
 
   /// Explicit specialization for bool.
-  _Cxx_hashtable_define_trivial_hash(bool);
+  _Cxx_hashtable_define_trivial_hash(bool)
 
   /// Explicit specialization for char.
-  _Cxx_hashtable_define_trivial_hash(char);
+  _Cxx_hashtable_define_trivial_hash(char)
 
   /// Explicit specialization for signed char.
-  _Cxx_hashtable_define_trivial_hash(signed char);
+  _Cxx_hashtable_define_trivial_hash(signed char)
 
   /// Explicit specialization for unsigned char.
-  _Cxx_hashtable_define_trivial_hash(unsigned char);
+  _Cxx_hashtable_define_trivial_hash(unsigned char)
 
   /// Explicit specialization for wchar_t.
-  _Cxx_hashtable_define_trivial_hash(wchar_t);
+  _Cxx_hashtable_define_trivial_hash(wchar_t)
 
   /// Explicit specialization for char16_t.
-  _Cxx_hashtable_define_trivial_hash(char16_t);
+  _Cxx_hashtable_define_trivial_hash(char16_t)
 
   /// Explicit specialization for char32_t.
-  _Cxx_hashtable_define_trivial_hash(char32_t);
+  _Cxx_hashtable_define_trivial_hash(char32_t)
 
   /// Explicit specialization for short.
-  _Cxx_hashtable_define_trivial_hash(short);
+  _Cxx_hashtable_define_trivial_hash(short)
 
   /// Explicit specialization for int.
-  _Cxx_hashtable_define_trivial_hash(int);
+  _Cxx_hashtable_define_trivial_hash(int)
 
   /// Explicit specialization for long.
-  _Cxx_hashtable_define_trivial_hash(long);
+  _Cxx_hashtable_define_trivial_hash(long)
 
   /// Explicit specialization for long long.
-  _Cxx_hashtable_define_trivial_hash(long long);
+  _Cxx_hashtable_define_trivial_hash(long long)
 
   /// Explicit specialization for unsigned short.
-  _Cxx_hashtable_define_trivial_hash(unsigned short);
+  _Cxx_hashtable_define_trivial_hash(unsigned short)
 
   /// Explicit specialization for unsigned int.
-  _Cxx_hashtable_define_trivial_hash(unsigned int);
+  _Cxx_hashtable_define_trivial_hash(unsigned int)
 
   /// Explicit specialization for unsigned long.
-  _Cxx_hashtable_define_trivial_hash(unsigned long);
+  _Cxx_hashtable_define_trivial_hash(unsigned long)
 
   /// Explicit specialization for unsigned long long.
-  _Cxx_hashtable_define_trivial_hash(unsigned long long);
+  _Cxx_hashtable_define_trivial_hash(unsigned long long)
 
 #undef _Cxx_hashtable_define_trivial_hash
 
@@ -162,26 +165,36 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   /// Specialization for float.
   template<>
-    inline size_t
-    hash<float>::operator()(float __val) const
+    struct hash<float> : public __hash_base<size_t, float>
     {
-      // 0 and -0 both hash to zero.
-      return __val != 0.0f ? std::_Hash_impl::hash(__val) : 0;
-    }
+      size_t
+      operator()(float __val) const noexcept
+      {
+       // 0 and -0 both hash to zero.
+       return __val != 0.0f ? std::_Hash_impl::hash(__val) : 0;
+      }
+    };
 
   /// Specialization for double.
   template<>
-    inline size_t
-    hash<double>::operator()(double __val) const
+    struct hash<double> : public __hash_base<size_t, double>
     {
-      // 0 and -0 both hash to zero.
-      return __val != 0.0 ? std::_Hash_impl::hash(__val) : 0;
-    }
+      size_t
+      operator()(double __val) const noexcept
+      {
+       // 0 and -0 both hash to zero.
+       return __val != 0.0 ? std::_Hash_impl::hash(__val) : 0;
+      }
+    };
 
   /// Specialization for long double.
   template<>
-    _GLIBCXX_PURE size_t
-    hash<long double>::operator()(long double __val) const;
+    struct hash<long double>
+    : public __hash_base<size_t, long double>
+    {
+      _GLIBCXX_PURE size_t
+      operator()(long double __val) const noexcept;
+    };
 
   // @} group hashes
 
index 32addf9..33128dd 100644 (file)
@@ -619,7 +619,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     : public __hash_base<size_t, shared_ptr<_Tp>>
     {
       size_t
-      operator()(const shared_ptr<_Tp>& __s) const
+      operator()(const shared_ptr<_Tp>& __s) const noexcept
       { return std::hash<_Tp*>()(__s.get()); }
     };
 
index fbbadd1..c067754 100644 (file)
@@ -1450,7 +1450,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     : public __hash_base<size_t, __shared_ptr<_Tp, _Lp>>
     {
       size_t
-      operator()(const __shared_ptr<_Tp, _Lp>& __s) const
+      operator()(const __shared_ptr<_Tp, _Lp>& __s) const noexcept
       { return std::hash<_Tp*>()(__s.get()); }
     };
 
index 8f28640..bec63ff 100644 (file)
@@ -1075,7 +1075,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     : public __hash_base<size_t, _GLIBCXX_STD_C::vector<bool, _Alloc>>
     {
       size_t
-      operator()(const _GLIBCXX_STD_C::vector<bool, _Alloc>& __b) const;
+      operator()(const _GLIBCXX_STD_C::vector<bool, _Alloc>&) const noexcept;
     };
 
 _GLIBCXX_END_NAMESPACE_VERSION
index 869d931..0a12799 100644 (file)
@@ -545,7 +545,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     : public __hash_base<size_t, unique_ptr<_Tp, _Dp>>
     {
       size_t
-      operator()(const unique_ptr<_Tp, _Dp>& __u) const
+      operator()(const unique_ptr<_Tp, _Dp>& __u) const noexcept
       {
        typedef unique_ptr<_Tp, _Dp> _UP;
        return std::hash<typename _UP::pointer>()(__u.get());
index b746842..d9c3b65 100644 (file)
@@ -818,7 +818,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   template<typename _Alloc>
     size_t
     hash<_GLIBCXX_STD_C::vector<bool, _Alloc>>::
-    operator()(const _GLIBCXX_STD_C::vector<bool, _Alloc>& __b) const
+    operator()(const _GLIBCXX_STD_C::vector<bool, _Alloc>& __b) const noexcept
     {
       size_t __hash = 0;
       using _GLIBCXX_STD_C::_S_word_bit;
index 21d2817..f44bbcd 100644 (file)
@@ -414,7 +414,7 @@ namespace __debug
     : public __hash_base<size_t, __debug::bitset<_Nb>>
     {
       size_t
-      operator()(const __debug::bitset<_Nb>& __b) const
+      operator()(const __debug::bitset<_Nb>& __b) const noexcept
       { return std::hash<_GLIBCXX_STD_C::bitset<_Nb>>()(__b._M_base()); }
     };
 #endif
index 82662b4..5ee0fab 100644 (file)
@@ -625,7 +625,7 @@ namespace __debug
     : public __hash_base<size_t, __debug::vector<bool, _Alloc>>
     {
       size_t
-      operator()(const __debug::vector<bool, _Alloc>& __b) const
+      operator()(const __debug::vector<bool, _Alloc>& __b) const noexcept
       { return std::hash<_GLIBCXX_STD_C::vector<bool, _Alloc>>()
          (__b._M_base()); }
     };
index a613e36..8c4120a 100644 (file)
@@ -2769,7 +2769,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     : public __hash_base<size_t, __gnu_cxx::__vstring>
     {
       size_t
-      operator()(const __gnu_cxx::__vstring& __s) const
+      operator()(const __gnu_cxx::__vstring& __s) const noexcept
       { return std::_Hash_impl::hash(__s.data(), __s.length()); }
     };
 
@@ -2780,7 +2780,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     : public __hash_base<size_t, __gnu_cxx::__wvstring>
     {
       size_t
-      operator()(const __gnu_cxx::__wvstring& __s) const
+      operator()(const __gnu_cxx::__wvstring& __s) const noexcept
       { return std::_Hash_impl::hash(__s.data(),
                                      __s.length() * sizeof(wchar_t)); }
     };
@@ -2793,7 +2793,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     : public __hash_base<size_t, __gnu_cxx::__u16vstring>
     {
       size_t
-      operator()(const __gnu_cxx::__u16vstring& __s) const
+      operator()(const __gnu_cxx::__u16vstring& __s) const noexcept
       { return std::_Hash_impl::hash(__s.data(),
                                      __s.length() * sizeof(char16_t)); }
     };
@@ -2804,7 +2804,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     : public __hash_base<size_t, __gnu_cxx::__u32vstring>
     {
       size_t
-      operator()(const __gnu_cxx::__u32vstring& __s) const
+      operator()(const __gnu_cxx::__u32vstring& __s) const noexcept
       { return std::_Hash_impl::hash(__s.data(),
                                      __s.length() * sizeof(char32_t)); }
     };
index bd4aa3e..a2cba5e 100644 (file)
@@ -372,7 +372,7 @@ namespace __profile
     : public __hash_base<size_t, __profile::bitset<_Nb>>
     {
       size_t
-      operator()(const __profile::bitset<_Nb>& __b) const
+      operator()(const __profile::bitset<_Nb>& __b) const noexcept
       { return std::hash<_GLIBCXX_STD_C::bitset<_Nb>>()(__b._M_base()); }
     };
 #endif
index 86aefd6..0526c5a 100644 (file)
@@ -529,7 +529,7 @@ namespace __profile
     : public __hash_base<size_t, __profile::vector<bool, _Alloc>>
     {
       size_t
-      operator()(const __profile::vector<bool, _Alloc>& __b) const
+      operator()(const __profile::vector<bool, _Alloc>& __b) const noexcept
       { return std::hash<_GLIBCXX_STD_C::vector<bool, _Alloc>>()
          (__b._M_base()); }
     };
index 813ed4b..e07c5e0 100644 (file)
@@ -1555,7 +1555,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     : public __hash_base<size_t, _GLIBCXX_STD_C::bitset<_Nb>>
     {
       size_t
-      operator()(const _GLIBCXX_STD_C::bitset<_Nb>& __b) const
+      operator()(const _GLIBCXX_STD_C::bitset<_Nb>& __b) const noexcept
       {
        const size_t __clength = (_Nb + __CHAR_BIT__ - 1) / __CHAR_BIT__;
        return std::_Hash_impl::hash(__b._M_getdata(), __clength);
@@ -1567,7 +1567,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     : public __hash_base<size_t, _GLIBCXX_STD_C::bitset<0>>
     {
       size_t
-      operator()(const _GLIBCXX_STD_C::bitset<0>&) const
+      operator()(const _GLIBCXX_STD_C::bitset<0>&) const noexcept
       { return 0; }
     };
 
index 565261e..19482bc 100644 (file)
@@ -361,7 +361,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     : public __hash_base<size_t, error_code>
     {
       size_t
-      operator()(const error_code& __e) const
+      operator()(const error_code& __e) const noexcept
       {
        const size_t __tmp = std::_Hash_impl::hash(__e._M_value);
        return std::_Hash_impl::__hash_combine(__e._M_cat, __tmp);
index 8cc0690..1d17337 100644 (file)
@@ -221,7 +221,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     : public __hash_base<size_t, thread::id>
     {
       size_t
-      operator()(const thread::id& __id) const
+      operator()(const thread::id& __id) const noexcept
       { return std::_Hash_impl::hash(__id._M_thread); }
     };
 
index a92c296..fa07ac6 100644 (file)
@@ -76,7 +76,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     { return !_M_target->before(*__rhs._M_target); }
 
     size_t
-    hash_code() const
+    hash_code() const noexcept
     { return _M_target->hash_code(); }
 
     const char*
@@ -97,7 +97,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       typedef type_index  argument_type;
 
       size_t
-      operator()(const type_index& __ti) const
+      operator()(const type_index& __ti) const noexcept
       { return __ti.hash_code(); }
     };
 
index 69311d6..22ef49f 100644 (file)
@@ -140,7 +140,7 @@ namespace std
     { return !operator==(__arg); }
 
 #ifdef __GXX_EXPERIMENTAL_CXX0X__
-    size_t hash_code() const throw()
+    size_t hash_code() const noexcept
     {
 #  if !__GXX_MERGED_TYPEINFO_NAMES
       return _Hash_bytes(name(), __builtin_strlen(name()),
index a9bdb8b..a103856 100644 (file)
@@ -1,6 +1,6 @@
 // Compatibility symbols for -mlong-double-64 compatibility -*- C++ -*-
 
-// Copyright (C) 2006, 2008, 2009, 2010
+// Copyright (C) 2006, 2008, 2009, 2010, 2011
 // Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
@@ -69,14 +69,7 @@ namespace std _GLIBCXX_VISIBILITY(default)
 
 // For std::tr1::hash<long double>::operator()
 #define _GLIBCXX_LONG_DOUBLE_COMPAT_IMPL
-
-namespace std _GLIBCXX_VISIBILITY(default)
-{
-  namespace tr1 
-  {
-#include "hash-long-double-aux.cc"
-  }
-}
+#include "hash-long-double-tr1-aux.cc"
 
 // std::tr1::hash<long double>::operator()
 // and std::hash<long double>::operator()
diff --git a/libstdc++-v3/src/hash-long-double-aux.cc b/libstdc++-v3/src/hash-long-double-aux.cc
deleted file mode 100644 (file)
index d54d635..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-//  std::hash and std::tr1::hash definitions, long double bits -*- C++ -*-
-
-// Copyright (C) 2010 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/>.
-
-  // For long double, careful with random padding bits (e.g., on x86,
-  // 10 bytes -> 12 bytes) and resort to frexp.
-  template<>
-    size_t
-    hash<long double>::operator()(long double __val) const
-    {
-      // 0 and -0 both hash to zero.
-      if (__val == 0.0L)
-       return 0;
-
-      int __exponent;
-      __val = __builtin_frexpl(__val, &__exponent);
-      __val = __val < 0.0l ? -(__val + 0.5l) : __val;
-
-      const long double __mult = __SIZE_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 size_t __hibits = (size_t)__val;
-      __val = (__val - (long double)__hibits) * __mult;
-
-      const size_t __coeff = __SIZE_MAX__ / __LDBL_MAX_EXP__;
-
-      return __hibits + (size_t)__val + __coeff * __exponent;
-    }
diff --git a/libstdc++-v3/src/hash-long-double-tr1-aux.cc b/libstdc++-v3/src/hash-long-double-tr1-aux.cc
new file mode 100644 (file)
index 0000000..70ed45b
--- /dev/null
@@ -0,0 +1,56 @@
+// std::tr1::hash definitions, long double bits -*- C++ -*-
+
+// Copyright (C) 2010, 2011 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/>.
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+  namespace tr1 
+  {
+    // For long double, careful with random padding bits (e.g., on x86,
+    // 10 bytes -> 12 bytes) and resort to frexp.
+    template<>
+      size_t
+      hash<long double>::operator()(long double __val) const
+      {
+       // 0 and -0 both hash to zero.
+       if (__val == 0.0L)
+         return 0;
+
+       int __exponent;
+       __val = __builtin_frexpl(__val, &__exponent);
+       __val = __val < 0.0l ? -(__val + 0.5l) : __val;
+
+       const long double __mult = __SIZE_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 size_t __hibits = (size_t)__val;
+       __val = (__val - (long double)__hibits) * __mult;
+
+       const size_t __coeff = __SIZE_MAX__ / __LDBL_MAX_EXP__;
+
+       return __hibits + (size_t)__val + __coeff * __exponent;
+      }
+  }
+}
index 852498d..d685074 100644 (file)
@@ -1,6 +1,6 @@
 // std::hash definitions -*- C++ -*-
 
-// Copyright (C) 2010 Free Software Foundation, Inc.
+// Copyright (C) 2010, 2011 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
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
-#include "hash-long-double-aux.cc"
+  _GLIBCXX_PURE size_t
+  hash<long double>::operator()(long double __val) const noexcept
+  {
+    // 0 and -0 both hash to zero.
+    if (__val == 0.0L)
+      return 0;
+
+    int __exponent;
+    __val = __builtin_frexpl(__val, &__exponent);
+    __val = __val < 0.0l ? -(__val + 0.5l) : __val;
+
+    const long double __mult = __SIZE_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 size_t __hibits = (size_t)__val;
+    __val = (__val - (long double)__hibits) * __mult;
+
+    const size_t __coeff = __SIZE_MAX__ / __LDBL_MAX_EXP__;
+
+    return __hibits + (size_t)__val + __coeff * __exponent;
+  }
 }
index e707e82..a5ac87e 100644 (file)
@@ -1,6 +1,6 @@
 // std::tr1::hash definitions -*- C++ -*-
 
-// Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+// Copyright (C) 2007, 2008, 2009, 2010, 2011 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
 #include <string>
 #include <tr1/functional>
 
+#include "hash-long-double-tr1-aux.cc"
+
 namespace std _GLIBCXX_VISIBILITY(default)
 {
   namespace tr1 
   {
-#include "hash-long-double-aux.cc"
-
 #ifndef _GLIBCXX_LONG_DOUBLE_COMPAT_IMPL
   template<>
     size_t