From: Willy Tarreau <w@1wt.eu>
To: "Thomas Weißschuh" <linux@weissschuh.net>
Cc: Ammar Faizi <ammarfaizi2@openresty.com>,
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: Mon, 27 Jul 2026 05:30:43 +0200 [thread overview]
Message-ID: <ambQ4715PGeb6uFq@1wt.eu> (raw)
In-Reply-To: <dca5a72c-3186-4f94-bd94-aab127dec64e@t-8ch.de>
Hi Thomas, hi Ammar,
On Sun, Jul 26, 2026 at 10:16:42PM +0200, Thomas Weißschuh wrote:
> 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.
Well, at other places we already have typeof(arg) which is exactly the
same, more explicit, and doesn't come with such restrictions, so I'd
rather suggest we use it instead.
> We really should have a documented policy for that.
We could indeed. Till now the principle has been not to break support for
older compilers without a really good reason (i.e. something that would
become too complicated or impossible to do). At least we should add a
README in the directory indicating what is oldest supported version, as
it really doesn't cost anything to preserve support for that for a long
time.
> > + __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.
Yes, I wasn't aware of that either. Also I'd like to recheck that
MIPS continues to work fine because I seem to remember that its
constraints tend to be harder to respect in syscall6() and it took
us a few times to get it right. But maybe this could have helped
instead.
willy
next prev parent reply other threads:[~2026-07-27 3:30 UTC|newest]
Thread overview: 15+ 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
2026-07-27 1:21 ` Ammar Faizi
2026-07-27 3:42 ` Willy Tarreau
2026-07-27 3:30 ` Willy Tarreau [this message]
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-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-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=ambQ4715PGeb6uFq@1wt.eu \
--to=w@1wt.eu \
--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=linux@weissschuh.net \
--cc=llvm@lists.linux.dev \
--cc=morbo@google.com \
--cc=nathan@kernel.org \
--cc=nick.desaulniers+lkml@gmail.com \
--cc=shuah@kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).