]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - sysdeps/unix/sysv/linux/futex-internal.h
Prefer https to http for gnu.org and fsf.org URLs
[thirdparty/glibc.git] / sysdeps / unix / sysv / linux / futex-internal.h
index 1add836ebc2f898eeea357d8d39f31fd4212fc0b..5a4f4ff8182d1de75f19caab3a6bcbadab360d2b 100644 (file)
@@ -1,5 +1,5 @@
 /* futex operations for glibc-internal use.  Linux version.
-   Copyright (C) 2014-2016 Free Software Foundation, Inc.
+   Copyright (C) 2014-2019 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -14,7 +14,7 @@
 
    You should have received a copy of the GNU Lesser General Public
    License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
+   <https://www.gnu.org/licenses/>.  */
 
 #ifndef FUTEX_INTERNAL_H
 #define FUTEX_INTERNAL_H
@@ -22,7 +22,7 @@
 #include <sysdeps/nptl/futex-internal.h>
 #include <errno.h>
 #include <lowlevellock-futex.h>
-#include <nptl/pthreadP.h>
+#include <sysdep-cancel.h>
 
 /* See sysdeps/nptl/futex-internal.h for documentation; this file only
    contains Linux-specific comments.
@@ -46,14 +46,6 @@ futex_supports_pshared (int pshared)
     return EINVAL;
 }
 
-/* The Linux kernel supports relative timeouts measured against the
-   CLOCK_MONOTONIC clock.  */
-static __always_inline bool
-futex_supports_exact_relative_timeouts (void)
-{
-  return true;
-}
-
 /* See sysdeps/nptl/futex-internal.h for details.  */
 static __always_inline int
 futex_wait (unsigned int *futex_word, unsigned int expected, int private)
@@ -138,9 +130,9 @@ futex_reltimed_wait_cancelable (unsigned int *futex_word,
                                const struct timespec *reltime, int private)
 {
   int oldtype;
-  oldtype = __pthread_enable_asynccancel ();
+  oldtype = LIBC_CANCEL_ASYNC ();
   int err = lll_futex_timed_wait (futex_word, expected, reltime, private);
-  __pthread_disable_asynccancel (oldtype);
+  LIBC_CANCEL_RESET (oldtype);
   switch (err)
     {
     case 0:
@@ -160,17 +152,26 @@ futex_reltimed_wait_cancelable (unsigned int *futex_word,
     }
 }
 
+/* See sysdeps/nptl/futex-internal.h for details.  */
+static __always_inline int
+futex_abstimed_supported_clockid (clockid_t clockid)
+{
+  return lll_futex_supported_clockid (clockid);
+}
+
 /* See sysdeps/nptl/futex-internal.h for details.  */
 static __always_inline int
 futex_abstimed_wait (unsigned int *futex_word, unsigned int expected,
+                    clockid_t clockid,
                     const struct timespec *abstime, int private)
 {
   /* Work around the fact that the kernel rejects negative timeout values
      despite them being valid.  */
   if (__glibc_unlikely ((abstime != NULL) && (abstime->tv_sec < 0)))
     return ETIMEDOUT;
-  int err = lll_futex_timed_wait_bitset (futex_word, expected, abstime,
-                                        FUTEX_CLOCK_REALTIME, private);
+  int err = lll_futex_clock_wait_bitset (futex_word, expected,
+                                        clockid, abstime,
+                                        private);
   switch (err)
     {
     case 0:
@@ -180,8 +181,9 @@ futex_abstimed_wait (unsigned int *futex_word, unsigned int expected,
       return -err;
 
     case -EFAULT: /* Must have been caused by a glibc or application bug.  */
-    case -EINVAL: /* Either due to wrong alignment or due to the timeout not
-                    being normalized.  Must have been caused by a glibc or
+    case -EINVAL: /* Either due to wrong alignment, unsupported
+                    clockid or due to the timeout not being
+                    normalized. Must have been caused by a glibc or
                     application bug.  */
     case -ENOSYS: /* Must have been caused by a glibc bug.  */
     /* No other errors are documented at this time.  */
@@ -194,6 +196,7 @@ futex_abstimed_wait (unsigned int *futex_word, unsigned int expected,
 static __always_inline int
 futex_abstimed_wait_cancelable (unsigned int *futex_word,
                                unsigned int expected,
+                               clockid_t clockid,
                                const struct timespec *abstime, int private)
 {
   /* Work around the fact that the kernel rejects negative timeout values
@@ -202,8 +205,9 @@ futex_abstimed_wait_cancelable (unsigned int *futex_word,
     return ETIMEDOUT;
   int oldtype;
   oldtype = __pthread_enable_asynccancel ();
-  int err = lll_futex_timed_wait_bitset (futex_word, expected, abstime,
-                                        FUTEX_CLOCK_REALTIME, private);
+  int err = lll_futex_clock_wait_bitset (futex_word, expected,
+                                       clockid, abstime,
+                                       private);
   __pthread_disable_asynccancel (oldtype);
   switch (err)
     {