libc_hidden_proto (__pthread_cond_init)
extern int __pthread_cond_signal (pthread_cond_t *cond);
extern int __pthread_cond_wait (pthread_cond_t *cond, pthread_mutex_t *mutex);
+
+#if __TIMESIZE == 64
+# define __pthread_clockjoin_np64 __pthread_clockjoin_np
+# define __pthread_timedjoin_np64 __pthread_timedjoin_np
+#else
+extern int __pthread_clockjoin_np64 (pthread_t threadid, void **thread_return,
+ clockid_t clockid,
+ const struct __timespec64 *abstime);
+libc_hidden_proto (__pthread_clockjoin_np64)
+extern int __pthread_timedjoin_np64 (pthread_t threadid, void **thread_return,
+ const struct __timespec64 *abstime);
+libc_hidden_proto (__pthread_timedjoin_np64)
+#endif
+
extern int __pthread_cond_timedwait (pthread_cond_t *cond,
pthread_mutex_t *mutex,
const struct timespec *abstime);
extern void __pthread_disable_asynccancel (int oldtype) attribute_hidden;
extern void __pthread_testcancel (void);
extern int __pthread_clockjoin_ex (pthread_t, void **, clockid_t,
- const struct timespec *, bool)
+ const struct __timespec64 *, bool)
attribute_hidden;
extern int __pthread_sigmask (int, const sigset_t *, sigset_t *);
libc_hidden_proto (__pthread_sigmask);
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
+#include <time.h>
#include "pthreadP.h"
int
-__pthread_clockjoin_np (pthread_t threadid, void **thread_return,
- clockid_t clockid,
- const struct timespec *abstime)
+__pthread_clockjoin_np64 (pthread_t threadid, void **thread_return,
+ clockid_t clockid, const struct __timespec64 *abstime)
{
return __pthread_clockjoin_ex (threadid, thread_return,
clockid, abstime, true);
}
+
+#if __TIMESIZE != 64
+libc_hidden_def (__pthread_clockjoin_np64)
+
+int
+__pthread_clockjoin_np (pthread_t threadid, void **thread_return,
+ clockid_t clockid, const struct timespec *abstime)
+{
+ struct __timespec64 ts64 = valid_timespec_to_timespec64 (*abstime);
+
+ return __pthread_clockjoin_np64 (threadid, thread_return, clockid, &ts64);
+}
+#endif
weak_alias (__pthread_clockjoin_np, pthread_clockjoin_np)
#include <atomic.h>
#include <stap-probe.h>
#include <time.h>
+#include <futex-internal.h>
static void
cleanup (void *arg)
afterwards. The kernel up to version 3.16.3 does not use the private futex
operations for futex wake-up when the clone terminates. */
static int
-clockwait_tid (pid_t *tidp, clockid_t clockid, const struct timespec *abstime)
+clockwait_tid (pid_t *tidp, clockid_t clockid,
+ const struct __timespec64 *abstime)
{
pid_t tid;
+ int ret;
if (! valid_nanoseconds (abstime->tv_nsec))
return EINVAL;
/* Repeat until thread terminated. */
while ((tid = *tidp) != 0)
{
- struct timespec rt;
+ struct __timespec64 rt;
/* Get the current time. This can only fail if clockid is
invalid. */
- if (__glibc_unlikely (__clock_gettime (clockid, &rt)))
+ if (__glibc_unlikely (__clock_gettime64 (clockid, &rt)))
return EINVAL;
/* Compute relative timeout. */
/* If *tidp == tid, wait until thread terminates or the wait times out.
The kernel up to version 3.16.3 does not use the private futex
operations for futex wake-up when the clone terminates. */
- if (lll_futex_timed_wait_cancel (tidp, tid, &rt, LLL_SHARED)
- == -ETIMEDOUT)
- return ETIMEDOUT;
+ ret = futex_timed_wait_cancel64 (tidp, tid, &rt, LLL_SHARED);
+ if (ret == -ETIMEDOUT || ret == -EOVERFLOW)
+ return -ret;
}
return 0;
int
__pthread_clockjoin_ex (pthread_t threadid, void **thread_return,
- clockid_t clockid,
- const struct timespec *abstime, bool block)
+ clockid_t clockid,
+ const struct __timespec64 *abstime, bool block)
{
struct pthread *pd = (struct pthread *) threadid;
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
+#include <time.h>
#include "pthreadP.h"
int
-__pthread_timedjoin_np (pthread_t threadid, void **thread_return,
- const struct timespec *abstime)
+__pthread_timedjoin_np64 (pthread_t threadid, void **thread_return,
+ const struct __timespec64 *abstime)
{
return __pthread_clockjoin_ex (threadid, thread_return,
CLOCK_REALTIME, abstime, true);
}
+
+#if __TIMESIZE != 64
+libc_hidden_def (__pthread_timedjoin_np64)
+
+int
+__pthread_timedjoin_np (pthread_t threadid, void **thread_return,
+ const struct timespec *abstime)
+{
+ struct __timespec64 ts64 = valid_timespec_to_timespec64 (*abstime);
+
+ return __pthread_timedjoin_np64 (threadid, thread_return, &ts64);
+}
+#endif
weak_alias (__pthread_timedjoin_np, pthread_timedjoin_np)
}
}
+#ifndef __NR_futex_time64
+# define __NR_futex_time64 __NR_futex
+#endif
+
+static __always_inline int
+futex_timed_wait_cancel64 (pid_t *tidp, pid_t tid,
+ const struct __timespec64 *timeout, int private)
+{
+ int err = INTERNAL_SYSCALL_CANCEL (futex_time64, tidp,
+ __lll_private_flag
+ (FUTEX_WAIT, private), tid, timeout);
+#ifndef __ASSUME_TIME64_SYSCALLS
+ if (err == -ENOSYS)
+ {
+ if (in_time_t_range (timeout->tv_sec))
+ {
+ struct timespec ts32 = valid_timespec64_to_timespec (*timeout);
+
+ err = INTERNAL_SYSCALL_CANCEL (futex, tidp,
+ __lll_private_flag (FUTEX_WAIT,
+ private),
+ tid, &ts32);
+ }
+ else
+ err = -EOVERFLOW;
+ }
+#endif
+ switch (err)
+ {
+ case 0:
+ case -EAGAIN:
+ case -EINTR:
+ case -ETIMEDOUT:
+ case -EDEADLK:
+ case -ENOSYS:
+ case -EOVERFLOW: /* Passed absolute timeout uses 64 bit time_t type, but
+ underlying kernel does not support 64 bit time_t futex
+ syscalls. */
+ case -EPERM: /* The caller is not allowed to attach itself to the futex.
+ Used to check if PI futexes are supported by the
+ kernel. */
+ return -err;
+
+ case -EINVAL: /* Either due to wrong alignment or due to the timeout not
+ being normalized. Must have been caused by a glibc or
+ application bug. */
+ case -EFAULT: /* Must have been caused by a glibc or application bug. */
+ /* No other errors are documented at this time. */
+ default:
+ futex_fatal_error ();
+ }
+}
#endif /* futex-internal.h */