[3/4] kernel32: Added InitOnceInitialize() implementation
Nikolay Sivov
nsivov at codeweavers.com
Mon Jul 23 02:57:40 CDT 2012
Added InitOnceInitialize() implementation
-------------- next part --------------
>From e28c9405c1057bc383a58d34fddc7a058e54c1d4 Mon Sep 17 00:00:00 2001
From: Nikolay Sivov <nsivov at codeweavers.com>
Date: Sun, 22 Jul 2012 18:33:14 +0400
Subject: [PATCH 3/5] Added InitOnceInitialize() implementation
---
dlls/kernel32/kernel32.spec | 1 +
dlls/kernel32/sync.c | 9 +++++++++
dlls/kernel32/tests/sync.c | 18 ++++++++++++++++++
dlls/ntdll/ntdll.spec | 1 +
dlls/ntdll/sync.c | 5 +++++
include/winbase.h | 7 +++++++
include/winnt.h | 7 +++++++
7 files changed, 48 insertions(+), 0 deletions(-)
diff --git a/dlls/kernel32/kernel32.spec b/dlls/kernel32/kernel32.spec
index 5906ca3..da38ede 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)
@ 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 3264884..b40b05d 100644
--- a/dlls/kernel32/sync.c
+++ b/dlls/kernel32/sync.c
@@ -36,6 +36,7 @@
#define WIN32_NO_STATUS
#include "windef.h"
#include "winbase.h"
+#include "winnt.h"
#include "winerror.h"
#include "winnls.h"
#include "winternl.h"
@@ -2238,6 +2239,14 @@ BOOL WINAPI QueryMemoryResourceNotification(HANDLE handle, PBOOL state)
return FALSE;
}
+/***********************************************************************
+ * InitOnceInitialize (KERNEL32.@)
+ */
+VOID WINAPI InitOnceInitialize(INIT_ONCE *initonce)
+{
+ RtlRunOnceInitialize(initonce);
+}
+
#ifdef __i386__
/***********************************************************************
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;
--
1.5.6.5
More information about the wine-patches
mailing list