From b2b5446af04b1ab2ee227aeeec2557692c993f10 Mon Sep 17 00:00:00 2001 From: Daniel Schopf Date: Fri, 21 May 2021 09:29:06 +0200 Subject: [PATCH 1/5] Fix compiler error due to mismatched braces (broken in f5fd897c1d) --- src/google/protobuf/stubs/port.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/google/protobuf/stubs/port.h b/src/google/protobuf/stubs/port.h index eec96faf387d..bead0af74306 100644 --- a/src/google/protobuf/stubs/port.h +++ b/src/google/protobuf/stubs/port.h @@ -263,14 +263,14 @@ static inline uint32 bswap_32(uint32 x) { #ifndef bswap_64 static inline uint64 bswap_64(uint64 x) { - return (((x & uint64_t{0xFFu)) << 56) | - ((x & uint64_t{0xFF00u)) << 40) | - ((x & uint64_t{0xFF0000u)) << 24) | - ((x & uint64_t{0xFF000000u)) << 8) | - ((x & uint64_t{0xFF00000000u)) >> 8) | - ((x & uint64_t{0xFF0000000000u)) >> 24) | - ((x & uint64_t{0xFF000000000000u)) >> 40) | - ((x & uint64_t{0xFF00000000000000u)) >> 56)); + return (((x & uint64_t{0xFFu}) << 56) | + ((x & uint64_t{0xFF00u}) << 40) | + ((x & uint64_t{0xFF0000u}) << 24) | + ((x & uint64_t{0xFF000000u}) << 8) | + ((x & uint64_t{0xFF00000000u}) >> 8) | + ((x & uint64_t{0xFF0000000000u}) >> 24) | + ((x & uint64_t{0xFF000000000000u}) >> 40) | + ((x & uint64_t{0xFF00000000000000u}) >> 56)); } #define bswap_64(x) bswap_64(x) #endif From bd9d47db414a8e55b48b955c99319490e903be44 Mon Sep 17 00:00:00 2001 From: Daniel Schopf Date: Fri, 21 May 2021 09:29:58 +0200 Subject: [PATCH 2/5] endian.h is not available on QNX --- src/google/protobuf/io/coded_stream.h | 2 ++ src/google/protobuf/stubs/port.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/google/protobuf/io/coded_stream.h b/src/google/protobuf/io/coded_stream.h index b6c11d27a217..1cf006832a7b 100644 --- a/src/google/protobuf/io/coded_stream.h +++ b/src/google/protobuf/io/coded_stream.h @@ -136,8 +136,10 @@ #elif defined(__FreeBSD__) #include // __BYTE_ORDER #else +#if !defined(__QNX__) #include // __BYTE_ORDER #endif +#endif #if ((defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__)) || \ (defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN)) && \ !defined(PROTOBUF_DISABLE_LITTLE_ENDIAN_OPT_FOR_TEST) diff --git a/src/google/protobuf/stubs/port.h b/src/google/protobuf/stubs/port.h index bead0af74306..d4d2736c8579 100644 --- a/src/google/protobuf/stubs/port.h +++ b/src/google/protobuf/stubs/port.h @@ -62,8 +62,10 @@ #elif defined(__FreeBSD__) #include // __BYTE_ORDER #else +#if !defined(__QNX__) #include // __BYTE_ORDER #endif +#endif #if ((defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__)) || \ (defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN) || \ (defined(BYTE_ORDER) && BYTE_ORDER == LITTLE_ENDIAN)) && \ From 779a6adfc8b78f39f19d2ef0e50b66dacb64e445 Mon Sep 17 00:00:00 2001 From: Daniel Schopf Date: Fri, 21 May 2021 09:30:36 +0200 Subject: [PATCH 3/5] Add support for 64 bit QNX builds --- src/google/protobuf/stubs/platform_macros.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/google/protobuf/stubs/platform_macros.h b/src/google/protobuf/stubs/platform_macros.h index ce1b1e365576..24799600dcf8 100644 --- a/src/google/protobuf/stubs/platform_macros.h +++ b/src/google/protobuf/stubs/platform_macros.h @@ -46,7 +46,11 @@ #define GOOGLE_PROTOBUF_ARCH_32_BIT 1 #elif defined(__QNX__) #define GOOGLE_PROTOBUF_ARCH_ARM_QNX 1 +#if defined(__aarch64__) +#define GOOGLE_PROTOBUF_ARCH_64_BIT 1 +#else #define GOOGLE_PROTOBUF_ARCH_32_BIT 1 +#endif #elif defined(_M_ARM) || defined(__ARMEL__) #define GOOGLE_PROTOBUF_ARCH_ARM 1 #define GOOGLE_PROTOBUF_ARCH_32_BIT 1 From 12a9feca47c1995ceb4bfbe0a0a32e7d1e8a5c85 Mon Sep 17 00:00:00 2001 From: Daniel Schopf Date: Fri, 21 May 2021 09:32:11 +0200 Subject: [PATCH 4/5] Fix compiler error with brace initializer (conflicts with #8492) --- src/google/protobuf/stubs/mutex.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/google/protobuf/stubs/mutex.h b/src/google/protobuf/stubs/mutex.h index bff96814b441..79c9f6784894 100644 --- a/src/google/protobuf/stubs/mutex.h +++ b/src/google/protobuf/stubs/mutex.h @@ -116,7 +116,11 @@ class CallOnceInitializedMutex { // mutexes. class GOOGLE_PROTOBUF_CAPABILITY("mutex") PROTOBUF_EXPORT WrappedMutex { public: +#if defined(__QNX__) + constexpr WrappedMutex() = default; +#else constexpr WrappedMutex() {} +#endif void Lock() GOOGLE_PROTOBUF_ACQUIRE() { mu_.lock(); } void Unlock() GOOGLE_PROTOBUF_RELEASE() { mu_.unlock(); } // Crash if this Mutex is not held exclusively by this thread. From bbccb31e8b50a0ead02276bd5fbc94819e47c64c Mon Sep 17 00:00:00 2001 From: Daniel Schopf Date: Fri, 21 May 2021 09:32:45 +0200 Subject: [PATCH 5/5] Fix compiler error for empty default ctor for std::atomic variables --- src/google/protobuf/compiler/cpp/cpp_enum_field.cc | 2 +- src/google/protobuf/compiler/cpp/cpp_primitive_field.cc | 2 +- src/google/protobuf/descriptor.pb.cc | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/google/protobuf/compiler/cpp/cpp_enum_field.cc b/src/google/protobuf/compiler/cpp/cpp_enum_field.cc index 57e6d7e6ce9d..1c1a413dccca 100644 --- a/src/google/protobuf/compiler/cpp/cpp_enum_field.cc +++ b/src/google/protobuf/compiler/cpp/cpp_enum_field.cc @@ -496,7 +496,7 @@ void RepeatedEnumFieldGenerator::GenerateConstinitInitializer( format("$name$_()"); if (descriptor_->is_packed() && HasGeneratedMethods(descriptor_->file(), options_)) { - format("\n, _$name$_cached_byte_size_()"); + format("\n, _$name$_cached_byte_size_(0)"); } } diff --git a/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc b/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc index 9f7f61e16973..40e06403a327 100644 --- a/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc +++ b/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc @@ -486,7 +486,7 @@ void RepeatedPrimitiveFieldGenerator::GenerateConstinitInitializer( format("$name$_()"); if (descriptor_->is_packed() && FixedSize(descriptor_->type()) == -1 && HasGeneratedMethods(descriptor_->file(), options_)) { - format("\n, _$name$_cached_byte_size_()"); + format("\n, _$name$_cached_byte_size_(0)"); } } diff --git a/src/google/protobuf/descriptor.pb.cc b/src/google/protobuf/descriptor.pb.cc index 9fb0dfac8807..bb91024d2396 100644 --- a/src/google/protobuf/descriptor.pb.cc +++ b/src/google/protobuf/descriptor.pb.cc @@ -393,9 +393,9 @@ PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT UninterpretedOptionDefaultTypeI constexpr SourceCodeInfo_Location::SourceCodeInfo_Location( ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) : path_() - , _path_cached_byte_size_() + , _path_cached_byte_size_(0) , span_() - , _span_cached_byte_size_() + , _span_cached_byte_size_(0) , leading_detached_comments_() , leading_comments_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) , trailing_comments_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string){} @@ -423,7 +423,7 @@ PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT SourceCodeInfoDefaultTypeIntern constexpr GeneratedCodeInfo_Annotation::GeneratedCodeInfo_Annotation( ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized) : path_() - , _path_cached_byte_size_() + , _path_cached_byte_size_(0) , source_file_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string) , begin_(0) , end_(0){}