summaryrefslogtreecommitdiff
path: root/libc/misc
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 /libc/misc
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 'libc/misc')
-rw-r--r--libc/misc/sysvipc/sem.c11
-rw-r--r--libc/misc/time/time.c9
2 files changed, 17 insertions, 3 deletions
diff --git a/libc/misc/sysvipc/sem.c b/libc/misc/sysvipc/sem.c
index 64be1cae0..cd541761c 100644
--- a/libc/misc/sysvipc/sem.c
+++ b/libc/misc/sysvipc/sem.c
@@ -53,7 +53,12 @@ int semctl(int semid, int semnum, int cmd, ...)
arg = va_arg (ap, union semun);
va_end (ap);
#ifdef __NR_semctl
- return __semctl(semid, semnum, cmd | __IPC_64, arg.__pad);
+ int __ret = __semctl(semid, semnum, cmd | __IPC_64, arg.__pad);
+#if defined(__UCLIBC_USE_TIME64__)
+ arg.buf->sem_otime = (__time_t)arg.buf->__sem_otime_internal_1 | (__time_t)(arg.buf->__sem_otime_internal_2) << 32;
+ arg.buf->sem_ctime = (__time_t)arg.buf->__sem_ctime_internal_1 | (__time_t)(arg.buf->__sem_ctime_internal_2) << 32;
+#endif
+ return __ret;
#else
return __syscall_ipc(IPCOP_semctl, semid, semnum, cmd|__IPC_64, &arg, NULL);
#endif
@@ -90,7 +95,9 @@ int semop (int semid, struct sembuf *sops, size_t nsops)
#ifdef L_semtimedop
-#ifdef __NR_semtimedop
+#if defined(__UCLIBC_USE_TIME64__) && defined(__NR_semtimedop_time64)
+_syscall4_time64(int, semtimedop, int, semid, struct sembuf *, sops, size_t, nsops, const struct timespec *, timeout)
+#elif defined(__NR_semtimedop)
_syscall4(int, semtimedop, int, semid, struct sembuf *, sops, size_t, nsops, const struct timespec *, timeout)
#else
diff --git a/libc/misc/time/time.c b/libc/misc/time/time.c
index 0f7c6a33f..b6a5b097d 100644
--- a/libc/misc/time/time.c
+++ b/libc/misc/time/time.c
@@ -2478,9 +2478,16 @@ DST_CORRECT:
+ p[3]) + p[7])));
DST_CORRECT:
+#if defined(__UCLIBC_USE_TIME64__)
+ if (((unsigned long long)(secs - LLONG_MIN))
+ > (((unsigned long long)LLONG_MAX) - LLONG_MIN)
+ )
+#else
if (((unsigned long long)(secs - LONG_MIN))
> (((unsigned long long)LONG_MAX) - LONG_MIN)
- ) {
+ )
+#endif
+ {
t = ((time_t)(-1));
goto DONE;
}