From nobody Tue Dec 2 01:05:46 2025 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 C5C2020DD51; Sat, 22 Nov 2025 16:59:52 +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=1763830794; cv=none; b=e5XYdFj77obC9NiHsl8KgBj1gbxw/J10IaiJk+v50XWiSOUilu3Uw38Y48UKHs3uyUhTe4ql/8azDcsVSkbaiFNoxVn/ZG+3Qt09CmLNPqVlyqdBxcbL1DysK1yOnY7rfd/z9EDwfvEa1b3VG+EnW5laMhVSyd1acohlmOtCM1Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763830794; c=relaxed/simple; bh=OXjYAaSKgSUp1SYFjqpEYfE2DfwsOyHI6zFHrIiJQ48=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=htfisvF8qSQ9CMXqyeHffUbD+p4+aTuy2Bd3xvJlfebEgByWFn7i3pEq9YVg1cGQHCqa61/23NTXcxLBzDb6gL4lRn9rDCPlutLwjHBUGDMc7/Y7oDNoF4lgInSOj/Ut6FhVky8BPJn3cSae2eKkTGQHTTo+XT6ESHVZv0p1/yo= 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=IJKXpAXT; 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="IJKXpAXT" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1763830790; bh=OXjYAaSKgSUp1SYFjqpEYfE2DfwsOyHI6zFHrIiJQ48=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=IJKXpAXTOrEvjiD1CGLZBbRmr+t6hNQZcUp961mSWvS0RRGctlmcO1v20so9O5MdN dX2HxxA8n91NFrfRgdF+XhukWWboXD3hQcmXqcBkRmEwDzkQa6bh7mzNgYheKi1298 4FEg56qrm0iMI/qHdzWNy/dL8r2B+9nfu2D7fpUw= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sat, 22 Nov 2025 17:59:07 +0100 Subject: [PATCH v2 01/13] 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: <20251122-nolibc-uapi-types-v2-1-b814a43654f5@weissschuh.net> References: <20251122-nolibc-uapi-types-v2-0-b814a43654f5@weissschuh.net> In-Reply-To: <20251122-nolibc-uapi-types-v2-0-b814a43654f5@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=1763830790; l=1619; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=OXjYAaSKgSUp1SYFjqpEYfE2DfwsOyHI6zFHrIiJQ48=; b=91uPi2WXdzPL5fEM3KLwwgRubqN1R77wr6/Xrqp5dWOe+uihm5aPzDxcW4lkHBIKCttDjDCzL P+FMUeao2/4ANia8Y27lx/RdzsWtIwAf/oOrDEsSU6mFRmblfu2jVCh 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 --- 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 Tue Dec 2 01:05:46 2025 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 AF786280329; Sat, 22 Nov 2025 16:59:53 +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=1763830795; cv=none; b=bNMUKe2FWeN3PUuxSlgxsAnVxxnump/RqXjZ7Hte4z+c/JZhEzsg8NoWBkteiQSdvP5rlyvdsAW7fwM8UavlugSQVxTDHhdcM1mtzU16Vx5iBnzHbeet9wtVqN5VYyxmitX59OxlR27sWlYcJD8JqFva5QNDuD/XPyBglkXW4qY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763830795; c=relaxed/simple; bh=FcBX6WX6eEYWTFM1loQqCICXVcxi2FvrUgIrTEODT3U=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ILdsdImvCDuJdjTfnMdaET/efJFgVHZnzC2bKjOYirdrn2K7tOGNi0EUMMSkG5Nok3ynSl4zZJwoS28CqDCmtRBfhFIhNaFx3VMkVu0u9At4MrLb2lb2dFIgN2aslfaeEHdRy3e9xsCDtpsIm7jJvJC9ADVvZXUln7Emev3amJk= 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=swzFT3z+; 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="swzFT3z+" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1763830790; bh=FcBX6WX6eEYWTFM1loQqCICXVcxi2FvrUgIrTEODT3U=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=swzFT3z+Jg3yO0jp1LdhOxwjCDYyUO2mIuJ6gxnm60JIzsdKjn9tnXqjRmo1drhg7 Hssqn1f5Kn9OWjWu9NxNShr7yMvYkuGngq42ekmQ2O9D/5LsaolELmvOdhTiPyqd+Y M5oOKsbNns0ZjFV5WFcWZ2nUT86vffcmhT3jDh8g= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sat, 22 Nov 2025 17:59:08 +0100 Subject: [PATCH v2 02/13] 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: <20251122-nolibc-uapi-types-v2-2-b814a43654f5@weissschuh.net> References: <20251122-nolibc-uapi-types-v2-0-b814a43654f5@weissschuh.net> In-Reply-To: <20251122-nolibc-uapi-types-v2-0-b814a43654f5@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=1763830790; l=1128; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=FcBX6WX6eEYWTFM1loQqCICXVcxi2FvrUgIrTEODT3U=; b=0Mhlv6bJ19TqeJ+H3XN2EVDzMiB+gFo1aeGFBuMn5Mas1bOkuPxfIL8Dp44Oqp8JC4cy9ZF7T hK1x0qmeq2OD6LZsaebusOPovMVVZwrsVVkccOIp0CwBe2BdpZhP7Xg 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 --- 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 Tue Dec 2 01:05:46 2025 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 282492D8DD0; Sat, 22 Nov 2025 16:59:56 +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=1763830798; cv=none; b=VALwA0XvbGUQWAKt0wLO7B1J+rSt3MtNQUh/l5TgsEIVov5kzXQrDaxGVEKdRGMOSe7L9CFEUvFp5PJBWRrt2ajIr5uznTCMNXtRiHiOMgqL5r9KK8/QjOdORfS5lEqdjvFpSR9tLadsJS3rSBX5tvV/02byBFgxs6zikSByb3E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763830798; c=relaxed/simple; bh=l9dUdwc7wiqkjKdJBg+bWqZ2xAX/mhq03Y3wW58x0Jk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=jX3t4kCdsSNRzxQSI6F52+8t9ONK6a9RowJF9j+saYQFVPZz2iQFKVeFKbaGOHHQSeQC8eWSYg8s12nfavkYpMEG2QJUhHmiOSxbcBv7QL724W9tiR0g1sEBaXdnh+v+mvAWE/D1EnatZol7fcK6zYe9h/nrioTVWsIegQJ6zUA= 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=ZhAfOUMc; 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="ZhAfOUMc" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1763830790; bh=l9dUdwc7wiqkjKdJBg+bWqZ2xAX/mhq03Y3wW58x0Jk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=ZhAfOUMcLxG1BCDxaaajUn3d5n5JUYsUiGDEAK4ScZPZbbG+vHxe27ZqmfAEFY4RX j40eDP/0ZGNfZQjKGlFjNrgHriMdIZbLzbPfhCllIgNrL00AIEa1jWWFUxLBgm0gyf Ft5DkmlW57jeVJiialMTYkhBIalO2WcNVItcrFT4= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sat, 22 Nov 2025 17:59:09 +0100 Subject: [PATCH v2 03/13] 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: <20251122-nolibc-uapi-types-v2-3-b814a43654f5@weissschuh.net> References: <20251122-nolibc-uapi-types-v2-0-b814a43654f5@weissschuh.net> In-Reply-To: <20251122-nolibc-uapi-types-v2-0-b814a43654f5@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=1763830790; l=1503; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=l9dUdwc7wiqkjKdJBg+bWqZ2xAX/mhq03Y3wW58x0Jk=; b=PdFfyZgacglLLCCcbulKErE3oG1pu+XigHNY5HccJxyO4RR+Wr/B+RY0nVP18ZU8Y7asLxscY +85FAc7nly9BwPbcnY3bjgK1JtOg5YJiH81pEVSbFemtc53Pj6JfIj0 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 --- 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 Tue Dec 2 01:05:46 2025 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 282C92D94BA; Sat, 22 Nov 2025 16:59:55 +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=1763830797; cv=none; b=hu9LToAbdvZnFYv3PRqfJhiQqU5OQjfEdmTfsvFrzuM9On+eblHLiV2k2xclCbJnvOfqnZn/QejPXYCwuJFqnq35trcCU5p3dY/fa93bsqr/+9fWqiULhkoYPU+fvBa0Hg28bLe4RKZlC5rp4fgvOOXqBNPTR14WjT77N0KQx9Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763830797; c=relaxed/simple; bh=QKw3UT6TASNbtH8Q1/NguvYLGcJ0Y+8XijBIm9WC2YQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=lhpFgHmZnhYom/LjYNXzx2BtSzLq0UUfbNyUOtXDH4+F6To6SDFtYdrIigeMTexPB1Oq2Iv7H2faVpy0ZU3ariINUrC/7AJIzk2k+5lXUXo0/DuN/MkOL2W0C02pRrJcMlfsOyuRl3TpT/FHZKfkym1FIM5YLpWG2y+4vlIlSek= 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=uBdyzfw/; 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="uBdyzfw/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1763830790; bh=QKw3UT6TASNbtH8Q1/NguvYLGcJ0Y+8XijBIm9WC2YQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=uBdyzfw/IChOS3NQ1pguLv1q0JmuwwQfroIXyPTfLqaoX7BeTHGePm2YHiLdsHdag SlJK+e6gHF4fQ9sqNQScAiWNJUZ+H37C3CIkjZI+VIviOfVnLWyJwWwmU+7U10MF4a fjOYtlAT8njdb5N3uihZb1ViF69gAF9W45Q/3WAc= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sat, 22 Nov 2025 17:59:10 +0100 Subject: [PATCH v2 04/13] 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: <20251122-nolibc-uapi-types-v2-4-b814a43654f5@weissschuh.net> References: <20251122-nolibc-uapi-types-v2-0-b814a43654f5@weissschuh.net> In-Reply-To: <20251122-nolibc-uapi-types-v2-0-b814a43654f5@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=1763830790; l=1125; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=QKw3UT6TASNbtH8Q1/NguvYLGcJ0Y+8XijBIm9WC2YQ=; b=pXysmdDiKxP+ca/CQvQpJzyLzcJxfUeAVeUJE6jhYC7ujBWCFSFfElbz8WPEizwIPMT7U2+t+ UVlUfP389M1DrhattPIBygd+o9KCaWLw1t5Ne8bGs+YuFTxS3ja12Ug 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 --- 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 Tue Dec 2 01:05:46 2025 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 6755E27054C; Sat, 22 Nov 2025 16:59:53 +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=1763830795; cv=none; b=MmGnDMz7ent5TXr4t+n7shKYBrCr8Ut+b2oTeqQq8wcn36IT2Ks4+HoBBNxCva+SctBGsgUPkB3R9ffNh2oSPWdh6xxcFj1XpfKtAdDL3tl6aHGSluFx8/PKrrTkjY3i35NAiF9GMikads3uQC29mSB6dVIP0pkcx+uNBGCUVl4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763830795; c=relaxed/simple; bh=dGVCEDJxREG493qX1+ElpZCtsb7NtbI9/rcSZtj2REU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=AJ6lVE4ki9mwpLgNsl7uugME9lxNmpr5YGnoaItEjKQxHRPs07DJt1w0HjLnJHSw+BuXbN3pSP0QbOMHmBkjnBfOyPi+PlEQCci7eUONvB6b+roB11LMkn0YXt81hppXqxiIoD+Kkc7fVcQJWKifmYsmDyBU5yQxxNdHraPC24A= 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=fi1qAUhK; 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="fi1qAUhK" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1763830791; bh=dGVCEDJxREG493qX1+ElpZCtsb7NtbI9/rcSZtj2REU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=fi1qAUhKINZAiT1Jt9SxGzuhtICtzS+p1mwYuPsj0nFuDu4IQsZFbklqtFTLvBc3L HMHoLJE0WP8qDpnFJvZRdtt9ZtEp/Df2RsKtuMILTgCHso9cQrWlNZ/ZNO+4P4iH3o RA+qAJQhcTNVj4lxhqp8KpWjAB7K0xboDzS1BQ9g= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sat, 22 Nov 2025 17:59:11 +0100 Subject: [PATCH v2 05/13] 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: <20251122-nolibc-uapi-types-v2-5-b814a43654f5@weissschuh.net> References: <20251122-nolibc-uapi-types-v2-0-b814a43654f5@weissschuh.net> In-Reply-To: <20251122-nolibc-uapi-types-v2-0-b814a43654f5@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=1763830790; l=8483; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=dGVCEDJxREG493qX1+ElpZCtsb7NtbI9/rcSZtj2REU=; b=Feb5lMep6GeYqnbn6g7aGStUXJdC8awIxhxLDcxCRMAX6D2KJIHuSUOmktNCbjDZ4yLj3J3uC q2sA8FYZ4ckDkNB3eYbxo9c6fqgk9yQOG6/WBspDwKLiqpcolJLGygs 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 --- 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 Tue Dec 2 01:05:46 2025 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 4DA0128C84A; Sat, 22 Nov 2025 16:59:57 +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=1763830799; cv=none; b=bTg6lLOlL5LuIjWCeZqKs1VkFuXm0/T71VUyQEgCtM1Ru/RVZsDlW5ALis8KRxMsaX45GnYASbRF/cSqBEZvBro1iERza/zUcXIHYKWYgU1gwMA6LnBzCM0jSHrLOSxZ0Nd6Pofp2fhbuQ8Q9uSv30Syw1U/C+2i8X8X2gYQLXg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763830799; c=relaxed/simple; bh=rZNFs92ggHWt1n0B8ucHPV4F1K6FynP/LBgA0cQHUIA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=W8+FSr3aU+rXQpAxoLPvNBNOm2XKdggdsywVxiKi3ieddZQT3L66/wY0ekUOlpBf9kPNpPYp/di0RgcTfDGnAImoNxY0W3rZH9ELxi+K1sJt/tIdpKfcOPqvm46GTSDWBcg0ubC4WtX0J11rKE7p/GT5QTAhayOYboZexp8wexA= 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=IiG2Jvpe; 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="IiG2Jvpe" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1763830791; bh=rZNFs92ggHWt1n0B8ucHPV4F1K6FynP/LBgA0cQHUIA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=IiG2JvpeYxmW/VZZEgAS5L9G+scH6uOhzwDJN0vTZrsbxMddwo/xopfYJA6GLVbgu mdcYrF/FSOGzM8YuQJJRxJXOI+gvi3PaRBdjw9LsWnZQQWKJmwYg4Jgd1ZYLr0mXUT 4z0FFKjGvE7jPGyq9tcVDahxpN+7l6QZQ7Tjld00= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sat, 22 Nov 2025 17:59:12 +0100 Subject: [PATCH v2 06/13] 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: <20251122-nolibc-uapi-types-v2-6-b814a43654f5@weissschuh.net> References: <20251122-nolibc-uapi-types-v2-0-b814a43654f5@weissschuh.net> In-Reply-To: <20251122-nolibc-uapi-types-v2-0-b814a43654f5@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=1763830790; l=1067; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=rZNFs92ggHWt1n0B8ucHPV4F1K6FynP/LBgA0cQHUIA=; b=qsVpovwjhSpIkBq9r56QxWk+q25Zidosvnk0ZXOn1ozdluBRYSPuMOPDCGU9fUKzVZyYhkI8l UnDVi4ege+/CwvB7ytzqNtlSC3KsONMxa/ukevzUFvVW4ARL5MyF/jz 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 Tue Dec 2 01:05:46 2025 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 DD1E8285CA9; Sat, 22 Nov 2025 16:59:53 +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=1763830795; cv=none; b=cHvHQHK20LTAoM1Qs8KhFpoLWdk8cC07lWCIDNCOeIPchWYSXtIA91PneBWtO9qeG28HMi7C4do4vN0E3FjOtwsQaEtqbuNJfAaFpZNvpzy78bfD6879SPrhY+pRyDVXTZRUhjpA+XTczcHSc8vT3IYFKm+gF5JuM8ghaLV39Iw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763830795; c=relaxed/simple; bh=XjElBhpMXWH0kxV1GFxd879u/AH0m7wiE5TmbhqXv+E=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Y9e8rdjAG6B2bKmd94fWKc+V7pcy3EfAfQWZIVm4jG2c7YAIb3IAYZHrFh8nyVmht9WJ9+xg6pVBlxD2YJHjA9NapJPp/4R1CM4RBIFUX/b9zHH0EHoh4WcDGYk5+uQbKgIr2ir2rXi5ogWFVE1Tr/Cjg4o9OXQlmk4GKKrCIPQ= 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=nW+9Pchq; 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="nW+9Pchq" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1763830791; bh=XjElBhpMXWH0kxV1GFxd879u/AH0m7wiE5TmbhqXv+E=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=nW+9Pchq9yJSvsSiiqCnVYBGlmcN7VSh8H+KVspR4G+JsHOLmQHz8st+InTq9bza4 MZcANpPjk/K2iGUPvFVpuyn7lYLvm5wSkw0ynEwA6BPCjPvsb+YYpi4D0CBqFOCPmE Zm/c9iax7eXIRP1dp8gvk0jubTW8UJ3pllO1fzxc= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sat, 22 Nov 2025 17:59:13 +0100 Subject: [PATCH v2 07/13] 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: <20251122-nolibc-uapi-types-v2-7-b814a43654f5@weissschuh.net> References: <20251122-nolibc-uapi-types-v2-0-b814a43654f5@weissschuh.net> In-Reply-To: <20251122-nolibc-uapi-types-v2-0-b814a43654f5@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=1763830790; l=1444; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=XjElBhpMXWH0kxV1GFxd879u/AH0m7wiE5TmbhqXv+E=; b=wnqI3Cd1pBq56uXjJRWyuMpMnLm2ZjeLcOqUvdodGpUpPtGtNf3Br2ARRWeiIQcrJg2zPQr7h upBLpKX8rCMAdnqt2t1GVPTbpuYjCT6rrgBJkn/ka4CWhlioMfcS4rY 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 --- 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 Tue Dec 2 01:05:46 2025 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 79E292E7BAA; Sat, 22 Nov 2025 16:59:56 +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=1763830798; cv=none; b=QW33S+yidYQ0GflNQLXnNBSU3QY2DKLPY/1bfIk8QOrz5Ikt890zULDbOzPOJ/ZfNzEc7W6aqzTVIjsFoGT1sq/7TQKiVso+dSgkaRS3EBrTE+4XUemb6FM0Aej0AGDKisKGOIM0hri5bD+1Sbol5BpQb9is7iKtychgqmXPpV4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763830798; c=relaxed/simple; bh=bPkH6voRfrAwZjOsEEP1623h6Mf0N8JgvChGd5XT+5c=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=G8wPZ9lxh+3hkpzo2HUHf4+iAL1C49YeMWrfKAndd53nR+n2zGpXJA1i+Y/rWt+9dZ6ZVZtuoF28+6vVcj+lQfeoamJVobixOXL9Y8EN8xPC54Tfb6nnErPQ/IoVyPGt9QtNWqldK+pP2+KrUhLTFzlpIYKXJ7J61UzORDoGiO4= 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=uEF4JVMW; 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="uEF4JVMW" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1763830791; bh=bPkH6voRfrAwZjOsEEP1623h6Mf0N8JgvChGd5XT+5c=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=uEF4JVMWSQBktcIXS9pvlp1cfSi3CiRJR5mWIFfA0pfJLnfbBRRziPD5BTnQNyJEl BLYjZPtUq+fqP8Sins4Qx937wK/1/vE/X811lLTAEXEPhrQ8RYZVfG8jibh4CEsH+1 zhJLXmDK6bk9F7nEfnEtYmDUqHG20KTsbhbESN3g= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sat, 22 Nov 2025 17:59:14 +0100 Subject: [PATCH v2 08/13] 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: <20251122-nolibc-uapi-types-v2-8-b814a43654f5@weissschuh.net> References: <20251122-nolibc-uapi-types-v2-0-b814a43654f5@weissschuh.net> In-Reply-To: <20251122-nolibc-uapi-types-v2-0-b814a43654f5@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=1763830790; l=1759; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=bPkH6voRfrAwZjOsEEP1623h6Mf0N8JgvChGd5XT+5c=; b=rnlNsRGSiYjUe6f20u1gGvDlUCD/+EVQKjx+pSTw2zjtkFvVoxcZHiAN5zTMjWrnIX3nY0ymC HVyLcrPDB0CD9Feqx7aXZzpYdVw5z7Ev7f00dwLYGLPWrj65KhEVt9z 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 --- 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 6237211385c0..1e87ac42ab9c 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 Tue Dec 2 01:05:46 2025 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 E2C352F28EC; Sat, 22 Nov 2025 16:59:56 +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=1763830799; cv=none; b=s8LmmRrPBgDfvI0dISCV+/CT9VL0OgKjsC/aC0LMWL576+nIaF0mMzBSjsm2GyF8gW/e/Pdam+0aNO8SUAr9/xX9gslM91dA5SSqVSx1FnTWgq4WV3k/MNwN6dnm5jLrAxI0AKkM3JrVpXhaSsmCybmveP/L7NJBMgEhJFn6eKI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763830799; c=relaxed/simple; bh=/10X4PhbIf+Sqc14wCkpJwL51CxgUwakpQp4brgLpgw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=B5B44zbkyyRwcXhypafVYXdQ3itdVQfYj/aYMcQ9GhoAtsA8vuL0b0PUaTXop+tPu2EXk/asEgNERYeuxKm1bM9gZIlIdjDkThol0p5piD8japy/6Jd//PhyrJI9kY+y5Xy3SRCRXCOxHBIuJgWJ/OjShH+XlVeQ/hsgQtcHH94= 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=FILubYNw; 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="FILubYNw" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1763830791; bh=/10X4PhbIf+Sqc14wCkpJwL51CxgUwakpQp4brgLpgw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=FILubYNwbKbKBdhSxera6hs+lkqJqsx6BsJuj7oA3QfFJ/hDVz0UmwvhoeigsV3MB XmXwnunCem2kkCZKwDwVeQUGIfUaOkfvYW9PG4q83OageaRLyafDyMKu9Om/UNqssd DCwb0mvWSqX3+/REZTnmqH+jRAk2BovmPtQKhPBM= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sat, 22 Nov 2025 17:59:15 +0100 Subject: [PATCH v2 09/13] 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: <20251122-nolibc-uapi-types-v2-9-b814a43654f5@weissschuh.net> References: <20251122-nolibc-uapi-types-v2-0-b814a43654f5@weissschuh.net> In-Reply-To: <20251122-nolibc-uapi-types-v2-0-b814a43654f5@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=1763830790; l=1489; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=/10X4PhbIf+Sqc14wCkpJwL51CxgUwakpQp4brgLpgw=; b=0/glYwR1rBVaO832oYGnsGgf8LyzS5lycUJcqWn0BV4zPcsQU6k/TwkX6L9K9r6qZBSIPiFzY ph7OJ9GyI5iDhABmM0p5Mexx2uvoDv5VgvbJHAfHgYwFekNodLrNKB/ 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 --- 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 Tue Dec 2 01:05:46 2025 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 948D02E8B8B; Sat, 22 Nov 2025 16:59:56 +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=1763830798; cv=none; b=PfRYLOFYbtE/OGEjnGEa63/0/4d1WtV0NT0SQ8gAzZXIkeI1nzcXpOQYbBsHqdOgDgiMFOj0oCvzgnK2gXGGG9ze26/uV45Vwg4wnZydoNVSllZqY6aQA+3eKd2/PRxp8048n0nRr9nuh6JoRT5puwUCGsIeDHZMmoGktYn2vmc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763830798; c=relaxed/simple; bh=zVlfBuvSWTC8u1cxFlDc1diGCWQOUvi9vXBHqIirOyk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=HBIibN9eeJm95zj1G0abyQ8Mwg0KmIlDA+m/KQSwvpiHmoXfMKMPLTKixri4p/zV/ZqxBWrdEWv+Z8Gkvk9m7edQSZ4QvQfTTbay2v8Abtajg3eUzo8FSWohDeKq0EcWai5nGQ78hEL5hKKeWL5uGQ+yTJ9nU+B0/nwWaV3VpuA= 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=UZ9CZiWX; 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="UZ9CZiWX" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1763830791; bh=zVlfBuvSWTC8u1cxFlDc1diGCWQOUvi9vXBHqIirOyk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=UZ9CZiWXTbY9CFnIpVXDrfayvZzkChvvZ4+xy8qPwpA8/6/sqr2wjNpvAHZwEAz4p Bw6CNUMT0IH0RO2sopVeJApRdJp/F6rJfjNaXztwnj0Z+Ns6KNjMBGUAMazYUR5hVJ ANbIdXUqmOOEH7f+Iz+homEsS8YWTU33E3RIX8iE= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sat, 22 Nov 2025 17:59:16 +0100 Subject: [PATCH v2 10/13] 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: <20251122-nolibc-uapi-types-v2-10-b814a43654f5@weissschuh.net> References: <20251122-nolibc-uapi-types-v2-0-b814a43654f5@weissschuh.net> In-Reply-To: <20251122-nolibc-uapi-types-v2-0-b814a43654f5@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=1763830790; l=1823; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=zVlfBuvSWTC8u1cxFlDc1diGCWQOUvi9vXBHqIirOyk=; b=MDLh33pWyZGEiDAtsJjWAJzIn9EwSAjzSVJY0KDdV864nDWb7a2jP9JZhUO67hyX5oII7wJHh HLt0uoKJLi4Dq1cILKXEo6nMHdefFV2ZeZd6CGjgib5KBHkO0tvJz2B 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 --- 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 3c5a226dad3a..3446d76a984e 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -1428,6 +1428,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; @@ -1553,6 +1579,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 Tue Dec 2 01:05:46 2025 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 4DC9B2F49E9; Sat, 22 Nov 2025 16:59:57 +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=1763830799; cv=none; b=TiFWyivUyMzcjoxgC/ZsRWaQnbIR3jpdItBdlaTOxCBA3T6kptsgsxhD2VkFvhTaxb+pvT5XNWJMvzrdw1Y8kPk7Pg8Zwks85cQyXUZZLjEGLTTgRQvQSGX87P5qAluCK26fzZAfCoQIDnhsx33kSqxbKdlQVL6w8YHuSI3TocA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763830799; c=relaxed/simple; bh=bsQW4lHwKKOWdaZNmUTzPbVW4plm0Vc565vNPYmYsB0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=QqEHEVN67SjPl/HUvT9Xk2ndMgrZcCoLsCovaBq9Wy5/OF186BHS10MXn8RltGgxkLNSBPpVFaHBpH5yPnNG3yOJhT1RTNmtw7KaFEGvVwfQxrlDxP8N3DQngevcMTltnX1UqzEgg+izz1KdRFnxFceUlDbXnMxiamNeolRXk/I= 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=NRLQt+wn; 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="NRLQt+wn" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1763830792; bh=bsQW4lHwKKOWdaZNmUTzPbVW4plm0Vc565vNPYmYsB0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=NRLQt+wnRr0BSCzmD+FM+xl1op6CLbhMGA+FuNGp33DZjuamsY/bWjYMYVSHkOkXh zaLneOMB2+SKooa0chX3BxKxO89ODO9+MTxZmul4lu8oZTp8myUa4e+LCB4GXYXW3q S3ZAyIHGulR1KX9agMKq2FpbksnoH7+T5Zn61cYs= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sat, 22 Nov 2025 17:59:17 +0100 Subject: [PATCH v2 11/13] 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: <20251122-nolibc-uapi-types-v2-11-b814a43654f5@weissschuh.net> References: <20251122-nolibc-uapi-types-v2-0-b814a43654f5@weissschuh.net> In-Reply-To: <20251122-nolibc-uapi-types-v2-0-b814a43654f5@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=1763830790; l=6491; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=bsQW4lHwKKOWdaZNmUTzPbVW4plm0Vc565vNPYmYsB0=; b=89Q/NKTm6FrBXMF50DdWZvKlnXbBwssaHeDF0IZ4DaE1a4310m0qPwArWJarZn0RSXyJmxwyB 9r7aJuKhDIcCT6yF2SgUruX6EUa+Z7iB8gBJM8AqUf0WyIkPMZdQ1jf 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 --- 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 Tue Dec 2 01:05:46 2025 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 E2BA22F28E5; Sat, 22 Nov 2025 16:59:56 +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=1763830799; cv=none; b=fxA3UksOW3uR9T9ac65mV1rH2k9mE9JsE8FikbyYXXhdBnlQYodukF7ZtfPVlNToXZpbSh9ojLo6TGMcFihLxHPpPomcd6Fd7RfEmnchNuaJ7F3xuTuU8mFExQCZxxHvJA2MKxsVjF92mKkNdrFVD/oI6hNBNYJM7H4BHJ/SLmg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763830799; c=relaxed/simple; bh=LDTQ2RXtrLnWulNZC+qrUzz1Cvpm1f33+iPtPhUBWZQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=PkpekXnW5GNDfS1Jh1Qtav7Aq7Be4R4qrP2QjSqlI5a2DUF6m6MQMMZUxAkLY3uCBm369v0sG1y3DKtnv1TX7ekIX3evnIAf7LQKYomDg2Zh7bPeaUm2HgLhHiTUn/OGHlCrieZRrDtMPBapXFo5mz+jKIRlDskWbF4ihR9z8vU= 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=toRCeuFK; 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="toRCeuFK" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1763830792; bh=LDTQ2RXtrLnWulNZC+qrUzz1Cvpm1f33+iPtPhUBWZQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=toRCeuFKY439+3lUGk9Y5voH7L94hoHL61yl9Ac4M6eq4A0ZPxnogDl6RA+GYJcvW rGQ7CqYI+ZiwXM2iZGSlrsaOZofcKv0jYGJThQHAqKzZnEdQhSZO/vNm5XSl3zzm40 SR8Et0UN2+s9MJsezshhVnV2Zwy1DHdd6mI4W5IQ= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sat, 22 Nov 2025 17:59:18 +0100 Subject: [PATCH v2 12/13] 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: <20251122-nolibc-uapi-types-v2-12-b814a43654f5@weissschuh.net> References: <20251122-nolibc-uapi-types-v2-0-b814a43654f5@weissschuh.net> In-Reply-To: <20251122-nolibc-uapi-types-v2-0-b814a43654f5@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=1763830790; l=863; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=LDTQ2RXtrLnWulNZC+qrUzz1Cvpm1f33+iPtPhUBWZQ=; b=nRhboJj7ujvw2RpN7XPuVyznOCYENiBYlGf2DP7r1nqdfl75R2tjjtmEm0jG1sCp4UUXSOc+e c6nr7Kt7HscD329ezbnkzuUeAlv4OzjZxzDiBlJ9mSTnKdJaxzfS9ia 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. If it turns out that _Static_assert can't be used in some contexts, this wrapper can be adapted. Signed-off-by: Thomas Wei=C3=9Fschuh Acked-by: Willy Tarreau --- tools/include/nolibc/compiler.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/include/nolibc/compiler.h b/tools/include/nolibc/compile= r.h index 87090bbc53e0..ef247e916552 100644 --- a/tools/include/nolibc/compiler.h +++ b/tools/include/nolibc/compiler.h @@ -47,4 +47,6 @@ # define __nolibc_fallthrough do { } while (0) #endif /* __nolibc_has_attribute(fallthrough) */ =20 +#define __nolibc_static_assert(_t) _Static_assert(_t, "") + #endif /* _NOLIBC_COMPILER_H */ --=20 2.52.0 From nobody Tue Dec 2 01:05:46 2025 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 E711E2F291A; Sat, 22 Nov 2025 16:59:56 +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=1763830799; cv=none; b=kXRWygeOXCZjrvDpUI9wMmZjeBbAU+3UttW0G3C4kVNfK8AQjHjdkmX/K9Jkl1H+o+1hFTfZDw3cerhyalOflqdqcD/jniE2HoUj9UAjrq4RuCIRAxGOGV4XodF5Id2YH1GB/P88nI8NE4JeuzOJ0z+WqIVXu+Q3jQ6SNivwzaw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763830799; c=relaxed/simple; bh=DGGFbtrCGkFAYALb/LFAgRmgYHNiZTify5lh6Fq4wXY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=klLixb9P4OwpuCjhfqviYzJMD2qQiSqrMqb7wcivDZDrz5EDCvQswT7dMvZB7oStPnpj1b5uPm+/UF+U1YtOqmdrBSzbm3dpRQeQ2WS1Y07EphC9BLUwLLqnC4p8AFS+N/Rh9UoEZ02AxDRo7/WXdSt8Y8hKh9J1lgtORtDHTA8= 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=GnKySNMC; 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="GnKySNMC" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1763830792; bh=DGGFbtrCGkFAYALb/LFAgRmgYHNiZTify5lh6Fq4wXY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=GnKySNMC8mLPXy6E7ER8ve+84oTqdhXyd2PYGOOtdrQAW1ciAQBSq1PlwJGQnbRRn WfgfRINFWnGt0/ranpFyiI1iX9Nkugb9xlvLlMiMThvQA0ZQ+XqxkMqgpxfSPRvay/ ik6NeA1t0HRJ5iWUcHlQmV2qJODaQriSQgfUjG74= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sat, 22 Nov 2025 17:59:19 +0100 Subject: [PATCH v2 13/13] 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: <20251122-nolibc-uapi-types-v2-13-b814a43654f5@weissschuh.net> References: <20251122-nolibc-uapi-types-v2-0-b814a43654f5@weissschuh.net> In-Reply-To: <20251122-nolibc-uapi-types-v2-0-b814a43654f5@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=1763830790; l=4449; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=DGGFbtrCGkFAYALb/LFAgRmgYHNiZTify5lh6Fq4wXY=; b=RqQUDy8oIubMSEc2e4Y5IH0Pm/s2Sz83uDUIEK4azAqhQ/nK3g0uaN8FqqNZQhQM2fkWJISN7 J+y0r6hhGzGCsG3kxk/6v2X51Jg/0hPUQ+K7jICAsnHd6xYOKKLP2bf 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 --- 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