Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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-winehq
Commits
f2f0dead
Commit
f2f0dead
authored
Nov 13, 2008
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32/tests: Fix the thread test to cope with the Win95 InterlockedIncrement behavior.
parent
22949d94
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
10 deletions
+9
-10
thread.c
dlls/kernel32/tests/thread.c
+9
-10
No files found.
dlls/kernel32/tests/thread.c
View file @
f2f0dead
...
@@ -105,23 +105,22 @@ CreateThread
...
@@ -105,23 +105,22 @@ CreateThread
it. It basically makes multithreaded execution linear, which defeats
it. It basically makes multithreaded execution linear, which defeats
the purpose of multiple threads, but makes testing easy. */
the purpose of multiple threads, but makes testing easy. */
static
HANDLE
start_event
,
stop_event
;
static
HANDLE
start_event
,
stop_event
;
static
LONG
num_sync
ing_threads
,
num_sync
ed
;
static
LONG
num_synced
;
static
void
init_thread_sync_helpers
(
LONG
num_threads
)
static
void
init_thread_sync_helpers
(
void
)
{
{
start_event
=
CreateEvent
(
NULL
,
TRUE
,
FALSE
,
NULL
);
start_event
=
CreateEvent
(
NULL
,
TRUE
,
FALSE
,
NULL
);
ok
(
start_event
!=
NULL
,
"CreateEvent failed
\n
"
);
ok
(
start_event
!=
NULL
,
"CreateEvent failed
\n
"
);
stop_event
=
CreateEvent
(
NULL
,
TRUE
,
FALSE
,
NULL
);
stop_event
=
CreateEvent
(
NULL
,
TRUE
,
FALSE
,
NULL
);
ok
(
stop_event
!=
NULL
,
"CreateEvent failed
\n
"
);
ok
(
stop_event
!=
NULL
,
"CreateEvent failed
\n
"
);
num_syncing_threads
=
num_threads
;
num_synced
=
-
1
;
num_synced
=
0
;
}
}
static
BOOL
sync_threads_and_run_one
(
DWORD
sync_id
,
DWORD
my_id
)
static
BOOL
sync_threads_and_run_one
(
DWORD
sync_id
,
DWORD
my_id
)
{
{
LONG
num
=
InterlockedIncrement
(
&
num_synced
);
LONG
num
=
InterlockedIncrement
(
&
num_synced
);
assert
(
0
<
num
&&
num
<=
num_syncing_threads
);
assert
(
-
1
<=
num
&&
num
<=
1
);
if
(
num
==
num_syncing_threads
)
if
(
num
==
1
)
{
{
ResetEvent
(
stop_event
);
ResetEvent
(
stop_event
);
SetEvent
(
start_event
);
SetEvent
(
start_event
);
...
@@ -129,7 +128,7 @@ static BOOL sync_threads_and_run_one(DWORD sync_id, DWORD my_id)
...
@@ -129,7 +128,7 @@ static BOOL sync_threads_and_run_one(DWORD sync_id, DWORD my_id)
else
else
{
{
DWORD
ret
=
WaitForSingleObject
(
start_event
,
10000
);
DWORD
ret
=
WaitForSingleObject
(
start_event
,
10000
);
ok
(
ret
==
WAIT_OBJECT_0
,
"WaitForSingleObject failed
\n
"
);
ok
(
ret
==
WAIT_OBJECT_0
,
"WaitForSingleObject failed
%x
\n
"
,
ret
);
}
}
return
sync_id
==
my_id
;
return
sync_id
==
my_id
;
}
}
...
@@ -137,8 +136,8 @@ static BOOL sync_threads_and_run_one(DWORD sync_id, DWORD my_id)
...
@@ -137,8 +136,8 @@ static BOOL sync_threads_and_run_one(DWORD sync_id, DWORD my_id)
static
void
resync_after_run
(
void
)
static
void
resync_after_run
(
void
)
{
{
LONG
num
=
InterlockedDecrement
(
&
num_synced
);
LONG
num
=
InterlockedDecrement
(
&
num_synced
);
assert
(
0
<=
num
&&
num
<
num_syncing_threads
);
assert
(
-
1
<=
num
&&
num
<=
1
);
if
(
num
==
0
)
if
(
num
==
-
1
)
{
{
ResetEvent
(
start_event
);
ResetEvent
(
start_event
);
SetEvent
(
stop_event
);
SetEvent
(
stop_event
);
...
@@ -1171,7 +1170,7 @@ static void test_TLS(void)
...
@@ -1171,7 +1170,7 @@ static void test_TLS(void)
DWORD
ret
;
DWORD
ret
;
BOOL
suc
;
BOOL
suc
;
init_thread_sync_helpers
(
2
);
init_thread_sync_helpers
();
/* Allocate a TLS slot in the main thread to test for inheritance. */
/* Allocate a TLS slot in the main thread to test for inheritance. */
TLS_main
=
TlsAlloc
();
TLS_main
=
TlsAlloc
();
...
...
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