diff options
Diffstat (limited to 'librt')
-rw-r--r-- | librt/clock_getcpuclockid.c | 15 | ||||
-rw-r--r-- | librt/clock_gettime.c | 34 | ||||
-rw-r--r-- | librt/clock_nanosleep.c | 35 | ||||
-rw-r--r-- | librt/mq_receive.c | 2 | ||||
-rw-r--r-- | librt/mq_send.c | 2 | ||||
-rw-r--r-- | librt/mq_timedreceive.c | 10 | ||||
-rw-r--r-- | librt/mq_timedsend.c | 9 | ||||
-rw-r--r-- | librt/timer_gettime.c | 6 | ||||
-rw-r--r-- | librt/timer_settime.c | 14 |
9 files changed, 115 insertions, 12 deletions
diff --git a/librt/clock_getcpuclockid.c b/librt/clock_getcpuclockid.c index b6142a78a..a402e56d7 100644 --- a/librt/clock_getcpuclockid.c +++ b/librt/clock_getcpuclockid.c @@ -30,7 +30,7 @@ int clock_getcpuclockid (pid_t pid, clockid_t *clock_id) { -#ifdef __NR_clock_getres +#if defined(__NR_clock_getres) || defined(__NR_clock_getres_time64) /* The clockid_t value is a simple computation from the PID. But we do a clock_getres call to validate it. */ @@ -47,7 +47,11 @@ clock_getcpuclockid (pid_t pid, clockid_t *clock_id) # endif { INTERNAL_SYSCALL_DECL (err); +# if defined(__UCLIBC_USE_TIME64__) && defined(__NR_clock_getres_time64) + int r = INTERNAL_SYSCALL (clock_getres_time64, err, 2, pidclock, NULL); +# else int r = INTERNAL_SYSCALL (clock_getres, err, 2, pidclock, NULL); +# endif if (!INTERNAL_SYSCALL_ERROR_P (r, err)) { *clock_id = pidclock; @@ -66,12 +70,21 @@ clock_getcpuclockid (pid_t pid, clockid_t *clock_id) if (INTERNAL_SYSCALL_ERRNO (r, err) == EINVAL) { # if !(__ASSUME_POSIX_CPU_TIMERS > 0) +# if defined(__UCLIBC_USE_TIME64__) && defined(__NR_clock_getres_time64) + if (pidclock == MAKE_PROCESS_CPUCLOCK (0, CPUCLOCK_SCHED) + || INTERNAL_SYSCALL_ERROR_P (INTERNAL_SYSCALL + (clock_getres_time64, err, 2, + MAKE_PROCESS_CPUCLOCK + (0, CPUCLOCK_SCHED), NULL), + err)) +# else if (pidclock == MAKE_PROCESS_CPUCLOCK (0, CPUCLOCK_SCHED) || INTERNAL_SYSCALL_ERROR_P (INTERNAL_SYSCALL (clock_getres, err, 2, MAKE_PROCESS_CPUCLOCK (0, CPUCLOCK_SCHED), NULL), err)) +# endif /* The kernel doesn't support these clocks at all. */ __libc_missing_posix_cpu_timers = 1; else diff --git a/librt/clock_gettime.c b/librt/clock_gettime.c index e65d39d44..dd1f0c514 100644 --- a/librt/clock_gettime.c +++ b/librt/clock_gettime.c @@ -22,10 +22,30 @@ #include <sys/time.h> #include "kernel-posix-cpu-timers.h" +#ifdef __VDSO_SUPPORT__ +#include "ldso.h" +#endif + +#if defined(__UCLIBC_USE_TIME64__) +#include "internal/time64_helpers.h" +#endif +#if defined(__UCLIBC_USE_TIME64__) && defined(__NR_clock_gettime64) +#define SYSCALL_GETTIME \ + { \ + struct __ts64_struct __ts64; \ + retval = INLINE_SYSCALL (clock_gettime64, 2, clock_id, &__ts64); \ + if (tp) { \ + tp->tv_sec = __ts64.tv_sec; \ + tp->tv_nsec = __ts64.tv_nsec; \ + } \ + break; \ + } +#else #define SYSCALL_GETTIME \ retval = INLINE_SYSCALL (clock_gettime, 2, clock_id, tp); \ break +#endif /* The REALTIME and MONOTONIC clock are definitely supported in the kernel. */ #define SYSDEP_GETTIME \ @@ -52,9 +72,8 @@ realtime_gettime (struct timespec *tp) return retval; } -/* Get current value of CLOCK and store it in TP. */ int -clock_gettime (clockid_t clock_id, struct timespec *tp) +__libc_clock_gettime (clockid_t clock_id, struct timespec *tp) { int retval = -1; #ifndef HANDLED_REALTIME @@ -85,3 +104,14 @@ clock_gettime (clockid_t clock_id, struct timespec *tp) return retval; } + +/* Get current value of CLOCK and store it in TP. */ +int +clock_gettime (clockid_t clock_id, struct timespec *tp) +{ +#if defined(__VDSO_SUPPORT__) && defined(ARCH_VDSO_CLOCK_GETTIME) + return ARCH_VDSO_CLOCK_GETTIME(clock_id, tp); +#else + return __libc_clock_gettime(clock_id, tp); +#endif +} diff --git a/librt/clock_nanosleep.c b/librt/clock_nanosleep.c index 1515cf5b0..5537b0609 100644 --- a/librt/clock_nanosleep.c +++ b/librt/clock_nanosleep.c @@ -21,6 +21,9 @@ #include "kernel-posix-cpu-timers.h" +#if defined(__UCLIBC_USE_TIME64__) +#include "internal/time64_helpers.h" +#endif /* We can simply use the syscall. The CPU clocks are not supported with this function. */ @@ -36,18 +39,40 @@ clock_nanosleep (clockid_t clock_id, int flags, const struct timespec *req, if (clock_id == CLOCK_PROCESS_CPUTIME_ID) clock_id = MAKE_PROCESS_CPUCLOCK (0, CPUCLOCK_SCHED); -#if defined(SINGLE_THREAD_P) - r = INTERNAL_SYSCALL (clock_nanosleep, err, 4, clock_id, flags, req, rem); + if (SINGLE_THREAD_P) { +#if defined(__UCLIBC_USE_TIME64__) && defined(__NR_clock_nanosleep_time64) + struct __ts64_struct __req, __rem; + __req.tv_sec = req->tv_sec; + __req.tv_nsec = req->tv_nsec; + r = INTERNAL_SYSCALL (clock_nanosleep_time64, err, 4, clock_id, flags, &__req, &__rem); + if (rem) { + rem->tv_sec = (time_t) __rem.tv_sec; + rem->tv_nsec = __rem.tv_nsec; + } #else + r = INTERNAL_SYSCALL (clock_nanosleep, err, 4, clock_id, flags, req, rem); +#endif + } + else { +#ifdef __NEW_THREADS int oldstate = LIBC_CANCEL_ASYNC (); - +#if defined(__UCLIBC_USE_TIME64__) && defined(__NR_clock_nanosleep_time64) + struct __ts64_struct __req, __rem; + __req.tv_sec = req->tv_sec; + __req.tv_nsec = req->tv_nsec; + r = INTERNAL_SYSCALL (clock_nanosleep_time64, err, 4, clock_id, flags, &__req, &__rem); + if (rem) { + rem->tv_sec = (time_t) __rem.tv_sec; + rem->tv_nsec = __rem.tv_nsec; + } +#else r = INTERNAL_SYSCALL (clock_nanosleep, err, 4, clock_id, flags, req, rem); - +#endif LIBC_CANCEL_RESET (oldstate); - } #endif + } return (INTERNAL_SYSCALL_ERROR_P (r, err) ? INTERNAL_SYSCALL_ERRNO (r, err) : 0); diff --git a/librt/mq_receive.c b/librt/mq_receive.c index e6fd62b87..217848cca 100644 --- a/librt/mq_receive.c +++ b/librt/mq_receive.c @@ -8,7 +8,7 @@ #include <mqueue.h> -#ifdef __NR_mq_timedreceive +#if defined(__NR_mq_timedreceive) || defined(__NR_mq_timedreceive_time64) ssize_t mq_receive(mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned int *msg_prio) { return mq_timedreceive(mqdes, msg_ptr, msg_len, msg_prio, NULL); diff --git a/librt/mq_send.c b/librt/mq_send.c index fb4fa6555..079e804f7 100644 --- a/librt/mq_send.c +++ b/librt/mq_send.c @@ -8,7 +8,7 @@ #include <mqueue.h> -#ifdef __NR_mq_timedsend +#if defined(__NR_mq_timedsend) || defined(__NR_mq_timedsend_time64) int mq_send(mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned int msg_prio) { return mq_timedsend(mqdes, msg_ptr, msg_len, msg_prio, NULL); diff --git a/librt/mq_timedreceive.c b/librt/mq_timedreceive.c index 9f5efc4fa..f89b4c36b 100644 --- a/librt/mq_timedreceive.c +++ b/librt/mq_timedreceive.c @@ -8,9 +8,19 @@ #include <unistd.h> #include <cancel.h> +#if defined(__UCLIBC_USE_TIME64__) && defined(__NR_mq_timedreceive_time64) +#include "internal/time64_helpers.h" + +int _NC(mq_timedreceive)(mqd_t mqdes, char *restrict msg_ptr, size_t msg_len, unsigned int *restrict msq_prio, const struct timespec *restrict abs_timeout) +{ + return INLINE_SYSCALL(mq_timedreceive_time64, 5, mqdes, msg_ptr, msg_len, msq_prio, TO_TS64_P(abs_timeout)); +} +#else #define __NR___mq_timedreceive_nocancel __NR_mq_timedreceive _syscall5(ssize_t, __NC(mq_timedreceive), mqd_t, mqdes, char *__restrict, msg_ptr, size_t, msg_len, unsigned int *__restrict, msq_prio, const struct timespec *__restrict, abs_timeout) +#endif CANCELLABLE_SYSCALL(ssize_t, mq_timedreceive, (mqd_t mqdes, char *__restrict msg_ptr, size_t msq_len, unsigned int *__restrict msq_prio, const struct timespec *__restrict abs_timeout), (mqdes, msg_ptr, msq_len, msq_prio, abs_timeout)) + lt_libc_hidden(mq_timedreceive) diff --git a/librt/mq_timedsend.c b/librt/mq_timedsend.c index 7c2e97ee3..b081ac0ce 100644 --- a/librt/mq_timedsend.c +++ b/librt/mq_timedsend.c @@ -8,8 +8,17 @@ #include <unistd.h> #include <cancel.h> +#if defined(__UCLIBC_USE_TIME64__) && defined(__NR_mq_timedsend_time64) +#include "internal/time64_helpers.h" + +int _NC(mq_timedsend)(mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned int msq_prio, const struct timespec *abs_timeout) +{ + return INLINE_SYSCALL(mq_timedsend_time64, 5, mqdes, msg_ptr, msg_len, msq_prio, TO_TS64_P(abs_timeout)); +} +#else #define __NR___mq_timedsend_nocancel __NR_mq_timedsend _syscall5(int, __NC(mq_timedsend), mqd_t, mqdes, const char *, msg_ptr, size_t, msg_len, unsigned int, msq_prio, const struct timespec *, abs_timeout) +#endif CANCELLABLE_SYSCALL(int, mq_timedsend, (mqd_t mqdes, const char *msg_ptr, size_t msq_len, unsigned int msq_prio, const struct timespec *abs_timeout), (mqdes, msg_ptr, msq_len, msq_prio, abs_timeout)) diff --git a/librt/timer_gettime.c b/librt/timer_gettime.c index e13f44642..9495c802d 100644 --- a/librt/timer_gettime.c +++ b/librt/timer_gettime.c @@ -9,9 +9,13 @@ #include "kernel-posix-timers.h" -#ifdef __NR_timer_gettime +#if defined(__NR_timer_gettime) || defined(__NR_timer_gettime64) +#if defined(__UCLIBC_USE_TIME64__) && defined(__NR_timer_gettime64) +#define __NR___syscall_timer_gettime __NR_timer_gettime64 +#else #define __NR___syscall_timer_gettime __NR_timer_gettime +#endif static __inline__ _syscall2(int, __syscall_timer_gettime, kernel_timer_t, ktimerid, void *, value); diff --git a/librt/timer_settime.c b/librt/timer_settime.c index 2703fa913..425cd7ee9 100644 --- a/librt/timer_settime.c +++ b/librt/timer_settime.c @@ -9,9 +9,20 @@ #include "kernel-posix-timers.h" -#ifdef __NR_timer_settime +#if defined(__NR_timer_settime) || defined(__NR_timer_settime64) +#if defined(__UCLIBC_USE_TIME64__) && defined(__NR_timer_settime64) +#include "internal/time64_helpers.h" + +int timer_settime(timer_t timerid, int flags, const struct itimerspec *value, struct itimerspec *ovalue) +{ + struct timer *kt = (struct timer *)timerid; + + return INLINE_SYSCALL(timer_settime64, 4, kt->ktimerid, flags, TO_ITS64_P(value), ovalue); +} +#else #define __NR___syscall_timer_settime __NR_timer_settime + static __inline__ _syscall4(int, __syscall_timer_settime, kernel_timer_t, ktimerid, int, flags, const void *, value, void *, ovalue); @@ -26,3 +37,4 @@ int timer_settime(timer_t timerid, int flags, const struct itimerspec *value, } #endif +#endif |