Fix: compat_futex_noasync on Cygwin
[urcu.git] / urcu / futex.h
index 4d16cfa5201453954dc7e6233372ea6969d23c26..753df622005f8d4103010e9f324827e8f97f2b62 100644 (file)
@@ -73,7 +73,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 +102,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,
This page took 0.023398 seconds and 4 git commands to generate.