]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
hash_bytes.cc: Move...
authorPaolo Carlini <paolo.carlini@oracle.com>
Wed, 22 Sep 2010 08:19:08 +0000 (08:19 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Wed, 22 Sep 2010 08:19:08 +0000 (08:19 +0000)
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.

From-SVN: r164510

libstdc++-v3/ChangeLog
libstdc++-v3/config/abi/pre/gnu.ver
libstdc++-v3/libsupc++/Makefile.am
libstdc++-v3/libsupc++/Makefile.in
libstdc++-v3/libsupc++/hash_bytes.cc [moved from libstdc++-v3/src/hash_bytes.cc with 97% similarity]
libstdc++-v3/libsupc++/typeinfo
libstdc++-v3/src/Makefile.am
libstdc++-v3/src/Makefile.in
libstdc++-v3/testsuite/18_support/type_info/hash_code.cc [new file with mode: 0644]

index 4e96eab2e319049cded4c7caf40e352f5f3e0b23..bc75ce7f5a647848140aec530eb4d1c0bc982e0f 100644 (file)
@@ -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
index aff2593425e584c0392e6472837f880f873d8e9c..435f8579827ded11c1b6a3232bfa46410a55d8e8 100644 (file)
@@ -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;
index 0b2fd0bc78629f54d8e493fda34cf2240beba47d..5fbad83049a7a78c1fb1cc103f0f1019da22ae81 100644 (file)
@@ -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 \
index 7c00b672608dd866b2b5f4b7fd97a78addba0d79..394bd42afe0bada0953a199bb1081fef1baab16b 100644 (file)
@@ -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 \
similarity index 97%
rename from libstdc++-v3/src/hash_bytes.cc
rename to libstdc++-v3/libsupc++/hash_bytes.cc
index d14ad41a9fd96c2ee55f1cd0f282b2c6753305ee..e9a3812664e890aaafdf14a5737bdcb542f9bec3 100644 (file)
@@ -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]);
index 1a4736e1cbaa39b803b41b6e34e960d653241a39..8030eb40e2f0ef98c7be6e85bbcb649867b2e83c 100644 (file)
@@ -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;
 
index bd748aadb6e66cb3f3572b86f1ccfb69ff4cff27..d4efaf2e530fbbedc6511eaae9dcaed61c9471b7 100644 (file)
@@ -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
index ee1c9935c76e2b412901e461c62480faa7b0050e..647124e4674ede2d4d7aac91aaff0c835c62d2d1 100644 (file)
@@ -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 (file)
index 0000000..066736c
--- /dev/null
@@ -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;
+}