updated protobuf to 3.18.1

This commit is contained in:
Sven Czarnian
2021-10-10 20:51:05 +02:00
parent ea460b1aaf
commit 7d69203486
69 changed files with 6374 additions and 3669 deletions

View File

@@ -82,7 +82,7 @@ namespace internal {
// The current version, represented as a single integer to make comparison
// easier: major * 10^6 + minor * 10^3 + micro
#define GOOGLE_PROTOBUF_VERSION 3017003
#define GOOGLE_PROTOBUF_VERSION 3018001
// A suffix string for alpha, beta or rc releases. Empty for stable releases.
#define GOOGLE_PROTOBUF_VERSION_SUFFIX ""
@@ -90,15 +90,15 @@ namespace internal {
// The minimum header version which works with the current version of
// the library. This constant should only be used by protoc's C++ code
// generator.
static const int kMinHeaderVersionForLibrary = 3017000;
static const int kMinHeaderVersionForLibrary = 3018000;
// The minimum protoc version which works with the current version of the
// headers.
#define GOOGLE_PROTOBUF_MIN_PROTOC_VERSION 3017000
#define GOOGLE_PROTOBUF_MIN_PROTOC_VERSION 3018000
// The minimum header version which works with the current version of
// protoc. This constant should only be used in VerifyVersion().
static const int kMinHeaderVersionForProtoc = 3017000;
static const int kMinHeaderVersionForProtoc = 3018000;
// Verifies that the headers and libraries are compatible. Use the macro
// below to call this.
@@ -176,7 +176,7 @@ class FatalException : public std::exception {
: filename_(filename), line_(line), message_(message) {}
virtual ~FatalException() throw();
virtual const char* what() const throw();
virtual const char* what() const throw() override;
const char* filename() const { return filename_; }
int line() const { return line_; }

View File

@@ -52,10 +52,12 @@
__attribute__((acquire_capability(__VA_ARGS__)))
#define GOOGLE_PROTOBUF_RELEASE(...) \
__attribute__((release_capability(__VA_ARGS__)))
#define GOOGLE_PROTOBUF_SCOPED_CAPABILITY __attribute__((scoped_lockable))
#define GOOGLE_PROTOBUF_CAPABILITY(x) __attribute__((capability(x)))
#else
#define GOOGLE_PROTOBUF_ACQUIRE(...)
#define GOOGLE_PROTOBUF_RELEASE(...)
#define GOOGLE_PROTOBUF_SCOPED_CAPABILITY
#define GOOGLE_PROTOBUF_CAPABILITY(x)
#endif
@@ -140,10 +142,12 @@ class GOOGLE_PROTOBUF_CAPABILITY("mutex") PROTOBUF_EXPORT WrappedMutex {
using Mutex = WrappedMutex;
// MutexLock(mu) acquires mu when constructed and releases it when destroyed.
class PROTOBUF_EXPORT MutexLock {
class GOOGLE_PROTOBUF_SCOPED_CAPABILITY PROTOBUF_EXPORT MutexLock {
public:
explicit MutexLock(Mutex *mu) : mu_(mu) { this->mu_->Lock(); }
~MutexLock() { this->mu_->Unlock(); }
explicit MutexLock(Mutex *mu) GOOGLE_PROTOBUF_ACQUIRE(mu) : mu_(mu) {
this->mu_->Lock();
}
~MutexLock() GOOGLE_PROTOBUF_RELEASE() { this->mu_->Unlock(); }
private:
Mutex *const mu_;
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MutexLock);

View File

@@ -35,6 +35,8 @@
#include <google/protobuf/stubs/common.h>
#include <algorithm>
namespace google {
namespace protobuf {
@@ -48,6 +50,18 @@ inline void STLStringResizeUninitialized(std::string* s, size_t new_size) {
s->resize(new_size);
}
// As above, but we make sure to follow amortized growth in which we always
// increase the capacity by at least a constant factor >1.
inline void STLStringResizeUninitializedAmortized(std::string* s,
size_t new_size) {
const size_t cap = s->capacity();
if (new_size > cap) {
// Make sure to always grow by at least a factor of 2x.
s->reserve(std::max(new_size, 2 * cap));
}
STLStringResizeUninitialized(s, new_size);
}
// Return a mutable char* pointing to a string's internal buffer,
// which may not be null-terminated. Writing through this pointer will
// modify the string.

View File

@@ -148,6 +148,10 @@
#include <limits>
#include <string>
#if defined(__cpp_lib_string_view)
#include <string_view>
#endif
#include <google/protobuf/stubs/hash.h>
#include <google/protobuf/port_def.inc>
@@ -215,6 +219,14 @@ class PROTOBUF_EXPORT StringPiece {
length_ = CheckSize(str.size());
}
#if defined(__cpp_lib_string_view)
StringPiece( // NOLINT(runtime/explicit)
std::string_view str)
: ptr_(str.data()), length_(0) {
length_ = CheckSize(str.size());
}
#endif
StringPiece(const char* offset, size_type len)
: ptr_(offset), length_(CheckSize(len)) {}