Alexandre Julliard : kernel32: Move interlocked functions to kernelbase.

Alexandre Julliard julliard at winehq.org
Mon Sep 9 16:13:36 CDT 2019


Module: wine
Branch: master
Commit: c683e7e5a1a1bc1846ccf666e44a5869609b230f
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=c683e7e5a1a1bc1846ccf666e44a5869609b230f

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Sun Sep  8 13:17:48 2019 +0200

kernel32: Move interlocked functions to kernelbase.

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/kernel32/kernel32.spec     |  6 +--
 dlls/kernel32/sync.c            | 29 -------------
 dlls/kernelbase/kernelbase.spec | 16 ++++----
 dlls/kernelbase/sync.c          | 90 +++++++++++++++++++++++++++++++++++++++++
 4 files changed, 101 insertions(+), 40 deletions(-)

diff --git a/dlls/kernel32/kernel32.spec b/dlls/kernel32/kernel32.spec
index b562c74..0b0129f 100644
--- a/dlls/kernel32/kernel32.spec
+++ b/dlls/kernel32/kernel32.spec
@@ -940,9 +940,9 @@
 @ stdcall IdnToNameprepUnicode(long wstr long ptr long)
 @ stdcall IdnToUnicode(long wstr long ptr long)
 @ stdcall InitAtomTable(long)
-@ stdcall InitOnceBeginInitialize(ptr long ptr ptr)
-@ stdcall InitOnceComplete(ptr long ptr)
-@ stdcall InitOnceExecuteOnce(ptr ptr ptr ptr)
+@ stdcall InitOnceBeginInitialize(ptr long ptr ptr) kernelbase.InitOnceBeginInitialize
+@ stdcall InitOnceComplete(ptr long ptr) kernelbase.InitOnceComplete
+@ stdcall InitOnceExecuteOnce(ptr ptr ptr ptr) kernelbase.InitOnceExecuteOnce
 @ stdcall InitOnceInitialize(ptr) ntdll.RtlRunOnceInitialize
 @ stdcall InitializeConditionVariable(ptr) ntdll.RtlInitializeConditionVariable
 # @ stub InitializeContext
diff --git a/dlls/kernel32/sync.c b/dlls/kernel32/sync.c
index a510657..9c2d29f 100644
--- a/dlls/kernel32/sync.c
+++ b/dlls/kernel32/sync.c
@@ -1071,35 +1071,6 @@ BOOL WINAPI QueryMemoryResourceNotification(HANDLE handle, PBOOL state)
     return FALSE;
 }
 
