Nikolay Sivov : kernel32: Added InitOnceInitialize() implementation.
Alexandre Julliard
julliard at winehq.org
Mon Jul 23 13:54:23 CDT 2012
Module: wine
Branch: master
Commit: b1c3c8c898669a1d1c0b927a158116ce2172e5f9
URL: http://source.winehq.org/git/wine.git/?a=commit;h=b1c3c8c898669a1d1c0b927a158116ce2172e5f9
Author: Nikolay Sivov <nsivov at codeweavers.com>
Date: Sun Jul 22 18:33:14 2012 +0400
kernel32: Added InitOnceInitialize() implementation.
---
dlls/kernel32/kernel32.spec | 1 +
dlls/kernel32/tests/sync.c | 18 ++++++++++++++++++
dlls/ntdll/ntdll.spec | 1 +
dlls/ntdll/sync.c | 5 +++++
include/winbase.h | 7 +++++++
include/winnt.h | 7 +++++++
6 files changed, 39 insertions(+), 0 deletions(-)
diff --git a/dlls/kernel32/kernel32.spec b/dlls/kernel32/kernel32.spec
index 5906ca3..a916309 100644
--- a/dlls/kernel32/kernel32.spec
+++ b/dlls/kernel32/kernel32.spec
@@ -747,6 +747,7 @@
@ stdcall InitializeCriticalSectionAndSpinCount(ptr long)
@ stdcall InitializeCriticalSectionEx(ptr long long)
@ stdcall InitializeSListHead(ptr) ntdll.RtlInitializeSListHead
+@ stdcall InitOnceInitialize(ptr) ntdll.RtlRunOnceInitialize
@ 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/tests/sync.c b/dlls/kernel32/tests/sync.c
index 4068b22..ccb21bb 100644
--- a/dlls/kernel32/tests/sync.c
+++ b/dlls/kernel32/tests/sync.c
@@ -37,6 +37,7 @@ static BOOL (WINAPI *pDeleteTimerQueueTimer)(HANDLE, HANDLE, HANDLE);
static HANDLE (WINAPI *pOpenWaitableTimerA)(DWORD,BOOL,LPCSTR);
static HANDLE (WINAPI *pCreateMemoryResourceNotification)(MEMORY_RESOURCE_NOTIFICATION_TYPE);
static BOOL (WINAPI *pQueryMemoryResourceNotification)(HANDLE, PBOOL);
+static VOID (WINAPI *pInitOnceInitialize)(PINIT_ONCE);
static void test_signalandwait(void)
{
@@ -1135,6 +1136,21 @@ static void test_WaitForMultipleObjects(void)
if (maxevents[i]) CloseHandle(maxevents[i]);
}
+static void test_initonce(void)
+{
+ INIT_ONCE initonce;
+
+ if (!pInitOnceInitialize)
+ {
+ win_skip("one-time initialization API not supported\n");
+ return;
+ }
+
+ initonce.Ptr = (void*)0xdeadbeef;
+ pInitOnceInitialize(&initonce);
+ ok(initonce.Ptr == NULL, "got %p\n", initonce.Ptr);
+}
+
START_TEST(sync)
{
HMODULE hdll = GetModuleHandle("kernel32");
@@ -1147,6 +1163,7 @@ START_TEST(sync)
pOpenWaitableTimerA = (void*)GetProcAddress(hdll, "OpenWaitableTimerA");
pCreateMemoryResourceNotification = (void *)GetProcAddress(hdll, "CreateMemoryResourceNotification");
pQueryMemoryResourceNotification = (void *)GetProcAddress(hdll, "QueryMemoryResourceNotification");
+ pInitOnceInitialize = (void *)GetProcAddress(hdll, "InitOnceInitialize");
test_signalandwait();
test_mutex();
@@ -1158,4 +1175,5 @@ START_TEST(sync)
test_timer_queue();
test_WaitForSingleObject();
test_WaitForMultipleObjects();
+ test_initonce();
}
diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec
index 8de353f..4ace865 100644
--- a/dlls/ntdll/ntdll.spec
+++ b/dlls/ntdll/ntdll.spec
@@ -815,6 +815,7 @@
@ stub RtlRevertMemoryStream
@ stub RtlRunDecodeUnicodeString
@ stub RtlRunEncodeUnicodeString
+@ stdcall RtlRunOnceInitialize(ptr)
@ stdcall RtlSecondsSince1970ToTime(long ptr)
@ stdcall RtlSecondsSince1980ToTime(long ptr)
# @ stub RtlSeekMemoryStream
diff --git a/dlls/ntdll/sync.c b/dlls/ntdll/sync.c
index f759ce6..09151a9 100644
--- a/dlls/ntdll/sync.c
+++ b/dlls/ntdll/sync.c
@@ -1463,3 +1463,8 @@ NTSTATUS NTDLL_AddCompletion( HANDLE hFile, ULONG_PTR CompletionValue,
SERVER_END_REQ;
return status;
}
+
+VOID NTAPI RtlRunOnceInitialize(PRTL_RUN_ONCE initonce)
+{
+ initonce->Ptr = NULL;
+}
diff --git a/include/winbase.h b/include/winbase.h
index 8b5805c..532dbcd 100644
--- a/include/winbase.h
+++ b/include/winbase.h
@@ -1316,6 +1316,12 @@ typedef struct _WIN32_STREAM_ID {
#define LOGON_NETCREDENTIALS_ONLY 0x00000002
#define LOGON_ZERO_PASSWORD_BUFFER 0x80000000
+/* one-time initialisation API */
+typedef RTL_RUN_ONCE INIT_ONCE;
+typedef PRTL_RUN_ONCE PINIT_ONCE;
+typedef PRTL_RUN_ONCE LPINIT_ONCE;
+#define INIT_ONCE_STATIC_INIT RTL_RUN_ONCE_INIT
+
WINBASEAPI BOOL WINAPI ActivateActCtx(HANDLE,ULONG_PTR *);
WINADVAPI BOOL WINAPI AddAccessAllowedAce(PACL,DWORD,DWORD,PSID);
WINADVAPI BOOL WINAPI AddAccessAllowedAceEx(PACL,DWORD,DWORD,DWORD,PSID);
@@ -1876,6 +1882,7 @@ WINADVAPI BOOL WINAPI InitializeSecurityDescriptor(PSECURITY_DESCRIPTOR,
WINADVAPI BOOL WINAPI InitializeSid(PSID,PSID_IDENTIFIER_AUTHORITY,BYTE);
WINBASEAPI VOID WINAPI InitializeSListHead(PSLIST_HEADER);
WINBASEAPI VOID WINAPI InitializeSRWLock(PSRWLOCK);
+WINBASEAPI VOID WINAPI InitOnceInitialize(PINIT_ONCE);
WINBASEAPI PSLIST_ENTRY WINAPI InterlockedFlushSList(PSLIST_HEADER);
WINBASEAPI PSLIST_ENTRY WINAPI InterlockedPopEntrySList(PSLIST_HEADER);
WINBASEAPI PSLIST_ENTRY WINAPI InterlockedPushEntrySList(PSLIST_HEADER, PSLIST_ENTRY);
diff --git a/include/winnt.h b/include/winnt.h
index 16cc4e9..d65e2f6 100644
--- a/include/winnt.h
+++ b/include/winnt.h
@@ -5087,6 +5087,13 @@ typedef struct _RTL_SRWLOCK {
typedef VOID (NTAPI * WAITORTIMERCALLBACKFUNC) (PVOID, BOOLEAN );
typedef VOID (NTAPI * PFLS_CALLBACK_FUNCTION) ( PVOID );
+#define RTL_RUN_ONCE_INIT {0}
+typedef union _RTL_RUN_ONCE {
+ PVOID Ptr;
+} RTL_RUN_ONCE, *PRTL_RUN_ONCE;
+
+NTSYSAPI VOID NTAPI RtlRunOnceInitialize(PRTL_RUN_ONCE);
+
#include <pshpack8.h>
typedef struct _IO_COUNTERS {
ULONGLONG DECLSPEC_ALIGN(8) ReadOperationCount;
More information about the wine-cvs
mailing list