File tree 2 files changed +16
-0
lines changed
include/swift/Threading/Impl
2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -135,7 +135,10 @@ inline void lazy_mutex_unsafe_unlock(lazy_mutex_handle &handle) {
135
135
136
136
struct once_t {
137
137
std::atomic<std::int32_t > flag;
138
+ #if defined(__LP64__) || defined(_LP64)
139
+ // On 32-bit Linux we can't have the lock, so we'll be less efficient
138
140
linux::ulock_t lock;
141
+ #endif
139
142
};
140
143
141
144
void once_slow (once_t &predicate, void (*fn)(void *), void *context);
Original file line number Diff line number Diff line change @@ -36,6 +36,10 @@ class MainThreadRememberer {
36
36
37
37
MainThreadRememberer rememberer;
38
38
39
+ #if !defined(__LP64__) && !defined(_LP64)
40
+ pthread_mutex_t once_mutex = PTHREAD_MUTEX_INITIALIZER;
41
+ #endif
42
+
39
43
#pragma clang diagnostic pop
40
44
41
45
} // namespace
@@ -49,12 +53,21 @@ bool swift::threading_impl::thread_is_main() {
49
53
50
54
void swift::threading_impl::once_slow (once_t &predicate, void (*fn)(void *),
51
55
void *context) {
56
+ // On 32-bit Linux we can't have per-once locks
57
+ #if defined(__LP64__) || defined(_LP64)
52
58
linux::ulock_lock (&predicate.lock );
59
+ #else
60
+ pthread_mutex_lock (&once_mutex);
61
+ #endif
53
62
if (predicate.flag .load (std::memory_order_acquire) == 0 ) {
54
63
fn (context);
55
64
predicate.flag .store (-1 , std::memory_order_release);
56
65
}
66
+ #if defined(__LP64__) || defined(_LP64)
57
67
linux::ulock_unlock (&predicate.lock );
68
+ #else
69
+ pthread_mutex_unlock (&once_mutex);
70
+ #endif
58
71
}
59
72
60
73
llvm::Optional<swift::threading_impl::stack_bounds>
You can’t perform that action at this time.
0 commit comments