24
24
#import < objc/runtime.h>
25
25
#include " swift/Runtime/Once.h"
26
26
#include < dlfcn.h>
27
+ #include " swift/Runtime/Atomic.h"
27
28
28
29
typedef enum {
29
30
dyld_objc_string_kind
51
52
static swift_once_t initializeBridgingStateOnce;
52
53
53
54
static CFBridgingState const *getBridgingState () {
54
- return bridgingState.load (std::memory_order_acquire );
55
+ return bridgingState.load (SWIFT_MEMORY_ORDER_CONSUME );
55
56
}
56
57
57
58
extern " C" bool _dyld_is_objc_constant (DyldObjCConstantKind kind,
@@ -114,7 +115,7 @@ static inline bool initializeBridgingFunctions() {
114
115
state->NSSetClass = objc_lookUpClass (" NSSet" );
115
116
state->NSDictionaryClass = objc_lookUpClass (" NSDictionary" );
116
117
state->NSEnumeratorClass = objc_lookUpClass (" NSEnumerator" );
117
- bridgingState.store (state);
118
+ bridgingState.store (state, std::memory_order_relaxed );
118
119
_reparentClasses ();
119
120
});
120
121
auto state = getBridgingState ();
@@ -124,11 +125,11 @@ static inline bool initializeBridgingFunctions() {
124
125
SWIFT_RUNTIME_EXPORT void swift_initializeCoreFoundationState (CFBridgingState const * const state) {
125
126
// Consume the once token to make sure that the lazy version of this in initializeBridgingFunctions only runs if we didn't hit this
126
127
swift::once (initializeBridgingStateOnce, [state](){
127
- bridgingState.store (state);
128
+ bridgingState.store (state, std::memory_order_relaxed );
128
129
});
129
130
// It's fine if this runs more than once, it's a noop if it's been done before
130
131
// and we want to make sure it still happens if CF loads late after it failed initially
131
- bridgingState.store (state);
132
+ bridgingState.store (state, std::memory_order_release );
132
133
_reparentClasses ();
133
134
}
134
135
0 commit comments