summaryrefslogtreecommitdiff
path: root/libpthread
diff options
context:
space:
mode:
Diffstat (limited to 'libpthread')
-rw-r--r--libpthread/linuxthreads/condvar.c4
-rw-r--r--libpthread/nptl/init.c13
-rw-r--r--libpthread/nptl/pthread_condattr_setclock.c6
-rw-r--r--libpthread/nptl/pthread_mutex_init.c5
-rw-r--r--libpthread/nptl/pthread_mutex_lock.c13
-rw-r--r--libpthread/nptl/pthread_mutex_timedlock.c19
-rw-r--r--libpthread/nptl/pthread_mutex_trylock.c13
-rw-r--r--libpthread/nptl/pthread_mutex_unlock.c5
-rw-r--r--libpthread/nptl/sysdeps/pthread/pthread_cond_timedwait.c8
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/lowlevellock.h58
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/nanosleep.c12
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/timer_create.c5
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/timer_gettime.c4
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/timer_settime.c5
14 files changed, 165 insertions, 5 deletions
diff --git a/libpthread/linuxthreads/condvar.c b/libpthread/linuxthreads/condvar.c
index 6ac1622da..949991ad7 100644
--- a/libpthread/linuxthreads/condvar.c
+++ b/libpthread/linuxthreads/condvar.c
@@ -328,7 +328,11 @@ int pthread_condattr_setclock (pthread_condattr_t *attr, clockid_t clock_id)
INTERNAL_SYSCALL_DECL (err);
int val;
+#if defined(__UCLIBC_USE_TIME64__) && defined(__NR_clock_getres_time64)
+ val = INTERNAL_SYSCALL (clock_getres_time64, err, 2, CLOCK_MONOTONIC, &ts);
+#else
val = INTERNAL_SYSCALL (clock_getres, err, 2, CLOCK_MONOTONIC, &ts);
+#endif
avail = INTERNAL_SYSCALL_ERROR_P (val, err) ? -1 : 1;
}
diff --git a/libpthread/nptl/init.c b/libpthread/nptl/init.c
index ddc552f2e..a6c0ec6af 100644
--- a/libpthread/nptl/init.c
+++ b/libpthread/nptl/init.c
@@ -195,8 +195,14 @@ __pthread_initialize_minimal_internal (void)
doing the test once this early is beneficial. */
{
int word = 0;
+#if defined(__UCLIBC_USE_TIME64__) && defined(__NR_futex_time64)
+ word = INTERNAL_SYSCALL (futex_time64, err, 3, &word,
+ FUTEX_WAKE | FUTEX_PRIVATE_FLAG, 1);
+#else
word = INTERNAL_SYSCALL (futex, err, 3, &word,
FUTEX_WAKE | FUTEX_PRIVATE_FLAG, 1);
+#endif
+
if (!INTERNAL_SYSCALL_ERROR_P (word, err))
THREAD_SETMEM (pd, header.private_futex, FUTEX_PRIVATE_FLAG);
}
@@ -215,9 +221,16 @@ __pthread_initialize_minimal_internal (void)
is irrelevant. Given that passing six parameters is difficult
on some architectures we just pass whatever random value the
calling convention calls for to the kernel. It causes no harm. */
+#if defined(__UCLIBC_USE_TIME64__) && defined(__NR_futex_time64)
+ word = INTERNAL_SYSCALL (futex_time64, err, 5, &word,
+ FUTEX_WAIT_BITSET | FUTEX_CLOCK_REALTIME
+ | FUTEX_PRIVATE_FLAG, 1, NULL, 0);
+#else
word = INTERNAL_SYSCALL (futex, err, 5, &word,
FUTEX_WAIT_BITSET | FUTEX_CLOCK_REALTIME
| FUTEX_PRIVATE_FLAG, 1, NULL, 0);
+#endif
+
assert (INTERNAL_SYSCALL_ERROR_P (word, err));
if (INTERNAL_SYSCALL_ERRNO (word, err) != ENOSYS)
__set_futex_clock_realtime ();
diff --git a/libpthread/nptl/pthread_condattr_setclock.c b/libpthread/nptl/pthread_condattr_setclock.c
index b2f4aaf29..e7f3539d6 100644
--- a/libpthread/nptl/pthread_condattr_setclock.c
+++ b/libpthread/nptl/pthread_condattr_setclock.c
@@ -35,7 +35,7 @@ pthread_condattr_setclock (
if (clock_id == CLOCK_MONOTONIC)
{
#ifndef __ASSUME_POSIX_TIMERS
-# ifdef __NR_clock_getres
+# if defined(__NR_clock_getres) || defined(__NR_clock_getres_time64)
/* Check whether the clock is available. */
static int avail;
@@ -45,7 +45,11 @@ pthread_condattr_setclock (
INTERNAL_SYSCALL_DECL (err);
int val;
+#if defined(__UCLIBC_USE_TIME64__) && defined(__NR_clock_getres_time64)
+ val = INTERNAL_SYSCALL (clock_getres_time64, err, 2, CLOCK_MONOTONIC, &ts);
+#else
val = INTERNAL_SYSCALL (clock_getres, err, 2, CLOCK_MONOTONIC, &ts);
+#endif
avail = INTERNAL_SYSCALL_ERROR_P (val, err) ? -1 : 1;
}
diff --git a/libpthread/nptl/pthread_mutex_init.c b/libpthread/nptl/pthread_mutex_init.c
index bf4c4d151..ba5c916eb 100644
--- a/libpthread/nptl/pthread_mutex_init.c
+++ b/libpthread/nptl/pthread_mutex_init.c
@@ -62,8 +62,13 @@ __pthread_mutex_init (
{
int lock = 0;
INTERNAL_SYSCALL_DECL (err);
+#if defined(__UCLIBC_USE_TIME64__) && defined(__NR_futex_time64)
+ int ret = INTERNAL_SYSCALL (futex_time64, err, 4, &lock, FUTEX_UNLOCK_PI,
+ 0, 0);
+#else
int ret = INTERNAL_SYSCALL (futex, err, 4, &lock, FUTEX_UNLOCK_PI,
0, 0);
+#endif
assert (INTERNAL_SYSCALL_ERROR_P (ret, err));
tpi_supported = INTERNAL_SYSCALL_ERRNO (ret, err) == ENOSYS ? -1 : 1;
}
diff --git a/libpthread/nptl/pthread_mutex_lock.c b/libpthread/nptl/pthread_mutex_lock.c
index 8353e8cd3..6e98a9760 100644
--- a/libpthread/nptl/pthread_mutex_lock.c
+++ b/libpthread/nptl/pthread_mutex_lock.c
@@ -300,9 +300,15 @@ __pthread_mutex_lock_full (pthread_mutex_t *mutex)
? PTHREAD_ROBUST_MUTEX_PSHARED (mutex)
: PTHREAD_MUTEX_PSHARED (mutex));
INTERNAL_SYSCALL_DECL (__err);
+#if defined(__UCLIBC_USE_TIME64__) && defined(__NR_futex_time64)
+ int e = INTERNAL_SYSCALL (futex_time64, __err, 4, &mutex->__data.__lock,
+ __lll_private_flag (FUTEX_LOCK_PI,
+ private), 1, 0);
+#else
int e = INTERNAL_SYSCALL (futex, __err, 4, &mutex->__data.__lock,
__lll_private_flag (FUTEX_LOCK_PI,
private), 1, 0);
+#endif
if (INTERNAL_SYSCALL_ERROR_P (e, __err)
&& (INTERNAL_SYSCALL_ERRNO (e, __err) == ESRCH
@@ -357,10 +363,17 @@ __pthread_mutex_lock_full (pthread_mutex_t *mutex)
mutex->__data.__count = 0;
INTERNAL_SYSCALL_DECL (__err);
+#if defined(__UCLIBC_USE_TIME64__) && defined(__NR_futex_time64)
+ INTERNAL_SYSCALL (futex_time64, __err, 4, &mutex->__data.__lock,
+ __lll_private_flag (FUTEX_UNLOCK_PI,
+ PTHREAD_ROBUST_MUTEX_PSHARED (mutex)),
+ 0, 0);
+#else
INTERNAL_SYSCALL (futex, __err, 4, &mutex->__data.__lock,
__lll_private_flag (FUTEX_UNLOCK_PI,
PTHREAD_ROBUST_MUTEX_PSHARED (mutex)),
0, 0);
+#endif
THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
return ENOTRECOVERABLE;
diff --git a/libpthread/nptl/pthread_mutex_timedlock.c b/libpthread/nptl/pthread_mutex_timedlock.c
index f56f6c55e..25f9ec3b2 100644
--- a/libpthread/nptl/pthread_mutex_timedlock.c
+++ b/libpthread/nptl/pthread_mutex_timedlock.c
@@ -264,10 +264,17 @@ pthread_mutex_timedlock (
: PTHREAD_MUTEX_PSHARED (mutex));
INTERNAL_SYSCALL_DECL (__err);
+#if defined(__UCLIBC_USE_TIME64__) && defined(__NR_futex_time64)
+ int e = INTERNAL_SYSCALL (futex_time64, __err, 4, &mutex->__data.__lock,
+ __lll_private_flag (FUTEX_LOCK_PI,
+ private), 1,
+ abstime);
+#else
int e = INTERNAL_SYSCALL (futex, __err, 4, &mutex->__data.__lock,
__lll_private_flag (FUTEX_LOCK_PI,
private), 1,
abstime);
+#endif
if (INTERNAL_SYSCALL_ERROR_P (e, __err))
{
if (INTERNAL_SYSCALL_ERRNO (e, __err) == ETIMEDOUT)
@@ -289,8 +296,13 @@ pthread_mutex_timedlock (
struct timespec reltime;
struct timespec now;
+#if defined(__UCLIBC_USE_TIME64__) && defined(__NR_clock_gettime64)
+ INTERNAL_SYSCALL (clock_gettime64, __err, 2, CLOCK_REALTIME,
+ &now);
+#else
INTERNAL_SYSCALL (clock_gettime, __err, 2, CLOCK_REALTIME,
&now);
+#endif
reltime.tv_sec = abstime->tv_sec - now.tv_sec;
reltime.tv_nsec = abstime->tv_nsec - now.tv_nsec;
if (reltime.tv_nsec < 0)
@@ -340,10 +352,17 @@ pthread_mutex_timedlock (
mutex->__data.__count = 0;
INTERNAL_SYSCALL_DECL (__err);
+#if defined(__UCLIBC_USE_TIME64__) && defined(__NR_futex_time64)
+ INTERNAL_SYSCALL (futex_time64, __err, 4, &mutex->__data.__lock,
+ __lll_private_flag (FUTEX_UNLOCK_PI,
+ PTHREAD_ROBUST_MUTEX_PSHARED (mutex)),
+ 0, 0);
+#else
INTERNAL_SYSCALL (futex, __err, 4, &mutex->__data.__lock,
__lll_private_flag (FUTEX_UNLOCK_PI,
PTHREAD_ROBUST_MUTEX_PSHARED (mutex)),
0, 0);
+#endif
THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
return ENOTRECOVERABLE;
diff --git a/libpthread/nptl/pthread_mutex_trylock.c b/libpthread/nptl/pthread_mutex_trylock.c
index e0d54bda7..ca02109ee 100644
--- a/libpthread/nptl/pthread_mutex_trylock.c
+++ b/libpthread/nptl/pthread_mutex_trylock.c
@@ -234,9 +234,15 @@ __pthread_mutex_trylock (
? PTHREAD_ROBUST_MUTEX_PSHARED (mutex)
: PTHREAD_MUTEX_PSHARED (mutex));
INTERNAL_SYSCALL_DECL (__err);
+#if defined(__UCLIBC_USE_TIME64__) && defined(__NR_futex_time64)
+ int e = INTERNAL_SYSCALL (futex_time64, __err, 4, &mutex->__data.__lock,
+ __lll_private_flag (FUTEX_TRYLOCK_PI,
+ private), 0, 0);
+#else
int e = INTERNAL_SYSCALL (futex, __err, 4, &mutex->__data.__lock,
__lll_private_flag (FUTEX_TRYLOCK_PI,
private), 0, 0);
+#endif
if (INTERNAL_SYSCALL_ERROR_P (e, __err)
&& INTERNAL_SYSCALL_ERRNO (e, __err) == EWOULDBLOCK)
@@ -276,10 +282,17 @@ __pthread_mutex_trylock (
mutex->__data.__count = 0;
INTERNAL_SYSCALL_DECL (__err);
+#if defined(__UCLIBC_USE_TIME64__) && defined(__NR_futex_time64)
+ INTERNAL_SYSCALL (futex_time64, __err, 4, &mutex->__data.__lock,
+ __lll_private_flag (FUTEX_UNLOCK_PI,
+ PTHREAD_ROBUST_MUTEX_PSHARED (mutex)),
+ 0, 0);
+#else
INTERNAL_SYSCALL (futex, __err, 4, &mutex->__data.__lock,
__lll_private_flag (FUTEX_UNLOCK_PI,
PTHREAD_ROBUST_MUTEX_PSHARED (mutex)),
0, 0);
+#endif
THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
return ENOTRECOVERABLE;
diff --git a/libpthread/nptl/pthread_mutex_unlock.c b/libpthread/nptl/pthread_mutex_unlock.c
index 1123e3c42..6f3ed8c44 100644
--- a/libpthread/nptl/pthread_mutex_unlock.c
+++ b/libpthread/nptl/pthread_mutex_unlock.c
@@ -222,8 +222,13 @@ __pthread_mutex_unlock_full (pthread_mutex_t *mutex, int decr)
? PTHREAD_ROBUST_MUTEX_PSHARED (mutex)
: PTHREAD_MUTEX_PSHARED (mutex));
INTERNAL_SYSCALL_DECL (__err);
+#if defined(__UCLIBC_USE_TIME64__) && defined(__NR_futex_time64)
+ INTERNAL_SYSCALL (futex_time64, __err, 2, &mutex->__data.__lock,
+ __lll_private_flag (FUTEX_UNLOCK_PI, private));
+#else
INTERNAL_SYSCALL (futex, __err, 2, &mutex->__data.__lock,
__lll_private_flag (FUTEX_UNLOCK_PI, private));
+#endif
}
THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
diff --git a/libpthread/nptl/sysdeps/pthread/pthread_cond_timedwait.c b/libpthread/nptl/sysdeps/pthread/pthread_cond_timedwait.c
index f06b69e2f..49aab0293 100644
--- a/libpthread/nptl/sysdeps/pthread/pthread_cond_timedwait.c
+++ b/libpthread/nptl/sysdeps/pthread/pthread_cond_timedwait.c
@@ -102,10 +102,18 @@ __pthread_cond_timedwait (
# ifndef __ASSUME_POSIX_TIMERS
int ret =
# endif
+#if defined(__UCLIBC_USE_TIME64__) && defined(__NR_clock_gettime64)
+ INTERNAL_SYSCALL (clock_gettime64, err, 2,
+ (cond->__data.__nwaiters
+ & ((1 << COND_NWAITERS_SHIFT) - 1)),
+ &rt);
+#else
INTERNAL_SYSCALL (clock_gettime, err, 2,
(cond->__data.__nwaiters
& ((1 << COND_NWAITERS_SHIFT) - 1)),
&rt);
+#endif
+
# ifndef __ASSUME_POSIX_TIMERS
if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (ret, err), 0))
{
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/lowlevellock.h b/libpthread/nptl/sysdeps/unix/sysv/linux/lowlevellock.h
index b5b0afdf8..e72fe5234 100644
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/lowlevellock.h
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/lowlevellock.h
@@ -71,10 +71,33 @@
# endif
#endif
-
#define lll_futex_wait(futexp, val, private) \
lll_futex_timed_wait(futexp, val, NULL, private)
+#if defined(__UCLIBC_USE_TIME64__) && defined(__NR_futex_time64)
+
+#define lll_futex_timed_wait(futexp, val, timespec, private) \
+ ({ \
+ INTERNAL_SYSCALL_DECL (__err); \
+ long int __ret; \
+ __ret = INTERNAL_SYSCALL (futex_time64, __err, 4, (futexp), \
+ __lll_private_flag (FUTEX_WAIT, private), \
+ (val), (timespec)); \
+ __ret; \
+ })
+
+#define lll_futex_wake(futexp, nr, private) \
+ ({ \
+ INTERNAL_SYSCALL_DECL (__err); \
+ long int __ret; \
+ __ret = INTERNAL_SYSCALL (futex_time64, __err, 4, (futexp), \
+ __lll_private_flag (FUTEX_WAKE, private), \
+ (nr), 0); \
+ __ret; \
+ })
+
+#else
+
#define lll_futex_timed_wait(futexp, val, timespec, private) \
({ \
INTERNAL_SYSCALL_DECL (__err); \
@@ -95,6 +118,8 @@
__ret; \
})
+#endif
+
#define lll_robust_dead(futexv, private) \
do \
{ \
@@ -105,6 +130,35 @@
while (0)
/* Returns non-zero if error happened, zero if success. */
+
+#if defined(__UCLIBC_USE_TIME64__) && defined(__NR_futex_time64)
+
+#define lll_futex_requeue(futexp, nr_wake, nr_move, mutex, val, private) \
+ ({ \
+ INTERNAL_SYSCALL_DECL (__err); \
+ long int __ret; \
+ __ret = INTERNAL_SYSCALL (futex_time64, __err, 6, (futexp), \
+ __lll_private_flag (FUTEX_CMP_REQUEUE, private),\
+ (nr_wake), (nr_move), (mutex), (val)); \
+ INTERNAL_SYSCALL_ERROR_P (__ret, __err); \
+ })
+
+
+/* Returns non-zero if error happened, zero if success. */
+#define lll_futex_wake_unlock(futexp, nr_wake, nr_wake2, futexp2, private) \
+ ({ \
+ INTERNAL_SYSCALL_DECL (__err); \
+ long int __ret; \
+ __ret = INTERNAL_SYSCALL (futex_time64, __err, 6, (futexp), \
+ __lll_private_flag (FUTEX_WAKE_OP, private), \
+ (nr_wake), (nr_wake2), (futexp2), \
+ FUTEX_OP_CLEAR_WAKE_IF_GT_ONE); \
+ INTERNAL_SYSCALL_ERROR_P (__ret, __err); \
+ })
+
+#else
+
+
#define lll_futex_requeue(futexp, nr_wake, nr_move, mutex, val, private) \
({ \
INTERNAL_SYSCALL_DECL (__err); \
@@ -128,6 +182,8 @@
INTERNAL_SYSCALL_ERROR_P (__ret, __err); \
})
+#endif
+
#define lll_trylock(lock) \
atomic_compare_and_exchange_val_acq(&(lock), 1, 0)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/nanosleep.c b/libpthread/nptl/sysdeps/unix/sysv/linux/nanosleep.c
index 73fae44bc..9c7230934 100644
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/nanosleep.c
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/nanosleep.c
@@ -8,11 +8,17 @@
/* Pause execution for a number of nanoseconds. */
int
-nanosleep (const struct timespec *requested_time,
+_NC(nanosleep) (const struct timespec *requested_time,
struct timespec *remaining)
{
- return _syscall2(int, __NC(nanosleep), const struct timespec*,
- requested_time, struct timespec* remaining)
+ int __ret = clock_nanosleep(CLOCK_REALTIME, 0, requested_time, remaining);
+
+ if (__ret != 0) {
+ __set_errno(__ret);
+ return -1;
+ }
+
+ return __ret;
}
CANCELLABLE_SYSCALL(int, nanosleep, (const struct timespec *requested_time,
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/timer_create.c b/libpthread/nptl/sysdeps/unix/sysv/linux/timer_create.c
index 93e4e6070..cd8d2f84f 100644
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/timer_create.c
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/timer_create.c
@@ -140,8 +140,13 @@ timer_create (
INTERNAL_SYSCALL_DECL (err);
struct timespec ts;
int res;
+#if defined(__UCLIBC_USE_TIME64__) && defined(__NR_clock_getres_time64)
+ res = INTERNAL_SYSCALL (clock_getres_time64, err, 2,
+ CLOCK_REALTIME, &ts);
+#else
res = INTERNAL_SYSCALL (clock_getres, err, 2,
CLOCK_REALTIME, &ts);
+#endif
__no_posix_timers = (INTERNAL_SYSCALL_ERROR_P (res, err)
? -1 : 1);
}
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/timer_gettime.c b/libpthread/nptl/sysdeps/unix/sysv/linux/timer_gettime.c
index 699874f3f..220df0c37 100644
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/timer_gettime.c
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/timer_gettime.c
@@ -50,7 +50,11 @@ timer_gettime (
struct timer *kt = (struct timer *) timerid;
/* Delete the kernel timer object. */
+# if defined(__UCLIBC_USE_TIME64__) && defined(__NR_timer_gettime64)
+ int res = INLINE_SYSCALL (timer_gettime64, 2, kt->ktimerid, value);
+# else
int res = INLINE_SYSCALL (timer_gettime, 2, kt->ktimerid, value);
+# endif
# ifndef __ASSUME_POSIX_TIMERS
if (res != -1 || errno != ENOSYS)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/timer_settime.c b/libpthread/nptl/sysdeps/unix/sysv/linux/timer_settime.c
index 81a0fa568..80d242f21 100644
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/timer_settime.c
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/timer_settime.c
@@ -54,8 +54,13 @@ timer_settime (
struct timer *kt = (struct timer *) timerid;
/* Delete the kernel timer object. */
+# if defined(__UCLIBC_USE_TIME64__) && defined(__NR_timer_settime64)
+ int res = INLINE_SYSCALL (timer_settime64, 4, kt->ktimerid, flags,
+ value, ovalue);
+# else
int res = INLINE_SYSCALL (timer_settime, 4, kt->ktimerid, flags,
value, ovalue);
+# endif
# ifndef __ASSUME_POSIX_TIMERS
if (res != -1 || errno != ENOSYS)