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

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

Issue 835633003: Enable libc++ on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase to friending fixes Created 5 years, 10 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
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) 48 #if defined(OS_ANDROID) && defined(USE_STLPORT)
49 #include <hash_map> 49 #include <hash_map>
50 #include <hash_set> 50 #include <hash_set>
51 #define BASE_HASH_IMPL_NAMESPACE std 51 #define BASE_HASH_IMPL_NAMESPACE std
52 #else 52 #else
53 #include <ext/hash_map> 53 #include <ext/hash_map>
54 #include <ext/hash_set> 54 #include <ext/hash_set>
55 #define BASE_HASH_IMPL_NAMESPACE __gnu_cxx 55 #define BASE_HASH_IMPL_NAMESPACE __gnu_cxx
56 #endif 56 #endif
57 57
58 #include <string> 58 #include <string>
(...skipping 18 matching lines...) Expand all
77 }; 77 };
78 78
79 template<typename T> 79 template<typename T>
80 struct hash<T*> { 80 struct hash<T*> {
81 std::size_t operator()(T* value) const { 81 std::size_t operator()(T* value) const {
82 return BASE_HASH_IMPL_NAMESPACE::hash<uintptr_t>()( 82 return BASE_HASH_IMPL_NAMESPACE::hash<uintptr_t>()(
83 reinterpret_cast<uintptr_t>(value)); 83 reinterpret_cast<uintptr_t>(value));
84 } 84 }
85 }; 85 };
86 86
87 #if !defined(OS_ANDROID)
Fabrice (no longer in Chrome) 2015/02/04 13:24:22 Doesn't that need to stay for aosp?
jdduke (slow) 2015/02/05 18:37:15 I actually don't know why this was removed, probab
88 // The GNU C++ library provides identity hash functions for many integral types, 87 // 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 88 // 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 89 // narrower than |long long|. This is probably good enough for what we will
91 // use it for. 90 // use it for.
92 91
93 #define DEFINE_TRIVIAL_HASH(integral_type) \ 92 #define DEFINE_TRIVIAL_HASH(integral_type) \
94 template<> \ 93 template<> \
95 struct hash<integral_type> { \ 94 struct hash<integral_type> { \
96 std::size_t operator()(integral_type value) const { \ 95 std::size_t operator()(integral_type value) const { \
97 return static_cast<std::size_t>(value); \ 96 return static_cast<std::size_t>(value); \
98 } \ 97 } \
99 } 98 }
100 99
101 DEFINE_TRIVIAL_HASH(long long); 100 DEFINE_TRIVIAL_HASH(long long);
102 DEFINE_TRIVIAL_HASH(unsigned long long); 101 DEFINE_TRIVIAL_HASH(unsigned long long);
103 102
104 #undef DEFINE_TRIVIAL_HASH 103 #undef DEFINE_TRIVIAL_HASH
105 #endif // !defined(OS_ANDROID)
106 104
107 // Implement string hash functions so that strings of various flavors can 105 // 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 106 // 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 107 // 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 108 // versions prior to 4.3.2 are unable to compile <tr1/functional> when RTTI
111 // is disabled, as it is in our build. 109 // is disabled, as it is in our build.
112 110
113 #define DEFINE_STRING_HASH(string_type) \ 111 #define DEFINE_STRING_HASH(string_type) \
114 template<> \ 112 template<> \
115 struct hash<string_type> { \ 113 struct hash<string_type> { \
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 return base::HashPair(value.first, value.second); 317 return base::HashPair(value.first, value.second);
320 } 318 }
321 }; 319 };
322 320
323 } 321 }
324 322
325 #undef DEFINE_PAIR_HASH_FUNCTION_START 323 #undef DEFINE_PAIR_HASH_FUNCTION_START
326 #undef DEFINE_PAIR_HASH_FUNCTION_END 324 #undef DEFINE_PAIR_HASH_FUNCTION_END
327 325
328 #endif // BASE_CONTAINERS_HASH_TABLES_H_ 326 #endif // BASE_CONTAINERS_HASH_TABLES_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698