functional_hash.h: Add ext/numeric_traits.h.

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.

From-SVN: r128278
This commit is contained in:
Benjamin Kosnik 2007-09-09 00:05:13 +00:00 committed by Benjamin Kosnik
parent 96f52d87e8
commit 9adfc73cd3
18 changed files with 349 additions and 163 deletions

View File

@ -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:

View File

@ -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@

View File

@ -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;

View File

@ -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;

View File

@ -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)

View File

@ -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

View File

@ -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>

View File

@ -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)

View File

@ -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

View File

@ -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;
struct hash : public std::unary_function<_Tp, size_t>
{
size_t
operator()(_Tp __val) const;
};
#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); } \
}
// 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.
// Explicit specializations for floating point types.
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()); }
inline size_t
hash<float>::operator()(float __val) const
{
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;
};
#ifdef _GLIBCXX_USE_WCHAR_T
template<>
struct hash<std::wstring>
: public std::unary_function<std::wstring, std::size_t>
inline size_t
hash<double>::operator()(double __val) const
{
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
template<>
struct hash<float>
: public std::unary_function<float, std::size_t>
{
std::size_t
operator()(float __fval) const
{
std::size_t __result = 0;
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));
if (__val != 0.0)
__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>
{
std::size_t
operator()(double __dval) const
{
std::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));
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 std::size_t __coeff =
__gnu_cxx::__numeric_traits<std::size_t>::__max / __LDBL_MAX_EXP__;
__result = __hibits + (std::size_t)__ldval + __coeff * __exponent;
return __result;
}
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;
};
// Explicit specialization of member operator for types that are not builtin.
template<>
size_t
hash<string>::operator()(string) const;
template<>
size_t
hash<const string&>::operator()(const string&) const;
#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
}

View File

@ -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@

View File

@ -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@

View File

@ -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@

View File

@ -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}; \

View File

@ -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}; \

77
libstdc++-v3/src/hash.cc Normal file
View File

@ -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
}

View File

@ -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));
}
}

View File

@ -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@