[RFC PATCH v2 08/11] ntdll: Add a helper to process APC and wait for async in one function call.

Jinoh Kang jinoh.kang.kr at gmail.com
Sat Jan 22 08:36:53 CST 2022


Signed-off-by: Jinoh Kang <jinoh.kang.kr at gmail.com>
---

Notes:
    This essentially replaces the signal_wait_async() function from the previous
    patch serie.

 dlls/ntdll/unix/sync.c         | 19 +++++++++++++++++++
 dlls/ntdll/unix/unix_private.h |  1 +
 2 files changed, 20 insertions(+)

diff --git a/dlls/ntdll/unix/sync.c b/dlls/ntdll/unix/sync.c
index 8fe1e1145e7..05c27cfb5e4 100644
--- a/dlls/ntdll/unix/sync.c
+++ b/dlls/ntdll/unix/sync.c
@@ -2510,3 +2510,22 @@ NTSTATUS WINAPI NtWaitForAlertByThreadId( const void *address, const LARGE_INTEG
 }
 
 #endif
+
+NTSTATUS wait_async_after_apc( HANDLE optional_handle, BOOL alertable, NTSTATUS prev_status, const inline_apc_t *inline_apc )
+{
+    select_op_t select_op;
+    UINT flags = SELECT_INTERRUPTIBLE;
+
+    if (alertable) flags |= SELECT_ALERTABLE;
+
+    if (!optional_handle)
+    {
+        static const LARGE_INTEGER zero = {{ 0 }};
+        server_wait( NULL, 0, flags, &zero, inline_apc );
+        return prev_status;
+    }
+
+    select_op.wait.op = SELECT_WAIT_ALL;
+    select_op.wait.handles[0] = wine_server_obj_handle( optional_handle );
+    return server_wait( &select_op, offsetof( select_op_t, wait.handles[1] ), flags, NULL, inline_apc );
+}
diff --git a/dlls/ntdll/unix/unix_private.h b/dlls/ntdll/unix/unix_private.h
index fc7ae671314..ea46ff3eb55 100644
--- a/dlls/ntdll/unix/unix_private.h
+++ b/dlls/ntdll/unix/unix_private.h
@@ -275,6 +275,7 @@ extern NTSTATUS get_device_info( int fd, struct _FILE_FS_DEVICE_INFORMATION *inf
 extern void init_files(void) DECLSPEC_HIDDEN;
 extern void init_cpu_info(void) DECLSPEC_HIDDEN;
 extern void add_completion( HANDLE handle, ULONG_PTR value, NTSTATUS status, ULONG info, BOOL async ) DECLSPEC_HIDDEN;
+extern NTSTATUS wait_async_after_apc( HANDLE optional_handle, BOOL alertable, NTSTATUS prev_status, const inline_apc_t *inline_apc );
 
 extern void dbg_init(void) DECLSPEC_HIDDEN;
 
-- 
2.31.1




More information about the wine-devel mailing list