[PATCH] ntdll: Use FUTEX_PRIVATE_FLAG for critical section futexes when available
Maarten Lankhorst
m.b.lankhorst at gmail.com
Wed Aug 3 13:27:43 CDT 2011
---
dlls/ntdll/critsection.c | 12 ++++++++++--
1 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/dlls/ntdll/critsection.c b/dlls/ntdll/critsection.c
index 2f1abcf..fc7ecde 100644
--- a/dlls/ntdll/critsection.c
+++ b/dlls/ntdll/critsection.c
@@ -61,14 +61,17 @@ static inline void small_pause(void)
#ifdef __linux__
+static int wait_op = 128; /*FUTEX_WAIT|FUTEX_PRIVATE_FLAG*/
+static int wake_op = 129; /*FUTEX_WAKE|FUTEX_PRIVATE_FLAG*/
+
static inline int futex_wait( int *addr, int val, struct timespec *timeout )
{
- return syscall( SYS_futex, addr, 0/*FUTEX_WAIT*/, val, timeout, 0, 0 );
+ return syscall( SYS_futex, addr, wait_op, val, timeout, 0, 0 );
}
static inline int futex_wake( int *addr, int val )
{
- return syscall( SYS_futex, addr, 1/*FUTEX_WAKE*/, val, NULL, 0, 0 );
+ return syscall( SYS_futex, addr, wake_op, val, NULL, 0, 0 );
}
static inline int use_futexes(void)
@@ -78,6 +81,11 @@ static inline int use_futexes(void)
if (supported == -1)
{
futex_wait( &supported, 10, NULL );
+ if (errno == ENOSYS) {
+ wait_op = 0; /*FUTEX_WAIT*/
+ wake_op = 1; /*FUTEX_WAKE*/
+ futex_wait( &supported, 10, NULL );
+ }
supported = (errno != ENOSYS);
}
return supported;
--
1.7.6
More information about the wine-patches
mailing list