Module: wine Branch: master Commit: 146c2631276b3e826085a6d270d71c5f56b75d87 URL: https://gitlab.winehq.org/wine/wine/-/commit/146c2631276b3e826085a6d270d71c5...
Author: Paul Gofman pgofman@codeweavers.com Date: Fri Apr 5 12:11:51 2024 -0600
ntdll: Return STATUS_NO_YIELD_PERFORMED from NtYieldExecution() on Linux if no yield was performed.
---
dlls/ntdll/unix/sync.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
diff --git a/dlls/ntdll/unix/sync.c b/dlls/ntdll/unix/sync.c index ae7bc115ffe..e070233104b 100644 --- a/dlls/ntdll/unix/sync.c +++ b/dlls/ntdll/unix/sync.c @@ -43,6 +43,9 @@ #ifdef HAVE_SCHED_H # include <sched.h> #endif +#ifdef HAVE_SYS_RESOURCE_H +# include <sys/resource.h> +#endif #include <string.h> #include <stdarg.h> #include <stdio.h> @@ -1514,7 +1517,17 @@ NTSTATUS WINAPI NtSignalAndWaitForSingleObject( HANDLE signal, HANDLE wait, NTSTATUS WINAPI NtYieldExecution(void) { #ifdef HAVE_SCHED_YIELD +#ifdef RUSAGE_THREAD + struct rusage u1, u2; + int ret; + + ret = getrusage( RUSAGE_THREAD, &u1 ); +#endif sched_yield(); +#ifdef RUSAGE_THREAD + if (!ret) ret = getrusage( RUSAGE_THREAD, &u2 ); + if (!ret && u1.ru_nvcsw == u2.ru_nvcsw && u1.ru_nivcsw == u2.ru_nivcsw) return STATUS_NO_YIELD_PERFORMED; +#endif return STATUS_SUCCESS; #else return STATUS_NO_YIELD_PERFORMED;