Rebase against a550040d94de646c65f4013337b5cce89383b634.

This commit is contained in:
Alistair Leslie-Hughes
2025-05-21 07:45:33 +10:00
parent 47f77594ab
commit 7f2c4b8613
3 changed files with 33 additions and 33 deletions

View File

@@ -1,4 +1,4 @@
From 5f5cfac7099cf4e5be912f07a66665f8217f57f3 Mon Sep 17 00:00:00 2001
From 7925434a76b590f7cb2d1e9d6dcc9938e0374b35 Mon Sep 17 00:00:00 2001
From: Zebediah Figura <zfigura@codeweavers.com>
Date: Mon, 6 Jul 2020 17:17:31 -0500
Subject: [PATCH] ntdll, server: Implement alertable waits.
@@ -15,10 +15,10 @@ Subject: [PATCH] ntdll, server: Implement alertable waits.
8 files changed, 109 insertions(+), 9 deletions(-)
diff --git a/dlls/ntdll/unix/esync.c b/dlls/ntdll/unix/esync.c
index 2844f9f760c..aeeea1731ce 100644
index f805af251bb..a80019b76dd 100644
--- a/dlls/ntdll/unix/esync.c
+++ b/dlls/ntdll/unix/esync.c
@@ -599,17 +599,42 @@ static void update_grabbed_object( struct esync *obj )
@@ -601,17 +601,42 @@ static void update_grabbed_object( struct esync *obj )
static NTSTATUS __esync_wait_objects( DWORD count, const HANDLE *handles, BOOLEAN wait_any,
BOOLEAN alertable, const LARGE_INTEGER *timeout )
{
@@ -62,7 +62,7 @@ index 2844f9f760c..aeeea1731ce 100644
NtQuerySystemTime( &now );
if (timeout)
{
@@ -648,6 +673,8 @@ static NTSTATUS __esync_wait_objects( DWORD count, const HANDLE *handles, BOOLEA
@@ -650,6 +675,8 @@ static NTSTATUS __esync_wait_objects( DWORD count, const HANDLE *handles, BOOLEA
if (msgwait)
TRACE(" or driver events");
@@ -71,7 +71,7 @@ index 2844f9f760c..aeeea1731ce 100644
if (!timeout)
TRACE(", timeout = INFINITE.\n");
@@ -684,12 +711,27 @@ static NTSTATUS __esync_wait_objects( DWORD count, const HANDLE *handles, BOOLEA
@@ -686,12 +713,27 @@ static NTSTATUS __esync_wait_objects( DWORD count, const HANDLE *handles, BOOLEA
fds[i].fd = obj ? obj->fd : -1;
fds[i].events = POLLIN;
}
@@ -100,7 +100,7 @@ index 2844f9f760c..aeeea1731ce 100644
/* Find out which object triggered the wait. */
for (i = 0; i < count; i++)
{
@@ -763,6 +805,14 @@ static NTSTATUS __esync_wait_objects( DWORD count, const HANDLE *handles, BOOLEA
@@ -765,6 +807,14 @@ static NTSTATUS __esync_wait_objects( DWORD count, const HANDLE *handles, BOOLEA
tryagain:
/* First step: try to poll on each object in sequence. */
fds[0].events = POLLIN;
@@ -115,7 +115,7 @@ index 2844f9f760c..aeeea1731ce 100644
for (i = 0; i < count; i++)
{
struct esync *obj = objs[i];
@@ -778,9 +828,11 @@ tryagain:
@@ -780,9 +830,11 @@ tryagain:
continue;
}
@@ -128,7 +128,7 @@ index 2844f9f760c..aeeea1731ce 100644
if (fds[0].revents & (POLLHUP | POLLERR | POLLNVAL))
{
@@ -796,10 +848,12 @@ tryagain:
@@ -798,10 +850,12 @@ tryagain:
fds[i].fd = objs[i] ? objs[i]->fd : -1;
fds[i].events = POLLIN;
}
@@ -143,7 +143,7 @@ index 2844f9f760c..aeeea1731ce 100644
{
/* Quick, grab everything. */
for (i = 0; i < count; i++)
@@ -865,6 +919,19 @@ err:
@@ -867,6 +921,19 @@ err:
ERR("ppoll failed: %s\n", strerror(errno));
return errno_to_status( errno );
}
@@ -164,22 +164,22 @@ index 2844f9f760c..aeeea1731ce 100644
/* We need to let the server know when we are doing a message wait, and when we
diff --git a/dlls/ntdll/unix/unix_private.h b/dlls/ntdll/unix/unix_private.h
index b278ab8df84..a3f0368b731 100644
index c8e87a9d5aa..0454922dbe3 100644
--- a/dlls/ntdll/unix/unix_private.h
+++ b/dlls/ntdll/unix/unix_private.h
@@ -93,6 +93,7 @@ struct ntdll_thread_data
{
void *cpu_data[16]; /* reserved for CPU-specific data */
void *kernel_stack; /* stack for thread startup and kernel syscalls */
+ int esync_apc_fd; /* fd to wait on for user APCs */
int request_fd; /* fd for sending server requests */
int reply_fd; /* fd for receiving server replies */
int wait_fd[2]; /* fd for sleeping server requests */
@@ -104,6 +104,7 @@ struct ntdll_thread_data
void *cpu_data[16]; /* 1d4/02f0 reserved for CPU-specific data */
SYSTEM_SERVICE_TABLE *syscall_table; /* 214/0370 syscall table */
struct syscall_frame *syscall_frame; /* 218/0378 current syscall frame */
+ int esync_apc_fd; /* fd to wait on for user APCs */
int request_fd; /* fd for sending server requests */
int reply_fd; /* fd for receiving server replies */
int wait_fd[2]; /* fd for sleeping server requests */
diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c
index 2116b677adb..a7d0bb7e8c8 100644
index c797c89952f..0778ad73984 100644
--- a/dlls/ntdll/unix/virtual.c
+++ b/dlls/ntdll/unix/virtual.c
@@ -3646,6 +3646,7 @@ static TEB *init_teb( void *ptr, BOOL is_wow )
@@ -4014,6 +4014,7 @@ static TEB *init_teb( void *ptr, BOOL is_wow )
teb->StaticUnicodeString.Buffer = teb->StaticUnicodeBuffer;
teb->StaticUnicodeString.MaximumLength = sizeof(teb->StaticUnicodeBuffer);
thread_data = (struct ntdll_thread_data *)&teb->GdiTebBatch;
@@ -244,10 +244,10 @@ index 689d8569b73..e1588d205d9 100644
void esync_clear( int fd );
diff --git a/server/protocol.def b/server/protocol.def
index 8c728080d05..3ea700054c6 100644
index 807298b6bab..a2dcdd37204 100644
--- a/server/protocol.def
+++ b/server/protocol.def
@@ -3935,3 +3935,7 @@ enum esync_type
@@ -4148,3 +4148,7 @@ enum esync_type
@REPLY
int enable; /* previous state of auto-repeat enable */
@END
@@ -256,10 +256,10 @@ index 8c728080d05..3ea700054c6 100644
+@REQ(get_esync_apc_fd)
+@END
diff --git a/server/thread.c b/server/thread.c
index fd6b91b228a..8d7c520ced7 100644
index 11c36e49ae4..3a771838a98 100644
--- a/server/thread.c
+++ b/server/thread.c
@@ -232,6 +232,7 @@ static inline void init_thread_structure( struct thread *thread )
@@ -400,6 +400,7 @@ static inline void init_thread_structure( struct thread *thread )
thread->teb = 0;
thread->entry_point = 0;
thread->esync_fd = -1;
@@ -267,7 +267,7 @@ index fd6b91b228a..8d7c520ced7 100644
thread->system_regs = 0;
thread->queue = NULL;
thread->wait = NULL;
@@ -380,7 +381,10 @@ struct thread *create_thread( int fd, struct process *process, const struct secu
@@ -550,7 +551,10 @@ struct thread *create_thread( int fd, struct process *process, const struct secu
}
if (do_esync())
@@ -278,7 +278,7 @@ index fd6b91b228a..8d7c520ced7 100644
set_fd_events( thread->request_fd, POLLIN ); /* start listening to events */
add_process_thread( thread->process, thread );
@@ -1174,8 +1178,13 @@ static int queue_apc( struct process *process, struct thread *thread, struct thr
@@ -1384,8 +1388,13 @@ static int queue_apc( struct process *process, struct thread *thread, struct thr
grab_object( apc );
list_add_tail( queue, &apc->entry );
if (!list_prev( queue, &apc->entry )) /* first one */
@@ -292,7 +292,7 @@ index fd6b91b228a..8d7c520ced7 100644
return 1;
}
@@ -1221,6 +1230,10 @@ static struct thread_apc *thread_dequeue_apc( struct thread *thread, int system
@@ -1431,6 +1440,10 @@ static struct thread_apc *thread_dequeue_apc( struct thread *thread, int system
apc = LIST_ENTRY( ptr, struct thread_apc, entry );
list_remove( ptr );
}
@@ -304,10 +304,10 @@ index fd6b91b228a..8d7c520ced7 100644
}
diff --git a/server/thread.h b/server/thread.h
index 9129e473ba9..10e9e28b432 100644
index e826a7a25de..c320ac83af7 100644
--- a/server/thread.h
+++ b/server/thread.h
@@ -56,6 +56,7 @@ struct thread
@@ -57,6 +57,7 @@ struct thread
thread_id_t id; /* thread id */
struct list mutex_list; /* list of currently owned mutexes */
int esync_fd; /* esync file descriptor (signalled on exit) */
@@ -316,5 +316,5 @@ index 9129e473ba9..10e9e28b432 100644
struct msg_queue *queue; /* message queue */
struct thread_wait *wait; /* current wait condition if sleeping */
--
2.43.0
2.47.2

View File

@@ -64,7 +64,7 @@ index fb5259d8714..93020158d0b 100644
+static void sigsys_handler( int signal, siginfo_t *siginfo, void *sigcontext )
+{
+ extern const void *__wine_syscall_dispatcher_prolog_end_ptr;
+ struct syscall_frame *frame = amd64_thread_data()->syscall_frame;
+ struct syscall_frame *frame = get_syscall_frame();
+ ucontext_t *ctx = sigcontext;
+
+ TRACE_(seh)("SIGSYS, rax %#llx, rip %#llx.\n", ctx->uc_mcontext.gregs[REG_RAX],
@@ -171,7 +171,7 @@ index fb5259d8714..93020158d0b 100644
+ BPF_STMT(BPF_RET | BPF_K, SECCOMP_RET_ALLOW),
+ };
+ long (*test_syscall)(long sc_number);
+ struct syscall_frame *frame = amd64_thread_data()->syscall_frame;
+ struct syscall_frame *frame = get_syscall_frame();
+ struct sock_fprog prog;
+ NTSTATUS status;
+

View File

@@ -1 +1 @@
7f833db11ffea4f3f4fa07be31d30559aff9c5fb
a550040d94de646c65f4013337b5cce89383b634