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
d8f7d545
Commit
d8f7d545
authored
Sep 22, 2020
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll: Add inline wrappers for pthread mutex locking.
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
05d9df73
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
58 additions
and
48 deletions
+58
-48
cdrom.c
dlls/ntdll/unix/cdrom.c
+12
-12
file.c
dlls/ntdll/unix/file.c
+20
-20
server.c
dlls/ntdll/unix/server.c
+3
-3
sync.c
dlls/ntdll/unix/sync.c
+6
-6
system.c
dlls/ntdll/unix/system.c
+3
-3
unix_private.h
dlls/ntdll/unix/unix_private.h
+10
-0
virtual.c
dlls/ntdll/unix/virtual.c
+4
-4
No files found.
dlls/ntdll/unix/cdrom.c
View file @
d8f7d545
...
...
@@ -559,9 +559,9 @@ static NTSTATUS CDROM_SyncCache(int dev, int fd)
static
void
CDROM_ClearCacheEntry
(
int
dev
)
{
pthread_
mutex_lock
(
&
cache_mutex
);
mutex_lock
(
&
cache_mutex
);
cdrom_cache
[
dev
].
toc_good
=
0
;
pthread_
mutex_unlock
(
&
cache_mutex
);
mutex_unlock
(
&
cache_mutex
);
}
...
...
@@ -667,7 +667,7 @@ static NTSTATUS CDROM_Open(int fd, int* dev)
if
(
fstat
(
fd
,
&
st
)
==
-
1
)
return
errno_to_status
(
errno
);
pthread_
mutex_lock
(
&
cache_mutex
);
mutex_lock
(
&
cache_mutex
);
for
(
*
dev
=
0
;
*
dev
<
MAX_CACHE_ENTRIES
;
(
*
dev
)
++
)
{
if
(
empty
==
-
1
&&
...
...
@@ -688,7 +688,7 @@ static NTSTATUS CDROM_Open(int fd, int* dev)
cdrom_cache
[
*
dev
].
inode
=
st
.
st_ino
;
}
}
pthread_
mutex_unlock
(
&
cache_mutex
);
mutex_unlock
(
&
cache_mutex
);
TRACE
(
"%d, %d
\n
"
,
*
dev
,
fd
);
return
ret
;
...
...
@@ -840,13 +840,13 @@ static NTSTATUS CDROM_ReadTOC(int dev, int fd, CDROM_TOC* toc)
if
(
dev
<
0
||
dev
>=
MAX_CACHE_ENTRIES
)
return
STATUS_INVALID_PARAMETER
;
pthread_
mutex_lock
(
&
cache_mutex
);
mutex_lock
(
&
cache_mutex
);
if
(
cdrom_cache
[
dev
].
toc_good
||
!
(
ret
=
CDROM_SyncCache
(
dev
,
fd
)))
{
*
toc
=
cdrom_cache
[
dev
].
toc
;
ret
=
STATUS_SUCCESS
;
}
pthread_
mutex_unlock
(
&
cache_mutex
);
mutex_unlock
(
&
cache_mutex
);
return
ret
;
}
...
...
@@ -926,7 +926,7 @@ static NTSTATUS CDROM_ReadQChannel(int dev, int fd, const CDROM_SUB_Q_DATA_FORMA
switch
(
fmt
->
Format
)
{
case
IOCTL_CDROM_CURRENT_POSITION
:
pthread_
mutex_lock
(
&
cache_mutex
);
mutex_lock
(
&
cache_mutex
);
if
(
hdr
->
AudioStatus
==
AUDIO_STATUS_IN_PROGRESS
)
{
data
->
CurrentPosition
.
FormatCode
=
IOCTL_CDROM_CURRENT_POSITION
;
data
->
CurrentPosition
.
Control
=
sc
.
cdsc_ctrl
;
...
...
@@ -951,7 +951,7 @@ static NTSTATUS CDROM_ReadQChannel(int dev, int fd, const CDROM_SUB_Q_DATA_FORMA
cdrom_cache
[
dev
].
CurrentPosition
.
Header
=
*
hdr
;
/* Preserve header info */
data
->
CurrentPosition
=
cdrom_cache
[
dev
].
CurrentPosition
;
}
pthread_
mutex_unlock
(
&
cache_mutex
);
mutex_unlock
(
&
cache_mutex
);
break
;
case
IOCTL_CDROM_MEDIA_CATALOG
:
data
->
MediaCatalog
.
FormatCode
=
IOCTL_CDROM_MEDIA_CATALOG
;
...
...
@@ -1037,7 +1037,7 @@ static NTSTATUS CDROM_ReadQChannel(int dev, int fd, const CDROM_SUB_Q_DATA_FORMA
switch
(
fmt
->
Format
)
{
case
IOCTL_CDROM_CURRENT_POSITION
:
pthread_
mutex_lock
(
&
cache_mutex
);
mutex_lock
(
&
cache_mutex
);
if
(
hdr
->
AudioStatus
==
AUDIO_STATUS_IN_PROGRESS
)
{
data
->
CurrentPosition
.
FormatCode
=
IOCTL_CDROM_CURRENT_POSITION
;
data
->
CurrentPosition
.
Control
=
sc
.
what
.
position
.
control
;
...
...
@@ -1059,7 +1059,7 @@ static NTSTATUS CDROM_ReadQChannel(int dev, int fd, const CDROM_SUB_Q_DATA_FORMA
cdrom_cache
[
dev
].
CurrentPosition
.
Header
=
*
hdr
;
/* Preserve header info */
data
->
CurrentPosition
=
cdrom_cache
[
dev
].
CurrentPosition
;
}
pthread_
mutex_unlock
(
&
cache_mutex
);
mutex_unlock
(
&
cache_mutex
);
break
;
case
IOCTL_CDROM_MEDIA_CATALOG
:
data
->
MediaCatalog
.
FormatCode
=
IOCTL_CDROM_MEDIA_CATALOG
;
...
...
@@ -1248,7 +1248,7 @@ static NTSTATUS CDROM_SeekAudioMSF(int dev, int fd, const CDROM_SEEK_AUDIO_MSF*
if
(
i
<=
toc
.
FirstTrack
||
i
>
toc
.
LastTrack
+
1
)
return
STATUS_INVALID_PARAMETER
;
i
--
;
pthread_
mutex_lock
(
&
cache_mutex
);
mutex_lock
(
&
cache_mutex
);
cp
=
&
cdrom_cache
[
dev
].
CurrentPosition
;
cp
->
FormatCode
=
IOCTL_CDROM_CURRENT_POSITION
;
cp
->
Control
=
toc
.
TrackData
[
i
-
toc
.
FirstTrack
].
Control
;
...
...
@@ -1262,7 +1262,7 @@ static NTSTATUS CDROM_SeekAudioMSF(int dev, int fd, const CDROM_SEEK_AUDIO_MSF*
frame
-=
FRAME_OF_TOC
(
toc
,
i
);
cp
->
TrackRelativeAddress
[
0
]
=
0
;
MSF_OF_FRAME
(
cp
->
TrackRelativeAddress
[
1
],
frame
);
pthread_
mutex_unlock
(
&
cache_mutex
);
mutex_unlock
(
&
cache_mutex
);
/* If playing, then issue a seek command, otherwise do nothing */
#ifdef linux
...
...
dlls/ntdll/unix/file.c
View file @
d8f7d545
...
...
@@ -764,7 +764,7 @@ static char *get_default_drive_device( const char *root )
if
(
res
==
-
1
)
res
=
stat
(
root
,
&
st
);
if
(
res
==
-
1
)
return
NULL
;
pthread_
mutex_lock
(
&
mnt_mutex
);
mutex_lock
(
&
mnt_mutex
);
#ifdef __ANDROID__
if
((
f
=
fopen
(
"/proc/mounts"
,
"r"
)))
...
...
@@ -786,7 +786,7 @@ static char *get_default_drive_device( const char *root )
}
#endif
if
(
device
)
ret
=
strdup
(
device
);
pthread_
mutex_unlock
(
&
mnt_mutex
);
mutex_unlock
(
&
mnt_mutex
);
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__ ) || defined(__DragonFly__)
char
*
device
=
NULL
;
...
...
@@ -803,14 +803,14 @@ static char *get_default_drive_device( const char *root )
if
(
res
==
-
1
)
res
=
stat
(
root
,
&
st
);
if
(
res
==
-
1
)
return
NULL
;
pthread_
mutex_lock
(
&
mnt_mutex
);
mutex_lock
(
&
mnt_mutex
);
/* The FreeBSD parse_mount_entries doesn't require a file argument, so just
* pass NULL. Leave the argument in for symmetry.
*/
device
=
parse_mount_entries
(
NULL
,
st
.
st_dev
,
st
.
st_ino
);
if
(
device
)
ret
=
strdup
(
device
);
pthread_
mutex_unlock
(
&
mnt_mutex
);
mutex_unlock
(
&
mnt_mutex
);
#elif defined( sun )
FILE
*
f
;
...
...
@@ -828,7 +828,7 @@ static char *get_default_drive_device( const char *root )
if
(
res
==
-
1
)
res
=
stat
(
root
,
&
st
);
if
(
res
==
-
1
)
return
NULL
;
pthread_
mutex_lock
(
&
mnt_mutex
);
mutex_lock
(
&
mnt_mutex
);
if
((
f
=
fopen
(
"/etc/mnttab"
,
"r"
)))
{
...
...
@@ -842,7 +842,7 @@ static char *get_default_drive_device( const char *root )
fclose
(
f
);
}
if
(
device
)
ret
=
strdup
(
device
);
pthread_
mutex_unlock
(
&
mnt_mutex
);
mutex_unlock
(
&
mnt_mutex
);
#elif defined(__APPLE__)
struct
statfs
*
mntStat
;
...
...
@@ -860,7 +860,7 @@ static char *get_default_drive_device( const char *root )
dev
=
st
.
st_dev
;
ino
=
st
.
st_ino
;
pthread_
mutex_lock
(
&
mnt_mutex
);
mutex_lock
(
&
mnt_mutex
);
mntSize
=
getmntinfo
(
&
mntStat
,
MNT_NOWAIT
);
...
...
@@ -881,7 +881,7 @@ static char *get_default_drive_device( const char *root )
}
}
}
pthread_
mutex_unlock
(
&
mnt_mutex
);
mutex_unlock
(
&
mnt_mutex
);
#else
static
int
warned
;
if
(
!
warned
++
)
FIXME
(
"auto detection of DOS devices not supported on this platform
\n
"
);
...
...
@@ -902,7 +902,7 @@ static char *get_device_mount_point( dev_t dev )
#ifdef linux
FILE
*
f
;
pthread_
mutex_lock
(
&
mnt_mutex
);
mutex_lock
(
&
mnt_mutex
);
#ifdef __ANDROID__
if
((
f
=
fopen
(
"/proc/mounts"
,
"r"
)))
...
...
@@ -949,13 +949,13 @@ static char *get_device_mount_point( dev_t dev )
}
fclose
(
f
);
}
pthread_
mutex_unlock
(
&
mnt_mutex
);
mutex_unlock
(
&
mnt_mutex
);
#elif defined(__APPLE__)
struct
statfs
*
entry
;
struct
stat
st
;
int
i
,
size
;
pthread_
mutex_lock
(
&
mnt_mutex
);
mutex_lock
(
&
mnt_mutex
);
size
=
getmntinfo
(
&
entry
,
MNT_NOWAIT
);
for
(
i
=
0
;
i
<
size
;
i
++
)
...
...
@@ -967,7 +967,7 @@ static char *get_device_mount_point( dev_t dev )
break
;
}
}
pthread_
mutex_unlock
(
&
mnt_mutex
);
mutex_unlock
(
&
mnt_mutex
);
#else
static
int
warned
;
if
(
!
warned
++
)
FIXME
(
"unmounting devices not supported on this platform
\n
"
);
...
...
@@ -1851,7 +1851,7 @@ static unsigned int get_drives_info( struct file_identity info[MAX_DOS_DRIVES] )
unsigned
int
ret
;
time_t
now
=
time
(
NULL
);
pthread_
mutex_lock
(
&
cache_mutex
);
mutex_lock
(
&
cache_mutex
);
if
(
now
!=
last_update
)
{
char
*
buffer
,
*
p
;
...
...
@@ -1885,7 +1885,7 @@ static unsigned int get_drives_info( struct file_identity info[MAX_DOS_DRIVES] )
}
memcpy
(
info
,
cache
,
sizeof
(
cache
)
);
ret
=
nb_drives
;
pthread_
mutex_unlock
(
&
cache_mutex
);
mutex_unlock
(
&
cache_mutex
);
return
ret
;
}
...
...
@@ -2429,7 +2429,7 @@ NTSTATUS WINAPI NtQueryDirectoryFile( HANDLE handle, HANDLE event, PIO_APC_ROUTI
io
->
Information
=
0
;
pthread_
mutex_lock
(
&
dir_mutex
);
mutex_lock
(
&
dir_mutex
);
cwd
=
open
(
"."
,
O_RDONLY
);
if
(
fchdir
(
fd
)
!=
-
1
)
...
...
@@ -2456,7 +2456,7 @@ NTSTATUS WINAPI NtQueryDirectoryFile( HANDLE handle, HANDLE event, PIO_APC_ROUTI
}
else
status
=
errno_to_status
(
errno
);
pthread_
mutex_unlock
(
&
dir_mutex
);
mutex_unlock
(
&
dir_mutex
);
if
(
needs_close
)
close
(
fd
);
if
(
cwd
!=
-
1
)
close
(
cwd
);
...
...
@@ -3012,7 +3012,7 @@ static NTSTATUS file_id_to_unix_file_name( const OBJECT_ATTRIBUTES *attr, char *
goto
done
;
}
pthread_
mutex_lock
(
&
dir_mutex
);
mutex_lock
(
&
dir_mutex
);
if
((
old_cwd
=
open
(
"."
,
O_RDONLY
))
!=
-
1
&&
fchdir
(
root_fd
)
!=
-
1
)
{
/* shortcut for ".." */
...
...
@@ -3033,7 +3033,7 @@ static NTSTATUS file_id_to_unix_file_name( const OBJECT_ATTRIBUTES *attr, char *
if
(
fchdir
(
old_cwd
)
==
-
1
)
chdir
(
"/"
);
}
else
status
=
errno_to_status
(
errno
);
pthread_
mutex_unlock
(
&
dir_mutex
);
mutex_unlock
(
&
dir_mutex
);
if
(
old_cwd
!=
-
1
)
close
(
old_cwd
);
done:
...
...
@@ -3208,7 +3208,7 @@ static NTSTATUS nt_to_unix_file_name_attr( const OBJECT_ATTRIBUTES *attr, char *
}
else
{
pthread_
mutex_lock
(
&
dir_mutex
);
mutex_lock
(
&
dir_mutex
);
if
((
old_cwd
=
open
(
"."
,
O_RDONLY
))
!=
-
1
&&
fchdir
(
root_fd
)
!=
-
1
)
{
status
=
lookup_unix_name
(
name
,
name_len
,
&
unix_name
,
unix_len
,
1
,
...
...
@@ -3216,7 +3216,7 @@ static NTSTATUS nt_to_unix_file_name_attr( const OBJECT_ATTRIBUTES *attr, char *
if
(
fchdir
(
old_cwd
)
==
-
1
)
chdir
(
"/"
);
}
else
status
=
errno_to_status
(
errno
);
pthread_
mutex_unlock
(
&
dir_mutex
);
mutex_unlock
(
&
dir_mutex
);
if
(
old_cwd
!=
-
1
)
close
(
old_cwd
);
if
(
needs_close
)
close
(
root_fd
);
}
...
...
dlls/ntdll/unix/server.c
View file @
d8f7d545
...
...
@@ -297,7 +297,7 @@ unsigned int CDECL wine_server_call( void *req_ptr )
void
server_enter_uninterrupted_section
(
pthread_mutex_t
*
mutex
,
sigset_t
*
sigset
)
{
pthread_sigmask
(
SIG_BLOCK
,
&
server_block_set
,
sigset
);
pthread_
mutex_lock
(
mutex
);
mutex_lock
(
mutex
);
}
...
...
@@ -306,7 +306,7 @@ void server_enter_uninterrupted_section( pthread_mutex_t *mutex, sigset_t *sigse
*/
void
server_leave_uninterrupted_section
(
pthread_mutex_t
*
mutex
,
sigset_t
*
sigset
)
{
pthread_
mutex_unlock
(
mutex
);
mutex_unlock
(
mutex
);
pthread_sigmask
(
SIG_SETMASK
,
sigset
,
NULL
);
}
...
...
@@ -646,7 +646,7 @@ unsigned int server_select( const select_op_t *select_op, data_size_t size, UINT
pthread_sigmask
(
SIG_SETMASK
,
&
old_set
,
NULL
);
if
(
mutex
)
{
pthread_
mutex_unlock
(
mutex
);
mutex_unlock
(
mutex
);
mutex
=
NULL
;
}
if
(
ret
!=
STATUS_PENDING
)
break
;
...
...
dlls/ntdll/unix/sync.c
View file @
d8f7d545
...
...
@@ -2663,10 +2663,10 @@ NTSTATUS WINAPI RtlWaitOnAddress( const void *addr, const void *cmp, SIZE_T size
if
((
ret
=
fast_wait_addr
(
addr
,
cmp
,
size
,
timeout
))
!=
STATUS_NOT_IMPLEMENTED
)
return
ret
;
pthread_
mutex_lock
(
&
addr_mutex
);
mutex_lock
(
&
addr_mutex
);
if
(
!
compare_addr
(
addr
,
cmp
,
size
))
{
pthread_
mutex_unlock
(
&
addr_mutex
);
mutex_unlock
(
&
addr_mutex
);
return
STATUS_SUCCESS
;
}
...
...
@@ -2693,9 +2693,9 @@ void WINAPI RtlWakeAddressAll( const void *addr )
{
if
(
fast_wake_addr
(
addr
)
!=
STATUS_NOT_IMPLEMENTED
)
return
;
pthread_
mutex_lock
(
&
addr_mutex
);
mutex_lock
(
&
addr_mutex
);
while
(
NtReleaseKeyedEvent
(
0
,
addr
,
0
,
&
zero_timeout
)
==
STATUS_SUCCESS
)
{}
pthread_
mutex_unlock
(
&
addr_mutex
);
mutex_unlock
(
&
addr_mutex
);
}
/***********************************************************************
...
...
@@ -2705,7 +2705,7 @@ void WINAPI RtlWakeAddressSingle( const void *addr )
{
if
(
fast_wake_addr
(
addr
)
!=
STATUS_NOT_IMPLEMENTED
)
return
;
pthread_
mutex_lock
(
&
addr_mutex
);
mutex_lock
(
&
addr_mutex
);
NtReleaseKeyedEvent
(
0
,
addr
,
0
,
&
zero_timeout
);
pthread_
mutex_unlock
(
&
addr_mutex
);
mutex_unlock
(
&
addr_mutex
);
}
dlls/ntdll/unix/system.c
View file @
d8f7d545
...
...
@@ -1929,7 +1929,7 @@ static void get_timezone_info( RTL_DYNAMIC_TIME_ZONE_INFORMATION *tzi )
time_t
year_start
,
year_end
,
tmp
,
dlt
=
0
,
std
=
0
;
int
is_dst
,
bias
;
pthread_
mutex_lock
(
&
tz_mutex
);
mutex_lock
(
&
tz_mutex
);
year_start
=
time
(
NULL
);
tm
=
gmtime
(
&
year_start
);
...
...
@@ -1939,7 +1939,7 @@ static void get_timezone_info( RTL_DYNAMIC_TIME_ZONE_INFORMATION *tzi )
if
(
current_year
==
tm
->
tm_year
&&
current_bias
==
bias
)
{
*
tzi
=
cached_tzi
;
pthread_
mutex_unlock
(
&
tz_mutex
);
mutex_unlock
(
&
tz_mutex
);
return
;
}
...
...
@@ -2032,7 +2032,7 @@ static void get_timezone_info( RTL_DYNAMIC_TIME_ZONE_INFORMATION *tzi )
find_reg_tz_info
(
tzi
,
tz_name
,
current_year
+
1900
);
cached_tzi
=
*
tzi
;
pthread_
mutex_unlock
(
&
tz_mutex
);
mutex_unlock
(
&
tz_mutex
);
}
...
...
dlls/ntdll/unix/unix_private.h
View file @
d8f7d545
...
...
@@ -278,6 +278,16 @@ static inline void *get_signal_stack(void)
return
(
char
*
)
NtCurrentTeb
()
+
teb_size
-
teb_offset
;
}
static
inline
void
mutex_lock
(
pthread_mutex_t
*
mutex
)
{
pthread_mutex_lock
(
mutex
);
}
static
inline
void
mutex_unlock
(
pthread_mutex_t
*
mutex
)
{
pthread_mutex_unlock
(
mutex
);
}
#ifndef _WIN64
static
inline
TEB64
*
NtCurrentTeb64
(
void
)
{
return
(
TEB64
*
)
NtCurrentTeb
()
->
GdiBatchCount
;
}
#endif
...
...
dlls/ntdll/unix/virtual.c
View file @
d8f7d545
...
...
@@ -2899,7 +2899,7 @@ NTSTATUS virtual_handle_fault( void *addr, DWORD err, void *stack )
char
*
page
=
ROUND_ADDR
(
addr
,
page_mask
);
BYTE
vprot
;
pthread_
mutex_lock
(
&
virtual_mutex
);
/* no need for signal masking inside signal handler */
mutex_lock
(
&
virtual_mutex
);
/* no need for signal masking inside signal handler */
vprot
=
get_page_vprot
(
page
);
if
(
!
is_inside_signal_stack
(
stack
)
&&
(
vprot
&
VPROT_GUARD
))
{
...
...
@@ -2926,7 +2926,7 @@ NTSTATUS virtual_handle_fault( void *addr, DWORD err, void *stack )
ret
=
STATUS_SUCCESS
;
}
}
pthread_
mutex_unlock
(
&
virtual_mutex
);
mutex_unlock
(
&
virtual_mutex
);
return
ret
;
}
...
...
@@ -2969,13 +2969,13 @@ void *virtual_setup_exception( void *stack_ptr, size_t size, EXCEPTION_RECORD *r
}
else
if
(
stack
<
(
char
*
)
NtCurrentTeb
()
->
Tib
.
StackLimit
)
{
pthread_
mutex_lock
(
&
virtual_mutex
);
/* no need for signal masking inside signal handler */
mutex_lock
(
&
virtual_mutex
);
/* no need for signal masking inside signal handler */
if
((
get_page_vprot
(
stack
)
&
VPROT_GUARD
)
&&
grow_thread_stack
(
ROUND_ADDR
(
stack
,
page_mask
)))
{
rec
->
ExceptionCode
=
STATUS_STACK_OVERFLOW
;
rec
->
NumberParameters
=
0
;
}
pthread_
mutex_unlock
(
&
virtual_mutex
);
mutex_unlock
(
&
virtual_mutex
);
}
#if defined(VALGRIND_MAKE_MEM_UNDEFINED)
VALGRIND_MAKE_MEM_UNDEFINED
(
stack
,
size
);
...
...
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