diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 0b6538052539..4de61c716705 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,14 @@ +2007-11-20 Paolo Carlini + + * include/tr1_impl/functional_hash.h + (hash::operator()(long double)): Only declare. + * src/hash.cc: Define here. + * config/abi/pre/gnu.ver: Adjust exports. + * include/tr1/functional: Do not include . + * include/std/functional: Likewise. + + * include/std/functional: Include . + 2007-11-18 Paolo Carlini * include/tr1/type_traits (_DEFINE_SPEC_BODY): Remove. diff --git a/libstdc++-v3/config/abi/pre/gnu.ver b/libstdc++-v3/config/abi/pre/gnu.ver index 0983e93e686d..3a5bcb5e244f 100644 --- a/libstdc++-v3/config/abi/pre/gnu.ver +++ b/libstdc++-v3/config/abi/pre/gnu.ver @@ -770,12 +770,14 @@ GLIBCXX_3.4.10 { _ZNKSt3tr14hashIRKSsEclES2_; _ZNKSt3tr14hashISbIwSt11char_traitsIwESaIwEEEclES4_; _ZNKSt3tr14hashISsEclESs; + _ZNKSt3tr14hashIeEclEe; _ZNKSt4hashIRKSbIwSt11char_traitsIwESaIwEEEclES5_; _ZNKSt4hashIRKSsEclES1_; _ZNKSt4hashISbIwSt11char_traitsIwESaIwEEEclES3_; _ZNKSt4hashISsEclESs; _ZNKSt4hashISt10error_codeEclES0_; + _ZNKSt4hashIeEclEe; # for parallel mode _ZNSt9__cxx199815_List_node_base4hook*; diff --git a/libstdc++-v3/include/std/functional b/libstdc++-v3/include/std/functional index 83bf85aef292..6b0ca04bece0 100644 --- a/libstdc++-v3/include/std/functional +++ b/libstdc++-v3/include/std/functional @@ -58,8 +58,8 @@ # if defined(_GLIBCXX_INCLUDE_AS_TR1) # error C++0x header cannot be included from TR1 header # endif -# include # include +# include # include # include # include diff --git a/libstdc++-v3/include/tr1/functional b/libstdc++-v3/include/tr1/functional index 190f61ae66b3..fa3dc6537c2c 100644 --- a/libstdc++-v3/include/tr1/functional +++ b/libstdc++-v3/include/tr1/functional @@ -43,7 +43,6 @@ #include #include -#include #include #include #include diff --git a/libstdc++-v3/include/tr1_impl/functional_hash.h b/libstdc++-v3/include/tr1_impl/functional_hash.h index 2ac1a45f6ba5..0dfff38e7b9f 100644 --- a/libstdc++-v3/include/tr1_impl/functional_hash.h +++ b/libstdc++-v3/include/tr1_impl/functional_hash.h @@ -155,34 +155,9 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1 return __result; }; - // For long double, careful with random padding bits (e.g., on x86, - // 10 bytes -> 12 bytes) and resort to frexp. template<> - inline size_t - hash::operator()(long double __val) const - { - 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::__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 = - __gnu_cxx::__numeric_traits::__max / __LDBL_MAX_EXP__; - - __result = __hibits + (size_t)__val + __coeff * __exponent; - - return __result; - }; + size_t + hash::operator()(long double __val) const; // Explicit specialization of member operator for types that are not builtin. template<> diff --git a/libstdc++-v3/src/hash.cc b/libstdc++-v3/src/hash.cc index 60554dd2a92b..c2b3b0508cad 100644 --- a/libstdc++-v3/src/hash.cc +++ b/libstdc++-v3/src/hash.cc @@ -29,6 +29,7 @@ #include #include +#include #ifdef __GXX_EXPERIMENTAL_CXX0X__ #include @@ -45,6 +46,35 @@ namespace std { _GLIBCXX_BEGIN_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::operator()(long double __val) const + { + 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::__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 = + __gnu_cxx::__numeric_traits::__max / __LDBL_MAX_EXP__; + + __result = __hibits + (size_t)__val + __coeff * __exponent; + + return __result; + }; + template<> size_t hash::operator()(string __s) const