diff options
-rw-r--r-- | BUILD | 1 | ||||
-rw-r--r-- | cmake/extract_includes.bat.in | 1 | ||||
-rw-r--r-- | src/google/protobuf/stubs/port.h | 16 | ||||
-rw-r--r-- | src/google/protobuf/wire_format_lite.h | 4 |
4 files changed, 16 insertions, 6 deletions
@@ -72,6 +72,7 @@ cc_library( "src/google/protobuf/extension_set.cc", "src/google/protobuf/generated_message_table_driven_lite.cc", "src/google/protobuf/generated_message_util.cc", + "src/google/protobuf/implicit_weak_message.cc", "src/google/protobuf/io/coded_stream.cc", "src/google/protobuf/io/zero_copy_stream.cc", "src/google/protobuf/io/zero_copy_stream_impl_lite.cc", diff --git a/cmake/extract_includes.bat.in b/cmake/extract_includes.bat.in index 5212d00a..5178f5b2 100644 --- a/cmake/extract_includes.bat.in +++ b/cmake/extract_includes.bat.in @@ -53,6 +53,7 @@ copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_message_ref copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_message_table_driven.h" include\google\protobuf\generated_message_table_driven.h copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_message_util.h" include\google\protobuf\generated_message_util.h copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\has_bits.h" include\google\protobuf\has_bits.h +copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\implicit_weak_message.h" include\google\protobuf\implicit_weak_message.h copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\coded_stream.h" include\google\protobuf\io\coded_stream.h copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\gzip_stream.h" include\google\protobuf\io\gzip_stream.h copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\printer.h" include\google\protobuf\io\printer.h 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); diff --git a/src/google/protobuf/wire_format_lite.h b/src/google/protobuf/wire_format_lite.h index 265f5f93..76275518 100644 --- a/src/google/protobuf/wire_format_lite.h +++ b/src/google/protobuf/wire_format_lite.h @@ -860,7 +860,7 @@ inline uint32 WireFormatLite::ZigZagEncode32(int32 n) { inline int32 WireFormatLite::ZigZagDecode32(uint32 n) { // Note: Using unsigned types prevent undefined behavior - return static_cast<int32>((n >> 1) ^ -(n & 1)); + return static_cast<int32>((n >> 1) ^ (~(n & 1) + 1)); } inline uint64 WireFormatLite::ZigZagEncode64(int64 n) { @@ -871,7 +871,7 @@ inline uint64 WireFormatLite::ZigZagEncode64(int64 n) { inline int64 WireFormatLite::ZigZagDecode64(uint64 n) { // Note: Using unsigned types prevent undefined behavior - return static_cast<int64>((n >> 1) ^ -(n & 1)); + return static_cast<int64>((n >> 1) ^ (~(n & 1) + 1)); } // String is for UTF-8 text only, but, even so, ReadString() can simply |