aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/stubs
diff options
context:
space:
mode:
authorGravatar Adam Cozzette <acozzette@google.com>2017-12-07 14:31:54 -0800
committerGravatar Adam Cozzette <acozzette@google.com>2017-12-07 14:35:40 -0800
commit63a0afca7093d9c4e63dd27cb4dc1f1974d328a0 (patch)
tree036eb2ded83ecbe168f9563ac53e948d04a40336 /src/google/protobuf/stubs
parent9021f623e1420f513268a01a5ad43a23618a84ba (diff)
Use the portable version of Log2Floor for Clang with older Android NDK versions
This is necessary for avoiding a strange compiler error that we have already run into with older versions of Clang on NaCl.
Diffstat (limited to 'src/google/protobuf/stubs')
-rw-r--r--src/google/protobuf/stubs/port.h16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/google/protobuf/stubs/port.h b/src/google/protobuf/stubs/port.h
index cecefdcb..30bd7b1d 100644
--- a/src/google/protobuf/stubs/port.h
+++ b/src/google/protobuf/stubs/port.h
@@ -348,6 +348,13 @@ inline void GOOGLE_UNALIGNED_STORE64(void *p, uint64 v) {
}
#endif
+#if defined(GOOGLE_PROTOBUF_OS_NACL) \
+ || (defined(__ANDROID__) && defined(__clang__) \
+ && (__clang_major__ == 3 && __clang_minor__ == 8) \
+ && (__clang_patchlevel__ < 275480))
+# define GOOGLE_PROTOBUF_USE_PORTABLE_LOG2
+#endif
+
#if defined(_MSC_VER)
#define GOOGLE_THREAD_LOCAL __declspec(thread)
#else
@@ -413,12 +420,13 @@ class Bits {
}
static uint32 Log2FloorNonZero64(uint64 n) {
- // arm-nacl-clang runs into an instruction-selection failure when it
- // encounters __builtin_clzll:
+ // Older versions of clang run into an instruction-selection failure when
+ // it encounters __builtin_clzll:
// https://bugs.chromium.org/p/nativeclient/issues/detail?id=4395
- // To work around this, when we build for NaCl we use the portable
+ // This includes arm-nacl-clang and clang in older Android NDK versions.
+ // To work around this, when we build with those we use the portable
// implementation instead.
-#if defined(__GNUC__) && !defined(GOOGLE_PROTOBUF_OS_NACL)
+#if defined(__GNUC__) && !defined(GOOGLE_PROTOBUF_USE_PORTABLE_LOG2)
return 63 ^ static_cast<uint32>(__builtin_clzll(n));
#else
return Log2FloorNonZero64_Portable(n);