Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(641)

Side by Side Diff: base/containers/hash_tables.h

Issue 951983002: Reland "Enable libc++ on Android" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix clang+mesa Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/android/jni_array.cc ('k') | base/strings/string_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // 4 //
5 5
6 // 6 //
7 // Deal with the differences between Microsoft and GNU implemenations 7 // Deal with the differences between Microsoft and GNU implemenations
8 // of hash_map. Allows all platforms to use |base::hash_map| and 8 // of hash_map. Allows all platforms to use |base::hash_map| and
9 // |base::hash_set|. 9 // |base::hash_set|.
10 // eg: 10 // eg:
(...skipping 27 matching lines...) Expand all
38 #define BASE_HASH_NAMESPACE base_hash 38 #define BASE_HASH_NAMESPACE base_hash
39 39
40 // This is a hack to disable the gcc 4.4 warning about hash_map and hash_set 40 // This is a hack to disable the gcc 4.4 warning about hash_map and hash_set
41 // being deprecated. We can get rid of this when we upgrade to VS2008 and we 41 // being deprecated. We can get rid of this when we upgrade to VS2008 and we
42 // can use <tr1/unordered_map> and <tr1/unordered_set>. 42 // can use <tr1/unordered_map> and <tr1/unordered_set>.
43 #ifdef __DEPRECATED 43 #ifdef __DEPRECATED
44 #define CHROME_OLD__DEPRECATED __DEPRECATED 44 #define CHROME_OLD__DEPRECATED __DEPRECATED
45 #undef __DEPRECATED 45 #undef __DEPRECATED
46 #endif 46 #endif
47 47
48 #if defined(OS_ANDROID)
49 #include <hash_map>
50 #include <hash_set>
51 #define BASE_HASH_IMPL_NAMESPACE std
52 #else
53 #include <ext/hash_map> 48 #include <ext/hash_map>
54 #include <ext/hash_set> 49 #include <ext/hash_set>
55 #define BASE_HASH_IMPL_NAMESPACE __gnu_cxx 50 #define BASE_HASH_IMPL_NAMESPACE __gnu_cxx
56 #endif
57 51
58 #include <string> 52 #include <string>
59 53
60 #ifdef CHROME_OLD__DEPRECATED 54 #ifdef CHROME_OLD__DEPRECATED
61 #define __DEPRECATED CHROME_OLD__DEPRECATED 55 #define __DEPRECATED CHROME_OLD__DEPRECATED
62 #undef CHROME_OLD__DEPRECATED 56 #undef CHROME_OLD__DEPRECATED
63 #endif 57 #endif
64 58
65 namespace BASE_HASH_NAMESPACE { 59 namespace BASE_HASH_NAMESPACE {
66 60
(...skipping 10 matching lines...) Expand all
77 }; 71 };
78 72
79 template<typename T> 73 template<typename T>
80 struct hash<T*> { 74 struct hash<T*> {
81 std::size_t operator()(T* value) const { 75 std::size_t operator()(T* value) const {
82 return BASE_HASH_IMPL_NAMESPACE::hash<uintptr_t>()( 76 return BASE_HASH_IMPL_NAMESPACE::hash<uintptr_t>()(
83 reinterpret_cast<uintptr_t>(value)); 77 reinterpret_cast<uintptr_t>(value));
84 } 78 }
85 }; 79 };
86 80
87 #if !defined(OS_ANDROID)
88 // The GNU C++ library provides identity hash functions for many integral types, 81 // The GNU C++ library provides identity hash functions for many integral types,
89 // but not for |long long|. This hash function will truncate if |size_t| is 82 // but not for |long long|. This hash function will truncate if |size_t| is
90 // narrower than |long long|. This is probably good enough for what we will 83 // narrower than |long long|. This is probably good enough for what we will
91 // use it for. 84 // use it for.
92 85
93 #define DEFINE_TRIVIAL_HASH(integral_type) \ 86 #define DEFINE_TRIVIAL_HASH(integral_type) \
94 template<> \ 87 template<> \
95 struct hash<integral_type> { \ 88 struct hash<integral_type> { \
96 std::size_t operator()(integral_type value) const { \ 89 std::size_t operator()(integral_type value) const { \
97 return static_cast<std::size_t>(value); \ 90 return static_cast<std::size_t>(value); \
98 } \ 91 } \
99 } 92 }
100 93
101 DEFINE_TRIVIAL_HASH(long long); 94 DEFINE_TRIVIAL_HASH(long long);
102 DEFINE_TRIVIAL_HASH(unsigned long long); 95 DEFINE_TRIVIAL_HASH(unsigned long long);
103 96
104 #undef DEFINE_TRIVIAL_HASH 97 #undef DEFINE_TRIVIAL_HASH
105 #endif // !defined(OS_ANDROID)
106 98
107 // Implement string hash functions so that strings of various flavors can 99 // Implement string hash functions so that strings of various flavors can
108 // be used as keys in STL maps and sets. The hash algorithm comes from the 100 // be used as keys in STL maps and sets. The hash algorithm comes from the
109 // GNU C++ library, in <tr1/functional>. It is duplicated here because GCC 101 // GNU C++ library, in <tr1/functional>. It is duplicated here because GCC
110 // versions prior to 4.3.2 are unable to compile <tr1/functional> when RTTI 102 // versions prior to 4.3.2 are unable to compile <tr1/functional> when RTTI
111 // is disabled, as it is in our build. 103 // is disabled, as it is in our build.
112 104
113 #define DEFINE_STRING_HASH(string_type) \ 105 #define DEFINE_STRING_HASH(string_type) \
114 template<> \ 106 template<> \
115 struct hash<string_type> { \ 107 struct hash<string_type> { \
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 return base::HashPair(value.first, value.second); 311 return base::HashPair(value.first, value.second);
320 } 312 }
321 }; 313 };
322 314
323 } // namespace BASE_HASH_NAMESPACE 315 } // namespace BASE_HASH_NAMESPACE
324 316
325 #undef DEFINE_PAIR_HASH_FUNCTION_START 317 #undef DEFINE_PAIR_HASH_FUNCTION_START
326 #undef DEFINE_PAIR_HASH_FUNCTION_END 318 #undef DEFINE_PAIR_HASH_FUNCTION_END
327 319
328 #endif // BASE_CONTAINERS_HASH_TABLES_H_ 320 #endif // BASE_CONTAINERS_HASH_TABLES_H_
OLDNEW
« no previous file with comments | « base/android/jni_array.cc ('k') | base/strings/string_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698