diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c index f300dab6b8b..929508b6592 100644 --- a/dlls/ntdll/unix/loader.c +++ b/dlls/ntdll/unix/loader.c @@ -2254,6 +2254,7 @@ static struct unix_funcs unix_funcs = BOOL ac_odyssey; BOOL fsync_simulate_sched_quantum; +BOOL alert_simulate_sched_quantum; BOOL no_priv_elevation; BOOL localsystem_sid; @@ -2281,6 +2282,16 @@ static void hacks_init(void) if (fsync_simulate_sched_quantum) ERR("HACK: Simulating sched quantum in fsync.\n"); + env_str = getenv("WINE_ALERT_SIMULATE_SCHED_QUANTUM"); + if (env_str) + alert_simulate_sched_quantum = !!atoi(env_str); + else if (main_argc > 1) + { + alert_simulate_sched_quantum = !!strstr(main_argv[1], "GTA5.exe"); + } + if (alert_simulate_sched_quantum) + ERR("HACK: Simulating sched quantum in NtWaitForAlertByThreadId.\n"); + sgi = getenv("SteamGameId"); if (sgi && (!strcmp(sgi, "50130") || !strcmp(sgi, "202990") || !strcmp(sgi, "212910"))) setenv("WINESTEAMNOEXEC", "1", 0); diff --git a/dlls/ntdll/unix/sync.c b/dlls/ntdll/unix/sync.c index af0c53d441e..7cb41c25480 100644 --- a/dlls/ntdll/unix/sync.c +++ b/dlls/ntdll/unix/sync.c @@ -2597,6 +2597,7 @@ NTSTATUS WINAPI NtWaitForAlertByThreadId( const void *address, const LARGE_INTEG NTSTATUS WINAPI NtWaitForAlertByThreadId( const void *address, const LARGE_INTEGER *timeout ) { union tid_alert_entry *entry = get_tid_alert_entry( NtCurrentTeb()->ClientId.UniqueThread ); + BOOL waited = FALSE; NTSTATUS status; TRACE( "%p %s\n", address, debugstr_timeout( timeout ) ); @@ -2632,8 +2633,15 @@ NTSTATUS WINAPI NtWaitForAlertByThreadId( const void *address, const LARGE_INTEG else ret = futex_wait( futex, 0, NULL ); + if (!timeout || timeout->QuadPart) + waited = TRUE; + if (ret == -1 && errno == ETIMEDOUT) return STATUS_TIMEOUT; } + + if (alert_simulate_sched_quantum && waited) + usleep(0); + return STATUS_ALERTED; } #endif diff --git a/dlls/ntdll/unix/unix_private.h b/dlls/ntdll/unix/unix_private.h index 1edb55a275f..c243a5f5718 100644 --- a/dlls/ntdll/unix/unix_private.h +++ b/dlls/ntdll/unix/unix_private.h @@ -149,6 +149,7 @@ extern struct ldt_copy __wine_ldt_copy DECLSPEC_HIDDEN; extern BOOL ac_odyssey DECLSPEC_HIDDEN; extern BOOL fsync_simulate_sched_quantum DECLSPEC_HIDDEN; +extern BOOL alert_simulate_sched_quantum DECLSPEC_HIDDEN; extern BOOL no_priv_elevation DECLSPEC_HIDDEN; extern BOOL localsystem_sid DECLSPEC_HIDDEN;