Skip to content

Commit 48932f3

Browse files
committed
shims: convert _dispatch_preemption_yeild to an expression
Because `_dispatch_preemption_yield` is used an expression as: ~~~ ((void) (q), _dispatch_preemption_yield(n)) ~~~ we need to convert the expansion to an expression. We _could_ also just wrap the invocation into a parenthesis as an alternative approach, but this should be safe enough to let us get away with it.
1 parent 093d3a8 commit 48932f3

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/shims/yield.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -161,14 +161,14 @@ void *_dispatch_wait_for_enqueuer(void **ptr, void **tailp);
161161
#define _dispatch_preemption_yield_to(th, n) thread_switch(th, \
162162
DISPATCH_YIELD_THREAD_SWITCH_OPTION, (mach_msg_timeout_t)(n))
163163
#elif HAVE_PTHREAD_YIELD_NP
164-
#define _dispatch_preemption_yield(n) { (void)n; pthread_yield_np(); }
165-
#define _dispatch_preemption_yield_to(th, n) { (void)n; pthread_yield_np(); }
164+
#define _dispatch_preemption_yield(n) ({ (void)n; pthread_yield_np(); })
165+
#define _dispatch_preemption_yield_to(th, n) ({ (void)n; pthread_yield_np(); })
166166
#elif defined(_WIN32)
167-
#define _dispatch_preemption_yield(n) { (void)n; Sleep(0); }
168-
#define _dispatch_preemption_yield_to(th, n) { (void)n; Sleep(0); }
167+
#define _dispatch_preemption_yield(n) ({ (void)n; Sleep(0); })
168+
#define _dispatch_preemption_yield_to(th, n) ({ (void)n; Sleep(0); })
169169
#else
170-
#define _dispatch_preemption_yield(n) { (void)n; sched_yield(); }
171-
#define _dispatch_preemption_yield_to(th, n) { (void)n; sched_yield(); }
170+
#define _dispatch_preemption_yield(n) ({ (void)n; sched_yield(); })
171+
#define _dispatch_preemption_yield_to(th, n) ({ (void)n; sched_yield(); })
172172
#endif // HAVE_MACH
173173

174174
#if DISPATCH_HAVE_YIELD_TO_ENQUEUER

0 commit comments

Comments
 (0)