From: Mike Rapoport <rppt@kernel.org>
To: Peter Zijlstra <peterz@infradead.org>
Cc: masahiroy@kernel.org, mmarek@suse.cz,
paul.gortmaker@windriver.com, arnd@arndb.de, bp@alien8.de,
linux-kernel@vger.kernel.org
Subject: Re: [RFC][PATCH] kconfig: Add implicit CONFIG_ prefix to IS_ENABLED() and co
Date: Tue, 28 Jun 2022 13:28:55 +0300 [thread overview]
Message-ID: <YrrX594QO2pnpLxM@kernel.org> (raw)
In-Reply-To: <YrrQOifFIiISf/3g@hirez.programming.kicks-ass.net>
On Tue, Jun 28, 2022 at 11:56:10AM +0200, Peter Zijlstra wrote:
>
> Since IS_ENABLED() (and friends) are clearly meant to be used on
> CONFIG_foo symbols and IS_ENABLED(CONFIG_ is so long and almost an
> tautology, allow the more compact usage of: IS_ENABLED(foo).
>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
FWIW:
Reviewed-by: Mike Rapoport <rppt@linux.ibm.com>
> ---
>
> With this on, something like:
>
> for i in IS_BUILTIN IS_MODULE IS_REACHABLE IS_ENABLED;
> do
> git grep -wl $i | while read file;
> do
> sed -ie "s/${i}(CONFIG_/${i}(/g" $file;
> done;
> done
>
> can be used to convert all existing instance. Allowing, after time
> passes, to remove the CONFIG_ usage if so desired.
>
> ---
> tools/include/linux/kconfig.h | 7 ++++---
> include/linux/kconfig.h | 7 ++++---
> 2 files changed, 8 insertions(+), 6 deletions(-)
>
> --- a/include/linux/kconfig.h
> +++ b/include/linux/kconfig.h
> @@ -38,6 +38,7 @@
> * When CONFIG_BOOGER is not defined, we generate a (... 1, 0) pair, and when
> * the last step cherry picks the 2nd arg, we get a zero.
> */
> +#define _is_defined(x) __or(__is_defined(x), __is_defined(CONFIG_##x))
> #define __is_defined(x) ___is_defined(x)
> #define ___is_defined(val) ____is_defined(__ARG_PLACEHOLDER_##val)
> #define ____is_defined(arg1_or_junk) __take_second_arg(arg1_or_junk 1, 0)
> @@ -47,14 +48,14 @@
> * otherwise. For boolean options, this is equivalent to
> * IS_ENABLED(CONFIG_FOO).
> */
> -#define IS_BUILTIN(option) __is_defined(option)
> +#define IS_BUILTIN(option) _is_defined(option)
>
> /*
> * IS_MODULE(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'm', 0
> * otherwise. CONFIG_FOO=m results in "#define CONFIG_FOO_MODULE 1" in
> * autoconf.h.
> */
> -#define IS_MODULE(option) __is_defined(option##_MODULE)
> +#define IS_MODULE(option) _is_defined(option##_MODULE)
>
> /*
> * IS_REACHABLE(CONFIG_FOO) evaluates to 1 if the currently compiled
> @@ -63,7 +64,7 @@
> * built-in code when CONFIG_FOO is set to 'm'.
> */
> #define IS_REACHABLE(option) __or(IS_BUILTIN(option), \
> - __and(IS_MODULE(option), __is_defined(MODULE)))
> + __and(IS_MODULE(option), _is_defined(MODULE)))
>
> /*
> * IS_ENABLED(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y' or 'm',
> --- a/tools/include/linux/kconfig.h
> +++ b/tools/include/linux/kconfig.h
> @@ -32,6 +32,7 @@
> * When CONFIG_BOOGER is not defined, we generate a (... 1, 0) pair, and when
> * the last step cherry picks the 2nd arg, we get a zero.
> */
> +#define _is_defined(x) __or(__is_defined(x), __is_defined(CONFIG_##x))
> #define __is_defined(x) ___is_defined(x)
> #define ___is_defined(val) ____is_defined(__ARG_PLACEHOLDER_##val)
> #define ____is_defined(arg1_or_junk) __take_second_arg(arg1_or_junk 1, 0)
> @@ -41,13 +42,13 @@
> * otherwise. For boolean options, this is equivalent to
> * IS_ENABLED(CONFIG_FOO).
> */
> -#define IS_BUILTIN(option) __is_defined(option)
> +#define IS_BUILTIN(option) _is_defined(option)
>
> /*
> * IS_MODULE(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'm', 0
> * otherwise.
> */
> -#define IS_MODULE(option) __is_defined(option##_MODULE)
> +#define IS_MODULE(option) _is_defined(option##_MODULE)
>
> /*
> * IS_REACHABLE(CONFIG_FOO) evaluates to 1 if the currently compiled
> @@ -56,7 +57,7 @@
> * built-in code when CONFIG_FOO is set to 'm'.
> */
> #define IS_REACHABLE(option) __or(IS_BUILTIN(option), \
> - __and(IS_MODULE(option), __is_defined(MODULE)))
> + __and(IS_MODULE(option), _is_defined(MODULE)))
>
> /*
> * IS_ENABLED(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y' or 'm',
>
--
Sincerely yours,
Mike.
next prev parent reply other threads:[~2022-06-28 10:29 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-28 9:56 [RFC][PATCH] kconfig: Add implicit CONFIG_ prefix to IS_ENABLED() and co Peter Zijlstra
2022-06-28 10:28 ` Mike Rapoport [this message]
2022-06-28 11:19 ` Arnd Bergmann
2022-06-28 12:01 ` Peter Zijlstra
2022-06-28 12:09 ` Masahiro Yamada
2022-06-28 12:17 ` Rasmus Villemoes
2022-06-28 14:24 ` Paul Gortmaker
2022-06-29 14:37 ` Christoph Hellwig
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=YrrX594QO2pnpLxM@kernel.org \
--to=rppt@kernel.org \
--cc=arnd@arndb.de \
--cc=bp@alien8.de \
--cc=linux-kernel@vger.kernel.org \
--cc=masahiroy@kernel.org \
--cc=mmarek@suse.cz \
--cc=paul.gortmaker@windriver.com \
--cc=peterz@infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.