@@ -174,6 +174,14 @@ _dispatch_lock_has_failed_trylock(dispatch_lock lock_value)
174
174
#endif
175
175
#endif // HAVE_FUTEX
176
176
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
+
177
185
#if defined(__x86_64__ ) || defined(__i386__ ) || defined(__s390x__ )
178
186
#define DISPATCH_ONCE_USE_QUIESCENT_COUNTER 0
179
187
#elif __APPLE__
@@ -271,7 +279,7 @@ void _dispatch_wake_by_address(uint32_t volatile *address);
271
279
* This locking primitive has no notion of ownership
272
280
*/
273
281
typedef 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
275
283
// 1 means signalled but not waited on yet
276
284
// UINT32_MAX means waited on, but not signalled yet
277
285
// 0 is the initial and final state
@@ -289,7 +297,7 @@ DISPATCH_ALWAYS_INLINE
289
297
static inline void
290
298
_dispatch_thread_event_init (dispatch_thread_event_t dte )
291
299
{
292
- #if HAVE_UL_COMPARE_AND_WAIT || HAVE_FUTEX
300
+ #if HAVE_UL_COMPARE_AND_WAIT || HAVE_FUTEX || HAVE_WAIT_ON_ADDRESS
293
301
dte -> dte_value = 0 ;
294
302
#else
295
303
_dispatch_sema4_init (& dte -> dte_sema , _DSEMA4_POLICY_FIFO );
@@ -300,7 +308,7 @@ DISPATCH_ALWAYS_INLINE
300
308
static inline void
301
309
_dispatch_thread_event_signal (dispatch_thread_event_t dte )
302
310
{
303
- #if HAVE_UL_COMPARE_AND_WAIT || HAVE_FUTEX
311
+ #if HAVE_UL_COMPARE_AND_WAIT || HAVE_FUTEX || HAVE_WAIT_ON_ADDRESS
304
312
if (os_atomic_add_orig (& dte -> dte_value , 1u , release ) == 0 ) {
305
313
// 0 -> 1 transition doesn't need a signal
306
314
// force a wake even when the value is corrupt,
@@ -318,7 +326,7 @@ DISPATCH_ALWAYS_INLINE
318
326
static inline void
319
327
_dispatch_thread_event_wait (dispatch_thread_event_t dte )
320
328
{
321
- #if HAVE_UL_COMPARE_AND_WAIT || HAVE_FUTEX
329
+ #if HAVE_UL_COMPARE_AND_WAIT || HAVE_FUTEX || HAVE_WAIT_ON_ADDRESS
322
330
if (os_atomic_sub (& dte -> dte_value , 1u , acquire ) == 0 ) {
323
331
// 1 -> 0 is always a valid transition, so we can return
324
332
// for any other value, take the slow path which checks it's not corrupt
@@ -334,7 +342,7 @@ DISPATCH_ALWAYS_INLINE
334
342
static inline void
335
343
_dispatch_thread_event_destroy (dispatch_thread_event_t dte )
336
344
{
337
- #if HAVE_UL_COMPARE_AND_WAIT || HAVE_FUTEX
345
+ #if HAVE_UL_COMPARE_AND_WAIT || HAVE_FUTEX || HAVE_WAIT_ON_ADDRESS
338
346
// nothing to do
339
347
dispatch_assert (dte -> dte_value == 0 );
340
348
#else
0 commit comments