Update chromium code to newer versions (rev 23304) to avoid tr1/function which doesn't compile without RTTI on, and disable RTTI by default.
authorBenjamin Smedberg <benjamin@smedbergs.us>
Wed, 04 Nov 2009 15:46:27 -0500
changeset 36043 80dcc6b5f564856406f07fa862ce3cabab45a552
parent 36042 3b48ad476217f0cd44d0cbfd5158e0adb5c114e8
child 36044 7f8abab790b490f3f89f22f4f9f2ece3897d4298
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs23304
milestone1.9.3a1pre
Update chromium code to newer versions (rev 23304) to avoid tr1/function which doesn't compile without RTTI on, and disable RTTI by default.
configure.in
ipc/chromium/src/base/file_path.h
ipc/chromium/src/base/hash_tables.h
--- a/configure.in
+++ b/configure.in
@@ -7153,19 +7153,16 @@ if test "$ac_nscap_nonconst_opeq_bug" = 
     AC_DEFINE(NSCAP_DONT_PROVIDE_NONCONST_OPEQ)
 fi
 fi # SKIP_COMPILER_CHECKS
 
 dnl ========================================================
 dnl C++ rtti
 dnl Should be smarter and check that the compiler does indeed have rtti
 dnl ========================================================
-if test -n "$GNU_CC"; then
-    _MOZ_USE_RTTI=1
-fi
 
 MOZ_ARG_ENABLE_BOOL(cpp-rtti,
 [  --enable-cpp-rtti       Enable C++ RTTI ],
 [ _MOZ_USE_RTTI=1 ],
 [ _MOZ_USE_RTTI= ])
 
 if test "$_MOZ_USE_RTTI"; then
    _MOZ_RTTI_FLAGS=$_MOZ_RTTI_FLAGS_ON
--- a/ipc/chromium/src/base/file_path.h
+++ b/ipc/chromium/src/base/file_path.h
@@ -245,17 +245,17 @@ class FilePath {
 
 // Implement hash function so that we can use FilePaths in hashsets and maps.
 #if defined(COMPILER_GCC)
 namespace __gnu_cxx {
 
 template<>
 struct hash<FilePath> {
   size_t operator()(const FilePath& f) const {
-    return std::tr1::hash<FilePath::StringType>()(f.value());
+    return hash<FilePath::StringType>()(f.value());
   }
 };
 
 }  // namespace __gnu_cxx
 #elif defined(COMPILER_MSVC)
 namespace stdext {
 
 inline size_t hash_value(const FilePath& f) {
--- a/ipc/chromium/src/base/hash_tables.h
+++ b/ipc/chromium/src/base/hash_tables.h
@@ -7,21 +7,23 @@
 // Deal with the differences between Microsoft and GNU implemenations
 // of hash_map. Allows all platforms to use |base::hash_map| and
 // |base::hash_set|.
 //  eg:
 //   base::hash_map<int> my_map;
 //   base::hash_set<int> my_set;
 //
 
-#ifndef BASE_HASH_TABLES_H__
-#define BASE_HASH_TABLES_H__
+#ifndef BASE_HASH_TABLES_H_
+#define BASE_HASH_TABLES_H_
 
 #include "build/build_config.h"
 
+#include "base/string16.h"
+
 #if defined(COMPILER_MSVC)
 #include <hash_map>
 #include <hash_set>
 namespace base {
 using stdext::hash_map;
 using stdext::hash_set;
 }
 #elif defined(COMPILER_GCC)
@@ -30,78 +32,73 @@ using stdext::hash_set;
 // can use <tr1/unordered_map> and <tr1/unordered_set>.
 #ifdef __DEPRECATED
 #define CHROME_OLD__DEPRECATED __DEPRECATED
 #undef __DEPRECATED
 #endif
 
 #include <ext/hash_map>
 #include <ext/hash_set>
+#include <string>
 
 #ifdef CHROME_OLD__DEPRECATED
 #define __DEPRECATED CHROME_OLD__DEPRECATED
 #undef CHROME_OLD__DEPRECATED
 #endif
 
-#include <tr1/functional>
 namespace base {
 using __gnu_cxx::hash_map;
 using __gnu_cxx::hash_set;
-}
+}  // namespace base
 
-// Implement string hash functions so that strings of various flavors can
-// be used as keys in STL maps and sets.
 namespace __gnu_cxx {
 
-template<>
-struct hash<wchar_t*> {
-  size_t operator()(const wchar_t* s) const {
-    return std::tr1::hash<const wchar_t*>()(s);
-  }
-};
+// The GNU C++ library provides identiy hash functions for many integral types,
+// but not for |long long|.  This hash function will truncate if |size_t| is
+// narrower than |long long|.  This is probably good enough for what we will
+// use it for.
 
-template<>
-struct hash<const wchar_t*> {
-  size_t operator()(const wchar_t* s) const {
-    return std::tr1::hash<const wchar_t*>()(s);
-  }
-};
+#define DEFINE_TRIVIAL_HASH(integral_type) \
+    template<> \
+    struct hash<integral_type> { \
+      std::size_t operator()(integral_type value) const { \
+        return static_cast<std::size_t>(value); \
+      } \
+    }
 
-template<>
-struct hash<std::wstring> {
-  size_t operator()(const std::wstring& s) const {
-    return std::tr1::hash<std::wstring>()(s);
-  }
-};
+DEFINE_TRIVIAL_HASH(long long);
+DEFINE_TRIVIAL_HASH(unsigned long long);
+
+#undef DEFINE_TRIVIAL_HASH
+
+// Implement string hash functions so that strings of various flavors can
+// be used as keys in STL maps and sets.  The hash algorithm comes from the
+// GNU C++ library, in <tr1/functional>.  It is duplicated here because GCC
+// versions prior to 4.3.2 are unable to compile <tr1/functional> when RTTI
+// is disabled, as it is in our build.
 
-template<>
-struct hash<const std::wstring> {
-  size_t operator()(const std::wstring& s) const {
-    return std::tr1::hash<std::wstring>()(s);
-  }
-};
+#define DEFINE_STRING_HASH(string_type) \
+    template<> \
+    struct hash<string_type> { \
+      std::size_t operator()(const string_type& s) const { \
+        std::size_t result = 0; \
+        for (string_type::const_iterator i = s.begin(); i != s.end(); ++i) \
+          result = (result * 131) + *i; \
+        return result; \
+      } \
+    }
 
-template<>
-struct hash<std::string> {
-  size_t operator()(const std::string& s) const {
-    return std::tr1::hash<std::string>()(s);
-  }
-};
+DEFINE_STRING_HASH(std::string);
+DEFINE_STRING_HASH(std::wstring);
 
-template<>
-struct hash<const std::string> {
-  size_t operator()(const std::string& s) const {
-    return std::tr1::hash<std::string>()(s);
-  }
-};
+#if defined(WCHAR_T_IS_UTF32)
+// If string16 and std::wstring are not the same type, provide a
+// specialization for string16.
+DEFINE_STRING_HASH(string16);
+#endif  // WCHAR_T_IS_UTF32
 
-template<>
-struct hash<long long> {
-  size_t operator()(long long i) const {
-    return std::tr1::hash<long>()((long) i);
-  }
-};
+#undef DEFINE_STRING_HASH
+
+}  // namespace __gnu_cxx
 
-}
+#endif  // COMPILER
 
-#endif
-
-#endif  // BASE_HASH_TABLES_H__
+#endif  // BASE_HASH_TABLES_H_