Skip to content

Commit ba766a2

Browse files
Paul Gofmanivyl
Paul Gofman
authored andcommitted
ntdll: HACK: Add WINE_ALERT_SIMULATE_SCHED_QUANTUM option.
And enable it for GTA 5. CW-Bug-Id: #21194
1 parent cfa7ea5 commit ba766a2

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

dlls/ntdll/unix/loader.c

+11
Original file line numberDiff line numberDiff line change
@@ -1922,6 +1922,7 @@ static ULONG_PTR get_image_address(void)
19221922

19231923
BOOL ac_odyssey;
19241924
BOOL fsync_simulate_sched_quantum;
1925+
BOOL alert_simulate_sched_quantum;
19251926

19261927
static void hacks_init(void)
19271928
{
@@ -1945,6 +1946,16 @@ static void hacks_init(void)
19451946
if (fsync_simulate_sched_quantum)
19461947
ERR("HACK: Simulating sched quantum in fsync.\n");
19471948

1949+
env_str = getenv("WINE_ALERT_SIMULATE_SCHED_QUANTUM");
1950+
if (env_str)
1951+
alert_simulate_sched_quantum = !!atoi(env_str);
1952+
else if (main_argc > 1)
1953+
{
1954+
alert_simulate_sched_quantum = !!strstr(main_argv[1], "GTA5.exe");
1955+
}
1956+
if (alert_simulate_sched_quantum)
1957+
ERR("HACK: Simulating sched quantum in NtWaitForAlertByThreadId.\n");
1958+
19481959
switch (sgi ? atoi( sgi ) : -1)
19491960
{
19501961
case 25700: /* Madballs in Babo: Invasion */

dlls/ntdll/unix/sync.c

+8
Original file line numberDiff line numberDiff line change
@@ -2706,6 +2706,7 @@ NTSTATUS WINAPI NtWaitForAlertByThreadId( const void *address, const LARGE_INTEG
27062706
NTSTATUS WINAPI NtWaitForAlertByThreadId( const void *address, const LARGE_INTEGER *timeout )
27072707
{
27082708
union tid_alert_entry *entry = get_tid_alert_entry( NtCurrentTeb()->ClientId.UniqueThread );
2709+
BOOL waited = FALSE;
27092710
NTSTATUS status;
27102711

27112712
TRACE( "%p %s\n", address, debugstr_timeout( timeout ) );
@@ -2741,8 +2742,15 @@ NTSTATUS WINAPI NtWaitForAlertByThreadId( const void *address, const LARGE_INTEG
27412742
else
27422743
ret = futex_wait( futex, 0, NULL );
27432744

2745+
if (!timeout || timeout->QuadPart)
2746+
waited = TRUE;
2747+
27442748
if (ret == -1 && errno == ETIMEDOUT) return STATUS_TIMEOUT;
27452749
}
2750+
2751+
if (alert_simulate_sched_quantum && waited)
2752+
usleep(0);
2753+
27462754
return STATUS_ALERTED;
27472755
}
27482756
#endif

dlls/ntdll/unix/unix_private.h

+1
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ extern struct ldt_copy __wine_ldt_copy;
180180

181181
extern BOOL ac_odyssey;
182182
extern BOOL fsync_simulate_sched_quantum;
183+
extern BOOL alert_simulate_sched_quantum;
183184

184185
extern void init_environment(void);
185186
extern void init_startup_info(void);

0 commit comments

Comments
 (0)