2021-04-30 16:09:47 -07:00
|
|
|
From 4c99070bbd7dd897a6e27bd94e8f50206b3ad49c Mon Sep 17 00:00:00 2001
|
2020-12-08 18:56:56 -08:00
|
|
|
From: Zebediah Figura <z.figura12@gmail.com>
|
|
|
|
Date: Mon, 2 Nov 2020 20:24:07 -0600
|
2020-12-28 10:22:10 -08:00
|
|
|
Subject: [PATCH] ntdll: Reimplement Win32 futexes on top of thread-ID alerts.
|
2020-12-08 18:56:56 -08:00
|
|
|
|
|
|
|
Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
|
|
|
|
---
|
2021-04-30 16:09:47 -07:00
|
|
|
dlls/ntdll/sync.c | 158 +++++++++++++++++++++++++++++++++++++-
|
2020-12-08 18:56:56 -08:00
|
|
|
dlls/ntdll/unix/loader.c | 3 -
|
2021-04-30 16:09:47 -07:00
|
|
|
dlls/ntdll/unix/sync.c | 162 ---------------------------------------
|
2021-02-27 15:16:06 -08:00
|
|
|
dlls/ntdll/unixlib.h | 6 +-
|
2021-04-30 16:09:47 -07:00
|
|
|
4 files changed, 156 insertions(+), 173 deletions(-)
|
2020-12-08 18:56:56 -08:00
|
|
|
|
|
|
|
diff --git a/dlls/ntdll/sync.c b/dlls/ntdll/sync.c
|
2021-04-30 16:09:47 -07:00
|
|
|
index f1263ae33fd..348f260c3b0 100644
|
2020-12-08 18:56:56 -08:00
|
|
|
--- a/dlls/ntdll/sync.c
|
|
|
|
+++ b/dlls/ntdll/sync.c
|
2021-02-27 15:16:06 -08:00
|
|
|
@@ -36,6 +36,13 @@
|
2020-12-08 18:56:56 -08:00
|
|
|
#include "wine/debug.h"
|
|
|
|
#include "ntdll_misc.h"
|
|
|
|
|
|
|
|
+WINE_DEFAULT_DEBUG_CHANNEL(sync);
|
|
|
|
+
|
|
|
|
+static const char *debugstr_timeout( const LARGE_INTEGER *timeout )
|
|
|
|
+{
|
|
|
|
+ if (!timeout) return "(infinite)";
|
|
|
|
+ return wine_dbgstr_longlong( timeout->QuadPart );
|
|
|
|
+}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* RtlRunOnceInitialize (NTDLL.@)
|
2021-04-30 16:09:47 -07:00
|
|
|
@@ -530,13 +537,111 @@ NTSTATUS WINAPI RtlSleepConditionVariableSRW( RTL_CONDITION_VARIABLE *variable,
|
2020-12-08 18:56:56 -08:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2020-12-28 10:22:10 -08:00
|
|
|
+
|
2021-04-30 16:09:47 -07:00
|
|
|
+#define FUTEX_ADDR_BLOCK_SIZE (65536 / sizeof(void *))
|
|
|
|
+static void **futex_addr_blocks[4096];
|
2020-12-28 10:22:10 -08:00
|
|
|
+
|
2021-04-30 16:09:47 -07:00
|
|
|
+static unsigned int tid_to_index( DWORD tid, unsigned int *block_idx )
|
2020-12-28 10:22:10 -08:00
|
|
|
+{
|
2021-04-30 16:09:47 -07:00
|
|
|
+ unsigned int idx = (tid >> 2) - 1;
|
|
|
|
+ *block_idx = idx / FUTEX_ADDR_BLOCK_SIZE;
|
|
|
|
+ return idx % FUTEX_ADDR_BLOCK_SIZE;
|
|
|
|
+}
|
2020-12-28 10:22:10 -08:00
|
|
|
+
|
2021-04-30 16:09:47 -07:00
|
|
|
+static HANDLE index_to_tid( unsigned int block_idx, unsigned int idx )
|
|
|
|
+{
|
|
|
|
+ return (HANDLE)((((block_idx * FUTEX_ADDR_BLOCK_SIZE) + idx) + 1) << 2);
|
|
|
|
+}
|
2020-12-28 10:22:10 -08:00
|
|
|
+
|
2021-04-30 16:09:47 -07:00
|
|
|
+static void **get_futex_entry( DWORD tid )
|
2020-12-28 10:22:10 -08:00
|
|
|
+{
|
2021-04-30 16:09:47 -07:00
|
|
|
+ unsigned int block_idx, idx = tid_to_index( tid, &block_idx );
|
2020-12-28 10:22:10 -08:00
|
|
|
+
|
2021-04-30 16:09:47 -07:00
|
|
|
+ if (block_idx > ARRAY_SIZE(futex_addr_blocks))
|
2020-12-28 10:22:10 -08:00
|
|
|
+ {
|
2021-04-30 16:09:47 -07:00
|
|
|
+ FIXME( "tid %#x is too high\n", tid );
|
|
|
|
+ return NULL;
|
|
|
|
+ }
|
2020-12-28 10:22:10 -08:00
|
|
|
+
|
2021-04-30 16:09:47 -07:00
|
|
|
+ if (!futex_addr_blocks[block_idx])
|
|
|
|
+ {
|
|
|
|
+ SIZE_T size = FUTEX_ADDR_BLOCK_SIZE * sizeof(void *);
|
|
|
|
+ void *ptr = NULL;
|
2020-12-28 10:22:10 -08:00
|
|
|
+
|
2021-04-30 16:09:47 -07:00
|
|
|
+ if (NtAllocateVirtualMemory( NtCurrentProcess(), &ptr, 0, &size, MEM_COMMIT, PAGE_READWRITE ))
|
2020-12-28 10:22:10 -08:00
|
|
|
+ return NULL;
|
2021-04-30 16:09:47 -07:00
|
|
|
+ if (InterlockedCompareExchangePointer( (void **)&futex_addr_blocks[block_idx], ptr, NULL ))
|
|
|
|
+ NtFreeVirtualMemory( NtCurrentProcess(), &ptr, &size, MEM_RELEASE ); /* someone beat us to it */
|
2020-12-28 10:22:10 -08:00
|
|
|
+ }
|
|
|
|
+
|
2021-04-30 16:09:47 -07:00
|
|
|
+ return &futex_addr_blocks[block_idx][idx % FUTEX_ADDR_BLOCK_SIZE];
|
2020-12-28 10:36:15 -08:00
|
|
|
+}
|
|
|
|
+
|
2020-12-08 18:56:56 -08:00
|
|
|
+static BOOL compare_addr( const void *addr, const void *cmp, SIZE_T size )
|
|
|
|
+{
|
|
|
|
+ switch (size)
|
|
|
|
+ {
|
|
|
|
+ case 1:
|
|
|
|
+ return (*(const UCHAR *)addr == *(const UCHAR *)cmp);
|
|
|
|
+ case 2:
|
|
|
|
+ return (*(const USHORT *)addr == *(const USHORT *)cmp);
|
|
|
|
+ case 4:
|
|
|
|
+ return (*(const ULONG *)addr == *(const ULONG *)cmp);
|
|
|
|
+ case 8:
|
|
|
|
+ return (*(const ULONG64 *)addr == *(const ULONG64 *)cmp);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return FALSE;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
/***********************************************************************
|
|
|
|
* RtlWaitOnAddress (NTDLL.@)
|
|
|
|
*/
|
|
|
|
NTSTATUS WINAPI RtlWaitOnAddress( const void *addr, const void *cmp, SIZE_T size,
|
|
|
|
const LARGE_INTEGER *timeout )
|
|
|
|
{
|
|
|
|
- return unix_funcs->RtlWaitOnAddress( addr, cmp, size, timeout );
|
2021-04-30 16:09:47 -07:00
|
|
|
+ void **entry = get_futex_entry( GetCurrentThreadId() );
|
2020-12-08 18:56:56 -08:00
|
|
|
+ NTSTATUS ret;
|
|
|
|
+
|
|
|
|
+ TRACE("addr %p cmp %p size %#Ix timeout %s\n", addr, cmp, size, debugstr_timeout( timeout ));
|
|
|
|
+
|
|
|
|
+ if (size != 1 && size != 2 && size != 4 && size != 8)
|
|
|
|
+ return STATUS_INVALID_PARAMETER;
|
|
|
|
+
|
2021-04-30 16:09:47 -07:00
|
|
|
+ if (!entry) return STATUS_NO_MEMORY;
|
2020-12-28 10:22:10 -08:00
|
|
|
+
|
2021-04-30 16:09:47 -07:00
|
|
|
+ InterlockedExchangePointer( entry, (void *)addr );
|
2020-12-08 18:56:56 -08:00
|
|
|
+
|
2021-01-21 21:32:19 -08:00
|
|
|
+ /* Ensure that the compare-and-swap above is ordered before the comparison
|
|
|
|
+ * below. This barrier is paired with another in RtlWakeByAddress*().
|
|
|
|
+ *
|
|
|
|
+ * In more detail, given the following sequence:
|
|
|
|
+ *
|
|
|
|
+ * Thread A Thread B
|
|
|
|
+ * -----------------------------------------------------------------
|
|
|
|
+ * RtlWaitOnAddress( &val ); val = 1;
|
|
|
|
+ * queue thread RtlWakeByAddress( &val );
|
|
|
|
+ * MemoryBarrier(); <---- paired with ----> MemoryBarrier();
|
|
|
|
+ * compare_addr( &val ); if (thread is queued)
|
|
|
|
+ *
|
|
|
|
+ * We must ensure that the thread is queued [through the above
|
|
|
|
+ * InterlockedExchangePointer()] before reading "val", and that writes to
|
|
|
|
+ * "val" by the application happen before we check for queued threads.
|
|
|
|
+ * Otherwise, thread A can deadlock: "val" may appear unchanged, while
|
|
|
|
+ * thread B observed that thread A was not queued.
|
|
|
|
+ */
|
|
|
|
+ MemoryBarrier();
|
|
|
|
+
|
2020-12-08 18:56:56 -08:00
|
|
|
+ if (!compare_addr( addr, cmp, size ))
|
|
|
|
+ {
|
2021-04-30 16:09:47 -07:00
|
|
|
+ InterlockedExchangePointer( entry, NULL );
|
2020-12-08 18:56:56 -08:00
|
|
|
+ return STATUS_SUCCESS;
|
|
|
|
+ }
|
|
|
|
+
|
2020-12-28 10:22:10 -08:00
|
|
|
+ ret = NtWaitForAlertByThreadId( NULL, timeout );
|
2021-04-30 16:09:47 -07:00
|
|
|
+ InterlockedExchangePointer( entry, NULL );
|
2020-12-08 18:56:56 -08:00
|
|
|
+ if (ret == STATUS_ALERTED) ret = STATUS_SUCCESS;
|
|
|
|
+ return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2021-04-30 16:09:47 -07:00
|
|
|
@@ -544,7 +649,29 @@ NTSTATUS WINAPI RtlWaitOnAddress( const void *addr, const void *cmp, SIZE_T size
|
2020-12-08 18:56:56 -08:00
|
|
|
*/
|
|
|
|
void WINAPI RtlWakeAddressAll( const void *addr )
|
|
|
|
{
|
|
|
|
- return unix_funcs->RtlWakeAddressAll( addr );
|
2021-04-30 16:09:47 -07:00
|
|
|
+ unsigned int i, j;
|
|
|
|
+ void **block;
|
2020-12-08 18:56:56 -08:00
|
|
|
+
|
|
|
|
+ TRACE("%p\n", addr);
|
|
|
|
+
|
|
|
|
+ if (!addr) return;
|
|
|
|
+
|
2021-01-21 21:32:19 -08:00
|
|
|
+ /* Ensure that memory stores to "addr" are ordered before reading the
|
|
|
|
+ * array below. Paired with another barrier in RtlWaitOnAddress() [q.v.].
|
|
|
|
+ */
|
|
|
|
+ MemoryBarrier();
|
|
|
|
+
|
2021-04-30 16:09:47 -07:00
|
|
|
+ for (i = 0; i < ARRAY_SIZE(futex_addr_blocks); ++i)
|
2020-12-08 18:56:56 -08:00
|
|
|
+ {
|
2021-04-30 16:09:47 -07:00
|
|
|
+ block = futex_addr_blocks[i];
|
|
|
|
+ if (!block) continue;
|
|
|
|
+
|
|
|
|
+ for (j = 0; j < FUTEX_ADDR_BLOCK_SIZE; ++j)
|
2020-12-28 10:22:10 -08:00
|
|
|
+ {
|
2021-04-30 16:09:47 -07:00
|
|
|
+ if (block[j] == addr)
|
|
|
|
+ NtAlertThreadByThreadId( index_to_tid( i, j ) );
|
2020-12-28 10:22:10 -08:00
|
|
|
+ }
|
2020-12-08 18:56:56 -08:00
|
|
|
+ }
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2021-04-30 16:09:47 -07:00
|
|
|
@@ -552,5 +679,30 @@ void WINAPI RtlWakeAddressAll( const void *addr )
|
2020-12-08 18:56:56 -08:00
|
|
|
*/
|
|
|
|
void WINAPI RtlWakeAddressSingle( const void *addr )
|
|
|
|
{
|
|
|
|
- return unix_funcs->RtlWakeAddressSingle( addr );
|
2021-04-30 16:09:47 -07:00
|
|
|
+ unsigned int i, j;
|
|
|
|
+ void **block;
|
2020-12-08 18:56:56 -08:00
|
|
|
+
|
|
|
|
+ TRACE("%p\n", addr);
|
|
|
|
+
|
|
|
|
+ if (!addr) return;
|
|
|
|
+
|
2021-01-21 21:32:19 -08:00
|
|
|
+ /* Ensure that memory stores to "addr" are ordered before reading the
|
|
|
|
+ * array below. Paired with another barrier in RtlWaitOnAddress() [q.v.].
|
|
|
|
+ */
|
|
|
|
+ MemoryBarrier();
|
|
|
|
+
|
2021-04-30 16:09:47 -07:00
|
|
|
+ for (i = 0; i < ARRAY_SIZE(futex_addr_blocks); ++i)
|
2020-12-08 18:56:56 -08:00
|
|
|
+ {
|
2021-04-30 16:09:47 -07:00
|
|
|
+ block = futex_addr_blocks[i];
|
|
|
|
+ if (!block) continue;
|
|
|
|
+
|
|
|
|
+ for (j = 0; j < FUTEX_ADDR_BLOCK_SIZE; ++j)
|
2020-12-08 18:56:56 -08:00
|
|
|
+ {
|
2021-04-30 16:09:47 -07:00
|
|
|
+ if (block[j] == addr && InterlockedCompareExchangePointer( &block[j], NULL, (void *)addr ) == addr)
|
2020-12-28 10:22:10 -08:00
|
|
|
+ {
|
2021-04-30 16:09:47 -07:00
|
|
|
+ NtAlertThreadByThreadId( index_to_tid( i, j ) );
|
2020-12-28 10:22:10 -08:00
|
|
|
+ return;
|
|
|
|
+ }
|
2020-12-08 18:56:56 -08:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c
|
2021-04-30 16:09:47 -07:00
|
|
|
index e4c062cea98..3a4a943c65f 100644
|
2020-12-08 18:56:56 -08:00
|
|
|
--- a/dlls/ntdll/unix/loader.c
|
|
|
|
+++ b/dlls/ntdll/unix/loader.c
|
2021-04-30 16:09:47 -07:00
|
|
|
@@ -1816,9 +1816,6 @@ static struct unix_funcs unix_funcs =
|
2021-01-21 15:44:50 -08:00
|
|
|
#endif
|
2020-12-08 18:56:56 -08:00
|
|
|
DbgUiIssueRemoteBreakin,
|
|
|
|
RtlGetSystemTimePrecise,
|
|
|
|
- RtlWaitOnAddress,
|
|
|
|
- RtlWakeAddressAll,
|
|
|
|
- RtlWakeAddressSingle,
|
|
|
|
fast_RtlpWaitForCriticalSection,
|
|
|
|
fast_RtlpUnWaitCriticalSection,
|
|
|
|
fast_RtlDeleteCriticalSection,
|
|
|
|
diff --git a/dlls/ntdll/unix/sync.c b/dlls/ntdll/unix/sync.c
|
2021-04-30 16:09:47 -07:00
|
|
|
index 4fa890e5acc..8394a1b8601 100644
|
2020-12-08 18:56:56 -08:00
|
|
|
--- a/dlls/ntdll/unix/sync.c
|
|
|
|
+++ b/dlls/ntdll/unix/sync.c
|
2021-04-30 16:09:47 -07:00
|
|
|
@@ -80,10 +80,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(sync);
|
2020-12-08 18:56:56 -08:00
|
|
|
|
|
|
|
HANDLE keyed_event = 0;
|
|
|
|
|
|
|
|
-static const LARGE_INTEGER zero_timeout;
|
|
|
|
-
|
|
|
|
-static pthread_mutex_t addr_mutex = PTHREAD_MUTEX_INITIALIZER;
|
|
|
|
-
|
|
|
|
static const char *debugstr_timeout( const LARGE_INTEGER *timeout )
|
|
|
|
{
|
|
|
|
if (!timeout) return "(infinite)";
|
2021-04-30 16:09:47 -07:00
|
|
|
@@ -193,24 +189,6 @@ static void timespec_from_timeout( struct timespec *timespec, const LARGE_INTEGE
|
2020-12-08 18:56:56 -08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
-static BOOL compare_addr( const void *addr, const void *cmp, SIZE_T size )
|
|
|
|
-{
|
|
|
|
- switch (size)
|
|
|
|
- {
|
|
|
|
- case 1:
|
|
|
|
- return (*(const UCHAR *)addr == *(const UCHAR *)cmp);
|
|
|
|
- case 2:
|
|
|
|
- return (*(const USHORT *)addr == *(const USHORT *)cmp);
|
|
|
|
- case 4:
|
|
|
|
- return (*(const ULONG *)addr == *(const ULONG *)cmp);
|
|
|
|
- case 8:
|
|
|
|
- return (*(const ULONG64 *)addr == *(const ULONG64 *)cmp);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return FALSE;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-
|
|
|
|
/* create a struct security_descriptor and contained information in one contiguous piece of memory */
|
|
|
|
NTSTATUS alloc_object_attributes( const OBJECT_ATTRIBUTES *attr, struct object_attributes **ret,
|
|
|
|
data_size_t *ret_len )
|
2021-04-30 16:09:47 -07:00
|
|
|
@@ -2911,71 +2889,6 @@ NTSTATUS CDECL fast_RtlWakeConditionVariable( RTL_CONDITION_VARIABLE *variable,
|
2020-12-08 18:56:56 -08:00
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
-/* We can't map addresses to futex directly, because an application can wait on
|
|
|
|
- * 8 bytes, and we can't pass all 8 as the compare value to futex(). Instead we
|
|
|
|
- * map all addresses to a small fixed table of futexes. This may result in
|
|
|
|
- * spurious wakes, but the application is already expected to handle those. */
|
|
|
|
-
|
|
|
|
-static int addr_futex_table[256];
|
|
|
|
-
|
|
|
|
-static inline int *hash_addr( const void *addr )
|
|
|
|
-{
|
|
|
|
- ULONG_PTR val = (ULONG_PTR)addr;
|
|
|
|
-
|
|
|
|
- return &addr_futex_table[(val >> 2) & 255];
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-static inline NTSTATUS fast_wait_addr( const void *addr, const void *cmp, SIZE_T size,
|
|
|
|
- const LARGE_INTEGER *timeout )
|
|
|
|
-{
|
|
|
|
- int *futex;
|
|
|
|
- int val;
|
|
|
|
- struct timespec timespec;
|
|
|
|
- int ret;
|
|
|
|
-
|
|
|
|
- if (!use_futexes())
|
|
|
|
- return STATUS_NOT_IMPLEMENTED;
|
|
|
|
-
|
|
|
|
- futex = hash_addr( addr );
|
|
|
|
-
|
|
|
|
- /* We must read the previous value of the futex before checking the value
|
|
|
|
- * of the address being waited on. That way, if we receive a wake between
|
|
|
|
- * now and waiting on the futex, we know that val will have changed.
|
|
|
|
- * Use an atomic load so that memory accesses are ordered between this read
|
|
|
|
- * and the increment below. */
|
|
|
|
- val = InterlockedCompareExchange( futex, 0, 0 );
|
|
|
|
- if (!compare_addr( addr, cmp, size ))
|
|
|
|
- return STATUS_SUCCESS;
|
|
|
|
-
|
|
|
|
- if (timeout)
|
|
|
|
- {
|
|
|
|
- timespec_from_timeout( ×pec, timeout );
|
|
|
|
- ret = futex_wait( futex, val, ×pec );
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- ret = futex_wait( futex, val, NULL );
|
|
|
|
-
|
|
|
|
- if (ret == -1 && errno == ETIMEDOUT)
|
|
|
|
- return STATUS_TIMEOUT;
|
|
|
|
- return STATUS_SUCCESS;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-static inline NTSTATUS fast_wake_addr( const void *addr )
|
|
|
|
-{
|
|
|
|
- int *futex;
|
|
|
|
-
|
|
|
|
- if (!use_futexes())
|
|
|
|
- return STATUS_NOT_IMPLEMENTED;
|
|
|
|
-
|
|
|
|
- futex = hash_addr( addr );
|
|
|
|
-
|
|
|
|
- InterlockedIncrement( futex );
|
|
|
|
-
|
|
|
|
- futex_wake( futex, INT_MAX );
|
|
|
|
- return STATUS_SUCCESS;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
#else
|
|
|
|
|
|
|
|
NTSTATUS CDECL fast_RtlTryAcquireSRWLockExclusive( RTL_SRWLOCK *lock )
|
2021-04-30 16:09:47 -07:00
|
|
|
@@ -3018,79 +2931,4 @@ NTSTATUS CDECL fast_wait_cv( RTL_CONDITION_VARIABLE *variable, const void *value
|
2020-12-08 18:56:56 -08:00
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
-static inline NTSTATUS fast_wait_addr( const void *addr, const void *cmp, SIZE_T size,
|
|
|
|
- const LARGE_INTEGER *timeout )
|
|
|
|
-{
|
|
|
|
- return STATUS_NOT_IMPLEMENTED;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-static inline NTSTATUS fast_wake_addr( const void *addr )
|
|
|
|
-{
|
|
|
|
- return STATUS_NOT_IMPLEMENTED;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
#endif
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-/***********************************************************************
|
|
|
|
- * RtlWaitOnAddress (NTDLL.@)
|
|
|
|
- */
|
|
|
|
-NTSTATUS WINAPI RtlWaitOnAddress( const void *addr, const void *cmp, SIZE_T size,
|
|
|
|
- const LARGE_INTEGER *timeout )
|
|
|
|
-{
|
|
|
|
- select_op_t select_op;
|
|
|
|
- NTSTATUS ret;
|
|
|
|
- timeout_t abs_timeout = timeout ? timeout->QuadPart : TIMEOUT_INFINITE;
|
|
|
|
-
|
|
|
|
- if (size != 1 && size != 2 && size != 4 && size != 8)
|
|
|
|
- return STATUS_INVALID_PARAMETER;
|
|
|
|
-
|
|
|
|
- if ((ret = fast_wait_addr( addr, cmp, size, timeout )) != STATUS_NOT_IMPLEMENTED)
|
|
|
|
- return ret;
|
|
|
|
-
|
|
|
|
- mutex_lock( &addr_mutex );
|
|
|
|
- if (!compare_addr( addr, cmp, size ))
|
|
|
|
- {
|
|
|
|
- mutex_unlock( &addr_mutex );
|
|
|
|
- return STATUS_SUCCESS;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (abs_timeout < 0)
|
|
|
|
- {
|
|
|
|
- LARGE_INTEGER now;
|
|
|
|
-
|
|
|
|
- NtQueryPerformanceCounter( &now, NULL );
|
|
|
|
- abs_timeout -= now.QuadPart;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- select_op.keyed_event.op = SELECT_KEYED_EVENT_WAIT;
|
|
|
|
- select_op.keyed_event.handle = wine_server_obj_handle( keyed_event );
|
|
|
|
- select_op.keyed_event.key = wine_server_client_ptr( addr );
|
|
|
|
-
|
|
|
|
- return server_select( &select_op, sizeof(select_op.keyed_event), SELECT_INTERRUPTIBLE,
|
|
|
|
- abs_timeout, NULL, &addr_mutex, NULL );
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-/***********************************************************************
|
|
|
|
- * RtlWakeAddressAll (NTDLL.@)
|
|
|
|
- */
|
|
|
|
-void WINAPI RtlWakeAddressAll( const void *addr )
|
|
|
|
-{
|
|
|
|
- if (fast_wake_addr( addr ) != STATUS_NOT_IMPLEMENTED) return;
|
|
|
|
-
|
|
|
|
- mutex_lock( &addr_mutex );
|
|
|
|
- while (NtReleaseKeyedEvent( 0, addr, 0, &zero_timeout ) == STATUS_SUCCESS) {}
|
|
|
|
- mutex_unlock( &addr_mutex );
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-/***********************************************************************
|
|
|
|
- * RtlWakeAddressSingle (NTDLL.@)
|
|
|
|
- */
|
|
|
|
-void WINAPI RtlWakeAddressSingle( const void *addr )
|
|
|
|
-{
|
|
|
|
- if (fast_wake_addr( addr ) != STATUS_NOT_IMPLEMENTED) return;
|
|
|
|
-
|
|
|
|
- mutex_lock( &addr_mutex );
|
|
|
|
- NtReleaseKeyedEvent( 0, addr, 0, &zero_timeout );
|
|
|
|
- mutex_unlock( &addr_mutex );
|
|
|
|
-}
|
|
|
|
diff --git a/dlls/ntdll/unixlib.h b/dlls/ntdll/unixlib.h
|
2021-03-30 15:06:03 -07:00
|
|
|
index 04ae8230b1a..21e34842778 100644
|
2020-12-08 18:56:56 -08:00
|
|
|
--- a/dlls/ntdll/unixlib.h
|
|
|
|
+++ b/dlls/ntdll/unixlib.h
|
2021-03-30 15:06:03 -07:00
|
|
|
@@ -26,7 +26,7 @@
|
|
|
|
struct _DISPATCHER_CONTEXT;
|
2021-02-27 15:16:06 -08:00
|
|
|
|
|
|
|
/* increment this when you change the function table */
|
2021-03-30 15:06:03 -07:00
|
|
|
-#define NTDLL_UNIXLIB_VERSION 120
|
|
|
|
+#define NTDLL_UNIXLIB_VERSION 121
|
2021-02-27 15:16:06 -08:00
|
|
|
|
|
|
|
struct unix_funcs
|
|
|
|
{
|
2021-03-30 15:06:03 -07:00
|
|
|
@@ -38,10 +38,6 @@ struct unix_funcs
|
2020-12-08 18:56:56 -08:00
|
|
|
/* other Win32 API functions */
|
|
|
|
NTSTATUS (WINAPI *DbgUiIssueRemoteBreakin)( HANDLE process );
|
|
|
|
LONGLONG (WINAPI *RtlGetSystemTimePrecise)(void);
|
|
|
|
- NTSTATUS (WINAPI *RtlWaitOnAddress)( const void *addr, const void *cmp, SIZE_T size,
|
|
|
|
- const LARGE_INTEGER *timeout );
|
|
|
|
- void (WINAPI *RtlWakeAddressAll)( const void *addr );
|
|
|
|
- void (WINAPI *RtlWakeAddressSingle)( const void *addr );
|
|
|
|
|
|
|
|
/* fast locks */
|
|
|
|
NTSTATUS (CDECL *fast_RtlpWaitForCriticalSection)( RTL_CRITICAL_SECTION *crit, int timeout );
|
|
|
|
--
|
2021-03-27 08:31:02 -07:00
|
|
|
2.30.2
|
2020-12-08 18:56:56 -08:00
|
|
|
|