diff options
Diffstat (limited to 'objectivec/google/protobuf/Struct.pbobjc.m')
-rw-r--r-- | objectivec/google/protobuf/Struct.pbobjc.m | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/objectivec/google/protobuf/Struct.pbobjc.m b/objectivec/google/protobuf/Struct.pbobjc.m index f36ec582..816fd6df 100644 --- a/objectivec/google/protobuf/Struct.pbobjc.m +++ b/objectivec/google/protobuf/Struct.pbobjc.m @@ -13,6 +13,8 @@ #import "GPBProtocolBuffers_RuntimeSupport.h" #endif +#import <stdatomic.h> + #if GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS #import <Protobuf/Struct.pbobjc.h> #else @@ -51,7 +53,7 @@ static GPBFileDescriptor *GPBStructRoot_FileDescriptor(void) { #pragma mark - Enum GPBNullValue GPBEnumDescriptor *GPBNullValue_EnumDescriptor(void) { - static GPBEnumDescriptor *descriptor = NULL; + static _Atomic(GPBEnumDescriptor*) descriptor = nil; if (!descriptor) { static const char *valueNames = "NullValue\000"; @@ -64,7 +66,8 @@ GPBEnumDescriptor *GPBNullValue_EnumDescriptor(void) { values:values count:(uint32_t)(sizeof(values) / sizeof(int32_t)) enumVerifier:GPBNullValue_IsValidValue]; - if (!OSAtomicCompareAndSwapPtrBarrier(nil, worker, (void * volatile *)&descriptor)) { + GPBEnumDescriptor *expected = nil; + if (!atomic_compare_exchange_strong(&descriptor, &expected, worker)) { [worker release]; } } |