@@ -174,6 +174,14 @@ _dispatch_lock_has_failed_trylock(dispatch_lock lock_value)
174174#endif
175175#endif // HAVE_FUTEX
176176
177+ #ifndef HAVE_WAIT_ON_ADDRESS
178+ #if defined(_WIN32 )
179+ #define HAVE_WAIT_ON_ADDRESS 1
180+ #else
181+ #define HAVE_WIAT_ON_ADDRESS 0
182+ #endif
183+ #endif
184+
177185#if defined(__x86_64__ ) || defined(__i386__ ) || defined(__s390x__ )
178186#define DISPATCH_ONCE_USE_QUIESCENT_COUNTER 0
179187#elif __APPLE__
@@ -271,7 +279,7 @@ void _dispatch_wake_by_address(uint32_t volatile *address);
271279 * This locking primitive has no notion of ownership
272280 */
273281typedef struct dispatch_thread_event_s {
274- #if HAVE_UL_COMPARE_AND_WAIT || HAVE_FUTEX
282+ #if HAVE_UL_COMPARE_AND_WAIT || HAVE_FUTEX || HAVE_WAIT_ON_ADDRESS
275283 // 1 means signalled but not waited on yet
276284 // UINT32_MAX means waited on, but not signalled yet
277285 // 0 is the initial and final state
@@ -289,7 +297,7 @@ DISPATCH_ALWAYS_INLINE
289297static inline void
290298_dispatch_thread_event_init (dispatch_thread_event_t dte )
291299{
292- #if HAVE_UL_COMPARE_AND_WAIT || HAVE_FUTEX
300+ #if HAVE_UL_COMPARE_AND_WAIT || HAVE_FUTEX || HAVE_WAIT_ON_ADDRESS
293301 dte -> dte_value = 0 ;
294302#else
295303 _dispatch_sema4_init (& dte -> dte_sema , _DSEMA4_POLICY_FIFO );
@@ -300,7 +308,7 @@ DISPATCH_ALWAYS_INLINE
300308static inline void
301309_dispatch_thread_event_signal (dispatch_thread_event_t dte )
302310{
303- #if HAVE_UL_COMPARE_AND_WAIT || HAVE_FUTEX
311+ #if HAVE_UL_COMPARE_AND_WAIT || HAVE_FUTEX || HAVE_WAIT_ON_ADDRESS
304312 if (os_atomic_add_orig (& dte -> dte_value , 1u , release ) == 0 ) {
305313 // 0 -> 1 transition doesn't need a signal
306314 // force a wake even when the value is corrupt,
@@ -318,7 +326,7 @@ DISPATCH_ALWAYS_INLINE
318326static inline void
319327_dispatch_thread_event_wait (dispatch_thread_event_t dte )
320328{
321- #if HAVE_UL_COMPARE_AND_WAIT || HAVE_FUTEX
329+ #if HAVE_UL_COMPARE_AND_WAIT || HAVE_FUTEX || HAVE_WAIT_ON_ADDRESS
322330 if (os_atomic_sub (& dte -> dte_value , 1u , acquire ) == 0 ) {
323331 // 1 -> 0 is always a valid transition, so we can return
324332 // for any other value, take the slow path which checks it's not corrupt
@@ -334,7 +342,7 @@ DISPATCH_ALWAYS_INLINE
334342static inline void
335343_dispatch_thread_event_destroy (dispatch_thread_event_t dte )
336344{
337- #if HAVE_UL_COMPARE_AND_WAIT || HAVE_FUTEX
345+ #if HAVE_UL_COMPARE_AND_WAIT || HAVE_FUTEX || HAVE_WAIT_ON_ADDRESS
338346 // nothing to do
339347 dispatch_assert (dte -> dte_value == 0 );
340348#else
0 commit comments