aboutsummaryrefslogtreecommitdiff
path: root/objectivec/GPBMessage.m
diff options
context:
space:
mode:
authorJonathan Dierksen <jedierksen@gmail.com>2018-01-22 13:26:39 -0800
committerThomas Van Lenten <thomasvl@google.com>2018-01-22 16:26:39 -0500
commita721bf6d294915b412e4ba6b5d92a9b84c6bfef9 (patch)
treee2650a8219b383a4e622df32a6294b3418a00594 /objectivec/GPBMessage.m
parent47b7d2c7cadf74ceec90fc5042232819cd0dd557 (diff)
downloadprotobuf-a721bf6d294915b412e4ba6b5d92a9b84c6bfef9.tar.gz
protobuf-a721bf6d294915b412e4ba6b5d92a9b84c6bfef9.tar.bz2
protobuf-a721bf6d294915b412e4ba6b5d92a9b84c6bfef9.zip
Migrate away from deprecated OSAtomic APIs. (#4184)
* Migrate away from deprecated OSAtomic APIs.
Diffstat (limited to 'objectivec/GPBMessage.m')
-rw-r--r--objectivec/GPBMessage.m5
1 files changed, 3 insertions, 2 deletions
diff --git a/objectivec/GPBMessage.m b/objectivec/GPBMessage.m
index cc1a650a..a9f8bfe7 100644
--- a/objectivec/GPBMessage.m
+++ b/objectivec/GPBMessage.m
@@ -32,6 +32,7 @@
#import <objc/runtime.h>
#import <objc/message.h>
+#import <stdatomic.h>
#import "GPBArray_PackagePrivate.h"
#import "GPBCodedInputStream_PackagePrivate.h"
@@ -742,14 +743,14 @@ void GPBClearMessageAutocreator(GPBMessage *self) {
void GPBPrepareReadOnlySemaphore(GPBMessage *self) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdirect-ivar-access"
-#pragma clang diagnostic ignored "-Wdeprecated-declarations"
// Create the semaphore on demand (rather than init) as developers might not cause them
// to be needed, and the heap usage can add up. The atomic swap is used to avoid needing
// another lock around creating it.
if (self->readOnlySemaphore_ == nil) {
dispatch_semaphore_t worker = dispatch_semaphore_create(1);
- if (!OSAtomicCompareAndSwapPtrBarrier(NULL, worker, (void * volatile *)&(self->readOnlySemaphore_))) {
+ dispatch_semaphore_t expected = nil;
+ if (!atomic_compare_exchange_strong(&self->readOnlySemaphore_, &expected, worker)) {
dispatch_release(worker);
}
}