mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Thomas Weißschuh" <linux@weissschuh.net>
To: Ammar Faizi <ammarfaizi2@openresty.com>
Cc: Willy Tarreau <w@1wt.eu>,
	 Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Linux Kselftest Mailing List <linux-kselftest@vger.kernel.org>,
	 LLVM Mailing List <llvm@lists.linux.dev>,
	Yichun Zhang <yichun@openresty.com>,
	 Alviro Iskandar Setiawan <alviro.iskandar@gnuweeb.org>,
	Shuah Khan <shuah@kernel.org>,
	 Nathan Chancellor <nathan@kernel.org>,
	Nick Desaulniers <nick.desaulniers+lkml@gmail.com>,
	 Bill Wendling <morbo@google.com>,
	Justin Stitt <justinstitt@google.com>,
	gwml@gnuweeb.org
Subject: Re: [PATCH 1/4] tools/nolibc: evaluate syscall() arguments before the arch macros
Date: Sun, 26 Jul 2026 22:16:42 +0200	[thread overview]
Message-ID: <dca5a72c-3186-4f94-bd94-aab127dec64e@t-8ch.de> (raw)
In-Reply-To: <20260726101306.3772237-2-ammarfaizi2@openresty.com>

Thanks!

On 2026-07-26 17:13:02+0700, Ammar Faizi wrote:
(...)

> +#define __nolibc_syscall_eval6(_n, _a1, _a2, _a3, _a4, _a5, _a6)	\
> +({									\
> +	__auto_type __sc_n = (_n);					\
> +	__auto_type __sc_a1 = (_a1);					\
> +	__auto_type __sc_a2 = (_a2);					\
> +	__auto_type __sc_a3 = (_a3);					\
> +	__auto_type __sc_a4 = (_a4);					\
> +	__auto_type __sc_a5 = (_a5);					\
> +	__auto_type __sc_a6 = (_a6);					\

__auto_type is only supported from GCC 4.9. I think this is old enough,
but it should be mentioned at least.
We really should have a documented policy for that.

> +	__nolibc_syscall6(__sc_n, __sc_a1, __sc_a2, __sc_a3, __sc_a4,	\
> +			  __sc_a5, __sc_a6);				\
> +})
> +
>  #define ___nolibc_syscall_narg(_0, _1, _2, _3, _4, _5, _6, N, ...) N
>  #define __nolibc_syscall_narg(...) ___nolibc_syscall_narg(__VA_ARGS__, 6, 5, 4, 3, 2, 1, 0)
> -#define __nolibc_syscall(N, ...) __nolibc_syscall##N(__VA_ARGS__)
> +#define __nolibc_syscall(N, ...) __nolibc_syscall_eval##N(__VA_ARGS__)

I'd like to apply the same thing to the __nolibc_syscallN()
usage within nolibc itself. While today we seem not to have any
problematic cases, at least I was not aware of the issue and breakage
might creep in accidentally. We can problably rename the
architecture-specific macros to __nolibc_syscall_archN()
and make __nolibc_syscall() the properly evaluating wrapper.

>  #define __nolibc_syscall_n(N, ...) __nolibc_syscall(N, __VA_ARGS__)
>  #define _syscall(...) __nolibc_syscall_n(__nolibc_syscall_narg(__VA_ARGS__), ##__VA_ARGS__)
>  #define syscall(...) __sysret(_syscall(__VA_ARGS__))


Thomas

  reply	other threads:[~2026-07-26 20:16 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-26 10:13 [PATCH 0/4] nolibc: syscall() and abs() fixes, plus a cleanup Ammar Faizi
2026-07-26 10:13 ` [PATCH 1/4] tools/nolibc: evaluate syscall() arguments before the arch macros Ammar Faizi
2026-07-26 20:16   ` Thomas Weißschuh [this message]
2026-07-27  1:21     ` Ammar Faizi
2026-07-27  3:42       ` Willy Tarreau
2026-07-28  6:53         ` Ammar Faizi
2026-07-27  3:30     ` Willy Tarreau
2026-07-27 16:18       ` Thomas Weißschuh
2026-07-28  6:51         ` Ammar Faizi
2026-07-26 10:13 ` [PATCH 2/4] tools/nolibc: stdlib: avoid signed overflow in abs() and friends Ammar Faizi
2026-07-26 14:13   ` David Laight
2026-07-26 16:01     ` Willy Tarreau
2026-07-27  7:32       ` David Laight
2026-07-27 16:15         ` Thomas Weißschuh
2026-07-28  8:46   ` David Laight
2026-07-28 16:31     ` Thomas Weißschuh
2026-07-28 16:37       ` Ammar Faizi
2026-07-26 10:13 ` [PATCH 3/4] selftests/nolibc: add abs() range test Ammar Faizi
2026-07-26 20:00   ` Thomas Weißschuh
2026-07-27  1:32     ` Ammar Faizi
2026-07-27  2:01       ` Ammar Faizi
2026-07-27 16:13         ` Thomas Weißschuh
2026-07-28  6:14           ` Ammar Faizi
2026-07-26 10:13 ` [PATCH 4/4] tools/nolibc: remove dead __ARCH_WANT_SYS_OLD_SELECT Ammar Faizi
2026-07-26 20:01   ` Thomas Weißschuh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=dca5a72c-3186-4f94-bd94-aab127dec64e@t-8ch.de \
    --to=linux@weissschuh.net \
    --cc=alviro.iskandar@gnuweeb.org \
    --cc=ammarfaizi2@openresty.com \
    --cc=gwml@gnuweeb.org \
    --cc=justinstitt@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=morbo@google.com \
    --cc=nathan@kernel.org \
    --cc=nick.desaulniers+lkml@gmail.com \
    --cc=shuah@kernel.org \
    --cc=w@1wt.eu \
    --cc=yichun@openresty.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®