Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
a721bf6d
Commit
a721bf6d
authored
Jan 22, 2018
by
Jonathan Dierksen
Committed by
Thomas Van Lenten
Jan 22, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate away from deprecated OSAtomic APIs. (#4184)
* Migrate away from deprecated OSAtomic APIs.
parent
47b7d2c7
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
20 additions
and
16 deletions
+20
-16
GPBCodedInputStream_PackagePrivate.h
objectivec/GPBCodedInputStream_PackagePrivate.h
+0
-2
GPBMessage.m
objectivec/GPBMessage.m
+3
-2
GPBMessage_PackagePrivate.h
objectivec/GPBMessage_PackagePrivate.h
+2
-2
Struct.pbobjc.m
objectivec/google/protobuf/Struct.pbobjc.m
+3
-2
Type.pbobjc.m
objectivec/google/protobuf/Type.pbobjc.m
+9
-6
objectivec_enum.cc
src/google/protobuf/compiler/objectivec/objectivec_enum.cc
+3
-2
No files found.
objectivec/GPBCodedInputStream_PackagePrivate.h
View file @
a721bf6d
...
...
@@ -34,8 +34,6 @@
#import "GPBCodedInputStream.h"
#import <libkern/OSAtomic.h>
@class
GPBUnknownFieldSet
;
@class
GPBFieldDescriptor
;
...
...
objectivec/GPBMessage.m
View file @
a721bf6d
...
...
@@ -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
);
}
}
...
...
objectivec/GPBMessage_PackagePrivate.h
View file @
a721bf6d
...
...
@@ -34,7 +34,7 @@
#import "GPBMessage.h"
#import <
libkern/OSA
tomic.h>
#import <
stda
tomic.h>
#import "GPBBootstrap.h"
...
...
@@ -70,7 +70,7 @@ typedef struct GPBMessage_Storage *GPBMessage_StoragePtr;
// Use of readOnlySemaphore_ must be prefaced by a call to
// GPBPrepareReadOnlySemaphore to ensure it has been created. This allows
// readOnlySemaphore_ to be only created when actually needed.
dispatch_semaphore_t
readOnlySemaphore_
;
_Atomic
(
dispatch_semaphore_t
)
readOnlySemaphore_
;
}
// Gets an extension value without autocreating the result if not found. (i.e.
...
...
objectivec/google/protobuf/Struct.pbobjc.m
View file @
a721bf6d
...
...
@@ -51,7 +51,7 @@ static GPBFileDescriptor *GPBStructRoot_FileDescriptor(void) {
#pragma mark - Enum GPBNullValue
GPBEnumDescriptor
*
GPBNullValue_EnumDescriptor
(
void
)
{
static
GPBEnumDescriptor
*
descriptor
=
NULL
;
static
_Atomic
(
GPBEnumDescriptor
*
)
descriptor
=
NULL
;
if
(
!
descriptor
)
{
static
const
char
*
valueNames
=
"NullValue
\000
"
;
...
...
@@ -64,7 +64,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
];
}
}
...
...
objectivec/google/protobuf/Type.pbobjc.m
View file @
a721bf6d
...
...
@@ -54,7 +54,7 @@ static GPBFileDescriptor *GPBTypeRoot_FileDescriptor(void) {
#pragma mark - Enum GPBSyntax
GPBEnumDescriptor
*
GPBSyntax_EnumDescriptor
(
void
)
{
static
GPBEnumDescriptor
*
descriptor
=
NULL
;
static
_Atomic
(
GPBEnumDescriptor
*
)
descriptor
=
NULL
;
if
(
!
descriptor
)
{
static
const
char
*
valueNames
=
"SyntaxProto2
\000
SyntaxProto3
\000
"
;
...
...
@@ -68,7 +68,8 @@ GPBEnumDescriptor *GPBSyntax_EnumDescriptor(void) {
values
:
values
count
:
(
uint32_t
)(
sizeof
(
values
)
/
sizeof
(
int32_t
))
enumVerifier
:
GPBSyntax_IsValidValue
];
if
(
!
OSAtomicCompareAndSwapPtrBarrier
(
nil
,
worker
,
(
void
*
volatile
*
)
&
descriptor
))
{
GPBEnumDescriptor
*
expected
=
nil
;
if
(
!
atomic_compare_exchange_strong
(
&
descriptor
,
&
expected
,
worker
))
{
[
worker
release
];
}
}
...
...
@@ -368,7 +369,7 @@ void SetGPBField_Cardinality_RawValue(GPBField *message, int32_t value) {
#pragma mark - Enum GPBField_Kind
GPBEnumDescriptor
*
GPBField_Kind_EnumDescriptor
(
void
)
{
static
GPBEnumDescriptor
*
descriptor
=
NULL
;
static
_Atomic
(
GPBEnumDescriptor
*
)
descriptor
=
NULL
;
if
(
!
descriptor
)
{
static
const
char
*
valueNames
=
"TypeUnknown
\000
TypeDouble
\000
TypeFloat
\000
TypeInt"
...
...
@@ -404,7 +405,8 @@ GPBEnumDescriptor *GPBField_Kind_EnumDescriptor(void) {
values
:
values
count
:
(
uint32_t
)(
sizeof
(
values
)
/
sizeof
(
int32_t
))
enumVerifier
:
GPBField_Kind_IsValidValue
];
if
(
!
OSAtomicCompareAndSwapPtrBarrier
(
nil
,
worker
,
(
void
*
volatile
*
)
&
descriptor
))
{
GPBEnumDescriptor
*
expected
=
nil
;
if
(
!
atomic_compare_exchange_strong
(
&
descriptor
,
&
expected
,
worker
))
{
[
worker
release
];
}
}
...
...
@@ -441,7 +443,7 @@ BOOL GPBField_Kind_IsValidValue(int32_t value__) {
#pragma mark - Enum GPBField_Cardinality
GPBEnumDescriptor
*
GPBField_Cardinality_EnumDescriptor
(
void
)
{
static
GPBEnumDescriptor
*
descriptor
=
NULL
;
static
_Atomic
(
GPBEnumDescriptor
*
)
descriptor
=
NULL
;
if
(
!
descriptor
)
{
static
const
char
*
valueNames
=
"CardinalityUnknown
\000
CardinalityOptional
\000
C"
...
...
@@ -458,7 +460,8 @@ GPBEnumDescriptor *GPBField_Cardinality_EnumDescriptor(void) {
values
:
values
count
:
(
uint32_t
)(
sizeof
(
values
)
/
sizeof
(
int32_t
))
enumVerifier
:
GPBField_Cardinality_IsValidValue
];
if
(
!
OSAtomicCompareAndSwapPtrBarrier
(
nil
,
worker
,
(
void
*
volatile
*
)
&
descriptor
))
{
GPBEnumDescriptor
*
expected
=
nil
;
if
(
!
atomic_compare_exchange_strong
(
&
descriptor
,
&
expected
,
worker
))
{
[
worker
release
];
}
}
...
...
src/google/protobuf/compiler/objectivec/objectivec_enum.cc
View file @
a721bf6d
...
...
@@ -149,7 +149,7 @@ void EnumGenerator::GenerateSource(io::Printer* printer) {
printer
->
Print
(
"GPBEnumDescriptor *$name$_EnumDescriptor(void) {
\n
"
" static
GPBEnumDescriptor *
descriptor = NULL;
\n
"
" static
_Atomic(GPBEnumDescriptor*)
descriptor = NULL;
\n
"
" if (!descriptor) {
\n
"
,
"name"
,
name_
);
...
...
@@ -192,7 +192,8 @@ void EnumGenerator::GenerateSource(io::Printer* printer) {
"extraTextFormatInfo"
,
CEscape
(
text_format_decode_data
.
Data
()));
}
printer
->
Print
(
" if (!OSAtomicCompareAndSwapPtrBarrier(nil, worker, (void * volatile *)&descriptor)) {
\n
"
" GPBEnumDescriptor *expected = nil;
\n
"
" if (!atomic_compare_exchange_strong(&descriptor, &expected, worker)) {
\n
"
" [worker release];
\n
"
" }
\n
"
" }
\n
"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment