summaryrefslogtreecommitdiff
path: root/librt
diff options
context:
space:
mode:
authorDmitry Chestnykh <dm.chestnykh@gmail.com>2024-02-21 19:08:28 +0300
committerWaldemar Brodkorb <wbx@openadk.org>2024-02-22 19:50:09 +0100
commit8ea0140d5ffd2dc4ec0e36de71b67e6c1955f3cb (patch)
treebbb3b38f991f4e194a79610eef089feaca9451f9 /librt
parenta908621a934643f51a58042abcf1d1e42e281943 (diff)
Introduce time64 support.
This patch introduces *time64 syscalls support for uClibc-ng. Currently the redirection of syscalls to their *time64 analogs is fully supported for 32bit ARM (ARMv5, ARMv6, ARMv7). The main changes that take effect when time64 feature is enabled are: - sizeof(time_t) is 8. - There is a possibility os setting date beyond year 2038. - some syscalls are redirected: clock_adjtime -> clock_adjtime64 clock_getres -> clock_getres_time64 clock_gettime -> clock_gettime64 clock_nanosleep -> clock_nanosleep_time64 clock_settime -> clock_settime64 futex -> futex_time64 mq_timedreceive -> mq_timedreceive_time64 mq_timedsend -> mq_timedsend_time64 ppoll -> ppoll_time64 pselect6 -> pselect6_time64 recvmmsg -> recvmmsg_time64 rt_sigtimedwait -> rt_sigtimedwait_time64 sched_rr_get_interval -> sched_rr_get_interval_time64 semtimedop -> semtimedop_time64 timer_gettime -> timer_gettime64 timer_settime -> timer_settime64 timerfd_gettime -> timerfd_gettime64 timerfd_settime -> timerfd_settime64 utimensat -> utimensat_time64. - settimeofday uses clock_settime (like in glibc/musl). - gettimeofday uses clock_gettime (like in glibc/musl). - nanosleep uses clock_nanosleep (like in glibc/musl). - There are some fixes in data structures used by libc and kernel for correct data handling both with and without enabled time64 support. Signed-off-by: Dmitry Chestnykh <dm.chestnykh@gmail.com>
Diffstat (limited to 'librt')
-rw-r--r--librt/clock_getcpuclockid.c15
-rw-r--r--librt/clock_gettime.c7
-rw-r--r--librt/clock_nanosleep.c10
-rw-r--r--librt/mq_timedreceive.c6
-rw-r--r--librt/mq_timedsend.c6
-rw-r--r--librt/timer_gettime.c6
-rw-r--r--librt/timer_settime.c7
7 files changed, 50 insertions, 7 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..b66b60231 100644
--- a/librt/clock_gettime.c
+++ b/librt/clock_gettime.c
@@ -22,10 +22,15 @@
#include <sys/time.h>
#include "kernel-posix-cpu-timers.h"
-
+#if defined(__UCLIBC_USE_TIME64__) && defined(__NR_clock_gettime64)
+#define SYSCALL_GETTIME \
+ retval = INLINE_SYSCALL (clock_gettime64, 2, clock_id, tp); \
+ 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 \
diff --git a/librt/clock_nanosleep.c b/librt/clock_nanosleep.c
index 85db72fb3..eaae75720 100644
--- a/librt/clock_nanosleep.c
+++ b/librt/clock_nanosleep.c
@@ -37,15 +37,21 @@ clock_nanosleep (clockid_t clock_id, int flags, const struct timespec *req,
clock_id = MAKE_PROCESS_CPUCLOCK (0, CPUCLOCK_SCHED);
if (SINGLE_THREAD_P)
+#if defined(__UCLIBC_USE_TIME64__) && defined(__NR_clock_nanosleep_time64)
+ r = INTERNAL_SYSCALL (clock_nanosleep_time64, err, 4, clock_id, flags, req, rem);
+#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)
+ r = INTERNAL_SYSCALL (clock_nanosleep_time64, err, 4, clock_id, flags, req, rem);
+#else
r = INTERNAL_SYSCALL (clock_nanosleep, err, 4, clock_id, flags, req,
rem);
-
+#endif
LIBC_CANCEL_RESET (oldstate);
#endif
}
diff --git a/librt/mq_timedreceive.c b/librt/mq_timedreceive.c
index 9f5efc4fa..db1ae1aa8 100644
--- a/librt/mq_timedreceive.c
+++ b/librt/mq_timedreceive.c
@@ -8,9 +8,15 @@
#include <unistd.h>
#include <cancel.h>
+#if defined(__UCLIBC_USE_TIME64__) && defined(__NR_mq_timedreceive_time64)
+#define __NR___mq_timedreceive_nocancel __NR_mq_timedreceive_time64
+#else
#define __NR___mq_timedreceive_nocancel __NR_mq_timedreceive
+#endif
+
_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)
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..6afaf5157 100644
--- a/librt/mq_timedsend.c
+++ b/librt/mq_timedsend.c
@@ -8,9 +8,13 @@
#include <unistd.h>
#include <cancel.h>
+#if defined(__UCLIBC_USE_TIME64__) && defined(__NR_mq_timedsend_time64)
+#define __NR___mq_timedsend_nocancel __NR_mq_timedsend_time64
+#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
+_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)
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))
lt_libc_hidden(mq_timedsend)
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..022880297 100644
--- a/librt/timer_settime.c
+++ b/librt/timer_settime.c
@@ -9,9 +9,14 @@
#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)
+#define __NR___syscall_timer_settime __NR_timer_settime64
+#else
#define __NR___syscall_timer_settime __NR_timer_settime
+#endif
+
static __inline__ _syscall4(int, __syscall_timer_settime, kernel_timer_t, ktimerid,
int, flags, const void *, value, void *, ovalue);