-/***********************************************************************
- *           InitOnceBeginInitialize    (KERNEL32.@)
- */
-BOOL WINAPI InitOnceBeginInitialize( INIT_ONCE *once, DWORD flags, BOOL *pending, void **context )
-{
-    NTSTATUS status = RtlRunOnceBeginInitialize( once, flags, context );
-    if (status >= 0) *pending = (status == STATUS_PENDING);
-    else SetLastError( RtlNtStatusToDosError(status) );
-    return status >= 0;
-}
-
-/***********************************************************************
- *           InitOnceComplete    (KERNEL32.@)
- */
-BOOL WINAPI InitOnceComplete( INIT_ONCE *once, DWORD flags, void *context )
-{
-    NTSTATUS status = RtlRunOnceComplete( once, flags, context );
-    if (status != STATUS_SUCCESS) SetLastError( RtlNtStatusToDosError(status) );
-    return !status;
-}
-
-/***********************************************************************
- *           InitOnceExecuteOnce    (KERNEL32.@)
- */
-BOOL WINAPI InitOnceExecuteOnce( INIT_ONCE *once, PINIT_ONCE_FN func, void *param, void **context )
-{
-    return !RtlRunOnceExecuteOnce( once, (PRTL_RUN_ONCE_INIT_FN)func, param, context );
-}
-
 #ifdef __i386__
 
 /***********************************************************************
diff --git a/dlls/kernelbase/kernelbase.spec b/dlls/kernelbase/kernelbase.spec
index 7dff3ed..f554a0f 100644
--- a/dlls/kernelbase/kernelbase.spec
+++ b/dlls/kernelbase/kernelbase.spec
@@ -794,9 +794,9 @@
 @ stdcall ImpersonateNamedPipeClient(long)
 @ stdcall ImpersonateSelf(long)
 # @ stub IncrementPackageStatusVersion
-@ stdcall InitOnceBeginInitialize(ptr long ptr ptr) kernel32.InitOnceBeginInitialize
-@ stdcall InitOnceComplete(ptr long ptr) kernel32.InitOnceComplete
-@ stdcall InitOnceExecuteOnce(ptr ptr ptr ptr) kernel32.InitOnceExecuteOnce
+@ stdcall InitOnceBeginInitialize(ptr long ptr ptr)
+@ stdcall InitOnceComplete(ptr long ptr)
+@ stdcall InitOnceExecuteOnce(ptr ptr ptr ptr)
 @ stdcall InitOnceInitialize(ptr) ntdll.RtlRunOnceInitialize
 @ stdcall InitializeAcl(ptr long long)
 @ stdcall InitializeConditionVariable(ptr) ntdll.RtlInitializeConditionVariable
@@ -813,13 +813,13 @@
 @ stdcall InitializeSid(ptr ptr long)
 # @ stub InitializeSynchronizationBarrier
 # @ stub InstallELAMCertificateInfo
-@ stdcall -arch=i386 InterlockedCompareExchange(ptr long long) kernel32.InterlockedCompareExchange
+@ stdcall -arch=i386 InterlockedCompareExchange(ptr long long)
 @ stdcall -arch=i386 -ret64 InterlockedCompareExchange64(ptr int64 int64) ntdll.RtlInterlockedCompareExchange64
-@ stdcall -arch=i386 InterlockedDecrement(ptr) kernel32.InterlockedDecrement
-@ stdcall -arch=i386 InterlockedExchange(ptr long) kernel32.InterlockedExchange
-@ stdcall -arch=i386 InterlockedExchangeAdd(ptr long ) kernel32.InterlockedExchangeAdd
+@ stdcall -arch=i386 InterlockedDecrement(ptr)
+@ stdcall -arch=i386 InterlockedExchange(ptr long)
+@ stdcall -arch=i386 InterlockedExchangeAdd(ptr long )
 @ stdcall InterlockedFlushSList(ptr) ntdll.RtlInterlockedFlushSList
-@ stdcall -arch=i386 InterlockedIncrement(ptr) kernel32.InterlockedIncrement
+@ stdcall -arch=i386 InterlockedIncrement(ptr)
 @ stdcall InterlockedPopEntrySList(ptr) ntdll.RtlInterlockedPopEntrySList
 @ stdcall InterlockedPushEntrySList(ptr ptr) ntdll.RtlInterlockedPushEntrySList
 @ stdcall -fastcall InterlockedPushListSList(ptr ptr ptr long) ntdll.RtlInterlockedPushListSList
diff --git a/dlls/kernelbase/sync.c b/dlls/kernelbase/sync.c
index 31df6c7..51763c1 100644
--- a/dlls/kernelbase/sync.c
+++ b/dlls/kernelbase/sync.c
@@ -1383,3 +1383,93 @@ BOOL WINAPI DECLSPEC_HOTPATCH WaitNamedPipeW( LPCWSTR name, DWORD timeout )
     NtClose( pipe_dev );
     return set_ntstatus( status );
 }
+
+
+
+/***********************************************************************
+ * Interlocked functions
+ ***********************************************************************/
+
+
+/***********************************************************************
+ *           InitOnceBeginInitialize    (kernelbase.@)
+ */
+BOOL WINAPI DECLSPEC_HOTPATCH InitOnceBeginInitialize( INIT_ONCE *once, DWORD flags,
+                                                       BOOL *pending, void **context )
+{
+    NTSTATUS status = RtlRunOnceBeginInitialize( once, flags, context );
+    if (status >= 0) *pending = (status == STATUS_PENDING);
+    else SetLastError( RtlNtStatusToDosError(status) );
+    return status >= 0;
+}
+
+
+/***********************************************************************
+ *           InitOnceComplete    (kernelbase.@)
+ */
+BOOL WINAPI DECLSPEC_HOTPATCH InitOnceComplete( INIT_ONCE *once, DWORD flags, void *context )
+{
+    return set_ntstatus( RtlRunOnceComplete( once, flags, context ));
+}
+
+
+/***********************************************************************
+ *           InitOnceExecuteOnce    (kernelbase.@)
+ */
+BOOL WINAPI DECLSPEC_HOTPATCH InitOnceExecuteOnce( INIT_ONCE *once, PINIT_ONCE_FN func,
+                                                   void *param, void **context )
+{
+    return !RtlRunOnceExecuteOnce( once, (PRTL_RUN_ONCE_INIT_FN)func, param, context );
+}
+
+#ifdef __i386__
+
+/***********************************************************************
+ *	     InterlockedCompareExchange   (kernelbase.@)
+ */
+__ASM_STDCALL_FUNC(InterlockedCompareExchange, 12,
+                  "movl 12(%esp),%eax\n\t"
+                  "movl 8(%esp),%ecx\n\t"
+                  "movl 4(%esp),%edx\n\t"
+                  "lock; cmpxchgl %ecx,(%edx)\n\t"
+                  "ret $12")
+
+/***********************************************************************
+ *	     InterlockedExchange   (kernelbase.@)
+ */
+__ASM_STDCALL_FUNC(InterlockedExchange, 8,
+                  "movl 8(%esp),%eax\n\t"
+                  "movl 4(%esp),%edx\n\t"
+                  "lock; xchgl %eax,(%edx)\n\t"
+                  "ret $8")
+
+/***********************************************************************
+ *	     InterlockedExchangeAdd   (kernelbase.@)
+ */
+__ASM_STDCALL_FUNC(InterlockedExchangeAdd, 8,
+                  "movl 8(%esp),%eax\n\t"
+                  "movl 4(%esp),%edx\n\t"
+                  "lock; xaddl %eax,(%edx)\n\t"
+                  "ret $8")
+
+/***********************************************************************
+ *	     InterlockedIncrement   (kernelbase.@)
+ */
+__ASM_STDCALL_FUNC(InterlockedIncrement, 4,
+                  "movl 4(%esp),%edx\n\t"
+                  "movl $1,%eax\n\t"
+                  "lock; xaddl %eax,(%edx)\n\t"
+                  "incl %eax\n\t"
+                  "ret $4")
+
+/***********************************************************************
+ *	     InterlockedDecrement   (kernelbase.@)
+ */
+__ASM_STDCALL_FUNC(InterlockedDecrement, 4,
+                  "movl 4(%esp),%edx\n\t"
+                  "movl $-1,%eax\n\t"
+                  "lock; xaddl %eax,(%edx)\n\t"
+                  "decl %eax\n\t"
+                  "ret $4")
+
+#endif  /* __i386__ */




More information about the wine-cvs mailing list