+2010-09-22 Paolo Carlini <paolo.carlini@oracle.com>
+
+ * src/hash_bytes.cc: Move...
+ * libsupc++/hash_bytes.cc: ... here.
+ * src/Makefile.am: Adjust.
+ * libsupc++/Makefile.am: Likewise.
+ * config/abi/pre/gnu.ver: Likewise.
+ * libsupc++/typeinfo (type_info::hash_code): Add in C++0x mode.
+ * src/Makefile.in: Regenerate.
+ * libsupc++/Makefile.am: Likewise.
+ * testsuite/18_support/type_info/hash_code.cc: New.
+
2010-09-20 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
PR libstdc++/45711
_ZNSbIwSt11char_traitsIwESaIwEE4backEv;
_ZNKSbIwSt11char_traitsIwESaIwEE4backEv;
- # Default function.
- _ZSt11_Hash_bytesPKv*;
-
- # FNV hash.
- _ZSt15_Fnv_hash_bytesPKv*;
-
} GLIBCXX_3.4.14;
# Symbols in the support library (libsupc++) have their own tag.
_ZTIPDn;
_ZTIPKDn;
+ # Default function.
+ _ZSt11_Hash_bytesPKv*;
+
+ # FNV hash.
+ _ZSt15_Fnv_hash_bytesPKv*;
+
} CXXABI_1.3.4;
function_type_info.cc \
fundamental_type_info.cc \
guard.cc \
+ hash_bytes.cc \
new_handler.cc \
new_op.cc \
new_opnt.cc \
eh_globals.lo eh_personality.lo eh_ptr.lo eh_term_handler.lo \
eh_terminate.lo eh_throw.lo eh_type.lo eh_unex_handler.lo \
enum_type_info.lo function_type_info.lo \
- fundamental_type_info.lo guard.lo new_handler.lo new_op.lo \
- new_opnt.lo new_opv.lo new_opvnt.lo pbase_type_info.lo \
- pmem_type_info.lo pointer_type_info.lo pure.lo \
- si_class_type_info.lo tinfo.lo tinfo2.lo vec.lo \
+ fundamental_type_info.lo guard.lo hash_bytes.lo new_handler.lo \
+ new_op.lo new_opnt.lo new_opv.lo new_opvnt.lo \
+ pbase_type_info.lo pmem_type_info.lo pointer_type_info.lo \
+ pure.lo si_class_type_info.lo tinfo.lo tinfo2.lo vec.lo \
vmi_class_type_info.lo vterminate.lo
@GLIBCXX_HOSTED_TRUE@am__objects_2 = cp-demangle.lo
am_libsupc___la_OBJECTS = $(am__objects_1) $(am__objects_2)
function_type_info.cc \
fundamental_type_info.cc \
guard.cc \
+ hash_bytes.cc \
new_handler.cc \
new_op.cc \
new_opnt.cc \
// function apears to be better in both speed and hash quality, and
// FNV is provided primarily for backward compatibility.
-#include <cstring>
-#include <bits/functional_hash.h>
+#include <bits/c++config.h>
namespace
{
unaligned_load(const char* p)
{
std::size_t result;
- std::memcpy(&result, p, sizeof(result));
+ __builtin_memcpy(&result, p, sizeof(result));
return result;
}
inline std::size_t
load_bytes(const char* p, int n)
{
- size_t result = 0;
+ std::size_t result = 0;
--n;
do
result = (result << 8) + static_cast<unsigned char>(p[n]);
namespace std
{
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ size_t
+ _Hash_bytes(const void* __ptr, size_t __len, size_t __seed);
+#endif
+
/**
* @brief Part of RTTI.
*
bool operator!=(const type_info& __arg) const
{ return !operator==(__arg); }
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ size_t hash_code() const throw()
+ {
+# if !__GXX_MERGED_TYPEINFO_NAMES
+ return _Hash_bytes(name(), __builtin_strlen(name()),
+ static_cast<size_t>(0xc70f6907UL));
+# else
+ return reinterpret_cast<size_t>(__name);
+# endif
+ }
+#endif // __GXX_EXPERIMENTAL_CXX0X__
+
// Return true if this is a pointer type of some kind
virtual bool __is_pointer_p() const;
hash_tr1.cc \
hashtable_c++0x.cc \
hashtable_tr1.cc \
- hash_bytes.cc \
ios.cc \
ios_failure.cc \
ios_init.cc \
hashtable_c++0x.o: hashtable_c++0x.cc
$(CXXCOMPILE) -std=gnu++0x -c $<
-hash_bytes.lo: hash_bytes.cc
- $(LTCXXCOMPILE) -std=gnu++0x -c $<
-hash_bytes.o: hash_bytes.cc
- $(CXXCOMPILE) -std=gnu++0x -c $<
-
limits.lo: limits.cc
$(LTCXXCOMPILE) -std=gnu++0x -c $<
limits.o: limits.cc
compatibility-c++0x.lo compatibility-debug_list.lo \
compatibility-list.lo complex_io.lo ctype.lo debug.lo \
functexcept.lo globals_io.lo hash_c++0x.lo hash_tr1.lo \
- hashtable_c++0x.lo hashtable_tr1.lo hash_bytes.lo ios.lo \
- ios_failure.lo ios_init.lo ios_locale.lo limits.lo list.lo \
- debug_list.lo locale.lo locale_init.lo locale_facets.lo \
- localename.lo math_stubs_float.lo math_stubs_long_double.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 mutex.lo condition_variable.lo \
- chrono.lo thread.lo future.lo $(am__objects_1) \
- $(am__objects_4)
+ hashtable_c++0x.lo hashtable_tr1.lo ios.lo ios_failure.lo \
+ ios_init.lo ios_locale.lo limits.lo list.lo debug_list.lo \
+ locale.lo locale_init.lo locale_facets.lo localename.lo \
+ math_stubs_float.lo math_stubs_long_double.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 mutex.lo condition_variable.lo chrono.lo \
+ thread.lo future.lo $(am__objects_1) $(am__objects_4)
am_libstdc___la_OBJECTS = $(am__objects_5)
libstdc___la_OBJECTS = $(am_libstdc___la_OBJECTS)
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
hash_tr1.cc \
hashtable_c++0x.cc \
hashtable_tr1.cc \
- hash_bytes.cc \
ios.cc \
ios_failure.cc \
ios_init.cc \
hashtable_c++0x.o: hashtable_c++0x.cc
$(CXXCOMPILE) -std=gnu++0x -c $<
-hash_bytes.lo: hash_bytes.cc
- $(LTCXXCOMPILE) -std=gnu++0x -c $<
-hash_bytes.o: hash_bytes.cc
- $(CXXCOMPILE) -std=gnu++0x -c $<
-
limits.lo: limits.cc
$(LTCXXCOMPILE) -std=gnu++0x -c $<
limits.o: limits.cc
--- /dev/null
+// { dg-options "-std=gnu++0x" }
+
+// 2010-09-21 Paolo Carlini <paolo.carlini@oracle.com>
+//
+// Copyright (C) 2010 Free Software Foundation
+//
+// 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.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <typeinfo>
+#include <testsuite_hooks.h>
+
+class Abraca { };
+Abraca a1, a2_;
+const Abraca a2 = a2_;
+
+class Dabra { };
+Dabra d1;
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ VERIFY( typeid(int) != typeid(double) );
+ VERIFY( typeid(int).hash_code() != typeid(double).hash_code() );
+
+ VERIFY( typeid(a1) == typeid(a2) );
+ VERIFY( typeid(a1).hash_code() == typeid(a2).hash_code() );
+
+ VERIFY( typeid(Abraca) == typeid(const Abraca) );
+ VERIFY( typeid(Abraca).hash_code() == typeid(const Abraca).hash_code() );
+
+ VERIFY( typeid(Abraca) == typeid(a2) );
+ VERIFY( typeid(Abraca).hash_code() == typeid(a2).hash_code() );
+
+ VERIFY( typeid(Abraca) == typeid(const Abraca&) );
+ VERIFY( typeid(Abraca).hash_code() == typeid(const Abraca&).hash_code() );
+
+ VERIFY( typeid(Abraca) != typeid(Dabra) );
+ VERIFY( typeid(Abraca).hash_code() != typeid(Dabra).hash_code() );
+
+ VERIFY( typeid(a1) != typeid(d1) );
+ VERIFY( typeid(a1).hash_code() != typeid(d1).hash_code() );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}