[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2b6c62f1-c1f1-4f2c-ba0c-981e066f4268@t-8ch.de>
Date: Tue, 29 Aug 2023 11:14:09 +0200
From: Thomas Weißschuh <linux@...ssschuh.net>
To: Willy Tarreau <w@....eu>
Cc: Shuah Khan <shuah@...nel.org>, Zhangjin Wu <falcon@...ylab.org>,
Yuan Tan <tanyuan@...ylab.org>, linux-kernel@...r.kernel.org,
linux-kselftest@...r.kernel.org
Subject: Re: [PATCH 1/2] tools/nolibc: add stdarg.h header
Hi Willy!
On 2023-08-29 08:28:27+0200, Willy Tarreau wrote:
> On Sun, Aug 27, 2023 at 10:00:15AM +0200, Thomas Weißschuh wrote:
> > This allows nolic to work with `-nostdinc` avoiding any reliance on
> > system headers.
> >
> > The implementation has been lifted from musl libc 1.2.4.
> > There is already an implementation of stdarg.h in include/linux/stdarg.h
> > but that is GPL licensed and therefore not suitable for nolibc.
>
> I'm a bit confused because for me, stdarg was normally provided by the
> compiler, but I could be mistaken. It's just that it reminds me not so
> old memories. Therefore maybe we just need to include or define
> "something" to use it.
It is indeed provided by the compiler.
I could not find anybody doing this differently.
Using builtins seems to me to be the normal way to expose compiler
implementation specifics.
> > +#ifndef _NOLIBC_STDARG_H
> > +#define _NOLIBC_STDARG_H
> > +
> > +typedef __builtin_va_list va_list;
> > +#define va_start(v, l) __builtin_va_start(v, l)
> > +#define va_end(v) __builtin_va_end(v)
> > +#define va_arg(v, l) __builtin_va_arg(v, l)
> > +#define va_copy(d, s) __builtin_va_copy(d, s)
> > +
> > +#endif /* _NOLIBC_STDARG_H */
>
> Also, regarding the doubt above, I really think these should be guarded
> (maybe just use va_start as a hint), because the risk that they come
> from libc headers or maybe from the compiler via another include path
> is non-negligible.
I can add a guard.
It would only protect against the case where the other stdarg.h is
loaded first, not if ours is loaded first.
Although these symbols should always only come from some <stdarg.h>
and within a single CU this should always end up being the same file.
Thomas
Powered by blists - more mailing lists