X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=urcu%2Ffutex.h;h=c206c6fce0d373c4a6dcffbdb7df4e5b37144194;hb=1f616fb07fd4e86f35e471fd74074ab6fa96b4ea;hp=13d2b1a0a9c73904563e2b9b46d40d19e3316686;hpb=42dfe454abcd206bb2005261c6b79cb3d4f9ce29;p=userspace-rcu.git diff --git a/urcu/futex.h b/urcu/futex.h index 13d2b1a..c206c6f 100644 --- a/urcu/futex.h +++ b/urcu/futex.h @@ -25,10 +25,11 @@ #include #include +#include #ifdef __cplusplus extern "C" { -#endif +#endif #define FUTEX_WAIT 0 #define FUTEX_WAKE 1 @@ -57,7 +58,7 @@ extern int compat_futex_async(int32_t *uaddr, int op, int32_t val, #include #include #include -#include +#include static inline int futex(int32_t *uaddr, int op, int32_t val, const struct timespec *timeout, int32_t *uaddr2, int32_t val3) @@ -73,7 +74,16 @@ static inline int futex_noasync(int32_t *uaddr, int op, int32_t val, ret = futex(uaddr, op, val, timeout, uaddr2, val3); if (caa_unlikely(ret < 0 && errno == ENOSYS)) { - return compat_futex_noasync(uaddr, op, val, timeout, + /* + * The fallback on ENOSYS is the async-safe version of + * the compat futex implementation, because the + * async-safe compat implementation allows being used + * concurrently with calls to futex(). Indeed, sys_futex + * FUTEX_WAIT, on some architectures (mips and parisc), + * within a given process, spuriously return ENOSYS due + * to signal restart bugs on some kernel versions. + */ + return compat_futex_async(uaddr, op, val, timeout, uaddr2, val3); } return ret; @@ -93,6 +103,25 @@ static inline int futex_async(int32_t *uaddr, int op, int32_t val, return ret; } +#elif defined(__CYGWIN__) + +/* + * The futex_noasync compat code uses a weak symbol to share state across + * different shared object which is not possible on Windows with the + * Portable Executable format. Use the async compat code for both cases. + */ +static inline int futex_noasync(int32_t *uaddr, int op, int32_t val, + const struct timespec *timeout, int32_t *uaddr2, int32_t val3) +{ + return compat_futex_async(uaddr, op, val, timeout, uaddr2, val3); +} + +static inline int futex_async(int32_t *uaddr, int op, int32_t val, + const struct timespec *timeout, int32_t *uaddr2, int32_t val3) +{ + return compat_futex_async(uaddr, op, val, timeout, uaddr2, val3); +} + #else static inline int futex_noasync(int32_t *uaddr, int op, int32_t val, @@ -109,7 +138,7 @@ static inline int futex_async(int32_t *uaddr, int op, int32_t val, #endif -#ifdef __cplusplus +#ifdef __cplusplus } #endif