diff --git a/cmake/install.cmake b/cmake/install.cmake index 9d837ac536c9..e7eb2103be6e 100644 --- a/cmake/install.cmake +++ b/cmake/install.cmake @@ -8,10 +8,14 @@ list(APPEND _pc_targets "utf8_range") set(_protobuf_PC_REQUIRES "") set(_sep "") -foreach (_target IN LISTS _pc_target_list) +foreach (_target IN LISTS _pc_targets) string(CONCAT _protobuf_PC_REQUIRES "${_protobuf_PC_REQUIRES}" "${_sep}" "${_target}") set(_sep " ") endforeach () +set(_protobuf_PC_CFLAGS) +if (protobuf_BUILD_SHARED_LIBS) + set(_protobuf_PC_CFLAGS -DPROTOBUF_USE_DLLS) +endif () configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/protobuf.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/protobuf.pc @ONLY) diff --git a/cmake/protobuf-lite.pc.cmake b/cmake/protobuf-lite.pc.cmake index 7f88046998ea..47d911b303fa 100644 --- a/cmake/protobuf-lite.pc.cmake +++ b/cmake/protobuf-lite.pc.cmake @@ -9,5 +9,5 @@ Version: @protobuf_VERSION@ Requires: @_protobuf_PC_REQUIRES@ Requires.private: @_protobuf_PC_REQUIRES_PRIVATE@ Libs: -L${libdir} -lprotobuf-lite @CMAKE_THREAD_LIBS_INIT@ -Cflags: -I${includedir} +Cflags: -I${includedir} @_protobuf_PC_CFLAGS@ Conflicts: protobuf diff --git a/cmake/protobuf.pc.cmake b/cmake/protobuf.pc.cmake index b3cda920757c..8f6b78c28c64 100644 --- a/cmake/protobuf.pc.cmake +++ b/cmake/protobuf.pc.cmake @@ -9,5 +9,5 @@ Version: @protobuf_VERSION@ Requires: @_protobuf_PC_REQUIRES@ Requires.private: @_protobuf_PC_REQUIRES_PRIVATE@ Libs: -L${libdir} -lprotobuf @CMAKE_THREAD_LIBS_INIT@ -Cflags: -I${includedir} +Cflags: -I${includedir} @_protobuf_PC_CFLAGS@ Conflicts: protobuf-lite diff --git a/src/google/protobuf/arena_align.h b/src/google/protobuf/arena_align.h index 958bb9d072b8..d63393c84311 100644 --- a/src/google/protobuf/arena_align.h +++ b/src/google/protobuf/arena_align.h @@ -99,7 +99,7 @@ struct ArenaAlignDefault { } static inline PROTOBUF_ALWAYS_INLINE constexpr size_t Ceil(size_t n) { - return (n + align - 1) & -align; + return (n + align - 1) & ~(align - 1); } static inline PROTOBUF_ALWAYS_INLINE constexpr size_t Floor(size_t n) { return (n & ~(align - 1)); @@ -113,7 +113,7 @@ struct ArenaAlignDefault { template static inline PROTOBUF_ALWAYS_INLINE T* Ceil(T* ptr) { uintptr_t intptr = reinterpret_cast(ptr); - return reinterpret_cast((intptr + align - 1) & -align); + return reinterpret_cast((intptr + align - 1) & ~(align - 1)); } template @@ -142,7 +142,9 @@ struct ArenaAlign { return (reinterpret_cast(ptr) & (align - 1)) == 0U; } - constexpr size_t Ceil(size_t n) const { return (n + align - 1) & -align; } + constexpr size_t Ceil(size_t n) const { + return (n + align - 1) & ~(align - 1); + } constexpr size_t Floor(size_t n) const { return (n & ~(align - 1)); } constexpr size_t Padded(size_t n) const { @@ -156,7 +158,7 @@ struct ArenaAlign { template T* Ceil(T* ptr) const { uintptr_t intptr = reinterpret_cast(ptr); - return reinterpret_cast((intptr + align - 1) & -align); + return reinterpret_cast((intptr + align - 1) & ~(align - 1)); } template diff --git a/src/google/protobuf/repeated_field.h b/src/google/protobuf/repeated_field.h index bfcb93833d08..057565a41652 100644 --- a/src/google/protobuf/repeated_field.h +++ b/src/google/protobuf/repeated_field.h @@ -494,7 +494,7 @@ template inline RepeatedField::RepeatedField(const RepeatedField& rhs) : current_size_(0), total_size_(0), arena_or_elements_(nullptr) { StaticValidityCheck(); - if (size_t size = rhs.current_size_) { + if (auto size = rhs.current_size_) { Grow(0, size); ExchangeCurrentSize(size); UninitializedCopyN(rhs.elements(), size, unsafe_elements()); @@ -775,7 +775,7 @@ inline void RepeatedField::Clear() { template inline void RepeatedField::MergeFrom(const RepeatedField& rhs) { ABSL_DCHECK_NE(&rhs, this); - if (size_t size = rhs.current_size_) { + if (auto size = rhs.current_size_) { Reserve(current_size_ + size); Element* dst = elements() + ExchangeCurrentSize(current_size_ + size); UninitializedCopyN(rhs.elements(), size, dst);