From nobody Sun Feb 8 15:53:48 2026 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9AD5A2DE6F4; Sat, 20 Dec 2025 13:56:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766238967; cv=none; b=qiUnYRcUIBDkc+HaBmTFH1ynwcRi1XC0/62AVTe74ep6oGI8xwSOgAGmdsfJjWjTfaWo7LWBBuCcxq8yf/z4bIOYQtHjShckCmGWaPVkGZy8hNAeyptUNI7m/9mSAWmBmHuU7KOYtPBZYX7CxF6pJhe6TJQ73nKgsXPTrBv2EuU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766238967; c=relaxed/simple; bh=6N2OUgVowZtYioDgMO03QsrHw7wax3/lq8qAqnnDT9Y=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ZNu4afw/yd8/LY7CAk6ePiaCiGyvc4MR2HtVeJjKJlN1kOWtD5szhc/u19z24IMulVtt27Cza/P6tSQa5EWfmnlCvzTIH/EOqlC5uAUs3p4R/wOXqLpQjyZTJLR+u+eZ09W1uCaUv4VdLIns6uyGtAjamZRrQrr+SlbWAop23MY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=Yfwpd+9F; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="Yfwpd+9F" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1766238957; bh=6N2OUgVowZtYioDgMO03QsrHw7wax3/lq8qAqnnDT9Y=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Yfwpd+9Fe+cb99tVQ6qqoj69HD4+CUlxP+3Ztu1NAZnOziqdrTWxf3wTvvy4msrN7 vhORqNEo6sa/Qx+ZXYdl+aHCb5/KcQIUF3oswVJNIY7Qh/NxGqe9kXhvrcsI4wwxD9 hC4a7HN8hOFNLYI9Zf0YZ0THN6y8SKopvh5Lny9I= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sat, 20 Dec 2025 14:55:45 +0100 Subject: [PATCH v3 01/14] tools/nolibc/poll: use kernel types for system call invocations Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251220-nolibc-uapi-types-v3-1-c662992f75d7@weissschuh.net> References: <20251220-nolibc-uapi-types-v3-0-c662992f75d7@weissschuh.net> In-Reply-To: <20251220-nolibc-uapi-types-v3-0-c662992f75d7@weissschuh.net> To: Willy Tarreau , Shuah Khan Cc: Arnd Bergmann , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1766238956; l=1655; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=6N2OUgVowZtYioDgMO03QsrHw7wax3/lq8qAqnnDT9Y=; b=j0QMLr0U+QDQ0iiqP4ui6Hj7RIDJnMycPXjpWvliH3/ORam/BCS3rJWLgMiAbmLELfqb0HQFA DYER+s0tYlXBtFzCN4bJGAMZzsmAGnvvePCgNEE0/Kspu/WfIHfxieS X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= The system calls expect 'struct __kernel_old_timespec'. While currently 'struct __kernel_old_timespec' and 'struct timespec' are compatible, this is confusing. Especially as future patches will change the definition of 'struct timespec'. Use the correct kernel type instead. Suggested-by: Arnd Bergmann Link: https://lore.kernel.org/lkml/fbca1d3e-12e4-4c4e-8091-87464035fe39@app= .fastmail.com/ Signed-off-by: Thomas Wei=C3=9Fschuh Acked-by: Willy Tarreau Reviewed-by: Arnd Bergmann --- tools/include/nolibc/poll.h | 2 +- tools/include/nolibc/sys/select.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/include/nolibc/poll.h b/tools/include/nolibc/poll.h index 0d053f93ea99..df952bcf0905 100644 --- a/tools/include/nolibc/poll.h +++ b/tools/include/nolibc/poll.h @@ -24,7 +24,7 @@ static __attribute__((unused)) int sys_poll(struct pollfd *fds, int nfds, int timeout) { #if defined(__NR_ppoll) - struct timespec t; + struct __kernel_old_timespec t; =20 if (timeout >=3D 0) { t.tv_sec =3D timeout / 1000; diff --git a/tools/include/nolibc/sys/select.h b/tools/include/nolibc/sys/s= elect.h index 2a5619c01277..9a29e5b98a3c 100644 --- a/tools/include/nolibc/sys/select.h +++ b/tools/include/nolibc/sys/select.h @@ -75,7 +75,7 @@ int sys_select(int nfds, fd_set *rfds, fd_set *wfds, fd_s= et *efds, struct timeva #elif defined(__NR_select) return my_syscall5(__NR_select, nfds, rfds, wfds, efds, timeout); #elif defined(__NR_pselect6) - struct timespec t; + struct __kernel_old_timespec t; =20 if (timeout) { t.tv_sec =3D timeout->tv_sec; --=20 2.52.0 From nobody Sun Feb 8 15:53:48 2026 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9AC7529AAFA; Sat, 20 Dec 2025 13:56:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766238967; cv=none; b=sDFS0x1xAvWn6dO22CVcgPLoQPlQ1pB8Id5nf/iD6iuo1sFvR+1QVLNR+c8wYCt4hQQxBVdZZFSKbWrSGWX87cK0J4RD9KND7r+ZvXFv6UOseb3WjA9+l3eNQLQgOthLZqeR+v9N1SqluXvrYq/QveJRMJx4qJ/jjRYb+m197I8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766238967; c=relaxed/simple; bh=SLJeUwwi9ZNSa+MHhBcAuBf0JBKtu7Rmc82oI2zk0Ek=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=tTNLcIF1Q5RXl0/Rozjv5+O0wVocLF662QZcfvPbc6vBbzxYdDkrj5ynHjbWLq7Fji15EJmUPYxpUYDpZQR4pnL0hSe4aKGmpZ2WhO/jr0tUzsf0Fo4inRxlE/KuY/PkVMMCiHDlV7mkp0Y7DsK/81dJnjTVt+tKh1/atM58+6g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=h41IrtiF; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="h41IrtiF" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1766238957; bh=SLJeUwwi9ZNSa+MHhBcAuBf0JBKtu7Rmc82oI2zk0Ek=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=h41IrtiFnqJiYbiYwPzo2uXr9GQ6FRP0J9h2iTpHvco1s9Qr3R2cMJBd4V08JACLd X41v8oSSfBtn+KCumFD5FQirU5IDa45+xf9Re/Cs0CKSHznccFqEOzGrjSufOJZYlY UcaBPkr7sZsvSzBh2V1U//euXVsQ1dwo14+mfLI4= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sat, 20 Dec 2025 14:55:46 +0100 Subject: [PATCH v3 02/14] tools/nolibc/poll: drop __NR_poll fallback Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251220-nolibc-uapi-types-v3-2-c662992f75d7@weissschuh.net> References: <20251220-nolibc-uapi-types-v3-0-c662992f75d7@weissschuh.net> In-Reply-To: <20251220-nolibc-uapi-types-v3-0-c662992f75d7@weissschuh.net> To: Willy Tarreau , Shuah Khan Cc: Arnd Bergmann , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1766238956; l=1164; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=SLJeUwwi9ZNSa+MHhBcAuBf0JBKtu7Rmc82oI2zk0Ek=; b=hefLYNpU5eTUf2VDsQeDvYUC/miRDcJqxXy0XqLWeLIhjZRczqB9yovvdo0oon1I4vZz4BDQ8 c3H9APfECDhDdh/i+9ypS7mYrGV4BGbRmoSa7Q8LTw+q06U8dPJUtEO X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= This fallback is never used, remove it. Suggested-by: Arnd Bergmann Link: https://lore.kernel.org/lkml/fbca1d3e-12e4-4c4e-8091-87464035fe39@app= .fastmail.com/ Signed-off-by: Thomas Wei=C3=9Fschuh Acked-by: Willy Tarreau Reviewed-by: Arnd Bergmann --- tools/include/nolibc/poll.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tools/include/nolibc/poll.h b/tools/include/nolibc/poll.h index df952bcf0905..5b4fa339fbb5 100644 --- a/tools/include/nolibc/poll.h +++ b/tools/include/nolibc/poll.h @@ -31,7 +31,7 @@ int sys_poll(struct pollfd *fds, int nfds, int timeout) t.tv_nsec =3D (timeout % 1000) * 1000000; } return my_syscall5(__NR_ppoll, fds, nfds, (timeout >=3D 0) ? &t : NULL, N= ULL, 0); -#elif defined(__NR_ppoll_time64) +#else struct __kernel_timespec t; =20 if (timeout >=3D 0) { @@ -39,8 +39,6 @@ int sys_poll(struct pollfd *fds, int nfds, int timeout) t.tv_nsec =3D (timeout % 1000) * 1000000; } return my_syscall5(__NR_ppoll_time64, fds, nfds, (timeout >=3D 0) ? &t : = NULL, NULL, 0); -#else - return my_syscall3(__NR_poll, fds, nfds, timeout); #endif } =20 --=20 2.52.0 From nobody Sun Feb 8 15:53:48 2026 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C0C5E2C0F6E; Sat, 20 Dec 2025 13:56:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766238968; cv=none; b=jbINRTkNAThbAWpGOeXhI8DbFpBjfPJkJOPaAd1dMtHvjHusE7XFNPu0f106VjeW+Zh2OAfeFE5c/wFv248slVeI9YvSgK8tnBnhMDSuG3wN+ZhpCn7P4PUjeEzSO3HvTGuMWROQ4kKPu/zuC75xkyIJS8zsjuy8+wmwTm442UY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766238968; c=relaxed/simple; bh=FT8CdfUkzV1aTJPORp5DGeTUobkV9iWHje/A/ujkzzM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=CM2CXjQaEAtLPCnGcgzko8LMnhIKeXlKmEeH5IcDqoT2XPthb4N/kzbF0h+nV6eaKreqKgzJerxP7wiAM2FhzGpiamCyx/WfEH3fWs4noJbgx3bqe+OHGHQCDmYbhKIY5Lgc42QECqDG+sMrqKIGm8/Adl6HaEJqko4Nj/grIcA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=b7p2bnFz; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="b7p2bnFz" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1766238957; bh=FT8CdfUkzV1aTJPORp5DGeTUobkV9iWHje/A/ujkzzM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=b7p2bnFzDvw/oqN5cpWoH+UexM0JZtKBRmoAUozyrGTvyNbHZaSlYdjwSaE/KVg1e o9e73rOACCnW57BA5UI9ENR9Oj//O+Mppf/W5F8CvLsyu/gMTTr2iMEGZug9OF5yri czWWRwE3VFs+GMyYWyeDfGaaAwI6ZbgdAUIQOTyQ= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sat, 20 Dec 2025 14:55:47 +0100 Subject: [PATCH v3 03/14] tools/nolibc/select: drop non-pselect based implementations Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251220-nolibc-uapi-types-v3-3-c662992f75d7@weissschuh.net> References: <20251220-nolibc-uapi-types-v3-0-c662992f75d7@weissschuh.net> In-Reply-To: <20251220-nolibc-uapi-types-v3-0-c662992f75d7@weissschuh.net> To: Willy Tarreau , Shuah Khan Cc: Arnd Bergmann , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1766238956; l=1539; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=FT8CdfUkzV1aTJPORp5DGeTUobkV9iWHje/A/ujkzzM=; b=r83c2AbazMLzozlyuD9SbfcpVAXDEllwdxYCGa8QW3GPcB0P+WWYFi0sh+9zIdkaFskiddRXu 1EHazmqQm9rCETn4/r7LsMJE88i2qppvNGLTTcd7NqAbNI7OkwQ2dRs X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= These implementations use the libc 'struct timeval' with system calls which can lead to type mismatches. Currently this is fine, but will break with upcoming changes to 'struct timeval'. If the structure needs to be converted anyways, the implementations based on pselect can be used for all architectures. This simplifies the logic. Signed-off-by: Thomas Wei=C3=9Fschuh Acked-by: Willy Tarreau Reviewed-by: Arnd Bergmann --- tools/include/nolibc/sys/select.h | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/tools/include/nolibc/sys/select.h b/tools/include/nolibc/sys/s= elect.h index 9a29e5b98a3c..50b77dace7ef 100644 --- a/tools/include/nolibc/sys/select.h +++ b/tools/include/nolibc/sys/select.h @@ -63,18 +63,7 @@ typedef struct { static __attribute__((unused)) int sys_select(int nfds, fd_set *rfds, fd_set *wfds, fd_set *efds, struct = timeval *timeout) { -#if defined(__ARCH_WANT_SYS_OLD_SELECT) && !defined(__NR__newselect) - struct sel_arg_struct { - unsigned long n; - fd_set *r, *w, *e; - struct timeval *t; - } arg =3D { .n =3D nfds, .r =3D rfds, .w =3D wfds, .e =3D efds, .t =3D ti= meout }; - return my_syscall1(__NR_select, &arg); -#elif defined(__NR__newselect) - return my_syscall5(__NR__newselect, nfds, rfds, wfds, efds, timeout); -#elif defined(__NR_select) - return my_syscall5(__NR_select, nfds, rfds, wfds, efds, timeout); -#elif defined(__NR_pselect6) +#if defined(__NR_pselect6) struct __kernel_old_timespec t; =20 if (timeout) { --=20 2.52.0 From nobody Sun Feb 8 15:53:48 2026 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9ACEE2D877B; Sat, 20 Dec 2025 13:56:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766238967; cv=none; b=rNoY4MOpn4/4t70158XZ3QcvY8VNQkAl1P6o8bQW3dBav9WkaBsHEZSUrX73A+xuzwHMmhg5jn5VGynwSSlo4ts43T7rr6o//9wTQdVsGfK3RpNPO3Ft6iVzETjnUkGsC8XUl2Eyl3FgYx/aoJD1qjwVB1QkauUzdStqHZBI+gs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766238967; c=relaxed/simple; bh=gVq3x4tBxiNm+mJ5OxMCxytcQfvKNj8AIsptA23SvRM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=K+51MFkSZtcYeIQVPlsLw3WK5zWp0BllX6wZC1mhdtwwEi6XW9rSVn9erWH0o+BmyzgE8HGmZ+KAtFfdjoZMXC+9k89oG6j28sDBKBAvlLGA9oadg58KEUJd4R9L3qEnIVo+xbZH5QZa5o2fIdaXKM2Fo9S9NyrbhYMSQnRPX6A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=ksd+M9ly; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="ksd+M9ly" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1766238957; bh=gVq3x4tBxiNm+mJ5OxMCxytcQfvKNj8AIsptA23SvRM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=ksd+M9lyYMexCZvyIdY550I0FdyFYEcM+CRf51+tHy+R75ZvNPeeocY9RXeKG3ahS 8X7W6sEyfhawsFkrytnOLeAjd7CrIGzR1KtmOpSgMZwAw6/uxfib3xrUQfWTYBczOV d+qrLXk5yhnx3CcscKKZaDOHsoq7ytXHRUVEJKt8= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sat, 20 Dec 2025 14:55:48 +0100 Subject: [PATCH v3 04/14] tools/nolibc/time: drop invocation of gettimeofday system call Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251220-nolibc-uapi-types-v3-4-c662992f75d7@weissschuh.net> References: <20251220-nolibc-uapi-types-v3-0-c662992f75d7@weissschuh.net> In-Reply-To: <20251220-nolibc-uapi-types-v3-0-c662992f75d7@weissschuh.net> To: Willy Tarreau , Shuah Khan Cc: Arnd Bergmann , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1766238956; l=1161; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=gVq3x4tBxiNm+mJ5OxMCxytcQfvKNj8AIsptA23SvRM=; b=5Jft3oUvHE7l/o2Bt3xbgz1TiDTbli5bb2V4nLSzsa/i783iC+9aEYu2tzUco3SYcsUwJyv9k W6Ml1Qz76BIAMRFffwoFPnZyoVy3U9HTP/4G2l49QAV9N4OFqqF51Sz X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= This invocation uses libc types with a system call. While this works now, upcoming changes to 'struct timeval' would require type conversions. If types are converted anyways, the clock_gettime() based fallback can be used everywhere, simplifying the code. Signed-off-by: Thomas Wei=C3=9Fschuh Acked-by: Willy Tarreau Reviewed-by: Arnd Bergmann --- tools/include/nolibc/sys/time.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tools/include/nolibc/sys/time.h b/tools/include/nolibc/sys/tim= e.h index 33782a19aae9..171187836e6d 100644 --- a/tools/include/nolibc/sys/time.h +++ b/tools/include/nolibc/sys/time.h @@ -22,9 +22,6 @@ static int sys_clock_gettime(clockid_t clockid, struct ti= mespec *tp); static __attribute__((unused)) int sys_gettimeofday(struct timeval *tv, struct timezone *tz) { -#ifdef __NR_gettimeofday - return my_syscall2(__NR_gettimeofday, tv, tz); -#else (void) tz; /* Non-NULL tz is undefined behaviour */ =20 struct timespec tp; @@ -37,7 +34,6 @@ int sys_gettimeofday(struct timeval *tv, struct timezone = *tz) } =20 return ret; -#endif } =20 static __attribute__((unused)) --=20 2.52.0 From nobody Sun Feb 8 15:53:48 2026 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4DC1830ACEE; Sat, 20 Dec 2025 13:56:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766238972; cv=none; b=EbRMaO38lr7SuTEE5uaxU+Hawj74D6GWimTWAKND6oLPmSEa1PjxOdhPSYqUYBEtnbudHS1xJ0/bEmNNEZVMs9VZr9OBKb1DO5+VocY2LgwBJ/qvUm7A2mMmc3Nws0RDdNffM8flrx/A7Uw1T7kKhfR+6Q3/CD+NSuWjtU1KcpE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766238972; c=relaxed/simple; bh=zQ0VkWw6yM4/fD1Ihp8MUJmTQ6FCOtXiqjFpq2+1nu4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=s4q1NL4g9xNyx6RnQJ+idnj/UfjyuHhS6YRKTSZ12fnLSUCJ9jn4z62FhhjOQU3WXT/+3N4Lis/UJiaP/Ir0RDSAlCK8Z/Rq8oPEXCvGQQv0wJ1peI4tt6Y/ehI/LQt3f5KUbICLEqLVbv+GJRfGWGP5f7bPxblR9upaV6P+Il8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=oE7eomrG; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="oE7eomrG" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1766238957; bh=zQ0VkWw6yM4/fD1Ihp8MUJmTQ6FCOtXiqjFpq2+1nu4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=oE7eomrGGaA4hffT15Vq5c4hs8yE7eBWPwMzh8D6GuvuEMt03H97OZRzseYFttqmS q9sx1rfllBifigytik8YLa83JP8um4GUyczkZ7edsI33f1psXnaRkmHnpj65vr9ZFY LikHX7wfzj+8YighPhg8LVOSkn+IUkTibZ7Npf4E= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sat, 20 Dec 2025 14:55:49 +0100 Subject: [PATCH v3 05/14] tools/nolibc: prefer explicit 64-bit time-related system calls Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251220-nolibc-uapi-types-v3-5-c662992f75d7@weissschuh.net> References: <20251220-nolibc-uapi-types-v3-0-c662992f75d7@weissschuh.net> In-Reply-To: <20251220-nolibc-uapi-types-v3-0-c662992f75d7@weissschuh.net> To: Willy Tarreau , Shuah Khan Cc: Arnd Bergmann , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1766238956; l=8519; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=zQ0VkWw6yM4/fD1Ihp8MUJmTQ6FCOtXiqjFpq2+1nu4=; b=ZLOtbFGWOOrYZkJjRrxyBucFvTnA+1Xgw2Kj4JefP/Iw3LZmG/8tUh+IUZhv0Ggw7N9W8KX+u Xczo5o1a1c4Bwm047MWBtH2R4AjtKzhr1IpTNwKXNqO9P7fwP22xt98 X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= Make sure to always use the 64-bit safe system calls in preparation for 64-bit time_t on 32-bit architectures. Also prevent issues on kernels which disable CONFIG_COMPAT_32BIT_TIME and therefore don't provide the 32-bit system calls anymore. Signed-off-by: Thomas Wei=C3=9Fschuh Acked-by: Willy Tarreau Reviewed-by: Arnd Bergmann --- tools/include/nolibc/poll.h | 10 +++++----- tools/include/nolibc/sys/select.h | 10 +++++----- tools/include/nolibc/sys/timerfd.h | 12 ++++++------ tools/include/nolibc/time.h | 36 ++++++++++++++++++----------------= -- 4 files changed, 34 insertions(+), 34 deletions(-) diff --git a/tools/include/nolibc/poll.h b/tools/include/nolibc/poll.h index 5b4fa339fbb5..e854c94647b1 100644 --- a/tools/include/nolibc/poll.h +++ b/tools/include/nolibc/poll.h @@ -23,22 +23,22 @@ static __attribute__((unused)) int sys_poll(struct pollfd *fds, int nfds, int timeout) { -#if defined(__NR_ppoll) - struct __kernel_old_timespec t; +#if defined(__NR_ppoll_time64) + struct __kernel_timespec t; =20 if (timeout >=3D 0) { t.tv_sec =3D timeout / 1000; t.tv_nsec =3D (timeout % 1000) * 1000000; } - return my_syscall5(__NR_ppoll, fds, nfds, (timeout >=3D 0) ? &t : NULL, N= ULL, 0); + return my_syscall5(__NR_ppoll_time64, fds, nfds, (timeout >=3D 0) ? &t : = NULL, NULL, 0); #else - struct __kernel_timespec t; + struct __kernel_old_timespec t; =20 if (timeout >=3D 0) { t.tv_sec =3D timeout / 1000; t.tv_nsec =3D (timeout % 1000) * 1000000; } - return my_syscall5(__NR_ppoll_time64, fds, nfds, (timeout >=3D 0) ? &t : = NULL, NULL, 0); + return my_syscall5(__NR_ppoll, fds, nfds, (timeout >=3D 0) ? &t : NULL, N= ULL, 0); #endif } =20 diff --git a/tools/include/nolibc/sys/select.h b/tools/include/nolibc/sys/s= elect.h index 50b77dace7ef..f8870ad49687 100644 --- a/tools/include/nolibc/sys/select.h +++ b/tools/include/nolibc/sys/select.h @@ -63,22 +63,22 @@ typedef struct { static __attribute__((unused)) int sys_select(int nfds, fd_set *rfds, fd_set *wfds, fd_set *efds, struct = timeval *timeout) { -#if defined(__NR_pselect6) - struct __kernel_old_timespec t; +#if defined(__NR_pselect6_time64) + struct __kernel_timespec t; =20 if (timeout) { t.tv_sec =3D timeout->tv_sec; t.tv_nsec =3D timeout->tv_usec * 1000; } - return my_syscall6(__NR_pselect6, nfds, rfds, wfds, efds, timeout ? &t : = NULL, NULL); + return my_syscall6(__NR_pselect6_time64, nfds, rfds, wfds, efds, timeout = ? &t : NULL, NULL); #else - struct __kernel_timespec t; + struct __kernel_old_timespec t; =20 if (timeout) { t.tv_sec =3D timeout->tv_sec; t.tv_nsec =3D timeout->tv_usec * 1000; } - return my_syscall6(__NR_pselect6_time64, nfds, rfds, wfds, efds, timeout = ? &t : NULL, NULL); + return my_syscall6(__NR_pselect6, nfds, rfds, wfds, efds, timeout ? &t : = NULL, NULL); #endif } =20 diff --git a/tools/include/nolibc/sys/timerfd.h b/tools/include/nolibc/sys/= timerfd.h index 5dd61030c991..66f779553d31 100644 --- a/tools/include/nolibc/sys/timerfd.h +++ b/tools/include/nolibc/sys/timerfd.h @@ -32,9 +32,7 @@ int timerfd_create(int clockid, int flags) static __attribute__((unused)) 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 +#if defined(__NR_timerfd_gettime64) struct __kernel_itimerspec kcurr_value; int ret; =20 @@ -42,6 +40,8 @@ int sys_timerfd_gettime(int fd, struct itimerspec *curr_v= alue) __nolibc_timespec_kernel_to_user(&kcurr_value.it_interval, &curr_value->i= t_interval); __nolibc_timespec_kernel_to_user(&kcurr_value.it_value, &curr_value->it_v= alue); return ret; +#else + return my_syscall2(__NR_timerfd_gettime, fd, curr_value); #endif } =20 @@ -56,9 +56,7 @@ static __attribute__((unused)) int sys_timerfd_settime(int fd, int flags, const struct itimerspec *new_value, struct itimerspec *old_value) { -#if defined(__NR_timerfd_settime) - return my_syscall4(__NR_timerfd_settime, fd, flags, new_value, old_value); -#else +#if defined(__NR_timerfd_settime64) struct __kernel_itimerspec knew_value, kold_value; int ret; =20 @@ -70,6 +68,8 @@ int sys_timerfd_settime(int fd, int flags, __nolibc_timespec_kernel_to_user(&kold_value.it_value, &old_value->it_va= lue); } return ret; +#else + return my_syscall4(__NR_timerfd_settime, fd, flags, new_value, old_value); #endif } =20 diff --git a/tools/include/nolibc/time.h b/tools/include/nolibc/time.h index 48e78f8becf9..45df9b09d7b6 100644 --- a/tools/include/nolibc/time.h +++ b/tools/include/nolibc/time.h @@ -43,9 +43,7 @@ void __nolibc_timespec_kernel_to_user(const struct __kern= el_timespec *kts, struc static __attribute__((unused)) int sys_clock_getres(clockid_t clockid, struct timespec *res) { -#if defined(__NR_clock_getres) - return my_syscall2(__NR_clock_getres, clockid, res); -#else +#if defined(__NR_clock_getres_time64) struct __kernel_timespec kres; int ret; =20 @@ -53,6 +51,8 @@ int sys_clock_getres(clockid_t clockid, struct timespec *= res) if (res) __nolibc_timespec_kernel_to_user(&kres, res); return ret; +#else + return my_syscall2(__NR_clock_getres, clockid, res); #endif } =20 @@ -65,9 +65,7 @@ int clock_getres(clockid_t clockid, struct timespec *res) static __attribute__((unused)) int sys_clock_gettime(clockid_t clockid, struct timespec *tp) { -#if defined(__NR_clock_gettime) - return my_syscall2(__NR_clock_gettime, clockid, tp); -#else +#if defined(__NR_clock_gettime64) struct __kernel_timespec ktp; int ret; =20 @@ -75,6 +73,8 @@ int sys_clock_gettime(clockid_t clockid, struct timespec = *tp) if (tp) __nolibc_timespec_kernel_to_user(&ktp, tp); return ret; +#else + return my_syscall2(__NR_clock_gettime, clockid, tp); #endif } =20 @@ -87,13 +87,13 @@ int clock_gettime(clockid_t clockid, struct timespec *t= p) static __attribute__((unused)) int sys_clock_settime(clockid_t clockid, struct timespec *tp) { -#if defined(__NR_clock_settime) - return my_syscall2(__NR_clock_settime, clockid, tp); -#else +#if defined(__NR_clock_settime64) struct __kernel_timespec ktp; =20 __nolibc_timespec_user_to_kernel(tp, &ktp); return my_syscall2(__NR_clock_settime64, clockid, &ktp); +#else + return my_syscall2(__NR_clock_settime, clockid, tp); #endif } =20 @@ -107,9 +107,7 @@ static __attribute__((unused)) int sys_clock_nanosleep(clockid_t clockid, int flags, const struct timespe= c *rqtp, struct timespec *rmtp) { -#if defined(__NR_clock_nanosleep) - return my_syscall4(__NR_clock_nanosleep, clockid, flags, rqtp, rmtp); -#else +#if defined(__NR_clock_nanosleep_time64) struct __kernel_timespec krqtp, krmtp; int ret; =20 @@ -118,6 +116,8 @@ int sys_clock_nanosleep(clockid_t clockid, int flags, c= onst struct timespec *rqt if (rmtp) __nolibc_timespec_kernel_to_user(&krmtp, rmtp); return ret; +#else + return my_syscall4(__NR_clock_nanosleep, clockid, flags, rqtp, rmtp); #endif } =20 @@ -189,9 +189,7 @@ int timer_delete(timer_t timerid) static __attribute__((unused)) int sys_timer_gettime(timer_t timerid, struct itimerspec *curr_value) { -#if defined(__NR_timer_gettime) - return my_syscall2(__NR_timer_gettime, timerid, curr_value); -#else +#if defined(__NR_timer_gettime64) struct __kernel_itimerspec kcurr_value; int ret; =20 @@ -199,6 +197,8 @@ int sys_timer_gettime(timer_t timerid, struct itimerspe= c *curr_value) __nolibc_timespec_kernel_to_user(&kcurr_value.it_interval, &curr_value->i= t_interval); __nolibc_timespec_kernel_to_user(&kcurr_value.it_value, &curr_value->it_v= alue); return ret; +#else + return my_syscall2(__NR_timer_gettime, timerid, curr_value); #endif } =20 @@ -212,9 +212,7 @@ static __attribute__((unused)) int sys_timer_settime(timer_t timerid, int flags, const struct itimerspec *new_value, struct itimerspec *old_value) { -#if defined(__NR_timer_settime) - return my_syscall4(__NR_timer_settime, timerid, flags, new_value, old_val= ue); -#else +#if defined(__NR_timer_settime64) struct __kernel_itimerspec knew_value, kold_value; int ret; =20 @@ -226,6 +224,8 @@ int sys_timer_settime(timer_t timerid, int flags, __nolibc_timespec_kernel_to_user(&kold_value.it_value, &old_value->it_va= lue); } return ret; +#else + return my_syscall4(__NR_timer_settime, timerid, flags, new_value, old_val= ue); #endif } =20 --=20 2.52.0 From nobody Sun Feb 8 15:53:48 2026 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E46A33093D8; Sat, 20 Dec 2025 13:56:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766238970; cv=none; b=SQxlm6at6bKqforPu8EV2F/EFd/43b5DoZZEKLZJ0zjMxAvXi0GPS7boYxzd5vlE67wHLGVvtDGUpPGBHT9WaSygcuMVRaBL+Lv0OJwjm32STeU+LAXnQ3GDdDL4Pm9Q85qQKA5LSQ/rTX3Z/1q6EPbZqJlY8f5WQNEUi97Y2AA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766238970; c=relaxed/simple; bh=rZNFs92ggHWt1n0B8ucHPV4F1K6FynP/LBgA0cQHUIA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=BI/i9QWjbj++qabhnkp6omU0ic/OrafkrtqqVGS9bgoRZpq6jp5K5TZ1GoA6+scymunc7uhcIOnUTulO2mSh3H25IbqbCqrun5SX2ezR+jWgZu3sIzI/bpE7ODHuLUZBytkh9j41EfoK3ImJ8jbIHgB8gPTtytNsqu3J/462eqk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=cp2+kLMg; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="cp2+kLMg" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1766238957; bh=rZNFs92ggHWt1n0B8ucHPV4F1K6FynP/LBgA0cQHUIA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=cp2+kLMgXYqmCL3V6JjS57FlKpj8s+nwNSSmYdAFXaPU/pJGgC/tQWyF1RaGWd8Ns W6/Qg+cWYo5Aa4cmkUPnMzPxwTRN7O2sM+pdNXV3BRNfZtrRxbCMH/if7F7/ndJUVV XUoyrFr7UP5KfRQlZMn7BqPsmF8GKYz5RR2CSd5s= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sat, 20 Dec 2025 14:55:50 +0100 Subject: [PATCH v3 06/14] tools/nolibc/gettimeofday: avoid libgcc 64-bit divisions Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251220-nolibc-uapi-types-v3-6-c662992f75d7@weissschuh.net> References: <20251220-nolibc-uapi-types-v3-0-c662992f75d7@weissschuh.net> In-Reply-To: <20251220-nolibc-uapi-types-v3-0-c662992f75d7@weissschuh.net> To: Willy Tarreau , Shuah Khan Cc: Arnd Bergmann , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1766238956; l=1067; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=rZNFs92ggHWt1n0B8ucHPV4F1K6FynP/LBgA0cQHUIA=; b=8WRlm1Hxg8d28foZt91zz8Yj7ggXPufFisCBeVSmKM3wPqlpxUM5+fSuGNu/pXQYMoYu+A+UO JH9bzLJYH/VAAqnGo7I8/lPpO3rnWz43Qa+pS3DIeB98bztiGPgx80g X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= 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=C3=9Fschuh Reviewed-by: Arnd Bergmann Acked-by: Willy Tarreau --- 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/tim= e.h index 171187836e6d..afdb7e326df1 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 =3D sys_clock_gettime(CLOCK_REALTIME, &tp); if (!ret && tv) { tv->tv_sec =3D tp.tv_sec; - tv->tv_usec =3D tp.tv_nsec / 1000; + tv->tv_usec =3D (uint32_t)tp.tv_nsec / 1000; } =20 return ret; --=20 2.52.0 From nobody Sun Feb 8 15:53:48 2026 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E78D43093DF; Sat, 20 Dec 2025 13:56:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766238970; cv=none; b=XSbGWyis2QsaRVAJ2q9ObIEU0iUHJzIqGu48FcwhLbIjQYefb+J1kv9dirREt4HO1E4khNVcRF/XiELWREONq8tFFRg02K3Ie6ndKDFMH03bAtvVhgBwQ3QLbivrPRsGM5WhZQ2o8VSDtQQf8juCWRYCXgGDgEKdkycw+lYuq6g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766238970; c=relaxed/simple; bh=4uTrm4AF2R5U5BVS6YaJyByfQ2N8y4ad1rnEAkn6Ruo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=HqIcfqpL3KINErbk59KJLWJtqlumjXMbl6UKEloqrVufN7+8UDVNCNCInT28zR4yDeBLiHUMoOsAun3qbT/8n3bcP+8TvOduR2NO92iEeuNYQ6uJr5SJHqVDAM6K+YtvPsate/Ij+MJKomLn1mMPtF7M3vFAqHYuIsrAXvkRuPU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=LBW9jm44; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="LBW9jm44" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1766238957; bh=4uTrm4AF2R5U5BVS6YaJyByfQ2N8y4ad1rnEAkn6Ruo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=LBW9jm447mdYsJA19VUkiOVpk4bTo8WYpxO5Pnl3VKuw65G+wGv27RFYART9y1U/Y hvvUiBLL6TMrV/Iw/H/Yog1T06Ft5FyRefkFMH8rLkxiR8rfWpRE5r697bItWw7gJR FhFymXqoDVDxM3xcBlwn7SKH2w0R8BMl3hpOJaHE= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sat, 20 Dec 2025 14:55:51 +0100 Subject: [PATCH v3 07/14] tools/nolibc/select: avoid libgcc 64-bit multiplications Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251220-nolibc-uapi-types-v3-7-c662992f75d7@weissschuh.net> References: <20251220-nolibc-uapi-types-v3-0-c662992f75d7@weissschuh.net> In-Reply-To: <20251220-nolibc-uapi-types-v3-0-c662992f75d7@weissschuh.net> To: Willy Tarreau , Shuah Khan Cc: Arnd Bergmann , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1766238956; l=1480; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=4uTrm4AF2R5U5BVS6YaJyByfQ2N8y4ad1rnEAkn6Ruo=; b=pRlIbQNbkjzVYTOrDPdAvnTkRPYWIOHcVoaTdLYSLOjmpwaYR8slKcyyJemYTV/YaUIzgOMbL FfzlNB58TF4Dgf5yGhVWnBSUV9WQmOm0qOXE58SI7/8KBAC3eM5puqp X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= timeval::tv_usec is going to be 64-bit wide even on 32-bit architectures. As not all architectures support 64-bit multiplications instructions, calls to libgcc (__multi3()) may be emitted by the compiler which are not provided by nolibc. As tv_usec and tv_nsec are guaranteed to always fit into an uint32_t, perform a 32-bit multiplication instead. Signed-off-by: Thomas Wei=C3=9Fschuh Acked-by: Willy Tarreau Reviewed-by: Arnd Bergmann --- tools/include/nolibc/sys/select.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/include/nolibc/sys/select.h b/tools/include/nolibc/sys/s= elect.h index f8870ad49687..80cb3755ba18 100644 --- a/tools/include/nolibc/sys/select.h +++ b/tools/include/nolibc/sys/select.h @@ -68,7 +68,7 @@ int sys_select(int nfds, fd_set *rfds, fd_set *wfds, fd_s= et *efds, struct timeva =20 if (timeout) { t.tv_sec =3D timeout->tv_sec; - t.tv_nsec =3D timeout->tv_usec * 1000; + t.tv_nsec =3D (uint32_t)timeout->tv_usec * 1000; } return my_syscall6(__NR_pselect6_time64, nfds, rfds, wfds, efds, timeout = ? &t : NULL, NULL); #else @@ -76,7 +76,7 @@ int sys_select(int nfds, fd_set *rfds, fd_set *wfds, fd_s= et *efds, struct timeva =20 if (timeout) { t.tv_sec =3D timeout->tv_sec; - t.tv_nsec =3D timeout->tv_usec * 1000; + t.tv_nsec =3D (uint32_t)timeout->tv_usec * 1000; } return my_syscall6(__NR_pselect6, nfds, rfds, wfds, efds, timeout ? &t : = NULL, NULL); #endif --=20 2.52.0 From nobody Sun Feb 8 15:53:48 2026 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DEA273093B5; Sat, 20 Dec 2025 13:56:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766238970; cv=none; b=XWEqU1dNkHK6fF73lDinTE1s87rM9TGPilkB9BICh9kL1tr5xXfb/BMA7zss4+7bprkC0TBBjaXZm4QvLUJTjwY7fV3MUpxAV+soF8V/GTkXOwjzY6FPcQFe1itIk+nU7vMULZKu8sHEdpIpzUtnLz3F/Nd7bGxcCkh5uPNIn80= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766238970; c=relaxed/simple; bh=pQy/DAOtKUxUVvlXyyPTb8+FfFbofayILdjdyv3QpFQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=g8wDlpf1/KSjbj1Pzhe2B+iHdhfAO4vQmz/dGuMKOMZoVLLk+RsQpB6igOZVd293XRd97UFSZPjG85fR7sevSdvjHmoREP2cibuFAyFEETOwTGNHtwodYT2rwoomrf57jvOWPhg8peTw+Uxw3gEHwMbdRk/tdjUx+pxmkmJ1f04= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=XNvAgwYK; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="XNvAgwYK" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1766238957; bh=pQy/DAOtKUxUVvlXyyPTb8+FfFbofayILdjdyv3QpFQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=XNvAgwYKzpgs+8/JJP0xVQWmImFsaO4AgPFzHM5nvb6thkpAfzoDXKqR17fZC38lf PfazrLXV8gzN18qiZwILpLqSLXompyh2F9V2J9Htv+cdc3J1QT8YPQt6BCo+0yiDQt wRkKYnp2oII1be0+57htdOJrBTLBXaxNdcjyvGN8= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sat, 20 Dec 2025 14:55:52 +0100 Subject: [PATCH v3 08/14] tools/nolibc: use custom structs timespec and timeval Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251220-nolibc-uapi-types-v3-8-c662992f75d7@weissschuh.net> References: <20251220-nolibc-uapi-types-v3-0-c662992f75d7@weissschuh.net> In-Reply-To: <20251220-nolibc-uapi-types-v3-0-c662992f75d7@weissschuh.net> To: Willy Tarreau , Shuah Khan Cc: Arnd Bergmann , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1766238956; l=1795; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=pQy/DAOtKUxUVvlXyyPTb8+FfFbofayILdjdyv3QpFQ=; b=OyUD3UXG6cTDN7PyraCF70v7FpG1Ne8gvoyR/7KG2uvw1BSFLoIYburxyjpYVe7WFtOp9aqnn fOXNSBB9cNTCkvbrhKcy2NFnV4icNruyOO7e7I7XuEplb+iTmv7J+8B X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= A custom 'struct timespec' and 'struct timeval' will be necessary for 64-bit time types on 32-bit architectures. will define other time-related types in terms of the custom 'struct timespec'. Add custom struct definitions which for now mirror exactly the ones from the UAPI headers, but provide the foundation for further changes. Signed-off-by: Thomas Wei=C3=9Fschuh Acked-by: Willy Tarreau Reviewed-by: Arnd Bergmann --- tools/include/nolibc/arch-s390.h | 3 +++ tools/include/nolibc/types.h | 16 +++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/tools/include/nolibc/arch-s390.h b/tools/include/nolibc/arch-s= 390.h index 74125a254ce3..5bee6ecbde0a 100644 --- a/tools/include/nolibc/arch-s390.h +++ b/tools/include/nolibc/arch-s390.h @@ -5,6 +5,9 @@ =20 #ifndef _NOLIBC_ARCH_S390_H #define _NOLIBC_ARCH_S390_H + +#include "types.h" + #include #include =20 diff --git a/tools/include/nolibc/types.h b/tools/include/nolibc/types.h index 470a5f77bc0f..5d180ffabcb6 100644 --- a/tools/include/nolibc/types.h +++ b/tools/include/nolibc/types.h @@ -13,9 +13,23 @@ #include "std.h" #include #include -#include +#include #include =20 +struct timespec { + __kernel_old_time_t tv_sec; + long tv_nsec; +}; +#define _STRUCT_TIMESPEC + +struct timeval { + __kernel_old_time_t tv_sec; + __kernel_suseconds_t tv_usec; +}; + +#define timeval __nolibc_kernel_timeval +#include +#undef timeval =20 /* Only the generic macros and types may be defined here. The arch-specific * ones such as the O_RDONLY and related macros used by fcntl() and open() --=20 2.52.0 From nobody Sun Feb 8 15:53:48 2026 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 723CA30C612; Sat, 20 Dec 2025 13:56:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766238972; cv=none; b=O4wCtyoFeqil11gbJB4uGLzC8f6qY3n5VYMwvDZ0zEQkmbbh+Aojyynren45TcyjeeNCk40ZLzEeanpeEjhASBUEJl8ml1Pi39/h4CZLcpKz3o4o6Z+mXs+V8CRPswCzK553fCbZ/mM5P7NiKxqdV1zjK01eQbU5JHmcZYSKKGQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766238972; c=relaxed/simple; bh=K6K6XlIR438WXwjKl+1C/rJ/i+yI+SXJhICEMTIPyAI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=EGTMHMgpFSQx6WO8vEWdLcU1EGwAX7wCm+5IZQqm63gaCe0XqqWgs/tYV4O0/qkCraFFbOHsUZs6LN8vi5c5EgskXyZ31xYNx5wLaQ88nAm3arPHmtQ2QMFzvpMF23m3ecFr9apBJOLGzTbb8kRdCiTdJGFfFp1/ikiJJLtp/cI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=pGfEbjLX; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="pGfEbjLX" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1766238957; bh=K6K6XlIR438WXwjKl+1C/rJ/i+yI+SXJhICEMTIPyAI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=pGfEbjLXycu4Pq2WWaIbVVV8iYMX0Gzznh6/rZIO0OqOQmn2fb1Nlnxig9xvweqPd PWfOcT3S98+5VfNPpGLVl9bZsXNs6ZD2vqUo3fSD7FqCvjwd79VNjSA470R4J19BhO 3QOpIt6DIromxoxZkVwVDVbAXkwzjPVtcks22yms= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sat, 20 Dec 2025 14:55:53 +0100 Subject: [PATCH v3 09/14] tools/nolibc: always use 64-bit time types Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251220-nolibc-uapi-types-v3-9-c662992f75d7@weissschuh.net> References: <20251220-nolibc-uapi-types-v3-0-c662992f75d7@weissschuh.net> In-Reply-To: <20251220-nolibc-uapi-types-v3-0-c662992f75d7@weissschuh.net> To: Willy Tarreau , Shuah Khan Cc: Arnd Bergmann , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1766238956; l=1525; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=K6K6XlIR438WXwjKl+1C/rJ/i+yI+SXJhICEMTIPyAI=; b=455jKb7E25SzRb3OhxpnHcYPomJHwLdgcoaxe8JlFEDpxwXl36UF0ZRaTtBuVpe7wn17eceKA MYjk6ltiBiaCr4sNMdxD0ALZmTIrUs05mvn4jZz5fB93S0wQjffQQH9 X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= 32-bit time types will stop working in 2038. Switch to 64-bit time types everywhere. Suggested-by: Arnd Bergmann Link: https://lore.kernel.org/lkml/cec27d94-c99d-4c57-9a12-275ea663dda8@app= .fastmail.com/ Signed-off-by: Thomas Wei=C3=9Fschuh Acked-by: Willy Tarreau Reviewed-by: Arnd Bergmann --- tools/include/nolibc/std.h | 2 +- tools/include/nolibc/types.h | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/tools/include/nolibc/std.h b/tools/include/nolibc/std.h index 392f4dd94158..b9a116123902 100644 --- a/tools/include/nolibc/std.h +++ b/tools/include/nolibc/std.h @@ -29,6 +29,6 @@ typedef unsigned long nlink_t; typedef int64_t off_t; typedef signed long blksize_t; typedef signed long blkcnt_t; -typedef __kernel_time_t time_t; +typedef __kernel_time64_t time_t; =20 #endif /* _NOLIBC_STD_H */ diff --git a/tools/include/nolibc/types.h b/tools/include/nolibc/types.h index 5d180ffabcb6..8f3cb18df7f1 100644 --- a/tools/include/nolibc/types.h +++ b/tools/include/nolibc/types.h @@ -17,14 +17,15 @@ #include =20 struct timespec { - __kernel_old_time_t tv_sec; - long tv_nsec; + time_t tv_sec; + int64_t tv_nsec; }; #define _STRUCT_TIMESPEC =20 +/* Never use with system calls */ struct timeval { - __kernel_old_time_t tv_sec; - __kernel_suseconds_t tv_usec; + time_t tv_sec; + int64_t tv_usec; }; =20 #define timeval __nolibc_kernel_timeval --=20 2.52.0 From nobody Sun Feb 8 15:53:48 2026 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DB03430BF72; Sat, 20 Dec 2025 13:56:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766238971; cv=none; b=T2SSMhHCHEyyKLObZDEVxpy4DRQViRMli1mPsoHkahmiAgq6TKsMndQjLHm+WuJ0UUgJpzwMT7Nrz3jtEz36zvJipQ5eCRi4CVawG4zMMfne7dI5hnoXOH6dQtHZ2bnMC8L5+2u9ykNyUaU2h34nz56D+MFChPH050eenxqkAeI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766238971; c=relaxed/simple; bh=EC2fEZSIXJWQ9YW8xpxuEU0VYx6huxx/+xPGnxRLeFQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=mU2pJ6X4xB8Drw0yN91S/u8+CJGUK8gFauF7Q3hvFKu+ZYo4/TSTFNkVoOCCcY87G6wjPPqwpn2B1HCeRzUKDfx/D7i1GS+SpXwyLN3S4KnpVfpNp16RNaPJ+mv6OrPQ16+VysNLD8wdbUC1bZF4sbirfSGWUhKyj1KfGfnpDVE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=EYUPb8VU; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="EYUPb8VU" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1766238957; bh=EC2fEZSIXJWQ9YW8xpxuEU0VYx6huxx/+xPGnxRLeFQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=EYUPb8VUj461NkkeRBZR2DeXLUakWYhzR3eilZSwDGxY0UHzCc7fB7IXu0essPWIH WKKME3Ja1o0tnKBoepL8hVRcBl9JSEaTrYV9JkXOCt8JW5pa2ki0Htv1HmifOf8wot nHGukXV33d+zLJyXobb6nVNzpcnGqJ1Srf04QdWQ= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sat, 20 Dec 2025 14:55:54 +0100 Subject: [PATCH v3 10/14] selftests/nolibc: test compatibility of nolibc and kernel time types Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251220-nolibc-uapi-types-v3-10-c662992f75d7@weissschuh.net> References: <20251220-nolibc-uapi-types-v3-0-c662992f75d7@weissschuh.net> In-Reply-To: <20251220-nolibc-uapi-types-v3-0-c662992f75d7@weissschuh.net> To: Willy Tarreau , Shuah Khan Cc: Arnd Bergmann , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1766238956; l=1859; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=EC2fEZSIXJWQ9YW8xpxuEU0VYx6huxx/+xPGnxRLeFQ=; b=3ko0WBfV97djaugY+gWCQVbQUX8ThpCBTSrouQRQpLqgxSAcG3WzsGBTT/5jlF7Ty7NAM9x6n Ug4S2laNzIsBd5olOY7Zh5j5A6Zn5qc0B+4RnKZz2VwUUdw5wPmdZVL X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= Keeping 'struct timespec' and 'struct __kernel_timespec' compatible allows the source code to stay simple. Validate that the types stay compatible. Signed-off-by: Thomas Wei=C3=9Fschuh Acked-by: Willy Tarreau Reviewed-by: Arnd Bergmann --- tools/testing/selftests/nolibc/nolibc-test.c | 27 ++++++++++++++++++++++++= +++ 1 file changed, 27 insertions(+) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/s= elftests/nolibc/nolibc-test.c index 6888b20af259..72bcdbdbb2d3 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -1430,6 +1430,32 @@ int test_difftime(void) return 0; } =20 +int test_time_types(void) +{ + struct __kernel_timespec kts; + struct timespec ts; + + if (!__builtin_types_compatible_p(time_t, __kernel_time64_t)) + return 1; + + if (sizeof(ts) !=3D sizeof(kts)) + return 1; + + if (!__builtin_types_compatible_p(__typeof__(ts.tv_sec), __typeof__(kts.t= v_sec))) + return 1; + + if (!__builtin_types_compatible_p(__typeof__(ts.tv_nsec), __typeof__(kts.= tv_nsec))) + return 1; + + if (offsetof(__typeof__(ts), tv_sec) !=3D offsetof(__typeof__(kts), tv_se= c)) + return 1; + + if (offsetof(__typeof__(ts), tv_nsec) !=3D offsetof(__typeof__(kts), tv_n= sec)) + return 1; + + return 0; +} + int run_stdlib(int min, int max) { int test; @@ -1555,6 +1581,7 @@ int run_stdlib(int min, int max) CASE_TEST(difftime); EXPECT_ZR(1, test_difftime()); break; CASE_TEST(memchr_foobar6_o); EXPECT_STREQ(1, memchr("foobar", 'o'= , 6), "oobar"); break; CASE_TEST(memchr_foobar3_b); EXPECT_STRZR(1, memchr("foobar", 'b'= , 3)); break; + CASE_TEST(time_types); EXPECT_ZR(1, test_time_types()); bre= ak; =20 case __LINE__: return ret; /* must be last */ --=20 2.52.0 From nobody Sun Feb 8 15:53:48 2026 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5F22230B501; Sat, 20 Dec 2025 13:56:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766238971; cv=none; b=mNFaFT6iuMAKDNnE7XkYrnRsgQCFxt178wPNKM6QJt386V4HUlGLdDwiuVNuT6OQ0bTBiHn3v0AvPa7zb+3110YsB5sUazE/iap4cxNVijLSBflrVdABY9Up2Jsda9t95YybraAjDPx51i/i5WRysxfHULQwIQSN5Vw5x7d4B4E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766238971; c=relaxed/simple; bh=V9dIG7YK9Ou8S/4MV3BTMVP/Ykb1X0h2FaHI7fKlKlI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=hjpf74dRJ7ggM0QUuSalA3cX8Z1YFZZwaDW9i6OY1VRjIQB3F7tOvQNsG1XUJpdTZElRS/gyFQlrmUoyjMor3Z+1Z36IUvGPj0IAxZzCbRVWGLduWk/oqArOUSPFq9Kzf6GN7rSztQQn5xKElnHkrYXJYePnKu6BEkQeRvGbUhM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=bB2N/bAe; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="bB2N/bAe" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1766238958; bh=V9dIG7YK9Ou8S/4MV3BTMVP/Ykb1X0h2FaHI7fKlKlI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=bB2N/bAejkRlZQkqls5NtStb9mRLUxj5eQ9CxXL+zgZYD7vT7I75+mFDWrzviSrH8 inS5OuhlQd3cefjhOqWOupfMs4+/6atoh7AIMGN5lIBYbIlqoUFrtIjwW6Uv39mg07 Hn9bfKGoBH/Iy39TD/WY8nFwl+uZZ2cI28f7E1rM= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sat, 20 Dec 2025 14:55:55 +0100 Subject: [PATCH v3 11/14] tools/nolibc: remove time conversions Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251220-nolibc-uapi-types-v3-11-c662992f75d7@weissschuh.net> References: <20251220-nolibc-uapi-types-v3-0-c662992f75d7@weissschuh.net> In-Reply-To: <20251220-nolibc-uapi-types-v3-0-c662992f75d7@weissschuh.net> To: Willy Tarreau , Shuah Khan Cc: Arnd Bergmann , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1766238956; l=6527; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=V9dIG7YK9Ou8S/4MV3BTMVP/Ykb1X0h2FaHI7fKlKlI=; b=zen9Ey/7hUSaoMyhtoYninwoA1hbnN0xn905lPCQ3/G9pT6MAorgMOd0fMgLsxcFZCAJf44CK rt5WCPSqZ4ABd9CQu5lfv5VXNTBc8KS9QJh4eMa0eIxeIXPEWBlCGh+ X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= 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=C3=9Fschuh Acked-by: Willy Tarreau Reviewed-by: Arnd Bergmann --- 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 66f779553d31..616fcfb416a9 100644 --- a/tools/include/nolibc/sys/timerfd.h +++ b/tools/include/nolibc/sys/timerfd.h @@ -33,13 +33,7 @@ static __attribute__((unused)) int sys_timerfd_gettime(int fd, struct itimerspec *curr_value) { #if defined(__NR_timerfd_gettime64) - struct __kernel_itimerspec kcurr_value; - int ret; - - ret =3D my_syscall2(__NR_timerfd_gettime64, fd, &kcurr_value); - __nolibc_timespec_kernel_to_user(&kcurr_value.it_interval, &curr_value->i= t_interval); - __nolibc_timespec_kernel_to_user(&kcurr_value.it_value, &curr_value->it_v= alue); - return ret; + return my_syscall2(__NR_timerfd_gettime64, fd, curr_value); #else return my_syscall2(__NR_timerfd_gettime, fd, curr_value); #endif @@ -57,17 +51,7 @@ int sys_timerfd_settime(int fd, int flags, const struct itimerspec *new_value, struct itimerspec *old_value) { #if defined(__NR_timerfd_settime64) - struct __kernel_itimerspec knew_value, kold_value; - int ret; - - __nolibc_timespec_user_to_kernel(&new_value->it_value, &knew_value.it_val= ue); - __nolibc_timespec_user_to_kernel(&new_value->it_interval, &knew_value.it_= interval); - ret =3D 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_va= lue); - } - return ret; + return my_syscall4(__NR_timerfd_settime64, fd, flags, new_value, old_valu= e); #else return my_syscall4(__NR_timerfd_settime, 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 #include =20 -static __inline__ -void __nolibc_timespec_user_to_kernel(const struct timespec *ts, struct __= kernel_timespec *kts) -{ - kts->tv_sec =3D ts->tv_sec; - kts->tv_nsec =3D ts->tv_nsec; -} - -static __inline__ -void __nolibc_timespec_kernel_to_user(const struct __kernel_timespec *kts,= struct timespec *ts) -{ - ts->tv_sec =3D kts->tv_sec; - ts->tv_nsec =3D 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 =3D 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 =3D 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, c= onst 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 =3D 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, rmt= p); #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 =3D my_syscall2(__NR_timer_gettime64, timerid, &kcurr_value); - __nolibc_timespec_kernel_to_user(&kcurr_value.it_interval, &curr_value->i= t_interval); - __nolibc_timespec_kernel_to_user(&kcurr_value.it_value, &curr_value->it_v= alue); - 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_val= ue); - __nolibc_timespec_user_to_kernel(&new_value->it_interval, &knew_value.it_= interval); - ret =3D my_syscall4(__NR_timer_settime64, timerid, flags, &knew_value, &k= old_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_va= lue); - } - return ret; + return my_syscall4(__NR_timer_settime64, timerid, flags, new_value, old_v= alue); #else return my_syscall4(__NR_timer_settime, timerid, flags, new_value, old_val= ue); #endif --=20 2.52.0 From nobody Sun Feb 8 15:53:48 2026 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0B9F5309F04; Sat, 20 Dec 2025 13:56:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766238971; cv=none; b=MW3uCdseeqr0l5GgaqiWElH4A2z0wWkJ9eHXesfVLjJhHoy/Zf/RFGENwveDFaVeqcH4D9qWmqde0RIqOk80ULOHfY4ItbQnREGP1t1Z23C+7WPq07CymPS+wbPikgWemIC7awib+8wS261dkUpoSXZEjP0uzH2eoHPlP0mgGNo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766238971; c=relaxed/simple; bh=VaV7ZtdbOh7bYLktiPrnDr7zKQToeR+YSeV54YdWR+8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=BVug9P5jFwt3CX1MMyKAalakotMZfRhT3rXcky543x6i89hwBalFP3u539TxoVcpQQ6So05RbePzdp4D9SkM0Gz7gFWa4XjySCbmggrmxAtT86suE4TBKuT/aL6pJlkJDdObKYlO+dW2CbfQFURp2bS9IgOvgRDptegVc2E9Fgk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=RdJmkLpB; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="RdJmkLpB" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1766238958; bh=VaV7ZtdbOh7bYLktiPrnDr7zKQToeR+YSeV54YdWR+8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=RdJmkLpBGk/RwaJlPGpR2Szp6+5pYAAZOLz8tB19h8GRqPikZwZhWW7UQk3mu9i5T SCZbpttuzRSS3NidPFRoXYlsZrSzFKBRzYGH0XQxTmPHd8447hk0RVJeb5HtOGBerK hJBbLw6TuLZic4QrXc6nn2rj9wnqpV5Rfl1rtwEw= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sat, 20 Dec 2025 14:55:56 +0100 Subject: [PATCH v3 12/14] tools/nolibc: add compiler version detection macros Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251220-nolibc-uapi-types-v3-12-c662992f75d7@weissschuh.net> References: <20251220-nolibc-uapi-types-v3-0-c662992f75d7@weissschuh.net> In-Reply-To: <20251220-nolibc-uapi-types-v3-0-c662992f75d7@weissschuh.net> To: Willy Tarreau , Shuah Khan Cc: Arnd Bergmann , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1766238956; l=1159; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=VaV7ZtdbOh7bYLktiPrnDr7zKQToeR+YSeV54YdWR+8=; b=EHRjHanx1JGt2BiCDg4P2yGw8bGGXIumw6LbYSW8DHR7IC60EfCIu01H8/xfvyUK/nJdDWurb c+sYW3f8fSKA6EKhoHE0pA9jalAFtdnQ0BmOgy7CbS/qatGb5Rbwl87 X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= Some upcoming logic needs to depend on the version of GCC or clang. Add some helper macros to keep the conditionals readable. Signed-off-by: Thomas Wei=C3=9Fschuh Reviewed-by: Arnd Bergmann --- tools/include/nolibc/compiler.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tools/include/nolibc/compiler.h b/tools/include/nolibc/compile= r.h index 87090bbc53e0..c9ffd0496dae 100644 --- a/tools/include/nolibc/compiler.h +++ b/tools/include/nolibc/compiler.h @@ -47,4 +47,20 @@ # define __nolibc_fallthrough do { } while (0) #endif /* __nolibc_has_attribute(fallthrough) */ =20 +#define __nolibc_version(_major, _minor, _patch) ((_major) * 10000 + (_min= or) * 100 + (_patch)) + +#ifdef __GNUC__ +# define __nolibc_gnuc_version \ + __nolibc_version(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__) +#else +# define __nolibc_gnuc_version 0 +#endif /* __GNUC__ */ + +#ifdef __clang__ +# define __nolibc_clang_version \ + __nolibc_version(__clang_major__, __clang_minor__, __clang_patchlevel__) +#else +# define __nolibc_clang_version 0 +#endif /* __clang__ */ + #endif /* _NOLIBC_COMPILER_H */ --=20 2.52.0 From nobody Sun Feb 8 15:53:48 2026 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DD57130BF77; Sat, 20 Dec 2025 13:56:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766238971; cv=none; b=Pryt8T+7M4vEPazu3jQEsPpf50NQ7zdzZKMxSG6RWW2/ggVXHVozRMiDtnL1nb6XFT9JORXnMdCu0yRmypQs7248kmxJtmdj16sZJAseZjNHwuFiIEuTM5XmBWf72NseHUfSEFTvw+J29fX7pFaEXf+OIwlr9Qiel8osR3VGWsY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766238971; c=relaxed/simple; bh=i7gXFdUcxSaPlmzDotOMDeqrjXsxKbyoPN9Zigx2uPo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=PXMtJhX2+VpLse3aBjyO/4/nwxRgNEIcXYXLXxTE2VynTtwqp/jwVLfGkcy5jC0SzLSg6x5JD9nNQ0e567rkvTTpPUz4kdj+Lg5ZlxD+daAEQ+u1nE0vyuJbffFleukmaeaOVewpsWIeXq0+3c2tHrQtSJm8g1CFGw64qXgu0Ro= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=g+1LQ6z8; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="g+1LQ6z8" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1766238958; bh=i7gXFdUcxSaPlmzDotOMDeqrjXsxKbyoPN9Zigx2uPo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=g+1LQ6z8lDKBxHGAqLyqiyZRh14V3qRts2U+1Ybj9ngmNZY8267D6Cmj4ZbXw5VaQ uL9s/jphlMuJK14iNwpDVIzK+aZZA8PUBTuN+YdMsr5S89xj1cFD11hJrBSVfwzVz+ mTViWRoEwU2cbP1VqMFPHNyBF78lGF4TP4kwd7YY= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sat, 20 Dec 2025 14:55:57 +0100 Subject: [PATCH v3 13/14] tools/nolibc: add __nolibc_static_assert() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251220-nolibc-uapi-types-v3-13-c662992f75d7@weissschuh.net> References: <20251220-nolibc-uapi-types-v3-0-c662992f75d7@weissschuh.net> In-Reply-To: <20251220-nolibc-uapi-types-v3-0-c662992f75d7@weissschuh.net> To: Willy Tarreau , Shuah Khan Cc: Arnd Bergmann , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1766238956; l=1008; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=i7gXFdUcxSaPlmzDotOMDeqrjXsxKbyoPN9Zigx2uPo=; b=rIWWFm9viyfQ9MA7oU0xGbs4BlDfo6hFjeDHKEYsUTiWL9glQVqBEo/UXhyOl+13vVerFRVEP v5IJiYndex2Aa5lO6H2s1vEfN1g8Nb7Ik3JT1cokfgmQ5PiaxJTGtxH X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= Add a wrapper for _Static_assert() to use within nolibc. While _Static_assert() itself was only standardized in C11, in GCC and clang dialects it is also available in older standards. Link: https://lore.kernel.org/lkml/20251203192330.GA12995@1wt.eu/ Signed-off-by: Thomas Wei=C3=9Fschuh Reviewed-by: Arnd Bergmann --- tools/include/nolibc/compiler.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/include/nolibc/compiler.h b/tools/include/nolibc/compile= r.h index c9ffd0496dae..a8c7619dcdde 100644 --- a/tools/include/nolibc/compiler.h +++ b/tools/include/nolibc/compiler.h @@ -63,4 +63,12 @@ # define __nolibc_clang_version 0 #endif /* __clang__ */ =20 +#if __STDC_VERSION__ >=3D 201112L || \ + __nolibc_gnuc_version >=3D __nolibc_version(4, 6, 0) || \ + __nolibc_clang_version >=3D __nolibc_version(3, 0, 0) +# define __nolibc_static_assert(_t) _Static_assert(_t, "") +#else +# define __nolibc_static_assert(_t) +#endif + #endif /* _NOLIBC_COMPILER_H */ --=20 2.52.0 From nobody Sun Feb 8 15:53:48 2026 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B280330C62D; Sat, 20 Dec 2025 13:56:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766238974; cv=none; b=ZYMFdlfc4DrOINWgVkUnpcJMQz2t53D0DQcW9E8T9Dwto2rRPiubOhKZ5hsnlcBTJufDx0iD3BX3bk2j2bdLu9OzxxsNZ6es2wsATS7zYz26IBlRwsIlWDi4FzGVWuMvQDDGXpIil97sBrzsBxy2VJhmSWBaQ5dDeRDyZXqX9Lo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766238974; c=relaxed/simple; bh=AkKGdffRJhoV8i1ps7+8e6eSUsB3GUo6tcvXELLJVvI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=hdU6+YXpOF69pBmgD1M3AJnJ0O/9FpSEA6nt9BeF1L0NzrGKwH8I5bZqK07qUb49mk/iwU3BxI7KWO1M/mqZloYsAkqKb+bBW8d4dMCF23kicZjI/JnNDKQFuWIxZZhkIxSnDnkE5qV2xN0wvBMDUaM0/btF+BJVNx8cedKk+78= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=D1x7qdeC; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="D1x7qdeC" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1766238958; bh=AkKGdffRJhoV8i1ps7+8e6eSUsB3GUo6tcvXELLJVvI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=D1x7qdeCvFeBAaPcke5FwdqplVTFGvs2xOUzybEhV3wW+rplQQMPJChyyZOlh+lfJ RjIVdKGl9WPQKwQutTeJyaCD7Ci2cpfN1rjwz9MkOw9W8A9HboHBie+hIbIALX4ib+ ASP1KfcT5Rg97/qKnMryFXZyV0UDCg1oyj8PVZWs= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sat, 20 Dec 2025 14:55:58 +0100 Subject: [PATCH v3 14/14] selftests/nolibc: add static assertions around time types handling Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251220-nolibc-uapi-types-v3-14-c662992f75d7@weissschuh.net> References: <20251220-nolibc-uapi-types-v3-0-c662992f75d7@weissschuh.net> In-Reply-To: <20251220-nolibc-uapi-types-v3-0-c662992f75d7@weissschuh.net> To: Willy Tarreau , Shuah Khan Cc: Arnd Bergmann , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1766238956; l=4485; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=AkKGdffRJhoV8i1ps7+8e6eSUsB3GUo6tcvXELLJVvI=; b=rwfcwWYSFfDATp3sBwBy+RN7W4q3KTEFBSxblVEfod7ucPUPIWV+6dj45YIghwwB2ZOKlrucQ 5Y3XWVcx3YlC2miM2MoEpv+RMi5kJonOA3USYkG9woPApgRyePZGl9A X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= The nolibc system call wrappers expect the libc types to be compatible to the kernel types. Make sure these expectations hold at compile-time. Signed-off-by: Thomas Wei=C3=9Fschuh Acked-by: Willy Tarreau Reviewed-by: Arnd Bergmann --- tools/include/nolibc/sys/timerfd.h | 4 ++++ tools/include/nolibc/time.h | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/tools/include/nolibc/sys/timerfd.h b/tools/include/nolibc/sys/= timerfd.h index 616fcfb416a9..29fd92bd47d2 100644 --- a/tools/include/nolibc/sys/timerfd.h +++ b/tools/include/nolibc/sys/timerfd.h @@ -33,8 +33,10 @@ static __attribute__((unused)) int sys_timerfd_gettime(int fd, struct itimerspec *curr_value) { #if defined(__NR_timerfd_gettime64) + __nolibc_assert_time64_type(curr_value->it_value.tv_sec); return my_syscall2(__NR_timerfd_gettime64, fd, curr_value); #else + __nolibc_assert_native_time64(); return my_syscall2(__NR_timerfd_gettime, fd, curr_value); #endif } @@ -51,8 +53,10 @@ int sys_timerfd_settime(int fd, int flags, const struct itimerspec *new_value, struct itimerspec *old_value) { #if defined(__NR_timerfd_settime64) + __nolibc_assert_time64_type(new_value->it_value.tv_sec); return my_syscall4(__NR_timerfd_settime64, fd, flags, new_value, old_valu= e); #else + __nolibc_assert_native_time64(); return my_syscall4(__NR_timerfd_settime, fd, flags, new_value, old_value); #endif } diff --git a/tools/include/nolibc/time.h b/tools/include/nolibc/time.h index ab67f209c99f..f9257d6a7878 100644 --- a/tools/include/nolibc/time.h +++ b/tools/include/nolibc/time.h @@ -18,6 +18,12 @@ #include #include =20 +#define __nolibc_assert_time64_type(t) \ + __nolibc_static_assert(sizeof(t) =3D=3D 8) + +#define __nolibc_assert_native_time64() \ + __nolibc_assert_time64_type(__kernel_old_time_t) + /* * int clock_getres(clockid_t clockid, struct timespec *res); * int clock_gettime(clockid_t clockid, struct timespec *tp); @@ -30,8 +36,10 @@ static __attribute__((unused)) int sys_clock_getres(clockid_t clockid, struct timespec *res) { #if defined(__NR_clock_getres_time64) + __nolibc_assert_time64_type(res->tv_sec); return my_syscall2(__NR_clock_getres_time64, clockid, res); #else + __nolibc_assert_native_time64(); return my_syscall2(__NR_clock_getres, clockid, res); #endif } @@ -46,8 +54,10 @@ static __attribute__((unused)) int sys_clock_gettime(clockid_t clockid, struct timespec *tp) { #if defined(__NR_clock_gettime64) + __nolibc_assert_time64_type(tp->tv_sec); return my_syscall2(__NR_clock_gettime64, clockid, tp); #else + __nolibc_assert_native_time64(); return my_syscall2(__NR_clock_gettime, clockid, tp); #endif } @@ -62,8 +72,10 @@ static __attribute__((unused)) int sys_clock_settime(clockid_t clockid, struct timespec *tp) { #if defined(__NR_clock_settime64) + __nolibc_assert_time64_type(tp->tv_sec); return my_syscall2(__NR_clock_settime64, clockid, tp); #else + __nolibc_assert_native_time64(); return my_syscall2(__NR_clock_settime, clockid, tp); #endif } @@ -79,8 +91,10 @@ int sys_clock_nanosleep(clockid_t clockid, int flags, co= nst struct timespec *rqt struct timespec *rmtp) { #if defined(__NR_clock_nanosleep_time64) + __nolibc_assert_time64_type(rqtp->tv_sec); return my_syscall4(__NR_clock_nanosleep_time64, clockid, flags, rqtp, rmt= p); #else + __nolibc_assert_native_time64(); return my_syscall4(__NR_clock_nanosleep, clockid, flags, rqtp, rmtp); #endif } @@ -154,8 +168,10 @@ static __attribute__((unused)) int sys_timer_gettime(timer_t timerid, struct itimerspec *curr_value) { #if defined(__NR_timer_gettime64) + __nolibc_assert_time64_type(curr_value->it_value.tv_sec); return my_syscall2(__NR_timer_gettime64, timerid, curr_value); #else + __nolibc_assert_native_time64(); return my_syscall2(__NR_timer_gettime, timerid, curr_value); #endif } @@ -171,8 +187,10 @@ int sys_timer_settime(timer_t timerid, int flags, const struct itimerspec *new_value, struct itimerspec *old_value) { #if defined(__NR_timer_settime64) + __nolibc_assert_time64_type(new_value->it_value.tv_sec); return my_syscall4(__NR_timer_settime64, timerid, flags, new_value, old_v= alue); #else + __nolibc_assert_native_time64(); return my_syscall4(__NR_timer_settime, timerid, flags, new_value, old_val= ue); #endif } --=20 2.52.0