summaryrefslogtreecommitdiffstats
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2010-09-22 08:19:08 +0000
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2010-09-22 08:19:08 +0000
commit53d917a236f121cd3dc5d40b1eb5f196ddd977f1 (patch)
tree60040e6744c2b03019bf7e0a7363f0884f8b609a /libstdc++-v3
parentb5bc6d031eb34a837556a703b34649777f47ed27 (diff)
downloadppe42-gcc-53d917a236f121cd3dc5d40b1eb5f196ddd977f1.tar.gz
ppe42-gcc-53d917a236f121cd3dc5d40b1eb5f196ddd977f1.zip
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@164510 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/ChangeLog12
-rw-r--r--libstdc++-v3/config/abi/pre/gnu.ver12
-rw-r--r--libstdc++-v3/libsupc++/Makefile.am1
-rw-r--r--libstdc++-v3/libsupc++/Makefile.in9
-rw-r--r--libstdc++-v3/libsupc++/hash_bytes.cc (renamed from libstdc++-v3/src/hash_bytes.cc)7
-rw-r--r--libstdc++-v3/libsupc++/typeinfo17
-rw-r--r--libstdc++-v3/src/Makefile.am6
-rw-r--r--libstdc++-v3/src/Makefile.in29
-rw-r--r--libstdc++-v3/testsuite/18_support/type_info/hash_code.cc62
9 files changed, 117 insertions, 38 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 4e96eab2e31..bc75ce7f5a6 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,15 @@
+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
diff --git a/libstdc++-v3/config/abi/pre/gnu.ver b/libstdc++-v3/config/abi/pre/gnu.ver
index aff2593425e..435f8579827 100644
--- a/libstdc++-v3/config/abi/pre/gnu.ver
+++ b/libstdc++-v3/config/abi/pre/gnu.ver
@@ -1178,12 +1178,6 @@ GLIBCXX_3.4.15 {
_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.
@@ -1356,4 +1350,10 @@ CXXABI_1.3.5 {
_ZTIPDn;
_ZTIPKDn;
+ # Default function.
+ _ZSt11_Hash_bytesPKv*;
+
+ # FNV hash.
+ _ZSt15_Fnv_hash_bytesPKv*;
+
} CXXABI_1.3.4;
diff --git a/libstdc++-v3/libsupc++/Makefile.am b/libstdc++-v3/libsupc++/Makefile.am
index 0b2fd0bc786..5fbad83049a 100644
--- a/libstdc++-v3/libsupc++/Makefile.am
+++ b/libstdc++-v3/libsupc++/Makefile.am
@@ -69,6 +69,7 @@ sources = \
function_type_info.cc \
fundamental_type_info.cc \
guard.cc \
+ hash_bytes.cc \
new_handler.cc \
new_op.cc \
new_opnt.cc \
diff --git a/libstdc++-v3/libsupc++/Makefile.in b/libstdc++-v3/libsupc++/Makefile.in
index 7c00b672608..394bd42afe0 100644
--- a/libstdc++-v3/libsupc++/Makefile.in
+++ b/libstdc++-v3/libsupc++/Makefile.in
@@ -95,10 +95,10 @@ am__objects_1 = array_type_info.lo atexit_arm.lo bad_cast.lo \
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)
@@ -364,6 +364,7 @@ sources = \
function_type_info.cc \
fundamental_type_info.cc \
guard.cc \
+ hash_bytes.cc \
new_handler.cc \
new_op.cc \
new_opnt.cc \
diff --git a/libstdc++-v3/src/hash_bytes.cc b/libstdc++-v3/libsupc++/hash_bytes.cc
index d14ad41a9fd..e9a3812664e 100644
--- a/libstdc++-v3/src/hash_bytes.cc
+++ b/libstdc++-v3/libsupc++/hash_bytes.cc
@@ -32,8 +32,7 @@
// 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
{
@@ -41,7 +40,7 @@ namespace
unaligned_load(const char* p)
{
std::size_t result;
- std::memcpy(&result, p, sizeof(result));
+ __builtin_memcpy(&result, p, sizeof(result));
return result;
}
@@ -50,7 +49,7 @@ namespace
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]);
diff --git a/libstdc++-v3/libsupc++/typeinfo b/libstdc++-v3/libsupc++/typeinfo
index 1a4736e1cba..8030eb40e2f 100644
--- a/libstdc++-v3/libsupc++/typeinfo
+++ b/libstdc++-v3/libsupc++/typeinfo
@@ -78,6 +78,11 @@ namespace __cxxabiv1
namespace std
{
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ size_t
+ _Hash_bytes(const void* __ptr, size_t __len, size_t __seed);
+#endif
+
/**
* @brief Part of RTTI.
*
@@ -135,6 +140,18 @@ namespace std
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;
diff --git a/libstdc++-v3/src/Makefile.am b/libstdc++-v3/src/Makefile.am
index bd748aadb6e..d4efaf2e530 100644
--- a/libstdc++-v3/src/Makefile.am
+++ b/libstdc++-v3/src/Makefile.am
@@ -179,7 +179,6 @@ sources = \
hash_tr1.cc \
hashtable_c++0x.cc \
hashtable_tr1.cc \
- hash_bytes.cc \
ios.cc \
ios_failure.cc \
ios_init.cc \
@@ -310,11 +309,6 @@ hashtable_c++0x.lo: hashtable_c++0x.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
diff --git a/libstdc++-v3/src/Makefile.in b/libstdc++-v3/src/Makefile.in
index ee1c9935c76..647124e4674 100644
--- a/libstdc++-v3/src/Makefile.in
+++ b/libstdc++-v3/src/Makefile.in
@@ -100,18 +100,17 @@ am__objects_5 = atomic.lo bitmap_allocator.lo pool_allocator.lo \
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)
@@ -384,7 +383,6 @@ sources = \
hash_tr1.cc \
hashtable_c++0x.cc \
hashtable_tr1.cc \
- hash_bytes.cc \
ios.cc \
ios_failure.cc \
ios_init.cc \
@@ -887,11 +885,6 @@ hashtable_c++0x.lo: hashtable_c++0x.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
diff --git a/libstdc++-v3/testsuite/18_support/type_info/hash_code.cc b/libstdc++-v3/testsuite/18_support/type_info/hash_code.cc
new file mode 100644
index 00000000000..066736c4ecf
--- /dev/null
+++ b/libstdc++-v3/testsuite/18_support/type_info/hash_code.cc
@@ -0,0 +1,62 @@
+// { 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;
+}
OpenPOWER on IntegriCloud