linux-kselftest.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Willy Tarreau <w@1wt.eu>
To: "Thomas Weißschuh" <linux@weissschuh.net>
Cc: Shuah Khan <shuah@kernel.org>, Zhangjin Wu <falcon@tinylab.org>,
	Yuan Tan <tanyuan@tinylab.org>,
	linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: Re: [PATCH 1/2] tools/nolibc: add stdarg.h header
Date: Wed, 30 Aug 2023 09:27:45 +0200	[thread overview]
Message-ID: <ZO7vcTwa4GjWkPDe@1wt.eu> (raw)
In-Reply-To: <20230827-nolibc-nostdinc-v1-1-995d1811f1f3@weissschuh.net>

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.
> 
> The used compiler builtins have been validated to be at least available
> since GCC 4.1.2 and clang 3.0.0.
> 
> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
> ---
>  tools/include/nolibc/Makefile |  1 +
>  tools/include/nolibc/stdarg.h | 16 ++++++++++++++++
>  2 files changed, 17 insertions(+)
> 
> diff --git a/tools/include/nolibc/Makefile b/tools/include/nolibc/Makefile
> index 909b6eb500fe..e69c26abe1ea 100644
> --- a/tools/include/nolibc/Makefile
> +++ b/tools/include/nolibc/Makefile
> @@ -34,6 +34,7 @@ all_files := \
>  		signal.h \
>  		stackprotector.h \
>  		std.h \
> +		stdarg.h \
>  		stdint.h \
>  		stdlib.h \
>  		string.h \
> diff --git a/tools/include/nolibc/stdarg.h b/tools/include/nolibc/stdarg.h
> new file mode 100644
> index 000000000000..c628b5783da6
> --- /dev/null
> +++ b/tools/include/nolibc/stdarg.h
> @@ -0,0 +1,16 @@
> +/* SPDX-License-Identifier: LGPL-2.1 OR MIT */
> +/*
> + * Variadic argument support for NOLIBC
> + * Copyright (C) 2005-2020 Rich Felker, et al.
> + */
> +
> +#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 */

Now with your other explanation I agree, however we need to change:

  #include <stdarg.h>

to

  #include "stdarg.h"

in stdio.h and sys.h so that we always use ours from now on.

Willy

  parent reply	other threads:[~2023-08-30 18:37 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-27  8:00 [PATCH 0/2] nolibc: remove reliance on system headers Thomas Weißschuh
2023-08-27  8:00 ` [PATCH 1/2] tools/nolibc: add stdarg.h header Thomas Weißschuh
2023-08-29  6:28   ` Willy Tarreau
2023-08-29  9:14     ` Thomas Weißschuh
2023-08-29  9:26       ` Willy Tarreau
2023-08-29 10:16         ` Thomas Weißschuh
2023-08-29 12:12           ` Willy Tarreau
2023-08-30  6:21             ` Thomas Weißschuh
2023-08-30  7:23               ` Willy Tarreau
2023-08-30  7:27   ` Willy Tarreau [this message]
2023-08-27  8:00 ` [PATCH 2/2] selftests/nolibc: use -nostdinc for nolibc-test 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=ZO7vcTwa4GjWkPDe@1wt.eu \
    --to=w@1wt.eu \
    --cc=falcon@tinylab.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux@weissschuh.net \
    --cc=shuah@kernel.org \
    --cc=tanyuan@tinylab.org \
    /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).