Module: wine Branch: master Commit: 264996a75da61d2771d4dfe5d58a9ebac415a4bb URL: http://source.winehq.org/git/wine.git/?a=commit;h=264996a75da61d2771d4dfe5d5...
Author: Alexandre Julliard julliard@winehq.org Date: Mon Dec 27 12:01:52 2010 +0100
ntdll: Use the futex system calls on all Linux platforms.
---
dlls/ntdll/critsection.c | 23 ++++++++++++----------- 1 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/dlls/ntdll/critsection.c b/dlls/ntdll/critsection.c index 8a60109..2f1abcf 100644 --- a/dlls/ntdll/critsection.c +++ b/dlls/ntdll/critsection.c @@ -26,6 +26,9 @@ #include <stdarg.h> #include <stdio.h> #include <sys/types.h> +#ifdef HAVE_SYS_SYSCALL_H +#include <sys/syscall.h> +#endif #include <time.h> #include "ntstatus.h" #define WIN32_NO_STATUS @@ -56,29 +59,27 @@ static inline void small_pause(void) #endif }
-#if defined(linux) && defined(__i386__) +#ifdef __linux__
static inline int futex_wait( int *addr, int val, struct timespec *timeout ) { - int ret = syscall( 240/*SYS_futex*/, addr, 0/*FUTEX_WAIT*/, val, timeout, 0, 0 ); - if (ret < 0) - return -errno; - return ret; + return syscall( SYS_futex, addr, 0/*FUTEX_WAIT*/, val, timeout, 0, 0 ); }
static inline int futex_wake( int *addr, int val ) { - int ret = syscall( 240/*SYS_futex*/, addr, 1/*FUTEX_WAKE*/, val, NULL, 0, 0 ); - if (ret < 0) - return -errno; - return ret; + return syscall( SYS_futex, addr, 1/*FUTEX_WAKE*/, val, NULL, 0, 0 ); }
static inline int use_futexes(void) { static int supported = -1;
- if (supported == -1) supported = (futex_wait( &supported, 10, NULL ) != -ENOSYS); + if (supported == -1) + { + futex_wait( &supported, 10, NULL ); + supported = (errno != ENOSYS); + } return supported; }
@@ -95,7 +96,7 @@ static inline NTSTATUS fast_wait( RTL_CRITICAL_SECTION *crit, int timeout ) { /* note: this may wait longer than specified in case of signals or */ /* multiple wake-ups, but that shouldn't be a problem */ - if (futex_wait( (int *)&crit->LockSemaphore, val, ×pec ) == -ETIMEDOUT) + if (futex_wait( (int *)&crit->LockSemaphore, val, ×pec ) == -1 && errno == ETIMEDOUT) return STATUS_TIMEOUT; } return STATUS_WAIT_0;