File tree Expand file tree Collapse file tree 7 files changed +13
-17
lines changed Expand file tree Collapse file tree 7 files changed +13
-17
lines changed Original file line number Diff line number Diff line change @@ -95,9 +95,8 @@ struct lazy_mutex_handle {
9595 std::int32_t once; // -1 = initialized, 0 = uninitialized, 1 = initializing
9696};
9797
98- inline constexpr lazy_mutex_handle lazy_mutex_initializer () {
99- return (lazy_mutex_handle){};
100- }
98+ #define SWIFT_LAZY_MUTEX_INITIALIZER ((lazy_mutex_handle){})
99+
101100inline void lazy_mutex_init (lazy_mutex_handle &handle) {
102101 // Sadly, we can't use call_once() for this as it doesn't have a context
103102 if (std::atomic_load_explicit ((std::atomic<std::int32_t > *)&handle.once ,
Original file line number Diff line number Diff line change @@ -108,9 +108,8 @@ inline void mutex_unsafe_unlock(mutex_handle &handle) {
108108using lazy_mutex_handle = ::os_unfair_lock;
109109
110110// We don't need to be lazy here because Darwin has OS_UNFAIR_LOCK_INIT.
111- inline constexpr lazy_mutex_handle lazy_mutex_initializer () {
112- return OS_UNFAIR_LOCK_INIT;
113- }
111+ #define SWIFT_LAZY_MUTEX_INITIALIZER OS_UNFAIR_LOCK_INIT
112+
114113inline void lazy_mutex_destroy (lazy_mutex_handle &handle) {}
115114
116115inline void lazy_mutex_lock (lazy_mutex_handle &handle) {
Original file line number Diff line number Diff line change @@ -110,9 +110,8 @@ using lazy_mutex_handle = ::pthread_mutex_t;
110110
111111// We don't actually need to be lazy here because pthreads has
112112// PTHREAD_MUTEX_INITIALIZER.
113- inline constexpr lazy_mutex_handle lazy_mutex_initializer () {
114- return PTHREAD_MUTEX_INITIALIZER;
115- }
113+ #define SWIFT_LAZY_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
114+
116115inline void lazy_mutex_destroy (lazy_mutex_handle &handle) {
117116 SWIFT_LINUXTHREADS_CHECK (::pthread_mutex_destroy (&handle));
118117}
Original file line number Diff line number Diff line change @@ -50,7 +50,8 @@ inline void mutex_unsafe_unlock(mutex_handle &handle) {}
5050
5151using lazy_mutex_handle = unsigned ;
5252
53- inline constexpr lazy_mutex_handle lazy_mutex_initializer () { return 0 ; }
53+ #define SWIFT_LAZY_MUTEX_INITIALIZER 0
54+
5455inline void lazy_mutex_destroy (lazy_mutex_handle &handle) {}
5556inline void lazy_mutex_lock (lazy_mutex_handle &handle) {}
5657inline void lazy_mutex_unlock (lazy_mutex_handle &handle) {}
Original file line number Diff line number Diff line change @@ -107,9 +107,8 @@ using lazy_mutex_handle = ::pthread_mutex_t;
107107
108108// We don't actually need to be lazy here because pthreads has
109109// PTHREAD_MUTEX_INITIALIZER.
110- inline constexpr lazy_mutex_handle lazy_mutex_initializer () {
111- return PTHREAD_MUTEX_INITIALIZER;
112- }
110+ #define SWIFT_LAZY_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
111+
113112inline void lazy_mutex_destroy (lazy_mutex_handle &handle) {
114113 SWIFT_PTHREADS_CHECK (::pthread_mutex_destroy (&handle));
115114}
Original file line number Diff line number Diff line change @@ -66,9 +66,8 @@ inline void mutex_unsafe_unlock(mutex_handle &handle) {
6666using lazy_mutex_handle = SWIFT_SRWLOCK;
6767
6868// We don't need to be lazy here because Win32 has SRWLOCK_INIT.
69- inline constexpr lazy_mutex_handle lazy_mutex_initializer () {
70- return SRWLOCK_INIT;
71- }
69+ #define SWIFT_LAZY_MUTEX_INITIALIZER SRWLOCK_INIT
70+
7271inline void lazy_mutex_destroy (lazy_mutex_handle &handle) {}
7372
7473inline void lazy_mutex_lock (lazy_mutex_handle &handle) {
Original file line number Diff line number Diff line change @@ -144,7 +144,7 @@ class LazyMutex {
144144 LazyMutex &operator =(LazyMutex &&) = delete ;
145145
146146public:
147- constexpr LazyMutex () : Handle(threading_impl::lazy_mutex_initializer() ) {}
147+ constexpr LazyMutex () : Handle(SWIFT_LAZY_MUTEX_INITIALIZER ) {}
148148
149149 // No destructor; this is intentional; this class is for STATIC allocation
150150 // and you don't need to delete mutexes on termination.
You can’t perform that action at this time.
0 commit comments