summaryrefslogtreecommitdiff
path: root/libpthread/nptl/pthread_mutex_timedlock.c
diff options
context:
space:
mode:
Diffstat (limited to 'libpthread/nptl/pthread_mutex_timedlock.c')
-rw-r--r--libpthread/nptl/pthread_mutex_timedlock.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/libpthread/nptl/pthread_mutex_timedlock.c b/libpthread/nptl/pthread_mutex_timedlock.c
index f56f6c55e..1191639b6 100644
--- a/libpthread/nptl/pthread_mutex_timedlock.c
+++ b/libpthread/nptl/pthread_mutex_timedlock.c
@@ -23,6 +23,10 @@
#include <lowlevellock.h>
#include <not-cancel.h>
+#if defined(__UCLIBC_USE_TIME64__)
+#include "internal/time64_helpers.h"
+#endif
+
/* We need to build this function with optimization to avoid
* lll_timedlock erroring out with
* error: can't find a register in class ‘GENERAL_REGS’ while reloading ‘asm’
@@ -264,10 +268,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,
+ TO_TS64_P(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)
@@ -287,10 +298,23 @@ pthread_mutex_timedlock (
/* Delay the thread until the timeout is reached.
Then return ETIMEDOUT. */
struct timespec reltime;
- struct timespec now;
+#if defined(__UCLIBC_USE_TIME64__)
+ struct __ts64_struct __now64;
+#endif
+ struct timespec now = {.tv_sec = 0, .tv_nsec = 0};
+#if defined(__UCLIBC_USE_TIME64__) && defined(__NR_clock_gettime64)
+ int __r = INTERNAL_SYSCALL (clock_gettime64, __err, 2, CLOCK_REALTIME,
+ &__now64);
+
+ if (__r == 0) {
+ now.tv_sec = __now64.tv_sec;
+ now.tv_nsec = __now64.tv_nsec;
+ }
+#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 +364,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;