/* Hurd helpers for lowlevellocks.
- Copyright (C) 1999-2019 Free Software Foundation, Inc.
+ Copyright (C) 1999-2021 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
__lll_abstimed_wait (void *ptr, int val,
const struct timespec *tsp, int flags, int clk)
{
+ if (clk != CLOCK_REALTIME)
+ return EINVAL;
+
int mlsec = compute_reltime (tsp, clk);
- return mlsec < 0 ? KERN_TIMEDOUT : lll_timed_wait (ptr, val, mlsec, flags);
+ return mlsec < 0 ? KERN_TIMEDOUT : __lll_timed_wait (ptr, val, mlsec, flags);
+}
+
+int
+__lll_abstimed_wait_intr (void *ptr, int val,
+ const struct timespec *tsp, int flags, int clk)
+{
+ if (clk != CLOCK_REALTIME)
+ return EINVAL;
+
+ int mlsec = compute_reltime (tsp, clk);
+ return mlsec < 0 ? KERN_TIMEDOUT : __lll_timed_wait_intr (ptr, val, mlsec, flags);
}
int
__lll_abstimed_xwait (void *ptr, int lo, int hi,
const struct timespec *tsp, int flags, int clk)
{
+ if (clk != CLOCK_REALTIME)
+ return EINVAL;
+
int mlsec = compute_reltime (tsp, clk);
- return mlsec < 0 ? KERN_TIMEDOUT : lll_timed_xwait (ptr, lo, hi, mlsec,
+ return mlsec < 0 ? KERN_TIMEDOUT : __lll_timed_xwait (ptr, lo, hi, mlsec,
flags);
}
__lll_abstimed_lock (void *ptr,
const struct timespec *tsp, int flags, int clk)
{
- if (lll_trylock (ptr) == 0)
+ if (clk != CLOCK_REALTIME)
+ return EINVAL;
+
+ if (__lll_trylock (ptr) == 0)
return 0;
while (1)
{
if (atomic_exchange_acq ((int *)ptr, 2) == 0)
return 0;
- else if (tsp->tv_nsec < 0 || tsp->tv_nsec >= 1000000000)
+ else if (! valid_nanoseconds (tsp->tv_nsec))
return EINVAL;
int mlsec = compute_reltime (tsp, clk);
- if (mlsec < 0 || lll_timed_wait (ptr, 2, mlsec, flags) == KERN_TIMEDOUT)
+ if (mlsec < 0 || __lll_timed_wait (ptr, 2, mlsec, flags) == KERN_TIMEDOUT)
return ETIMEDOUT;
}
}
}
else
{
- lll_timed_wait (iptr, val, wait_time, flags);
+ __lll_timed_wait (iptr, val, wait_time, flags);
if (wait_time < MAX_WAIT_TIME)
wait_time <<= 1;
}
int wait_time = 25;
unsigned int val;
+ if (clk != CLOCK_REALTIME)
+ return EINVAL;
+
while (1)
{
val = *iptr;
else if (mlsec > wait_time)
mlsec = wait_time;
- int res = lll_timed_wait (iptr, val, mlsec, flags);
+ int res = __lll_timed_wait (iptr, val, mlsec, flags);
if (res == KERN_TIMEDOUT)
return ETIMEDOUT;
else if (wait_time < MAX_WAIT_TIME)
{
if (val & LLL_WAITERS)
{
- lll_set_wake (ptr, 0, flags);
+ __lll_set_wake (ptr, 0, flags);
break;
}
else if (atomic_compare_exchange_weak_release ((unsigned int *)ptr, &val, 0))