Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cherry-Pick protocolbuffers/protobuf#8714
Signed-off-by: Oliver Eikemeier <eikemeier@fillmore-labs.com>
- Loading branch information
Showing
5 changed files
with
41 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
*.bzl text | ||
*.java text | ||
*.json text | ||
*.patch text | ||
*.proto text | ||
*.yaml text | ||
BUILD text | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
https://github.com/protocolbuffers/protobuf/pull/8714 | ||
--- | ||
src/google/protobuf/stubs/mutex.h | 10 +++++++--- | ||
1 file changed, 7 insertions(+), 3 deletions(-) | ||
|
||
diff --git src/google/protobuf/stubs/mutex.h src/google/protobuf/stubs/mutex.h | ||
index 79c9f6784..5c025b149 100644 | ||
--- src/google/protobuf/stubs/mutex.h | ||
+++ src/google/protobuf/stubs/mutex.h | ||
@@ -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); | ||
-- |
Empty file.