From 7efd15d22a9b7e62d0659471bde25c35ef50c9e5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Thomas=20Wei=C3=9Fschuh?= Date: Sat, 20 Dec 2025 14:55:50 +0100 Subject: [PATCH] tools/nolibc/gettimeofday: avoid libgcc 64-bit divisions MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit timespec::tv_nsec is going to be 64-bit wide even on 32-bit architectures. As not all architectures support 64-bit division instructions, calls to libgcc (__divdi3()) may be emitted by the compiler which are not provided by nolibc. As tv_nsec is guaranteed to always fit into an uint32_t, perform a 32-bit division instead. Signed-off-by: Thomas Weißschuh Reviewed-by: Arnd Bergmann Acked-by: Willy Tarreau Link: https://patch.msgid.link/20251220-nolibc-uapi-types-v3-6-c662992f75d7@weissschuh.net --- tools/include/nolibc/sys/time.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/include/nolibc/sys/time.h b/tools/include/nolibc/sys/time.h index 171187836e6df..afdb7e326df17 100644 --- a/tools/include/nolibc/sys/time.h +++ b/tools/include/nolibc/sys/time.h @@ -30,7 +30,7 @@ int sys_gettimeofday(struct timeval *tv, struct timezone *tz) ret = sys_clock_gettime(CLOCK_REALTIME, &tp); if (!ret && tv) { tv->tv_sec = tp.tv_sec; - tv->tv_usec = tp.tv_nsec / 1000; + tv->tv_usec = (uint32_t)tp.tv_nsec / 1000; } return ret; -- 2.47.3