Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
93185287
Commit
93185287
authored
Jul 22, 2012
by
Nikolay Sivov
Committed by
Alexandre Julliard
Jul 23, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32: Single thread test for InitOnceExecuteOnce().
parent
b1c3c8c8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
2 deletions
+58
-2
sync.c
dlls/kernel32/tests/sync.c
+56
-2
winbase.h
include/winbase.h
+2
-0
No files found.
dlls/kernel32/tests/sync.c
View file @
93185287
...
...
@@ -38,6 +38,7 @@ 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
BOOL
(
WINAPI
*
pInitOnceExecuteOnce
)(
PINIT_ONCE
,
PINIT_ONCE_FN
,
PVOID
,
LPVOID
*
);
static
void
test_signalandwait
(
void
)
{
...
...
@@ -1136,19 +1137,71 @@ static void test_WaitForMultipleObjects(void)
if
(
maxevents
[
i
])
CloseHandle
(
maxevents
[
i
]);
}
static
BOOL
g_initcallback_ret
,
g_initcallback_called
;
BOOL
CALLBACK
initonce_callback
(
INIT_ONCE
*
initonce
,
void
*
parameter
,
void
**
ctxt
)
{
g_initcallback_called
=
TRUE
;
/* zero bit set means here that initialization is taking place - initialization locked */
ok
(
initonce
->
Ptr
==
(
void
*
)
0x1
,
"got %p
\n
"
,
initonce
->
Ptr
);
ok
(
parameter
==
(
void
*
)
0xdeadbeef
,
"got wrong parameter
\n
"
);
return
g_initcallback_ret
;
}
static
void
test_initonce
(
void
)
{
INIT_ONCE
initonce
;
void
*
ctxt
;
BOOL
ret
;
if
(
!
pInitOnceInitialize
)
if
(
!
pInitOnceInitialize
||
!
pInitOnceExecuteOnce
)
{
win_
skip
(
"one-time initialization API not supported
\n
"
);
skip
(
"one-time initialization API not supported
\n
"
);
return
;
}
initonce
.
Ptr
=
(
void
*
)
0xdeadbeef
;
pInitOnceInitialize
(
&
initonce
);
ok
(
initonce
.
Ptr
==
NULL
,
"got %p
\n
"
,
initonce
.
Ptr
);
/* initialisation completed successfully */
g_initcallback_ret
=
TRUE
;
ctxt
=
NULL
;
ret
=
pInitOnceExecuteOnce
(
&
initonce
,
&
initonce_callback
,
(
void
*
)
0xdeadbeef
,
&
ctxt
);
ok
(
ret
,
"got wrong ret value %d
\n
"
,
ret
);
ok
(
initonce
.
Ptr
==
(
void
*
)
0x2
,
"got %p
\n
"
,
initonce
.
Ptr
);
ok
(
ctxt
==
(
void
*
)
0x0
,
"got %p
\n
"
,
ctxt
);
ok
(
g_initcallback_called
,
"got %d
\n
"
,
g_initcallback_called
);
/* so it's been called already so won't be called again */
ctxt
=
NULL
;
g_initcallback_called
=
FALSE
;
ret
=
pInitOnceExecuteOnce
(
&
initonce
,
&
initonce_callback
,
(
void
*
)
0xdeadbeef
,
&
ctxt
);
ok
(
ret
,
"got wrong ret value %d
\n
"
,
ret
);
ok
(
initonce
.
Ptr
==
(
void
*
)
0x2
,
"got %p
\n
"
,
initonce
.
Ptr
);
ok
(
ctxt
==
(
void
*
)
0
,
"got %p
\n
"
,
ctxt
);
ok
(
!
g_initcallback_called
,
"got %d
\n
"
,
g_initcallback_called
);
pInitOnceInitialize
(
&
initonce
);
g_initcallback_called
=
FALSE
;
/* 2 lower order bits should never be used, you'll get a crash in result */
ctxt
=
(
void
*
)
0xFFFFFFF0
;
ret
=
pInitOnceExecuteOnce
(
&
initonce
,
&
initonce_callback
,
(
void
*
)
0xdeadbeef
,
&
ctxt
);
ok
(
ret
,
"got wrong ret value %d
\n
"
,
ret
);
ok
(
initonce
.
Ptr
==
(
void
*
)
0xFFFFFFF2
,
"got %p
\n
"
,
initonce
.
Ptr
);
ok
(
ctxt
==
(
void
*
)
0xFFFFFFF0
,
"got %p
\n
"
,
ctxt
);
ok
(
g_initcallback_called
,
"got %d
\n
"
,
g_initcallback_called
);
/* callback failed */
g_initcallback_ret
=
FALSE
;
g_initcallback_called
=
FALSE
;
ctxt
=
NULL
;
pInitOnceInitialize
(
&
initonce
);
ret
=
pInitOnceExecuteOnce
(
&
initonce
,
&
initonce_callback
,
(
void
*
)
0xdeadbeef
,
&
ctxt
);
ok
(
!
ret
,
"got wrong ret value %d
\n
"
,
ret
);
ok
(
initonce
.
Ptr
==
NULL
,
"got %p
\n
"
,
initonce
.
Ptr
);
ok
(
ctxt
==
NULL
,
"got %p
\n
"
,
ctxt
);
ok
(
g_initcallback_called
,
"got %d
\n
"
,
g_initcallback_called
);
}
START_TEST
(
sync
)
...
...
@@ -1164,6 +1217,7 @@ START_TEST(sync)
pCreateMemoryResourceNotification
=
(
void
*
)
GetProcAddress
(
hdll
,
"CreateMemoryResourceNotification"
);
pQueryMemoryResourceNotification
=
(
void
*
)
GetProcAddress
(
hdll
,
"QueryMemoryResourceNotification"
);
pInitOnceInitialize
=
(
void
*
)
GetProcAddress
(
hdll
,
"InitOnceInitialize"
);
pInitOnceExecuteOnce
=
(
void
*
)
GetProcAddress
(
hdll
,
"InitOnceExecuteOnce"
);
test_signalandwait
();
test_mutex
();
...
...
include/winbase.h
View file @
93185287
...
...
@@ -1321,6 +1321,8 @@ 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
/* initialization callback prototype */
typedef
BOOL
(
WINAPI
*
PINIT_ONCE_FN
)(
PINIT_ONCE
,
PVOID
,
PVOID
*
);
WINBASEAPI
BOOL
WINAPI
ActivateActCtx
(
HANDLE
,
ULONG_PTR
*
);
WINADVAPI
BOOL
WINAPI
AddAccessAllowedAce
(
PACL
,
DWORD
,
DWORD
,
PSID
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment