Signed-off-by: Dmitry Chestnykh dm.chestnykh@gmail.com --- ldso/include/dl-syscall.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/ldso/include/dl-syscall.h b/ldso/include/dl-syscall.h index 2e8bb3630..666a7c693 100644 --- a/ldso/include/dl-syscall.h +++ b/ldso/include/dl-syscall.h @@ -20,7 +20,7 @@ extern int _dl_errno; #define _SYS_MMAN_H 1 #include <bits/mman.h>
-#ifdef __ARCH_HAS_DEPRECATED_SYSCALLS__ +#if defined(__ARCH_HAS_DEPRECATED_SYSCALLS__) && !defined(__UCLIBC_USE_TIME64__) /* Pull in whatever this particular arch's kernel thinks the kernel version of * struct stat should look like. It turns out that each arch has a different * opinion on the subject, and different kernel revs use different names... */ @@ -116,7 +116,7 @@ static __always_inline _syscall3(unsigned long, _dl_read, int, fd, static __always_inline _syscall3(int, _dl_mprotect, const void *, addr, unsigned long, len, int, prot)
-#if defined __NR_fstatat64 && !defined __NR_stat +#if defined __NR_fstatat64 && !defined __NR_stat && !defined(__UCLIBC_USE_TIME64__) # define __NR__dl_fstatat64 __NR_fstatat64 static __always_inline _syscall4(int, _dl_fstatat64, int, fd, const char *, fn, struct stat *, stat, int, flags) @@ -126,7 +126,7 @@ static __always_inline int _dl_stat(const char *file_name, { return _dl_fstatat64(AT_FDCWD, file_name, buf, 0); } -#elif defined __NR_newfstatat && !defined __NR_stat +#elif defined __NR_newfstatat && !defined __NR_stat && !defined(__UCLIBC_USE_TIME64__) # define __NR__dl_newfstatat __NR_newfstatat static __always_inline _syscall4(int, _dl_newfstatat, int, fd, const char *, fn, struct stat *, stat, int, flags) @@ -136,7 +136,7 @@ static __always_inline int _dl_stat(const char *file_name, { return _dl_newfstatat(AT_FDCWD, file_name, buf, 0); } -#elif defined __NR_stat +#elif defined __NR_stat && !defined(__UCLIBC_USE_TIME64__) # define __NR__dl_stat __NR_stat static __always_inline _syscall2(int, _dl_stat, const char *, file_name, struct stat *, buf) @@ -160,7 +160,7 @@ static __always_inline int _dl_stat(const char *file_name, } #endif
-#if defined __NR_fstat64 && !defined __NR_fstat +#if defined __NR_fstat64 && !defined __NR_fstat && !defined(__UCLIBC_USE_TIME64__) # define __NR__dl_fstat __NR_fstat64 static __always_inline _syscall2(int, _dl_fstat, int, fd, struct stat *, buf) #elif defined __NR_fstat @@ -168,7 +168,7 @@ static __always_inline _syscall2(int, _dl_fstat, int, fd, struct stat *, buf) static __always_inline _syscall2(int, _dl_fstat, int, fd, struct stat *, buf) #elif defined __NR_statx && defined __UCLIBC_HAVE_STATX__ # define __NR__dl_fstatx __NR_statx -static __always_inline _syscall5(int, _dl_fstatx, int, fd, const char *, file_name, int, flags, unsigned int, mask, struct stat *, buf); +static __always_inline _syscall5(int, _dl_fstatx, int, fd, const char *, file_name, int, flags, unsigned int, mask, struct statx *, buf);
static __always_inline int _dl_fstat(int fd, struct stat *buf)
Signed-off-by: Dmitry Chestnykh dm.chestnykh@gmail.com --- libc/sysdeps/linux/common/fstat64.c | 2 +- libc/sysdeps/linux/common/fstatat64.c | 4 ++-- libc/sysdeps/linux/common/lstat64.c | 2 +- libc/sysdeps/linux/common/stat64.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/libc/sysdeps/linux/common/fstat64.c b/libc/sysdeps/linux/common/fstat64.c index 20a9acf01..359c22af6 100644 --- a/libc/sysdeps/linux/common/fstat64.c +++ b/libc/sysdeps/linux/common/fstat64.c @@ -9,7 +9,7 @@ #include <_lfs_64.h> #include <sys/syscall.h>
-#ifdef __NR_fstat64 +#if defined(__NR_fstat64) && !defined(__UCLIBC_USE_TIME64__) # include <unistd.h> # include <sys/stat.h> # include "xstatconv.h" diff --git a/libc/sysdeps/linux/common/fstatat64.c b/libc/sysdeps/linux/common/fstatat64.c index fdd17a0b7..16dbf9215 100644 --- a/libc/sysdeps/linux/common/fstatat64.c +++ b/libc/sysdeps/linux/common/fstatat64.c @@ -23,7 +23,7 @@ # define __NR_fstatat64 __NR_newfstatat #endif
-#ifdef __NR_fstatat64 +#if defined(__NR_fstatat64) && !defined(__UCLIBC_USE_TIME64__) # include <sys/stat.h> # include "xstatconv.h" int fstatat64(int fd, const char *file, struct stat64 *buf, int flag) @@ -57,7 +57,7 @@ int fstatat64(int fd, const char *file, struct stat64 *buf, int flag) STATX_BASIC_STATS, &tmp);
if (r == 0) - __cp_stat64_statx ((struct stat *)buf, &tmp); + __cp_stat64_statx ((struct stat64 *)buf, &tmp);
return r; } diff --git a/libc/sysdeps/linux/common/lstat64.c b/libc/sysdeps/linux/common/lstat64.c index 61892994e..efc5b1b7f 100644 --- a/libc/sysdeps/linux/common/lstat64.c +++ b/libc/sysdeps/linux/common/lstat64.c @@ -11,7 +11,7 @@ #include <unistd.h> #include <sys/stat.h>
-#if defined __NR_fstatat64 && !defined __NR_lstat +#if defined __NR_fstatat64 && !defined __NR_lstat && !defined(__UCLIBC_USE_TIME64__) # include <fcntl.h>
int lstat64(const char *file_name, struct stat64 *buf) diff --git a/libc/sysdeps/linux/common/stat64.c b/libc/sysdeps/linux/common/stat64.c index fdd2c49a9..0875ba39d 100644 --- a/libc/sysdeps/linux/common/stat64.c +++ b/libc/sysdeps/linux/common/stat64.c @@ -10,7 +10,7 @@ #include <sys/syscall.h> #include <sys/stat.h>
-#if defined __NR_fstatat64 && !defined __NR_stat64 +#if defined __NR_fstatat64 && !defined __NR_stat64 && !defined(__UCLIBC_USE_TIME64__) #include <fcntl.h> #include <unistd.h>
With time64 enabled we need to pass structure which consists of two 64bit fields to clock_gettime64() and clock_nanosleep_time64() syscalls with proper conversion to regular timespec structure after syscall execution.
Signed-off-by: Dmitry Chestnykh dm.chestnykh@gmail.com --- libpthread/nptl/pthread_mutex_timedlock.c | 14 ++++++++++--- .../sysdeps/pthread/pthread_cond_timedwait.c | 15 ++++++++++--- librt/clock_nanosleep.c | 21 ++++++++++++++++--- 3 files changed, 41 insertions(+), 9 deletions(-)
diff --git a/libpthread/nptl/pthread_mutex_timedlock.c b/libpthread/nptl/pthread_mutex_timedlock.c index d54983315..1191639b6 100644 --- a/libpthread/nptl/pthread_mutex_timedlock.c +++ b/libpthread/nptl/pthread_mutex_timedlock.c @@ -298,11 +298,19 @@ 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) - INTERNAL_SYSCALL (clock_gettime64, __err, 2, CLOCK_REALTIME, - &now); + 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); diff --git a/libpthread/nptl/sysdeps/pthread/pthread_cond_timedwait.c b/libpthread/nptl/sysdeps/pthread/pthread_cond_timedwait.c index 49aab0293..ce738b1a1 100644 --- a/libpthread/nptl/sysdeps/pthread/pthread_cond_timedwait.c +++ b/libpthread/nptl/sysdeps/pthread/pthread_cond_timedwait.c @@ -95,18 +95,27 @@ __pthread_cond_timedwait (
while (1) { - struct timespec rt; + struct timespec rt = {.tv_sec = 0, .tv_nsec = 0}; +#if defined(__UCLIBC_USE_TIME64__) + struct __ts64_struct __rt64; +#endif { #ifdef __NR_clock_gettime INTERNAL_SYSCALL_DECL (err); -# ifndef __ASSUME_POSIX_TIMERS +# if !defined(__ASSUME_POSIX_TIMERS) || defined(__UCLIBC_USE_TIME64__) int ret = # endif #if defined(__UCLIBC_USE_TIME64__) && defined(__NR_clock_gettime64) INTERNAL_SYSCALL (clock_gettime64, err, 2, (cond->__data.__nwaiters & ((1 << COND_NWAITERS_SHIFT) - 1)), - &rt); + &__rt64); + + if (ret == 0) { + rt.tv_sec = __rt64.tv_sec; + rt.tv_nsec = __rt64.tv_nsec; + } + #else INTERNAL_SYSCALL (clock_gettime, err, 2, (cond->__data.__nwaiters diff --git a/librt/clock_nanosleep.c b/librt/clock_nanosleep.c index ef59369df..5537b0609 100644 --- a/librt/clock_nanosleep.c +++ b/librt/clock_nanosleep.c @@ -39,18 +39,33 @@ 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 (SINGLE_THREAD_P) + 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, TO_TS64_P(req), rem); + 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) - r = INTERNAL_SYSCALL (clock_nanosleep_time64, err, 4, clock_id, flags, TO_TS64_P(req), rem); + 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);
Hi Dmitry, Dmitry Chestnykh wrote,
Signed-off-by: Dmitry Chestnykh dm.chestnykh@gmail.com
ldso/include/dl-syscall.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
Patch series applied and pushed, best regards Waldemar