Alexandre Julliard : kernel32: Implement the InitOnce functions.

Alexandre Julliard julliard at winehq.org
Thu Aug 29 13:18:14 CDT 2013


Module: wine
Branch: master
Commit: 1992f5005c9765bbf648ac884c8a7f9bfdaa929d
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=1992f5005c9765bbf648ac884c8a7f9bfdaa929d

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Wed Aug 28 21:11:00 2013 +0200

kernel32: Implement the InitOnce functions.

---

 dlls/kernel32/kernel32.spec |    7 +++++--
 dlls/kernel32/sync.c        |   29 +++++++++++++++++++++++++++++
 dlls/kernel32/tests/sync.c  |    2 +-
 3 files changed, 35 insertions(+), 3 deletions(-)

diff --git a/dlls/kernel32/kernel32.spec b/dlls/kernel32/kernel32.spec
index c9a4b5d..c0eda71 100644
--- a/dlls/kernel32/kernel32.spec
+++ b/dlls/kernel32/kernel32.spec
@@ -745,12 +745,15 @@
 @ stdcall IdnToNameprepUnicode(long wstr long ptr long)
 @ stdcall IdnToUnicode(long wstr long ptr long)
 @ stdcall InitAtomTable(long)
-@ stdcall InitializeSRWLock(ptr)
+@ stdcall InitOnceBeginInitialize(ptr long ptr ptr)
+@ stdcall InitOnceComplete(ptr long ptr)
+@ stdcall InitOnceExecuteOnce(ptr ptr ptr ptr)
+@ stdcall InitOnceInitialize(ptr) ntdll.RtlRunOnceInitialize
 @ stdcall InitializeCriticalSection(ptr)
 @ stdcall InitializeCriticalSectionAndSpinCount(ptr long)
 @ stdcall InitializeCriticalSectionEx(ptr long long)
 @ stdcall InitializeSListHead(ptr) ntdll.RtlInitializeSListHead
-@ stdcall InitOnceInitialize(ptr) ntdll.RtlRunOnceInitialize
+@ stdcall InitializeSRWLock(ptr)
 @ stdcall -arch=i386 InterlockedCompareExchange (ptr long long)
 @ stdcall -arch=i386 -ret64 InterlockedCompareExchange64(ptr int64 int64) ntdll.RtlInterlockedCompareExchange64
 @ stdcall -arch=i386 InterlockedDecrement(ptr)
diff --git a/dlls/kernel32/sync.c b/dlls/kernel32/sync.c
index a8133d4..5cb8e3f 100644
--- a/dlls/kernel32/sync.c
+++ b/dlls/kernel32/sync.c
@@ -2237,6 +2237,35 @@ 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/kernel32/tests/sync.c b/dlls/kernel32/tests/sync.c
index 4cbb132..a040c59 100644
--- a/dlls/kernel32/tests/sync.c
+++ b/dlls/kernel32/tests/sync.c
@@ -1164,7 +1164,7 @@ static void test_initonce(void)
 
     if (!pInitOnceInitialize || !pInitOnceExecuteOnce)
     {
-        todo_wine win_skip("one-time initialization API not supported\n");
+        win_skip("one-time initialization API not supported\n");
         return;
     }
 




More information about the wine-cvs mailing list