From: "Thomas Weißschuh" <linux@weissschuh.net>
To: Willy Tarreau <w@1wt.eu>, Shuah Khan <shuah@kernel.org>
Cc: "Arnd Bergmann" <arnd@arndb.de>,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
"Thomas Weißschuh" <linux@weissschuh.net>
Subject: [PATCH 12/12] tools/nolibc: remove time conversions
Date: Wed, 29 Oct 2025 17:03:02 +0100 [thread overview]
Message-ID: <20251029-nolibc-uapi-types-v1-12-e79de3b215d8@weissschuh.net> (raw)
In-Reply-To: <20251029-nolibc-uapi-types-v1-0-e79de3b215d8@weissschuh.net>
Now that 'struct timespec' and 'struct __kernel_timespec' are
compatible, the conversions are not necessary anymore.
The same holds true for 'struct itimerspec' and 'struct
__kernel_itimerspec'.
Remove the conversions.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
tools/include/nolibc/sys/timerfd.h | 20 ++----------
tools/include/nolibc/time.h | 64 ++++----------------------------------
2 files changed, 8 insertions(+), 76 deletions(-)
diff --git a/tools/include/nolibc/sys/timerfd.h b/tools/include/nolibc/sys/timerfd.h
index 5dd61030c991..ae3153b7635d 100644
--- a/tools/include/nolibc/sys/timerfd.h
+++ b/tools/include/nolibc/sys/timerfd.h
@@ -35,13 +35,7 @@ int sys_timerfd_gettime(int fd, struct itimerspec *curr_value)
#if defined(__NR_timerfd_gettime)
return my_syscall2(__NR_timerfd_gettime, fd, curr_value);
#else
- struct __kernel_itimerspec kcurr_value;
- int ret;
-
- ret = my_syscall2(__NR_timerfd_gettime64, fd, &kcurr_value);
- __nolibc_timespec_kernel_to_user(&kcurr_value.it_interval, &curr_value->it_interval);
- __nolibc_timespec_kernel_to_user(&kcurr_value.it_value, &curr_value->it_value);
- return ret;
+ return my_syscall2(__NR_timerfd_gettime64, fd, curr_value);
#endif
}
@@ -59,17 +53,7 @@ int sys_timerfd_settime(int fd, int flags,
#if defined(__NR_timerfd_settime)
return my_syscall4(__NR_timerfd_settime, fd, flags, new_value, old_value);
#else
- struct __kernel_itimerspec knew_value, kold_value;
- int ret;
-
- __nolibc_timespec_user_to_kernel(&new_value->it_value, &knew_value.it_value);
- __nolibc_timespec_user_to_kernel(&new_value->it_interval, &knew_value.it_interval);
- ret = my_syscall4(__NR_timerfd_settime64, fd, flags, &knew_value, &kold_value);
- if (old_value) {
- __nolibc_timespec_kernel_to_user(&kold_value.it_interval, &old_value->it_interval);
- __nolibc_timespec_kernel_to_user(&kold_value.it_value, &old_value->it_value);
- }
- return ret;
+ return my_syscall4(__NR_timerfd_settime64, fd, flags, new_value, old_value);
#endif
}
diff --git a/tools/include/nolibc/time.h b/tools/include/nolibc/time.h
index 45df9b09d7b6..ab67f209c99f 100644
--- a/tools/include/nolibc/time.h
+++ b/tools/include/nolibc/time.h
@@ -18,20 +18,6 @@
#include <linux/signal.h>
#include <linux/time.h>
-static __inline__
-void __nolibc_timespec_user_to_kernel(const struct timespec *ts, struct __kernel_timespec *kts)
-{
- kts->tv_sec = ts->tv_sec;
- kts->tv_nsec = ts->tv_nsec;
-}
-
-static __inline__
-void __nolibc_timespec_kernel_to_user(const struct __kernel_timespec *kts, struct timespec *ts)
-{
- ts->tv_sec = kts->tv_sec;
- ts->tv_nsec = kts->tv_nsec;
-}
-
/*
* int clock_getres(clockid_t clockid, struct timespec *res);
* int clock_gettime(clockid_t clockid, struct timespec *tp);
@@ -44,13 +30,7 @@ static __attribute__((unused))
int sys_clock_getres(clockid_t clockid, struct timespec *res)
{
#if defined(__NR_clock_getres_time64)
- struct __kernel_timespec kres;
- int ret;
-
- ret = my_syscall2(__NR_clock_getres_time64, clockid, &kres);
- if (res)
- __nolibc_timespec_kernel_to_user(&kres, res);
- return ret;
+ return my_syscall2(__NR_clock_getres_time64, clockid, res);
#else
return my_syscall2(__NR_clock_getres, clockid, res);
#endif
@@ -66,13 +46,7 @@ static __attribute__((unused))
int sys_clock_gettime(clockid_t clockid, struct timespec *tp)
{
#if defined(__NR_clock_gettime64)
- struct __kernel_timespec ktp;
- int ret;
-
- ret = my_syscall2(__NR_clock_gettime64, clockid, &ktp);
- if (tp)
- __nolibc_timespec_kernel_to_user(&ktp, tp);
- return ret;
+ return my_syscall2(__NR_clock_gettime64, clockid, tp);
#else
return my_syscall2(__NR_clock_gettime, clockid, tp);
#endif
@@ -88,10 +62,7 @@ static __attribute__((unused))
int sys_clock_settime(clockid_t clockid, struct timespec *tp)
{
#if defined(__NR_clock_settime64)
- struct __kernel_timespec ktp;
-
- __nolibc_timespec_user_to_kernel(tp, &ktp);
- return my_syscall2(__NR_clock_settime64, clockid, &ktp);
+ return my_syscall2(__NR_clock_settime64, clockid, tp);
#else
return my_syscall2(__NR_clock_settime, clockid, tp);
#endif
@@ -108,14 +79,7 @@ int sys_clock_nanosleep(clockid_t clockid, int flags, const struct timespec *rqt
struct timespec *rmtp)
{
#if defined(__NR_clock_nanosleep_time64)
- struct __kernel_timespec krqtp, krmtp;
- int ret;
-
- __nolibc_timespec_user_to_kernel(rqtp, &krqtp);
- ret = my_syscall4(__NR_clock_nanosleep_time64, clockid, flags, &krqtp, &krmtp);
- if (rmtp)
- __nolibc_timespec_kernel_to_user(&krmtp, rmtp);
- return ret;
+ return my_syscall4(__NR_clock_nanosleep_time64, clockid, flags, rqtp, rmtp);
#else
return my_syscall4(__NR_clock_nanosleep, clockid, flags, rqtp, rmtp);
#endif
@@ -190,13 +154,7 @@ static __attribute__((unused))
int sys_timer_gettime(timer_t timerid, struct itimerspec *curr_value)
{
#if defined(__NR_timer_gettime64)
- struct __kernel_itimerspec kcurr_value;
- int ret;
-
- ret = my_syscall2(__NR_timer_gettime64, timerid, &kcurr_value);
- __nolibc_timespec_kernel_to_user(&kcurr_value.it_interval, &curr_value->it_interval);
- __nolibc_timespec_kernel_to_user(&kcurr_value.it_value, &curr_value->it_value);
- return ret;
+ return my_syscall2(__NR_timer_gettime64, timerid, curr_value);
#else
return my_syscall2(__NR_timer_gettime, timerid, curr_value);
#endif
@@ -213,17 +171,7 @@ int sys_timer_settime(timer_t timerid, int flags,
const struct itimerspec *new_value, struct itimerspec *old_value)
{
#if defined(__NR_timer_settime64)
- struct __kernel_itimerspec knew_value, kold_value;
- int ret;
-
- __nolibc_timespec_user_to_kernel(&new_value->it_value, &knew_value.it_value);
- __nolibc_timespec_user_to_kernel(&new_value->it_interval, &knew_value.it_interval);
- ret = my_syscall4(__NR_timer_settime64, timerid, flags, &knew_value, &kold_value);
- if (old_value) {
- __nolibc_timespec_kernel_to_user(&kold_value.it_interval, &old_value->it_interval);
- __nolibc_timespec_kernel_to_user(&kold_value.it_value, &old_value->it_value);
- }
- return ret;
+ return my_syscall4(__NR_timer_settime64, timerid, flags, new_value, old_value);
#else
return my_syscall4(__NR_timer_settime, timerid, flags, new_value, old_value);
#endif
--
2.51.1.dirty
next prev parent reply other threads:[~2025-10-29 16:04 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-29 16:02 [PATCH 00/12] tools/nolibc: always use 64-bit ino_t, off_t and time-related types Thomas Weißschuh
2025-10-29 16:02 ` [PATCH 01/12] tools/nolibc: use 64-bit ino_t Thomas Weißschuh
2025-10-29 16:02 ` [PATCH 02/12] tools/nolibc: handle 64-bit off_t for llseek Thomas Weißschuh
2025-10-30 14:56 ` Arnd Bergmann
2025-10-29 16:02 ` [PATCH 03/12] tools/nolibc: prefer the llseek syscall Thomas Weißschuh
2025-10-29 16:02 ` [PATCH 04/12] tools/nolibc: use 64-bit off_t Thomas Weißschuh
2025-10-29 16:02 ` [PATCH 05/12] tools/nolibc: remove now superfluous overflow check in llseek Thomas Weißschuh
2025-10-30 14:58 ` Arnd Bergmann
2025-10-29 16:02 ` [PATCH 06/12] tools/nolibc: remove more __nolibc_enosys() fallbacks Thomas Weißschuh
2025-10-29 16:02 ` [PATCH 07/12] tools/nolibc: prefer explicit 64-bit time-related system calls Thomas Weißschuh
2025-10-30 14:44 ` Arnd Bergmann
2025-10-29 16:02 ` [PATCH 08/12] tools/nolibc: gettimeofday(): avoid libgcc 64-bit divisions Thomas Weißschuh
2025-10-30 14:57 ` Arnd Bergmann
2025-11-02 8:31 ` Willy Tarreau
2025-11-02 9:27 ` Thomas Weißschuh
2025-11-02 9:49 ` Willy Tarreau
2025-10-29 16:02 ` [PATCH 09/12] tools/nolibc: use a custom struct timespec Thomas Weißschuh
2025-10-30 14:46 ` Arnd Bergmann
2025-11-02 8:36 ` Willy Tarreau
2025-11-02 8:40 ` Willy Tarreau
2025-11-02 9:41 ` Thomas Weißschuh
2025-11-02 9:50 ` Willy Tarreau
2025-10-29 16:03 ` [PATCH 10/12] tools/nolibc: always use 64-bit time types Thomas Weißschuh
2025-10-29 16:03 ` [PATCH 11/12] selftests/nolibc: test compatibility of timespec and __kernel_timespec Thomas Weißschuh
2025-10-29 16:03 ` Thomas Weißschuh [this message]
2025-10-30 14:58 ` [PATCH 12/12] tools/nolibc: remove time conversions Arnd Bergmann
2025-11-02 8:44 ` [PATCH 00/12] tools/nolibc: always use 64-bit ino_t, off_t and time-related types Willy Tarreau
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251029-nolibc-uapi-types-v1-12-e79de3b215d8@weissschuh.net \
--to=linux@weissschuh.net \
--cc=arnd@arndb.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=shuah@kernel.org \
--cc=w@1wt.eu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®