From 8c52dfa0096ece368eb04435641dfac895ddcaa7 Mon Sep 17 00:00:00 2001 From: zeropool <1285055670@qq.com> Date: Wed, 20 May 2020 10:37:43 +0800 Subject: [PATCH] sched_yield support for non-POSIX windows gcc --- chan/eb_chan.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/chan/eb_chan.h b/chan/eb_chan.h index e4855b4..72189e1 100644 --- a/chan/eb_chan.h +++ b/chan/eb_chan.h @@ -30,6 +30,13 @@ #include +#if (defined(__MINGW32__) || defined(__CYGWIN__)) && !defined(_POSIX_PRIORITY_SCHEDULING) +#include +int sched_yield() { + return SwitchToThread(); +} +#endif + typedef uint64_t eb_nsec; /* Units of nanoseconds */ #define eb_nsec_zero UINT64_C(0) #define eb_nsec_forever UINT64_MAX @@ -1436,4 +1443,4 @@ eb_chan_op *eb_chan_select_list(eb_nsec timeout, eb_chan_op *const ops[], size_t return result; } -#endif /* EB_CHAN_H */ \ No newline at end of file +#endif /* EB_CHAN_H */