/* 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
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
#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.
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)
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:
}
}
+/* 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:
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. */
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
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)
{