aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.6/libstdc++-v3/src/hash_c++0x.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc-4.6/libstdc++-v3/src/hash_c++0x.cc')
-rw-r--r--gcc-4.6/libstdc++-v3/src/hash_c++0x.cc26
1 files changed, 24 insertions, 2 deletions
diff --git a/gcc-4.6/libstdc++-v3/src/hash_c++0x.cc b/gcc-4.6/libstdc++-v3/src/hash_c++0x.cc
index 852498d..d685074 100644
--- a/gcc-4.6/libstdc++-v3/src/hash_c++0x.cc
+++ b/gcc-4.6/libstdc++-v3/src/hash_c++0x.cc
@@ -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
@@ -30,5 +30,27 @@
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;
+ }
}