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
256c3445
Commit
256c3445
authored
Apr 14, 2023
by
Piotr Caban
Committed by
Alexandre Julliard
Apr 14, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msvcr100: Use Context blocking functions in reader_writer_lock class.
parent
c595bef6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
17 deletions
+12
-17
concurrency.c
dlls/msvcrt/concurrency.c
+12
-17
No files found.
dlls/msvcrt/concurrency.c
View file @
256c3445
...
@@ -68,6 +68,8 @@ typedef struct {
...
@@ -68,6 +68,8 @@ typedef struct {
unsigned int, (const Context*), (this))
unsigned int, (const Context*), (this))
#define call_Context_GetScheduleGroupId(this) CALL_VTBL_FUNC(this, 8, \
#define call_Context_GetScheduleGroupId(this) CALL_VTBL_FUNC(this, 8, \
unsigned int, (const Context*), (this))
unsigned int, (const Context*), (this))
#define call_Context_Unblock(this) CALL_VTBL_FUNC(this, 12, \
void, (Context*), (this))
#define call_Context_IsSynchronouslyBlocked(this) CALL_VTBL_FUNC(this, 16, \
#define call_Context_IsSynchronouslyBlocked(this) CALL_VTBL_FUNC(this, 16, \
bool, (const Context*), (this))
bool, (const Context*), (this))
#define call_Context_dtor(this, flags) CALL_VTBL_FUNC(this, 20, \
#define call_Context_dtor(this, flags) CALL_VTBL_FUNC(this, 20, \
...
@@ -324,6 +326,7 @@ typedef struct {
...
@@ -324,6 +326,7 @@ typedef struct {
typedef
struct
rwl_queue
typedef
struct
rwl_queue
{
{
struct
rwl_queue
*
next
;
struct
rwl_queue
*
next
;
Context
*
ctx
;
}
rwl_queue
;
}
rwl_queue
;
#define WRITER_WAITING 0x80000000
#define WRITER_WAITING 0x80000000
...
@@ -3129,14 +3132,6 @@ reader_writer_lock* __thiscall reader_writer_lock_ctor(reader_writer_lock *this)
...
@@ -3129,14 +3132,6 @@ reader_writer_lock* __thiscall reader_writer_lock_ctor(reader_writer_lock *this)
{
{
TRACE
(
"(%p)
\n
"
,
this
);
TRACE
(
"(%p)
\n
"
,
this
);
if
(
!
keyed_event
)
{
HANDLE
event
;
NtCreateKeyedEvent
(
&
event
,
GENERIC_READ
|
GENERIC_WRITE
,
NULL
,
0
);
if
(
InterlockedCompareExchangePointer
(
&
keyed_event
,
event
,
NULL
)
!=
NULL
)
NtClose
(
event
);
}
memset
(
this
,
0
,
sizeof
(
*
this
));
memset
(
this
,
0
,
sizeof
(
*
this
));
return
this
;
return
this
;
}
}
...
@@ -3170,7 +3165,7 @@ static inline void spin_wait_for_next_rwl(rwl_queue *q)
...
@@ -3170,7 +3165,7 @@ static inline void spin_wait_for_next_rwl(rwl_queue *q)
DEFINE_THISCALL_WRAPPER
(
reader_writer_lock_lock
,
4
)
DEFINE_THISCALL_WRAPPER
(
reader_writer_lock_lock
,
4
)
void
__thiscall
reader_writer_lock_lock
(
reader_writer_lock
*
this
)
void
__thiscall
reader_writer_lock_lock
(
reader_writer_lock
*
this
)
{
{
rwl_queue
q
=
{
NULL
},
*
last
;
rwl_queue
q
=
{
NULL
,
get_current_context
()
},
*
last
;
TRACE
(
"(%p)
\n
"
,
this
);
TRACE
(
"(%p)
\n
"
,
this
);
...
@@ -3183,11 +3178,11 @@ void __thiscall reader_writer_lock_lock(reader_writer_lock *this)
...
@@ -3183,11 +3178,11 @@ void __thiscall reader_writer_lock_lock(reader_writer_lock *this)
last
=
InterlockedExchangePointer
((
void
**
)
&
this
->
writer_tail
,
&
q
);
last
=
InterlockedExchangePointer
((
void
**
)
&
this
->
writer_tail
,
&
q
);
if
(
last
)
{
if
(
last
)
{
last
->
next
=
&
q
;
last
->
next
=
&
q
;
NtWaitForKeyedEvent
(
keyed_event
,
&
q
,
0
,
NULL
);
call_Context_Block
(
q
.
ctx
);
}
else
{
}
else
{
this
->
writer_head
=
&
q
;
this
->
writer_head
=
&
q
;
if
(
InterlockedOr
(
&
this
->
count
,
WRITER_WAITING
))
if
(
InterlockedOr
(
&
this
->
count
,
WRITER_WAITING
))
NtWaitForKeyedEvent
(
keyed_event
,
&
q
,
0
,
NULL
);
call_Context_Block
(
q
.
ctx
);
}
}
this
->
thread_id
=
GetCurrentThreadId
();
this
->
thread_id
=
GetCurrentThreadId
();
...
@@ -3204,7 +3199,7 @@ void __thiscall reader_writer_lock_lock(reader_writer_lock *this)
...
@@ -3204,7 +3199,7 @@ void __thiscall reader_writer_lock_lock(reader_writer_lock *this)
DEFINE_THISCALL_WRAPPER
(
reader_writer_lock_lock_read
,
4
)
DEFINE_THISCALL_WRAPPER
(
reader_writer_lock_lock_read
,
4
)
void
__thiscall
reader_writer_lock_lock_read
(
reader_writer_lock
*
this
)
void
__thiscall
reader_writer_lock_lock_read
(
reader_writer_lock
*
this
)
{
{
rwl_queue
q
;
rwl_queue
q
=
{
NULL
,
get_current_context
()
}
;
TRACE
(
"(%p)
\n
"
,
this
);
TRACE
(
"(%p)
\n
"
,
this
);
...
@@ -3226,17 +3221,17 @@ void __thiscall reader_writer_lock_lock_read(reader_writer_lock *this)
...
@@ -3226,17 +3221,17 @@ void __thiscall reader_writer_lock_lock_read(reader_writer_lock *this)
if
(
InterlockedCompareExchange
(
&
this
->
count
,
count
+
1
,
count
)
==
count
)
break
;
if
(
InterlockedCompareExchange
(
&
this
->
count
,
count
+
1
,
count
)
==
count
)
break
;
if
(
count
&
WRITER_WAITING
)
if
(
count
&
WRITER_WAITING
)
NtWaitForKeyedEvent
(
keyed_event
,
&
q
,
0
,
NULL
);
call_Context_Block
(
q
.
ctx
);
head
=
InterlockedExchangePointer
((
void
**
)
&
this
->
reader_head
,
NULL
);
head
=
InterlockedExchangePointer
((
void
**
)
&
this
->
reader_head
,
NULL
);
while
(
head
&&
head
!=
&
q
)
{
while
(
head
&&
head
!=
&
q
)
{
rwl_queue
*
next
=
head
->
next
;
rwl_queue
*
next
=
head
->
next
;
InterlockedIncrement
(
&
this
->
count
);
InterlockedIncrement
(
&
this
->
count
);
NtReleaseKeyedEvent
(
keyed_event
,
head
,
0
,
NULL
);
call_Context_Unblock
(
head
->
ctx
);
head
=
next
;
head
=
next
;
}
}
}
else
{
}
else
{
NtWaitForKeyedEvent
(
keyed_event
,
&
q
,
0
,
NULL
);
call_Context_Block
(
q
.
ctx
);
}
}
}
}
...
@@ -3314,7 +3309,7 @@ void __thiscall reader_writer_lock_unlock(reader_writer_lock *this)
...
@@ -3314,7 +3309,7 @@ void __thiscall reader_writer_lock_unlock(reader_writer_lock *this)
this
->
thread_id
=
0
;
this
->
thread_id
=
0
;
next
=
this
->
writer_head
->
next
;
next
=
this
->
writer_head
->
next
;
if
(
next
)
{
if
(
next
)
{
NtReleaseKeyedEvent
(
keyed_event
,
next
,
0
,
NULL
);
call_Context_Unblock
(
next
->
ctx
);
return
;
return
;
}
}
InterlockedAnd
(
&
this
->
count
,
~
WRITER_WAITING
);
InterlockedAnd
(
&
this
->
count
,
~
WRITER_WAITING
);
...
@@ -3322,7 +3317,7 @@ void __thiscall reader_writer_lock_unlock(reader_writer_lock *this)
...
@@ -3322,7 +3317,7 @@ void __thiscall reader_writer_lock_unlock(reader_writer_lock *this)
while
(
head
)
{
while
(
head
)
{
next
=
head
->
next
;
next
=
head
->
next
;
InterlockedIncrement
(
&
this
->
count
);
InterlockedIncrement
(
&
this
->
count
);
NtReleaseKeyedEvent
(
keyed_event
,
head
,
0
,
NULL
);
call_Context_Unblock
(
head
->
ctx
);
head
=
next
;
head
=
next
;
}
}
...
...
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