Re: [PATCH 1/2] tools/nolibc: add stdarg.h header

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux