aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/stubs/hash.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/google/protobuf/stubs/hash.h')
-rw-r--r--src/google/protobuf/stubs/hash.h10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/google/protobuf/stubs/hash.h b/src/google/protobuf/stubs/hash.h
index be998b29..612b5861 100644
--- a/src/google/protobuf/stubs/hash.h
+++ b/src/google/protobuf/stubs/hash.h
@@ -40,10 +40,9 @@
#define GOOGLE_PROTOBUF_HAVE_HASH_MAP 1
#define GOOGLE_PROTOBUF_HAVE_HASH_SET 1
-#define GOOGLE_PROTOBUF_HAVE_64BIT_HASH 1
// Use C++11 unordered_{map|set} if available.
-#if ((_LIBCPP_STD_VER >= 11) || \
+#if ((defined(_LIBCPP_STD_VER) && _LIBCPP_STD_VER >= 11) || \
(((__cplusplus >= 201103L) || defined(__GXX_EXPERIMENTAL_CXX0X)) && \
(__GLIBCXX__ > 20090421)))
# define GOOGLE_PROTOBUF_HAS_CXX11_HASH
@@ -93,8 +92,11 @@
# define GOOGLE_PROTOBUF_HASH_SET_CLASS hash_set
# endif
+// GCC <= 4.1 does not define std::tr1::hash for `long long int` or `long long unsigned int`
# if __GNUC__ == 4 && __GNUC__MINOR__ <= 1
-# undef GOOGLE_PROTOBUF_HAVE_64BIT_HASH
+# define GOOGLE_PROTOBUF_MISSING_HASH
+# include <map>
+# include <set>
# endif
// Version checks for MSC.
@@ -348,7 +350,7 @@ struct hash<const char*> {
inline size_t operator()(const char* str) const {
size_t result = 0;
for (; *str != '\0'; str++) {
- result = 5 * result + *str;
+ result = 5 * result + static_cast<size_t>(*str);
}
return result;
}