All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kconfig: Only generate config_is_xxx for bool and tristate options
@ 2011-05-17 15:35 Michal Marek
  2011-05-17 18:05 ` Jean-Christophe PLAGNIOL-VILLARD
                   ` (2 more replies)
  0 siblings, 3 replies; 48+ messages in thread
From: Michal Marek @ 2011-05-17 15:35 UTC (permalink / raw)
  To: linux-kbuild; +Cc: linux-kernel, Jean-Christophe PLAGNIOL-VILLARD

For strings and integers, the config_is_xxx macros are useless and
sometimes misleading:

  #define CONFIG_INITRAMFS_SOURCE ""
  #define config_is_initramfs_source() 1

Cc: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Michal Marek <mmarek@suse.cz>
---
 scripts/kconfig/confdata.c |    8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index db06af0..d40195d 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -808,7 +808,6 @@ int conf_write_autoconf(void)
 	const char *name;
 	FILE *out, *tristate, *out_h;
 	int i;
-	int fct_val;
 
 	sym_clear_all_valid();
 
@@ -849,7 +848,7 @@ int conf_write_autoconf(void)
 		       rootmenu.prompt->text);
 
 	for_all_symbols(i, sym) {
-		fct_val = 1;
+		int fct_val = 0;
 		sym_calc_value(sym);
 		if (!(sym->flags & SYMBOL_WRITE) || !sym->name)
 			continue;
@@ -863,7 +862,6 @@ int conf_write_autoconf(void)
 		case S_TRISTATE:
 			switch (sym_get_tristate_value(sym)) {
 			case no:
-				fct_val = 0;
 				break;
 			case mod:
 				fprintf(tristate, "%s%s=M\n",
@@ -878,8 +876,10 @@ int conf_write_autoconf(void)
 					    CONFIG_, sym->name);
 				fprintf(out_h, "#define %s%s 1\n",
 				    CONFIG_, sym->name);
+				fct_val = 1;
 				break;
 			}
+			conf_write_function_autoconf(out_h, CONFIG_, sym->name, fct_val);
 			break;
 		case S_STRING:
 			conf_write_string(true, sym->name, sym_get_string_value(sym), out_h);
@@ -897,10 +897,8 @@ int conf_write_autoconf(void)
 			    CONFIG_, sym->name, str);
 			break;
 		default:
-			fct_val = 0;
 			break;
 		}
-		conf_write_function_autoconf(out_h, CONFIG_, sym->name, fct_val);
 	}
 	fclose(out);
 	fclose(tristate);
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* Re: [PATCH] kconfig: Only generate config_is_xxx for bool and tristate options
  2011-05-17 15:35 [PATCH] kconfig: Only generate config_is_xxx for bool and tristate options Michal Marek
@ 2011-05-17 18:05 ` Jean-Christophe PLAGNIOL-VILLARD
  2011-05-17 19:44   ` Michal Marek
  2011-05-17 19:53 ` Sam Ravnborg
  2011-05-25 13:35 ` [PATCH] kconfig: Only generate config_is_xxx for bool and tristate options Michal Marek
  2 siblings, 1 reply; 48+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2011-05-17 18:05 UTC (permalink / raw)
  To: Michal Marek; +Cc: linux-kbuild, linux-kernel

On 17:35 Tue 17 May     , Michal Marek wrote:
> For strings and integers, the config_is_xxx macros are useless and
> sometimes misleading:
except if the interger or hex can be at 0
so the config_is_ is usefull to known that it's enabled
> 
>   #define CONFIG_INITRAMFS_SOURCE ""
>   #define config_is_initramfs_source() 1
here agreed but I'm nor sure if it's a special case or if it will we the case
for most of the string

Best Regards,
J.

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH] kconfig: Only generate config_is_xxx for bool and tristate options
  2011-05-17 18:05 ` Jean-Christophe PLAGNIOL-VILLARD
@ 2011-05-17 19:44   ` Michal Marek
  0 siblings, 0 replies; 48+ messages in thread
From: Michal Marek @ 2011-05-17 19:44 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: linux-kbuild, linux-kernel

On 17.5.2011 20:05, Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 17:35 Tue 17 May     , Michal Marek wrote:
>> For strings and integers, the config_is_xxx macros are useless and
>> sometimes misleading:
> except if the interger or hex can be at 0
> so the config_is_ is usefull to known that it's enabled

You can check if the option that the integer depends on is enabled.


>>   #define CONFIG_INITRAMFS_SOURCE ""
>>   #define config_is_initramfs_source() 1
> here agreed but I'm nor sure if it's a special case or if it will we the case
> for most of the string

Same here.

Michal

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH] kconfig: Only generate config_is_xxx for bool and tristate options
  2011-05-17 15:35 [PATCH] kconfig: Only generate config_is_xxx for bool and tristate options Michal Marek
  2011-05-17 18:05 ` Jean-Christophe PLAGNIOL-VILLARD
@ 2011-05-17 19:53 ` Sam Ravnborg
  2011-05-18  5:16   ` Jean-Christophe PLAGNIOL-VILLARD
  2011-05-18  6:23   ` Arnaud Lacombe
  2011-05-25 13:35 ` [PATCH] kconfig: Only generate config_is_xxx for bool and tristate options Michal Marek
  2 siblings, 2 replies; 48+ messages in thread
From: Sam Ravnborg @ 2011-05-17 19:53 UTC (permalink / raw)
  To: Michal Marek; +Cc: linux-kbuild, linux-kernel, Jean-Christophe PLAGNIOL-VILLARD

On Tue, May 17, 2011 at 05:35:32PM +0200, Michal Marek wrote:
> For strings and integers, the config_is_xxx macros are useless and
> sometimes misleading:
> 
>   #define CONFIG_INITRAMFS_SOURCE ""
>   #define config_is_initramfs_source() 1

I'm late with this comment....
Could we introduce "config_is_foo" using a syntax that
does not break grepability?

Maybe a syntax like this?

    #ifdef CONFIG_FOO

and

    if (KCONFIG_FOO())

Grepping for the use of a symbol is a very typical thing,
so we should try to keep this.
And with the suggested syntax above I expect fixdep to
catch up both usage types.

	Sam

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH] kconfig: Only generate config_is_xxx for bool and tristate options
  2011-05-17 19:53 ` Sam Ravnborg
@ 2011-05-18  5:16   ` Jean-Christophe PLAGNIOL-VILLARD
  2011-05-18  6:19     ` Sam Ravnborg
  2011-05-18  6:23   ` Arnaud Lacombe
  1 sibling, 1 reply; 48+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2011-05-18  5:16 UTC (permalink / raw)
  To: Sam Ravnborg; +Cc: Michal Marek, linux-kbuild, linux-kernel

On 21:53 Tue 17 May     , Sam Ravnborg wrote:
> On Tue, May 17, 2011 at 05:35:32PM +0200, Michal Marek wrote:
> > For strings and integers, the config_is_xxx macros are useless and
> > sometimes misleading:
> > 
> >   #define CONFIG_INITRAMFS_SOURCE ""
> >   #define config_is_initramfs_source() 1
> 
> I'm late with this comment....
> Could we introduce "config_is_foo" using a syntax that
> does not break grepability?
> 
> Maybe a syntax like this?
> 
>     #ifdef CONFIG_FOO
> 
> and
> 
>     if (KCONFIG_FOO())
> 
> Grepping for the use of a symbol is a very typical thing,
> so we should try to keep this.
> And with the suggested syntax above I expect fixdep to
> catch up both usage types.
I'll prefer kconfig_foo()
not uppercase

but if we use KCONFIG_FOO no need to touch fixdep

Best Regards,
J.

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH] kconfig: Only generate config_is_xxx for bool and tristate options
  2011-05-18  5:16   ` Jean-Christophe PLAGNIOL-VILLARD
@ 2011-05-18  6:19     ` Sam Ravnborg
  2011-05-18  6:27       ` Arnaud Lacombe
  0 siblings, 1 reply; 48+ messages in thread
From: Sam Ravnborg @ 2011-05-18  6:19 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: Michal Marek, linux-kbuild, linux-kernel

On Wed, May 18, 2011 at 07:16:45AM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 21:53 Tue 17 May     , Sam Ravnborg wrote:
> > On Tue, May 17, 2011 at 05:35:32PM +0200, Michal Marek wrote:
> > > For strings and integers, the config_is_xxx macros are useless and
> > > sometimes misleading:
> > > 
> > >   #define CONFIG_INITRAMFS_SOURCE ""
> > >   #define config_is_initramfs_source() 1
> > 
> > I'm late with this comment....
> > Could we introduce "config_is_foo" using a syntax that
> > does not break grepability?
> > 
> > Maybe a syntax like this?
> > 
> >     #ifdef CONFIG_FOO
> > 
> > and
> > 
> >     if (KCONFIG_FOO())
> > 
> > Grepping for the use of a symbol is a very typical thing,
> > so we should try to keep this.
> > And with the suggested syntax above I expect fixdep to
> > catch up both usage types.
> I'll prefer kconfig_foo()
> not uppercase
> 
> but if we use KCONFIG_FOO no need to touch fixdep

fixdep is easy to fix - albeit it may cost a bit of processing time.
wht I worry much more about is users that miss uses of CONFIG_ symbols, because
they do not show up in "git grep CONFIG_FOO".

Using "if (KCONFIG_FOO()) users are also awre this is a configuration
decided condition - which is nice to stand out.

	Sam

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH] kconfig: Only generate config_is_xxx for bool and tristate options
  2011-05-17 19:53 ` Sam Ravnborg
  2011-05-18  5:16   ` Jean-Christophe PLAGNIOL-VILLARD
@ 2011-05-18  6:23   ` Arnaud Lacombe
  2011-07-13 13:22     ` Michal Marek
  1 sibling, 1 reply; 48+ messages in thread
From: Arnaud Lacombe @ 2011-05-18  6:23 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: Michal Marek, linux-kbuild, linux-kernel,
	Jean-Christophe PLAGNIOL-VILLARD, Valdis.Kletnieks

Hi,

[added Valdis.Kletnieks@vt.edu to CC:]

On Tue, May 17, 2011 at 3:53 PM, Sam Ravnborg <sam@ravnborg.org> wrote:
> On Tue, May 17, 2011 at 05:35:32PM +0200, Michal Marek wrote:
>> For strings and integers, the config_is_xxx macros are useless and
>> sometimes misleading:
>>
>>   #define CONFIG_INITRAMFS_SOURCE ""
>>   #define config_is_initramfs_source() 1
>
> I'm late with this comment....
> Could we introduce "config_is_foo" using a syntax that
> does not break grepability?
>
> Maybe a syntax like this?
>
>    #ifdef CONFIG_FOO
>
> and
>
>    if (KCONFIG_FOO())
>
> Grepping for the use of a symbol is a very typical thing,
> so we should try to keep this.
> And with the suggested syntax above I expect fixdep to
> catch up both usage types.
>
Actually, there is already an issue, on a much smaller scale, in the
current tree with NUMA_BUILD and COMPACTION_BUILD. The real way to fix
this would be to always defines CONFIG_FOO, its value being 1 or 0
depending on whether or not the symbol is selected. This is a
+35k/-35k change.

Also, I find KCONFIG_FOO() is too specific to be in the kernel source,
and redundant with CONFIG_FOO.

I've been playing a bit with the preprocessor, and reached that point:

#define EXPAND(x)       __ ## x
#define CONFIGURED(x)   \
        ({  int __1 __maybe_unused = 1;         \
            int __ ## x __maybe_unused = 0;     \
            EXPAND(x); })

I am not specifically proud of that, use case would be:

extern func(void);
int fn()
{
        if(CONFIGURED(CONFIG_FOO))
                func();
}

The issue I am seeing is that it adds a dependency to the optimizer,
as gcc will not optimize the branch away at -O0.

The advantage is that it is not intrusive at all within kconfig.

 - Arnaud

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH] kconfig: Only generate config_is_xxx for bool and tristate options
  2011-05-18  6:19     ` Sam Ravnborg
@ 2011-05-18  6:27       ` Arnaud Lacombe
  0 siblings, 0 replies; 48+ messages in thread
From: Arnaud Lacombe @ 2011-05-18  6:27 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: Jean-Christophe PLAGNIOL-VILLARD, Michal Marek, linux-kbuild,
	linux-kernel

Hi,

On Wed, May 18, 2011 at 2:19 AM, Sam Ravnborg <sam@ravnborg.org> wrote:
> On Wed, May 18, 2011 at 07:16:45AM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
>> On 21:53 Tue 17 May     , Sam Ravnborg wrote:
>> > On Tue, May 17, 2011 at 05:35:32PM +0200, Michal Marek wrote:
>> > > For strings and integers, the config_is_xxx macros are useless and
>> > > sometimes misleading:
>> > >
>> > >   #define CONFIG_INITRAMFS_SOURCE ""
>> > >   #define config_is_initramfs_source() 1
>> >
>> > I'm late with this comment....
>> > Could we introduce "config_is_foo" using a syntax that
>> > does not break grepability?
>> >
>> > Maybe a syntax like this?
>> >
>> >     #ifdef CONFIG_FOO
>> >
>> > and
>> >
>> >     if (KCONFIG_FOO())
>> >
>> > Grepping for the use of a symbol is a very typical thing,
>> > so we should try to keep this.
>> > And with the suggested syntax above I expect fixdep to
>> > catch up both usage types.
>> I'll prefer kconfig_foo()
>> not uppercase
>>
>> but if we use KCONFIG_FOO no need to touch fixdep
>
> fixdep is easy to fix - albeit it may cost a bit of processing time.
> wht I worry much more about is users that miss uses of CONFIG_ symbols, because
> they do not show up in "git grep CONFIG_FOO".
>
agree.

> Using "if (KCONFIG_FOO()) users are also awre this is a configuration
> decided condition - which is nice to stand out.
>
this will not work if you do $(git -w CONFIG_FOO) to avoid getting all
kind of noise in your search.

 - Arnaud

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH] kconfig: Only generate config_is_xxx for bool and tristate options
  2011-05-17 15:35 [PATCH] kconfig: Only generate config_is_xxx for bool and tristate options Michal Marek
  2011-05-17 18:05 ` Jean-Christophe PLAGNIOL-VILLARD
  2011-05-17 19:53 ` Sam Ravnborg
@ 2011-05-25 13:35 ` Michal Marek
  2 siblings, 0 replies; 48+ messages in thread
From: Michal Marek @ 2011-05-25 13:35 UTC (permalink / raw)
  To: linux-kbuild; +Cc: linux-kernel, Jean-Christophe PLAGNIOL-VILLARD

On Tue, May 17, 2011 at 05:35:32PM +0200, Michal Marek wrote:
> For strings and integers, the config_is_xxx macros are useless and
> sometimes misleading:
> 
>   #define CONFIG_INITRAMFS_SOURCE ""
>   #define config_is_initramfs_source() 1
> 
> Cc: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> Signed-off-by: Michal Marek <mmarek@suse.cz>
> ---
>  scripts/kconfig/confdata.c |    8 +++-----
>  1 files changed, 3 insertions(+), 5 deletions(-)

I applied this to kbuild-2.6.git#kconfig, but I won't be sending this
and the config_is_xxx patch to Linus now. First, I'm a bit in hurry and
there have been proposals for either a different name of the macro, or a
different implementation, second, the fixdep fix is not here, so we
wouldn't be able to make use of the feature anyway. So let's settle on a
final solution for 2.6.41 or 3.1 or whatever comes second next.

Michal

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH] kconfig: Only generate config_is_xxx for bool and tristate options
  2011-05-18  6:23   ` Arnaud Lacombe
@ 2011-07-13 13:22     ` Michal Marek
  2011-07-13 15:20       ` Arnaud Lacombe
                         ` (2 more replies)
  0 siblings, 3 replies; 48+ messages in thread
From: Michal Marek @ 2011-07-13 13:22 UTC (permalink / raw)
  To: Arnaud Lacombe
  Cc: Sam Ravnborg, linux-kbuild, linux-kernel,
	Jean-Christophe PLAGNIOL-VILLARD, Valdis.Kletnieks

[-- Attachment #1: Type: text/plain, Size: 2538 bytes --]

On 18.5.2011 08:23, Arnaud Lacombe wrote:
> Hi,
>
> [added Valdis.Kletnieks@vt.edu to CC:]
>
> On Tue, May 17, 2011 at 3:53 PM, Sam Ravnborg<sam@ravnborg.org>  wrote:
>> On Tue, May 17, 2011 at 05:35:32PM +0200, Michal Marek wrote:
>>> For strings and integers, the config_is_xxx macros are useless and
>>> sometimes misleading:
>>>
>>>    #define CONFIG_INITRAMFS_SOURCE ""
>>>    #define config_is_initramfs_source() 1
>>
>> I'm late with this comment....
>> Could we introduce "config_is_foo" using a syntax that
>> does not break grepability?
>>
>> Maybe a syntax like this?
>>
>>     #ifdef CONFIG_FOO
>>
>> and
>>
>>     if (KCONFIG_FOO())
>>
>> Grepping for the use of a symbol is a very typical thing,
>> so we should try to keep this.
>> And with the suggested syntax above I expect fixdep to
>> catch up both usage types.
>>
> Actually, there is already an issue, on a much smaller scale, in the
> current tree with NUMA_BUILD and COMPACTION_BUILD. The real way to fix
> this would be to always defines CONFIG_FOO, its value being 1 or 0
> depending on whether or not the symbol is selected. This is a
> +35k/-35k change.
>
> Also, I find KCONFIG_FOO() is too specific to be in the kernel source,
> and redundant with CONFIG_FOO.
>
> I've been playing a bit with the preprocessor, and reached that point:
>
> #define EXPAND(x)       __ ## x
> #define CONFIGURED(x)   \
>          ({  int __1 __maybe_unused = 1;         \
>              int __ ## x __maybe_unused = 0;     \
>              EXPAND(x); })
>
> I am not specifically proud of that, use case would be:
>
> extern func(void);
> int fn()
> {
>          if(CONFIGURED(CONFIG_FOO))
>                  func();
> }

I finally got round to revisit this. Your approach inspired me to a much 
simpler scheme: Instead of generating the config_is_xxx macros for 
direct use in the code, name them __enabled_CONFIG_XXX or similar and 
have a macro that expands given CONFIG_XXX symbol to the other form:

/*
  * Usage: ENABLED(CONFIG_FOO)
  * Please do not use the __enabled_CONFIG_FOO defines directly to not break
  * grepability of the code.
  */
#define ENABLED(x) __enabled_ ## x

plus a checkpatch.pl check so that people do not use the 
__enabled_CONFIG_FOO macros in their code. git grep -w CONFIG_FOO 
continues to work, fixdep continues to work, it works with -O0 because 
it expands to a if(1) or if(0). Am I missing some obvious problem?

Attached is my test program:
$ gcc -Wall -O0 test.c
$ ./a.out
Foo1.0
Foo1.1
$ strings ./a.out | grep Foo
Foo1.0
Foo1.1

Michal

[-- Attachment #2: test.c --]
[-- Type: text/plain, Size: 520 bytes --]

#include <stdio.h>

#define CONFIG_FOO1 1
#undef CONFIG_FOO2
#define __enabled_CONFIG_FOO1 1
#define __enabled_CONFIG_FOO2 0

/*
 * Usage: ENABLED(CONFIG_FOO)
 * Please do not use the __enabled_CONFIG_FOO defines directly to not break
 * grepability of the code.
 */
#define ENABLED(x) __enabled_ ## x

int main(void)
{
#ifdef CONFIG_FOO1
	puts("Foo1.0");
#endif
#ifdef CONFIG_FOO2
	puts("Foo2.0");
#endif
	if (ENABLED(CONFIG_FOO1)) {
		puts("Foo1.1");
	}
	if (ENABLED(CONFIG_FOO2)) {
		puts("Foo2.1");
	}
	return 0;
}


^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH] kconfig: Only generate config_is_xxx for bool and tristate options
  2011-07-13 13:22     ` Michal Marek
@ 2011-07-13 15:20       ` Arnaud Lacombe
  2011-07-13 20:08       ` Sam Ravnborg
  2011-07-25 22:58       ` [RFC][PATCH 1/2] kconfig: Introduce KCONFIG(), KCONFIG_BUILTIN() and KCONFIG_MODULE() Michal Marek
  2 siblings, 0 replies; 48+ messages in thread
From: Arnaud Lacombe @ 2011-07-13 15:20 UTC (permalink / raw)
  To: Michal Marek
  Cc: Sam Ravnborg, linux-kbuild, linux-kernel,
	Jean-Christophe PLAGNIOL-VILLARD, Valdis.Kletnieks

Hi,

On Wed, Jul 13, 2011 at 9:22 AM, Michal Marek <mmarek@suse.cz> wrote:
> On 18.5.2011 08:23, Arnaud Lacombe wrote:
>>
>> Hi,
>>
>> [added Valdis.Kletnieks@vt.edu to CC:]
>>
>> On Tue, May 17, 2011 at 3:53 PM, Sam Ravnborg<sam@ravnborg.org>  wrote:
>>>
>>> On Tue, May 17, 2011 at 05:35:32PM +0200, Michal Marek wrote:
>>>>
>>>> For strings and integers, the config_is_xxx macros are useless and
>>>> sometimes misleading:
>>>>
>>>>   #define CONFIG_INITRAMFS_SOURCE ""
>>>>   #define config_is_initramfs_source() 1
>>>
>>> I'm late with this comment....
>>> Could we introduce "config_is_foo" using a syntax that
>>> does not break grepability?
>>>
>>> Maybe a syntax like this?
>>>
>>>    #ifdef CONFIG_FOO
>>>
>>> and
>>>
>>>    if (KCONFIG_FOO())
>>>
>>> Grepping for the use of a symbol is a very typical thing,
>>> so we should try to keep this.
>>> And with the suggested syntax above I expect fixdep to
>>> catch up both usage types.
>>>
>> Actually, there is already an issue, on a much smaller scale, in the
>> current tree with NUMA_BUILD and COMPACTION_BUILD. The real way to fix
>> this would be to always defines CONFIG_FOO, its value being 1 or 0
>> depending on whether or not the symbol is selected. This is a
>> +35k/-35k change.
>>
>> Also, I find KCONFIG_FOO() is too specific to be in the kernel source,
>> and redundant with CONFIG_FOO.
>>
>> I've been playing a bit with the preprocessor, and reached that point:
>>
>> #define EXPAND(x)       __ ## x
>> #define CONFIGURED(x)   \
>>         ({  int __1 __maybe_unused = 1;         \
>>             int __ ## x __maybe_unused = 0;     \
>>             EXPAND(x); })
>>
>> I am not specifically proud of that, use case would be:
>>
>> extern func(void);
>> int fn()
>> {
>>         if(CONFIGURED(CONFIG_FOO))
>>                 func();
>> }
>
> I finally got round to revisit this. Your approach inspired me to a much
> simpler scheme: Instead of generating the config_is_xxx macros for direct
> use in the code, name them __enabled_CONFIG_XXX or similar and have a macro
> that expands given CONFIG_XXX symbol to the other form:
>
> /*
>  * Usage: ENABLED(CONFIG_FOO)
>  * Please do not use the __enabled_CONFIG_FOO defines directly to not break
>  * grepability of the code.
>  */
> #define ENABLED(x) __enabled_ ## x
>
> plus a checkpatch.pl check so that people do not use the
> __enabled_CONFIG_FOO macros in their code. git grep -w CONFIG_FOO continues
> to work, fixdep continues to work, it works with -O0 because it expands to a
> if(1) or if(0). Am I missing some obvious problem?
>
not I see immediately. ENABLED() will conflict with existing keyword
in the tree, so it might need tweaking.

Basically, you are taking the approach of always defining CONFIG_FOO
(to 0 or 1), but by introducing a new macro, you avoid to break #ifdef
usage in the tree.

Actually, with this approach, we can even see forward and start replacing:

#ifdef CONFIG_FOO

by

#if ENABLED(CONFIG_FOO)

In a couple of release, we mark the old #ifdef syntax as deprecated,
then after a couple of release, get rid of the duplicated macro
altogether.

You evil ! :-)

 - Arnaud

> Attached is my test program:
> $ gcc -Wall -O0 test.c
> $ ./a.out
> Foo1.0
> Foo1.1
> $ strings ./a.out | grep Foo
> Foo1.0
> Foo1.1
>
> Michal
>

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH] kconfig: Only generate config_is_xxx for bool and tristate options
  2011-07-13 13:22     ` Michal Marek
  2011-07-13 15:20       ` Arnaud Lacombe
@ 2011-07-13 20:08       ` Sam Ravnborg
  2011-07-19 13:45         ` Michal Marek
  2011-07-25 22:58       ` [RFC][PATCH 1/2] kconfig: Introduce KCONFIG(), KCONFIG_BUILTIN() and KCONFIG_MODULE() Michal Marek
  2 siblings, 1 reply; 48+ messages in thread
From: Sam Ravnborg @ 2011-07-13 20:08 UTC (permalink / raw)
  To: Michal Marek
  Cc: Arnaud Lacombe, linux-kbuild, linux-kernel,
	Jean-Christophe PLAGNIOL-VILLARD, Valdis.Kletnieks

On Wed, Jul 13, 2011 at 03:22:45PM +0200, Michal Marek wrote:
> On 18.5.2011 08:23, Arnaud Lacombe wrote:
>> Hi,
>>
>> [added Valdis.Kletnieks@vt.edu to CC:]
>>
>> On Tue, May 17, 2011 at 3:53 PM, Sam Ravnborg<sam@ravnborg.org>  wrote:
>>> On Tue, May 17, 2011 at 05:35:32PM +0200, Michal Marek wrote:
>>>> For strings and integers, the config_is_xxx macros are useless and
>>>> sometimes misleading:
>>>>
>>>>    #define CONFIG_INITRAMFS_SOURCE ""
>>>>    #define config_is_initramfs_source() 1
>>>
>>> I'm late with this comment....
>>> Could we introduce "config_is_foo" using a syntax that
>>> does not break grepability?
>>>
>>> Maybe a syntax like this?
>>>
>>>     #ifdef CONFIG_FOO
>>>
>>> and
>>>
>>>     if (KCONFIG_FOO())
>>>
>>> Grepping for the use of a symbol is a very typical thing,
>>> so we should try to keep this.
>>> And with the suggested syntax above I expect fixdep to
>>> catch up both usage types.
>>>
>> Actually, there is already an issue, on a much smaller scale, in the
>> current tree with NUMA_BUILD and COMPACTION_BUILD. The real way to fix
>> this would be to always defines CONFIG_FOO, its value being 1 or 0
>> depending on whether or not the symbol is selected. This is a
>> +35k/-35k change.
>>
>> Also, I find KCONFIG_FOO() is too specific to be in the kernel source,
>> and redundant with CONFIG_FOO.
>>
>> I've been playing a bit with the preprocessor, and reached that point:
>>
>> #define EXPAND(x)       __ ## x
>> #define CONFIGURED(x)   \
>>          ({  int __1 __maybe_unused = 1;         \
>>              int __ ## x __maybe_unused = 0;     \
>>              EXPAND(x); })
>>
>> I am not specifically proud of that, use case would be:
>>
>> extern func(void);
>> int fn()
>> {
>>          if(CONFIGURED(CONFIG_FOO))
>>                  func();
>> }
>
> I finally got round to revisit this. Your approach inspired me to a much  
> simpler scheme: Instead of generating the config_is_xxx macros for  
> direct use in the code, name them __enabled_CONFIG_XXX or similar and  
> have a macro that expands given CONFIG_XXX symbol to the other form:

But then we clutter the namesapce with another set of variables that will
be misued. If not in the kernel then by other kconfig users.

Arnaud approach is nice as it does not require any additional
symbols to be generated.
We can always discuss tha naming - but the approach looks good.

To look at actual usage first:

int foo()
{
	if (KCONFIG(CONFIG_FOO)) {
		// this should be true for both module and non-module case
	}

	if (KCONFIG_NOT_MODULE(CONFIG_FOO)) {
		// this should be true only if this is not a module
	}



	if (KCONFIG_MODULE(CONFIG_FOO)) {
		// this should only be true for the module case
	}

}

Using the above even the naive reader is aware this is a kconfig generate
symbol.
Using "KCONFIG" in the name gives a stong hint that this is a kconfig thing.

We could stuff it all into a kconfig.h header like the attached (not tested)
but based on Arnauds sketch above - so creadits goes to him.

	Sam

diff --git a/include/linux/kconfig.h b/include/linux/kconfig.h
new file mode 100644
index 0000000..3ccdd73
--- /dev/null
+++ b/include/linux/kconfig.h
@@ -0,0 +1,30 @@
+#ifndef _LINUX_KCONFIG_H
+#define _LINUX_KCONFIG_H
+
+/*
+ * Helper macros for dealing with kconfig symbols
+ */
+
+#include <linux/compiler.h>
+
+#define __symbol_value(sym)       __ ## x
+#define __symbol_module(sym)      __symbol_value(__ ## sym ## _MODULE)
+
+/* return 1 if x is defined and not a module */
+#define KCONFIG_NON_MODULE(sym)					\
+	({ int __1 __maybe_unused = 1;				\
+	   int __ ## sym __maybe_unused = 0;			\
+	   __symbol_value(sym); })
+
+/* return 1 if sym is a module symbol */
+#define KCONFIG_MODULE(sym)					\
+	({ int __1 __maybe_unused = 1;				\
+	   int __ ## sym ## _MODULE __maybe_unused = 0;	\
+	   __symbol_value(sym); })
+
+/* return 1 if sym is defined - module or not */
+#define KCONFIG(sym) (KCONFIG_NON_MODULE(sym) || KCONFIG_MODULE(sym))
+
+#undef __symbol_value
+#undef __symbol_module
+#endif

^ permalink raw reply related	[flat|nested] 48+ messages in thread

* Re: [PATCH] kconfig: Only generate config_is_xxx for bool and tristate options
  2011-07-13 20:08       ` Sam Ravnborg
@ 2011-07-19 13:45         ` Michal Marek
  0 siblings, 0 replies; 48+ messages in thread
From: Michal Marek @ 2011-07-19 13:45 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: Arnaud Lacombe, linux-kbuild, linux-kernel,
	Jean-Christophe PLAGNIOL-VILLARD, Valdis.Kletnieks

On 13.7.2011 22:08, Sam Ravnborg wrote:
> On Wed, Jul 13, 2011 at 03:22:45PM +0200, Michal Marek wrote:
>> On 18.5.2011 08:23, Arnaud Lacombe wrote:
>>> I've been playing a bit with the preprocessor, and reached that point:
>>>
>>> #define EXPAND(x)       __ ## x
>>> #define CONFIGURED(x)   \
>>>           ({  int __1 __maybe_unused = 1;         \
>>>               int __ ## x __maybe_unused = 0;     \
>>>               EXPAND(x); })
>>>
>>> I am not specifically proud of that, use case would be:
>>>
>>> extern func(void);
>>> int fn()
>>> {
>>>           if(CONFIGURED(CONFIG_FOO))
>>>                   func();
>>> }
>>
>> I finally got round to revisit this. Your approach inspired me to a much
>> simpler scheme: Instead of generating the config_is_xxx macros for
>> direct use in the code, name them __enabled_CONFIG_XXX or similar and
>> have a macro that expands given CONFIG_XXX symbol to the other form:
>
> But then we clutter the namesapce with another set of variables that will
> be misued. If not in the kernel then by other kconfig users.

Well, no sane person will prefix their variables with 
"__enabled_CONFIG_", so I'm not so worried about the namespace pollution.


> Arnaud approach is nice as it does not require any additional
> symbols to be generated.

Sure, I would also prefer a solution without that doesn't require 
generating new macros. But your's and Arnaud's trick doesn't eliminate 
the configured-out code at -O0, while with the help of the generated 
helper macros, the compiler sees an if(0) or if(1).


> +#include<linux/compiler.h>
> +
> +#define __symbol_value(sym)       __ ## x
> +#define __symbol_module(sym)      __symbol_value(__ ## sym ## _MODULE)
> +
> +/* return 1 if x is defined and not a module */
> +#define KCONFIG_NON_MODULE(sym)					\
> +	({ int __1 __maybe_unused = 1;				\
> +	   int __ ## sym __maybe_unused = 0;			\
> +	   __symbol_value(sym); })
> +
> +/* return 1 if sym is a module symbol */
> +#define KCONFIG_MODULE(sym)					\
> +	({ int __1 __maybe_unused = 1;				\
> +	   int __ ## sym ## _MODULE __maybe_unused = 0;	\
> +	   __symbol_value(sym); })
> +
> +/* return 1 if sym is defined - module or not */
> +#define KCONFIG(sym) (KCONFIG_NON_MODULE(sym) || KCONFIG_MODULE(sym))

With this extra expansion, the passed CONFIG_FOO expands to 1 here and 
the KCONFIG(_NON)_MODULE macros will then only see the 1 and fail.

Michal

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [RFC][PATCH 1/2] kconfig: Introduce KCONFIG(), KCONFIG_BUILTIN() and KCONFIG_MODULE()
  2011-07-13 13:22     ` Michal Marek
  2011-07-13 15:20       ` Arnaud Lacombe
  2011-07-13 20:08       ` Sam Ravnborg
@ 2011-07-25 22:58       ` Michal Marek
  2011-07-25 22:58           ` Michal Marek
                           ` (3 more replies)
  2 siblings, 4 replies; 48+ messages in thread
From: Michal Marek @ 2011-07-25 22:58 UTC (permalink / raw)
  To: linux-kbuild; +Cc: lacombar, sam, linux-kernel, plagnioj

Replace the config_is_*() macros with a variant that allows for grepping
for usage of CONFIG_* options in the code. Usage:

  if (KCONFIG(CONFIG_NUMA))

or

  #if KCONFIG(CONFIG_NUMA)

The KCONFIG() macro evaluates to 1 if the argument is set (to either 'y'
or 'm'), KCONFIG_BUILTIN() and KCONFIG_MODULE() test if the respective
option is 'y' and 'm', respectively.

Signed-off-by: Michal Marek <mmarek@suse.cz>
---
 Makefile                   |    2 +-
 include/linux/kconfig.h    |   24 +++++++++++++++
 scripts/kconfig/confdata.c |   70 ++++++++-----------------------------------
 3 files changed, 38 insertions(+), 58 deletions(-)
 create mode 100644 include/linux/kconfig.h

diff --git a/Makefile b/Makefile
index afb8e0d..bd7629b 100644
--- a/Makefile
+++ b/Makefile
@@ -360,7 +360,7 @@ CFLAGS_GCOV	= -fprofile-arcs -ftest-coverage
 LINUXINCLUDE    := -I$(srctree)/arch/$(hdr-arch)/include \
                    -Iarch/$(hdr-arch)/include/generated -Iinclude \
                    $(if $(KBUILD_SRC), -I$(srctree)/include) \
-                   -include include/generated/autoconf.h
+                   -include $(srctree)/include/linux/kconfig.h
 
 KBUILD_CPPFLAGS := -D__KERNEL__
 
diff --git a/include/linux/kconfig.h b/include/linux/kconfig.h
new file mode 100644
index 0000000..fe80348
--- /dev/null
+++ b/include/linux/kconfig.h
@@ -0,0 +1,24 @@
+#ifndef __LINUX_KCONFIG_H
+#define __LINUX_KCONFIG_H
+
+#include <generated/autoconf.h>
+
+/*
+ * Evaluates to 1 if CONFIG_option is set to 'y', 0 otherwise
+ */
+#define KCONFIG_BUILTIN(option) __enabled_ ## option
+
+/*
+ * Evaluates to 1 if CONFIG_option is set to 'm', 0 otherwise
+ */
+#define KCONFIG_MODULE(option) __enabled_ ## option ## _MODULE
+
+/*
+ * Evaluates to 1 if CONFIG_option is set to 'y' or 'm', 0 otherwise
+ *
+ */
+#define KCONFIG(option) \
+	(__enabled_ ## option || __enabled_ ## option ## _MODULE)
+
+
+#endif /* __LINUX_KCONFIG_H */
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index df629ec..3bab40a 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -495,15 +495,24 @@ header_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg)
 
 		switch (*value) {
 		case 'n':
-			return;
+			break;
 		case 'm':
 			suffix = "_MODULE";
 			/* fall through */
 		default:
-			value = "1";
+			fprintf(fp, "#define %s%s%s 1\n",
+			    CONFIG_, sym->name, suffix);
 		}
-		fprintf(fp, "#define %s%s%s %s\n",
-		    CONFIG_, sym->name, suffix, value);
+		/*
+		 * Generate the __enabled_CONFIG_* and
+		 * __enabled_CONFIG_*_MODULE macros for use by the KCONFIG*()
+		 * macros. The _MODULE variant is generated even for booleans
+		 * so that the KCONFIG() macro works.
+		 */
+		fprintf(fp, "#define __enabled_" CONFIG_ "%s %d\n",
+				sym->name, (*value == 'y'));
+		fprintf(fp, "#define __enabled_" CONFIG_ "%s_MODULE %d\n",
+				sym->name, (*value == 'm'));
 		break;
 	}
 	case S_HEX: {
@@ -555,58 +564,6 @@ static struct conf_printer header_printer_cb =
 };
 
 /*
- * Function-style header printer
- *
- * This printer is used to generate the config_is_xxx() function-style macros
- * in `include/generated/autoconf.h' 
- */
-static void
-header_function_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg)
-{
-	int val = 0;
-	char c;
-	char *tmp, *d;
-
-	switch (sym->type) {
-	case S_BOOLEAN:
-	case S_TRISTATE:
-		break;
-	default:
-		return;
-	}
-	if (*value == 'm')
-		val = 2;
-	else if (*value == 'y')
-		val = 1;
-
-	d = strdup(CONFIG_);
-	tmp = d;
-	while ((c = *d)) {
-		*d = tolower(c);
-		d++;
-	}
-
-	fprintf(fp, "#define %sis_", tmp);
-	free(tmp);
-
-	d = strdup(sym->name);
-	tmp = d;
-	while ((c = *d)) {
-		*d = tolower(c);
-		d++;
-	}
-	fprintf(fp, "%s%s() %d\n", tmp, (val > 1) ? "_module" : "",
-		      val ? 1 : 0);
-	free(tmp);
-}
-
-static struct conf_printer header_function_printer_cb =
-{
-	.print_symbol = header_function_print_symbol,
-};
-
-
-/*
  * Tristate printer
  *
  * This printer is used when generating the `include/config/tristate.conf' file.
@@ -997,7 +954,6 @@ int conf_write_autoconf(void)
 		conf_write_symbol(tristate, sym, &tristate_printer_cb, (void *)1);
 
 		conf_write_symbol(out_h, sym, &header_printer_cb, NULL);
-		conf_write_symbol(out_h, sym, &header_function_printer_cb, NULL);
 	}
 	fclose(out);
 	fclose(tristate);
-- 
1.7.6


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [RFC][PATCH 2/2] mm: Switch NUMA_BUILD and COMPACTION_BUILD to new KCONFIG() syntax
  2011-07-25 22:58       ` [RFC][PATCH 1/2] kconfig: Introduce KCONFIG(), KCONFIG_BUILTIN() and KCONFIG_MODULE() Michal Marek
@ 2011-07-25 22:58           ` Michal Marek
  2011-07-26 13:01         ` [RFC][PATCH 1/2] kconfig: Introduce KCONFIG(), KCONFIG_BUILTIN() and KCONFIG_MODULE() Américo Wang
                             ` (2 subsequent siblings)
  3 siblings, 0 replies; 48+ messages in thread
From: Michal Marek @ 2011-07-25 22:58 UTC (permalink / raw)
  To: linux-kbuild; +Cc: lacombar, sam, linux-kernel, plagnioj, linux-mm

Cc: linux-mm@kvack.org
Signed-off-by: Michal Marek <mmarek@suse.cz>
---
 include/linux/gfp.h    |    2 +-
 include/linux/kernel.h |   14 --------------
 mm/page_alloc.c        |   12 ++++++------
 mm/vmalloc.c           |    4 ++--
 mm/vmscan.c            |    2 +-
 5 files changed, 10 insertions(+), 24 deletions(-)

diff --git a/include/linux/gfp.h b/include/linux/gfp.h
index cb40892..36860b2 100644
--- a/include/linux/gfp.h
+++ b/include/linux/gfp.h
@@ -262,7 +262,7 @@ static inline enum zone_type gfp_zone(gfp_t flags)
 
 static inline int gfp_zonelist(gfp_t flags)
 {
-	if (NUMA_BUILD && unlikely(flags & __GFP_THISNODE))
+	if (KCONFIG(CONFIG_NUMA) && unlikely(flags & __GFP_THISNODE))
 		return 1;
 
 	return 0;
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index fb0e732..ca635ad 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -717,20 +717,6 @@ extern int __build_bug_on_failed;
 /* Trap pasters of __FUNCTION__ at compile-time */
 #define __FUNCTION__ (__func__)
 
-/* This helps us to avoid #ifdef CONFIG_NUMA */
-#ifdef CONFIG_NUMA
-#define NUMA_BUILD 1
-#else
-#define NUMA_BUILD 0
-#endif
-
-/* This helps us avoid #ifdef CONFIG_COMPACTION */
-#ifdef CONFIG_COMPACTION
-#define COMPACTION_BUILD 1
-#else
-#define COMPACTION_BUILD 0
-#endif
-
 /* Rebuild everything on CONFIG_FTRACE_MCOUNT_RECORD */
 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
 # define REBUILD_DUE_TO_FTRACE_MCOUNT_RECORD
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index a4e1db3..7665fdf 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1659,7 +1659,7 @@ zonelist_scan:
 	 */
 	for_each_zone_zonelist_nodemask(zone, z, zonelist,
 						high_zoneidx, nodemask) {
-		if (NUMA_BUILD && zlc_active &&
+		if (KCONFIG(CONFIG_NUMA) && zlc_active &&
 			!zlc_zone_worth_trying(zonelist, z, allowednodes))
 				continue;
 		if ((alloc_flags & ALLOC_CPUSET) &&
@@ -1701,10 +1701,10 @@ try_this_zone:
 		if (page)
 			break;
 this_zone_full:
-		if (NUMA_BUILD)
+		if (KCONFIG(CONFIG_NUMA))
 			zlc_mark_zone_full(zonelist, z);
 try_next_zone:
-		if (NUMA_BUILD && !did_zlc_setup && nr_online_nodes > 1) {
+		if (KCONFIG(CONFIG_NUMA) && !did_zlc_setup && nr_online_nodes > 1) {
 			/*
 			 * we do zlc_setup after the first zone is tried but only
 			 * if there are multiple nodes make it worthwhile
@@ -1715,7 +1715,7 @@ try_next_zone:
 		}
 	}
 
-	if (unlikely(NUMA_BUILD && page == NULL && zlc_active)) {
+	if (unlikely(KCONFIG(CONFIG_NUMA) && page == NULL && zlc_active)) {
 		/* Disable zlc cache for second zonelist scan */
 		zlc_active = 0;
 		goto zonelist_scan;
@@ -2083,7 +2083,7 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,
 	 * allowed per node queues are empty and that nodes are
 	 * over allocated.
 	 */
-	if (NUMA_BUILD && (gfp_mask & GFP_THISNODE) == GFP_THISNODE)
+	if (KCONFIG(CONFIG_NUMA) && (gfp_mask & GFP_THISNODE) == GFP_THISNODE)
 		goto nopage;
 
 restart:
@@ -2461,7 +2461,7 @@ unsigned int nr_free_pagecache_pages(void)
 
 static inline void show_node(struct zone *zone)
 {
-	if (NUMA_BUILD)
+	if (KCONFIG(CONFIG_NUMA))
 		printk("Node %d ", zone_to_nid(zone));
 }
 
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 1d34d75..c5582a5 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -2482,7 +2482,7 @@ static void s_stop(struct seq_file *m, void *p)
 
 static void show_numa_info(struct seq_file *m, struct vm_struct *v)
 {
-	if (NUMA_BUILD) {
+	if (KCONFIG(CONFIG_NUMA)) {
 		unsigned int nr, *counters = m->private;
 
 		if (!counters)
@@ -2547,7 +2547,7 @@ static int vmalloc_open(struct inode *inode, struct file *file)
 	unsigned int *ptr = NULL;
 	int ret;
 
-	if (NUMA_BUILD) {
+	if (KCONFIG(CONFIG_NUMA)) {
 		ptr = kmalloc(nr_node_ids * sizeof(unsigned int), GFP_KERNEL);
 		if (ptr == NULL)
 			return -ENOMEM;
diff --git a/mm/vmscan.c b/mm/vmscan.c
index faa0a08..bc18d7f 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -310,7 +310,7 @@ static void set_reclaim_mode(int priority, struct scan_control *sc,
 	 * reclaim/compaction.Depending on the order, we will either set the
 	 * sync mode or just reclaim order-0 pages later.
 	 */
-	if (COMPACTION_BUILD)
+	if (KCONFIG(CONFIG_COMPACTION))
 		sc->reclaim_mode = RECLAIM_MODE_COMPACTION;
 	else
 		sc->reclaim_mode = RECLAIM_MODE_LUMPYRECLAIM;
-- 
1.7.6


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [RFC][PATCH 2/2] mm: Switch NUMA_BUILD and COMPACTION_BUILD to new KCONFIG() syntax
@ 2011-07-25 22:58           ` Michal Marek
  0 siblings, 0 replies; 48+ messages in thread
From: Michal Marek @ 2011-07-25 22:58 UTC (permalink / raw)
  To: linux-kbuild; +Cc: lacombar, sam, linux-kernel, plagnioj, linux-mm

Cc: linux-mm@kvack.org
Signed-off-by: Michal Marek <mmarek@suse.cz>
---
 include/linux/gfp.h    |    2 +-
 include/linux/kernel.h |   14 --------------
 mm/page_alloc.c        |   12 ++++++------
 mm/vmalloc.c           |    4 ++--
 mm/vmscan.c            |    2 +-
 5 files changed, 10 insertions(+), 24 deletions(-)

diff --git a/include/linux/gfp.h b/include/linux/gfp.h
index cb40892..36860b2 100644
--- a/include/linux/gfp.h
+++ b/include/linux/gfp.h
@@ -262,7 +262,7 @@ static inline enum zone_type gfp_zone(gfp_t flags)
 
 static inline int gfp_zonelist(gfp_t flags)
 {
-	if (NUMA_BUILD && unlikely(flags & __GFP_THISNODE))
+	if (KCONFIG(CONFIG_NUMA) && unlikely(flags & __GFP_THISNODE))
 		return 1;
 
 	return 0;
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index fb0e732..ca635ad 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -717,20 +717,6 @@ extern int __build_bug_on_failed;
 /* Trap pasters of __FUNCTION__ at compile-time */
 #define __FUNCTION__ (__func__)
 
-/* This helps us to avoid #ifdef CONFIG_NUMA */
-#ifdef CONFIG_NUMA
-#define NUMA_BUILD 1
-#else
-#define NUMA_BUILD 0
-#endif
-
-/* This helps us avoid #ifdef CONFIG_COMPACTION */
-#ifdef CONFIG_COMPACTION
-#define COMPACTION_BUILD 1
-#else
-#define COMPACTION_BUILD 0
-#endif
-
 /* Rebuild everything on CONFIG_FTRACE_MCOUNT_RECORD */
 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
 # define REBUILD_DUE_TO_FTRACE_MCOUNT_RECORD
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index a4e1db3..7665fdf 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1659,7 +1659,7 @@ zonelist_scan:
 	 */
 	for_each_zone_zonelist_nodemask(zone, z, zonelist,
 						high_zoneidx, nodemask) {
-		if (NUMA_BUILD && zlc_active &&
+		if (KCONFIG(CONFIG_NUMA) && zlc_active &&
 			!zlc_zone_worth_trying(zonelist, z, allowednodes))
 				continue;
 		if ((alloc_flags & ALLOC_CPUSET) &&
@@ -1701,10 +1701,10 @@ try_this_zone:
 		if (page)
 			break;
 this_zone_full:
-		if (NUMA_BUILD)
+		if (KCONFIG(CONFIG_NUMA))
 			zlc_mark_zone_full(zonelist, z);
 try_next_zone:
-		if (NUMA_BUILD && !did_zlc_setup && nr_online_nodes > 1) {
+		if (KCONFIG(CONFIG_NUMA) && !did_zlc_setup && nr_online_nodes > 1) {
 			/*
 			 * we do zlc_setup after the first zone is tried but only
 			 * if there are multiple nodes make it worthwhile
@@ -1715,7 +1715,7 @@ try_next_zone:
 		}
 	}
 
-	if (unlikely(NUMA_BUILD && page == NULL && zlc_active)) {
+	if (unlikely(KCONFIG(CONFIG_NUMA) && page == NULL && zlc_active)) {
 		/* Disable zlc cache for second zonelist scan */
 		zlc_active = 0;
 		goto zonelist_scan;
@@ -2083,7 +2083,7 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,
 	 * allowed per node queues are empty and that nodes are
 	 * over allocated.
 	 */
-	if (NUMA_BUILD && (gfp_mask & GFP_THISNODE) == GFP_THISNODE)
+	if (KCONFIG(CONFIG_NUMA) && (gfp_mask & GFP_THISNODE) == GFP_THISNODE)
 		goto nopage;
 
 restart:
@@ -2461,7 +2461,7 @@ unsigned int nr_free_pagecache_pages(void)
 
 static inline void show_node(struct zone *zone)
 {
-	if (NUMA_BUILD)
+	if (KCONFIG(CONFIG_NUMA))
 		printk("Node %d ", zone_to_nid(zone));
 }
 
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 1d34d75..c5582a5 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -2482,7 +2482,7 @@ static void s_stop(struct seq_file *m, void *p)
 
 static void show_numa_info(struct seq_file *m, struct vm_struct *v)
 {
-	if (NUMA_BUILD) {
+	if (KCONFIG(CONFIG_NUMA)) {
 		unsigned int nr, *counters = m->private;
 
 		if (!counters)
@@ -2547,7 +2547,7 @@ static int vmalloc_open(struct inode *inode, struct file *file)
 	unsigned int *ptr = NULL;
 	int ret;
 
-	if (NUMA_BUILD) {
+	if (KCONFIG(CONFIG_NUMA)) {
 		ptr = kmalloc(nr_node_ids * sizeof(unsigned int), GFP_KERNEL);
 		if (ptr == NULL)
 			return -ENOMEM;
diff --git a/mm/vmscan.c b/mm/vmscan.c
index faa0a08..bc18d7f 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -310,7 +310,7 @@ static void set_reclaim_mode(int priority, struct scan_control *sc,
 	 * reclaim/compaction.Depending on the order, we will either set the
 	 * sync mode or just reclaim order-0 pages later.
 	 */
-	if (COMPACTION_BUILD)
+	if (KCONFIG(CONFIG_COMPACTION))
 		sc->reclaim_mode = RECLAIM_MODE_COMPACTION;
 	else
 		sc->reclaim_mode = RECLAIM_MODE_LUMPYRECLAIM;
-- 
1.7.6

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 48+ messages in thread

* Re: [RFC][PATCH 1/2] kconfig: Introduce KCONFIG(), KCONFIG_BUILTIN() and KCONFIG_MODULE()
  2011-07-25 22:58       ` [RFC][PATCH 1/2] kconfig: Introduce KCONFIG(), KCONFIG_BUILTIN() and KCONFIG_MODULE() Michal Marek
  2011-07-25 22:58           ` Michal Marek
@ 2011-07-26 13:01         ` Américo Wang
  2011-07-26 13:21           ` Michal Marek
  2011-07-27 15:09         ` Arnaud Lacombe
  2011-07-29 13:51         ` [PATCH] kconfig: Introduce IS_ENABLED(), IS_BUILTIN() and IS_MODULE() Michal Marek
  3 siblings, 1 reply; 48+ messages in thread
From: Américo Wang @ 2011-07-26 13:01 UTC (permalink / raw)
  To: Michal Marek; +Cc: linux-kbuild, lacombar, sam, linux-kernel, plagnioj

On Tue, Jul 26, 2011 at 6:58 AM, Michal Marek <mmarek@suse.cz> wrote:
> Replace the config_is_*() macros with a variant that allows for grepping
> for usage of CONFIG_* options in the code. Usage:
>
>  if (KCONFIG(CONFIG_NUMA))
>
> or
>
>  #if KCONFIG(CONFIG_NUMA)
>
> The KCONFIG() macro evaluates to 1 if the argument is set (to either 'y'
> or 'm'), KCONFIG_BUILTIN() and KCONFIG_MODULE() test if the respective
> option is 'y' and 'm', respectively.

I think it's better to let KCONFIG_MODULE() returns true only for =m, so that
KCONFIG() will equal to KCONFIG_BUILTIN() || KCONFIG_MODULE().

BTW, the name KCONFIG(CONFIG_NUMA) seems ugly.

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [RFC][PATCH 1/2] kconfig: Introduce KCONFIG(), KCONFIG_BUILTIN() and KCONFIG_MODULE()
  2011-07-26 13:01         ` [RFC][PATCH 1/2] kconfig: Introduce KCONFIG(), KCONFIG_BUILTIN() and KCONFIG_MODULE() Américo Wang
@ 2011-07-26 13:21           ` Michal Marek
  2011-07-26 15:04             ` Randy Dunlap
  0 siblings, 1 reply; 48+ messages in thread
From: Michal Marek @ 2011-07-26 13:21 UTC (permalink / raw)
  To: Américo Wang; +Cc: linux-kbuild, lacombar, sam, linux-kernel, plagnioj

On 26.7.2011 15:01, Américo Wang wrote:
> On Tue, Jul 26, 2011 at 6:58 AM, Michal Marek<mmarek@suse.cz>  wrote:
>> Replace the config_is_*() macros with a variant that allows for grepping
>> for usage of CONFIG_* options in the code. Usage:
>>
>>   if (KCONFIG(CONFIG_NUMA))
>>
>> or
>>
>>   #if KCONFIG(CONFIG_NUMA)
>>
>> The KCONFIG() macro evaluates to 1 if the argument is set (to either 'y'
>> or 'm'), KCONFIG_BUILTIN() and KCONFIG_MODULE() test if the respective
>> option is 'y' and 'm', respectively.
>
> I think it's better to let KCONFIG_MODULE() returns true only for =m, so that
> KCONFIG() will equal to KCONFIG_BUILTIN() || KCONFIG_MODULE().

This is how it's done.


> BTW, the name KCONFIG(CONFIG_NUMA) seems ugly.

Suggest a better one :). The proposals so far:
config_is_numa() (breaks grep)
CONFIGURED(CONFIG_NUMA)
ENABLED(CONFIG_NUMA)
KCONFIG(CONFIG_NUMA)

Michal

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [RFC][PATCH 1/2] kconfig: Introduce KCONFIG(), KCONFIG_BUILTIN() and KCONFIG_MODULE()
  2011-07-26 13:21           ` Michal Marek
@ 2011-07-26 15:04             ` Randy Dunlap
  2011-07-26 18:28               ` Michal Marek
  0 siblings, 1 reply; 48+ messages in thread
From: Randy Dunlap @ 2011-07-26 15:04 UTC (permalink / raw)
  To: Michal Marek
  Cc: Américo Wang, linux-kbuild, lacombar, sam, linux-kernel, plagnioj

On Tue, 26 Jul 2011 15:21:39 +0200 Michal Marek wrote:

> On 26.7.2011 15:01, Américo Wang wrote:
> > On Tue, Jul 26, 2011 at 6:58 AM, Michal Marek<mmarek@suse.cz>  wrote:
> >> Replace the config_is_*() macros with a variant that allows for grepping
> >> for usage of CONFIG_* options in the code. Usage:
> >>
> >>   if (KCONFIG(CONFIG_NUMA))
> >>
> >> or
> >>
> >>   #if KCONFIG(CONFIG_NUMA)
> >>
> >> The KCONFIG() macro evaluates to 1 if the argument is set (to either 'y'
> >> or 'm'), KCONFIG_BUILTIN() and KCONFIG_MODULE() test if the respective
> >> option is 'y' and 'm', respectively.
> >
> > I think it's better to let KCONFIG_MODULE() returns true only for =m, so that
> > KCONFIG() will equal to KCONFIG_BUILTIN() || KCONFIG_MODULE().
> 
> This is how it's done.
> 
> 
> > BTW, the name KCONFIG(CONFIG_NUMA) seems ugly.
> 
> Suggest a better one :). The proposals so far:
> config_is_numa() (breaks grep)

explain, please.

> CONFIGURED(CONFIG_NUMA)
> ENABLED(CONFIG_NUMA)
> KCONFIG(CONFIG_NUMA)

CONFIG(NUMA) || CONFIG(NUMA_BUILTIN) || CONFIG(NUMA_MODULE)

---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [RFC][PATCH 2/2] mm: Switch NUMA_BUILD and COMPACTION_BUILD to new KCONFIG() syntax
  2011-07-25 22:58           ` Michal Marek
@ 2011-07-26 15:19             ` Michal Hocko
  -1 siblings, 0 replies; 48+ messages in thread
From: Michal Hocko @ 2011-07-26 15:19 UTC (permalink / raw)
  To: Michal Marek
  Cc: linux-kbuild, lacombar, sam, linux-kernel, plagnioj, linux-mm

On Tue 26-07-11 00:58:38, Michal Marek wrote:
> Cc: linux-mm@kvack.org
> Signed-off-by: Michal Marek <mmarek@suse.cz>

I assume that this is a cleanup. Without seeing the rest of the patch
set (probably not in linux-mm missing in the CC) and the cover email it
is hard to be sure. Could you add some description to the patch, please?

> ---
>  include/linux/gfp.h    |    2 +-
>  include/linux/kernel.h |   14 --------------
>  mm/page_alloc.c        |   12 ++++++------
>  mm/vmalloc.c           |    4 ++--
>  mm/vmscan.c            |    2 +-
>  5 files changed, 10 insertions(+), 24 deletions(-)

-- 
Michal Hocko
SUSE Labs
SUSE LINUX s.r.o.
Lihovarska 1060/12
190 00 Praha 9    
Czech Republic

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [RFC][PATCH 2/2] mm: Switch NUMA_BUILD and COMPACTION_BUILD to new KCONFIG() syntax
@ 2011-07-26 15:19             ` Michal Hocko
  0 siblings, 0 replies; 48+ messages in thread
From: Michal Hocko @ 2011-07-26 15:19 UTC (permalink / raw)
  To: Michal Marek
  Cc: linux-kbuild, lacombar, sam, linux-kernel, plagnioj, linux-mm

On Tue 26-07-11 00:58:38, Michal Marek wrote:
> Cc: linux-mm@kvack.org
> Signed-off-by: Michal Marek <mmarek@suse.cz>

I assume that this is a cleanup. Without seeing the rest of the patch
set (probably not in linux-mm missing in the CC) and the cover email it
is hard to be sure. Could you add some description to the patch, please?

> ---
>  include/linux/gfp.h    |    2 +-
>  include/linux/kernel.h |   14 --------------
>  mm/page_alloc.c        |   12 ++++++------
>  mm/vmalloc.c           |    4 ++--
>  mm/vmscan.c            |    2 +-
>  5 files changed, 10 insertions(+), 24 deletions(-)

-- 
Michal Hocko
SUSE Labs
SUSE LINUX s.r.o.
Lihovarska 1060/12
190 00 Praha 9    
Czech Republic

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [RFC][PATCH 1/2] kconfig: Introduce KCONFIG(), KCONFIG_BUILTIN() and KCONFIG_MODULE()
  2011-07-26 15:04             ` Randy Dunlap
@ 2011-07-26 18:28               ` Michal Marek
  2011-07-26 18:28                 ` Randy Dunlap
  0 siblings, 1 reply; 48+ messages in thread
From: Michal Marek @ 2011-07-26 18:28 UTC (permalink / raw)
  To: Randy Dunlap
  Cc: Américo Wang, linux-kbuild, lacombar, sam, linux-kernel, plagnioj

Dne 26.7.2011 17:04, Randy Dunlap napsal(a):
> On Tue, 26 Jul 2011 15:21:39 +0200 Michal Marek wrote:
>> On 26.7.2011 15:01, Américo Wang wrote:
>>> BTW, the name KCONFIG(CONFIG_NUMA) seems ugly.
>>
>> Suggest a better one :). The proposals so far:
>> config_is_numa() (breaks grep)
> 
> explain, please.

If you grep for CONFIG_FOO usage, you'll miss this alternate syntax.


>> CONFIGURED(CONFIG_NUMA)
>> ENABLED(CONFIG_NUMA)
>> KCONFIG(CONFIG_NUMA)
> 
> CONFIG(NUMA) || CONFIG(NUMA_BUILTIN) || CONFIG(NUMA_MODULE)

same problem.

Michal

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [RFC][PATCH 1/2] kconfig: Introduce KCONFIG(), KCONFIG_BUILTIN() and KCONFIG_MODULE()
  2011-07-26 18:28               ` Michal Marek
@ 2011-07-26 18:28                 ` Randy Dunlap
  2011-07-26 18:48                   ` Arnaud Lacombe
  0 siblings, 1 reply; 48+ messages in thread
From: Randy Dunlap @ 2011-07-26 18:28 UTC (permalink / raw)
  To: Michal Marek
  Cc: Américo Wang, linux-kbuild, lacombar, sam, linux-kernel, plagnioj

On Tue, 26 Jul 2011 20:28:05 +0200 Michal Marek wrote:

> Dne 26.7.2011 17:04, Randy Dunlap napsal(a):
> > On Tue, 26 Jul 2011 15:21:39 +0200 Michal Marek wrote:
> >> On 26.7.2011 15:01, Américo Wang wrote:
> >>> BTW, the name KCONFIG(CONFIG_NUMA) seems ugly.
> >>
> >> Suggest a better one :). The proposals so far:
> >> config_is_numa() (breaks grep)
> > 
> > explain, please.
> 
> If you grep for CONFIG_FOO usage, you'll miss this alternate syntax.
> 

Ack.

> 
> >> CONFIGURED(CONFIG_NUMA)
> >> ENABLED(CONFIG_NUMA)
> >> KCONFIG(CONFIG_NUMA)
> > 
> > CONFIG(NUMA) || CONFIG(NUMA_BUILTIN) || CONFIG(NUMA_MODULE)
> 
> same problem.

Yes, I sorta got that after I sent the email.

I guess I prefer your ENABLED() syntax then.

---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [RFC][PATCH 2/2] mm: Switch NUMA_BUILD and COMPACTION_BUILD to new KCONFIG() syntax
  2011-07-26 15:19             ` Michal Hocko
@ 2011-07-26 18:34               ` Michal Marek
  -1 siblings, 0 replies; 48+ messages in thread
From: Michal Marek @ 2011-07-26 18:34 UTC (permalink / raw)
  To: Michal Hocko
  Cc: linux-kbuild, lacombar, sam, linux-kernel, plagnioj, linux-mm

Dne 26.7.2011 17:19, Michal Hocko napsal(a):
> On Tue 26-07-11 00:58:38, Michal Marek wrote:
>> Cc: linux-mm@kvack.org
>> Signed-off-by: Michal Marek <mmarek@suse.cz>
> 
> I assume that this is a cleanup. Without seeing the rest of the patch
> set (probably not in linux-mm missing in the CC) and the cover email it
> is hard to be sure. Could you add some description to the patch, please?

Sorry for the confusion. Patch 1/2 is here:
https://lkml.org/lkml/2011/7/25/448 and provides a generic way to use
CONFIG_* options in C expressions. This patch 2/2 for demonstration
purposes only, if the first patch hits mainline, then I'll submit this
one properly.

Michal

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [RFC][PATCH 2/2] mm: Switch NUMA_BUILD and COMPACTION_BUILD to new KCONFIG() syntax
@ 2011-07-26 18:34               ` Michal Marek
  0 siblings, 0 replies; 48+ messages in thread
From: Michal Marek @ 2011-07-26 18:34 UTC (permalink / raw)
  To: Michal Hocko
  Cc: linux-kbuild, lacombar, sam, linux-kernel, plagnioj, linux-mm

Dne 26.7.2011 17:19, Michal Hocko napsal(a):
> On Tue 26-07-11 00:58:38, Michal Marek wrote:
>> Cc: linux-mm@kvack.org
>> Signed-off-by: Michal Marek <mmarek@suse.cz>
> 
> I assume that this is a cleanup. Without seeing the rest of the patch
> set (probably not in linux-mm missing in the CC) and the cover email it
> is hard to be sure. Could you add some description to the patch, please?

Sorry for the confusion. Patch 1/2 is here:
https://lkml.org/lkml/2011/7/25/448 and provides a generic way to use
CONFIG_* options in C expressions. This patch 2/2 for demonstration
purposes only, if the first patch hits mainline, then I'll submit this
one properly.

Michal

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [RFC][PATCH 1/2] kconfig: Introduce KCONFIG(), KCONFIG_BUILTIN() and KCONFIG_MODULE()
  2011-07-26 18:28                 ` Randy Dunlap
@ 2011-07-26 18:48                   ` Arnaud Lacombe
  2011-07-27  0:42                     ` Arnaud Lacombe
  0 siblings, 1 reply; 48+ messages in thread
From: Arnaud Lacombe @ 2011-07-26 18:48 UTC (permalink / raw)
  To: Randy Dunlap
  Cc: Michal Marek, Américo Wang, linux-kbuild, sam, linux-kernel,
	plagnioj

Hi,

On Tue, Jul 26, 2011 at 2:28 PM, Randy Dunlap <rdunlap@xenotime.net> wrote:
> On Tue, 26 Jul 2011 20:28:05 +0200 Michal Marek wrote:
>
>> Dne 26.7.2011 17:04, Randy Dunlap napsal(a):
>> > On Tue, 26 Jul 2011 15:21:39 +0200 Michal Marek wrote:
>> >> On 26.7.2011 15:01, Américo Wang wrote:
>> >>> BTW, the name KCONFIG(CONFIG_NUMA) seems ugly.
>> >>
>> >> Suggest a better one :). The proposals so far:
>> >> config_is_numa() (breaks grep)
>> >
>> > explain, please.
>>
>> If you grep for CONFIG_FOO usage, you'll miss this alternate syntax.
>>
>
> Ack.
>
>>
>> >> CONFIGURED(CONFIG_NUMA)
>> >> ENABLED(CONFIG_NUMA)
>> >> KCONFIG(CONFIG_NUMA)
>> >
>> > CONFIG(NUMA) || CONFIG(NUMA_BUILTIN) || CONFIG(NUMA_MODULE)
>>
>> same problem.
>
> Yes, I sorta got that after I sent the email.
>
> I guess I prefer your ENABLED() syntax then.
>
we need to be careful about namespace pollution/collision.

 - Arnaud

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [RFC][PATCH 2/2] mm: Switch NUMA_BUILD and COMPACTION_BUILD to new KCONFIG() syntax
  2011-07-26 18:34               ` Michal Marek
@ 2011-07-26 18:52                 ` Michal Hocko
  -1 siblings, 0 replies; 48+ messages in thread
From: Michal Hocko @ 2011-07-26 18:52 UTC (permalink / raw)
  To: Michal Marek
  Cc: linux-kbuild, lacombar, sam, linux-kernel, plagnioj, linux-mm

On Tue 26-07-11 20:34:08, Michal Marek wrote:
> Dne 26.7.2011 17:19, Michal Hocko napsal(a):
> > On Tue 26-07-11 00:58:38, Michal Marek wrote:
> >> Cc: linux-mm@kvack.org
> >> Signed-off-by: Michal Marek <mmarek@suse.cz>
> > 
> > I assume that this is a cleanup. Without seeing the rest of the patch
> > set (probably not in linux-mm missing in the CC) and the cover email it
> > is hard to be sure. Could you add some description to the patch, please?
> 
> Sorry for the confusion. Patch 1/2 is here:
> https://lkml.org/lkml/2011/7/25/448 and provides a generic way to use
> CONFIG_* options in C expressions.

Yeah, google told me but the email was on its way already.

> This patch 2/2 for demonstration purposes only, if the first patch
> hits mainline, then I'll submit this one properly.

I like the change I am just afraid that this will make some hackery
easier.
In this particular case the code looks better and more grep friendly.

-- 
Michal Hocko
SUSE Labs
SUSE LINUX s.r.o.
Lihovarska 1060/12
190 00 Praha 9    
Czech Republic

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [RFC][PATCH 2/2] mm: Switch NUMA_BUILD and COMPACTION_BUILD to new KCONFIG() syntax
@ 2011-07-26 18:52                 ` Michal Hocko
  0 siblings, 0 replies; 48+ messages in thread
From: Michal Hocko @ 2011-07-26 18:52 UTC (permalink / raw)
  To: Michal Marek
  Cc: linux-kbuild, lacombar, sam, linux-kernel, plagnioj, linux-mm

On Tue 26-07-11 20:34:08, Michal Marek wrote:
> Dne 26.7.2011 17:19, Michal Hocko napsal(a):
> > On Tue 26-07-11 00:58:38, Michal Marek wrote:
> >> Cc: linux-mm@kvack.org
> >> Signed-off-by: Michal Marek <mmarek@suse.cz>
> > 
> > I assume that this is a cleanup. Without seeing the rest of the patch
> > set (probably not in linux-mm missing in the CC) and the cover email it
> > is hard to be sure. Could you add some description to the patch, please?
> 
> Sorry for the confusion. Patch 1/2 is here:
> https://lkml.org/lkml/2011/7/25/448 and provides a generic way to use
> CONFIG_* options in C expressions.

Yeah, google told me but the email was on its way already.

> This patch 2/2 for demonstration purposes only, if the first patch
> hits mainline, then I'll submit this one properly.

I like the change I am just afraid that this will make some hackery
easier.
In this particular case the code looks better and more grep friendly.

-- 
Michal Hocko
SUSE Labs
SUSE LINUX s.r.o.
Lihovarska 1060/12
190 00 Praha 9    
Czech Republic

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [RFC][PATCH 1/2] kconfig: Introduce KCONFIG(), KCONFIG_BUILTIN() and KCONFIG_MODULE()
  2011-07-26 18:48                   ` Arnaud Lacombe
@ 2011-07-27  0:42                     ` Arnaud Lacombe
  2011-07-27  4:35                       ` Randy Dunlap
  0 siblings, 1 reply; 48+ messages in thread
From: Arnaud Lacombe @ 2011-07-27  0:42 UTC (permalink / raw)
  To: Randy Dunlap
  Cc: Michal Marek, Américo Wang, linux-kbuild, sam, linux-kernel,
	plagnioj

Hi,

On Tue, Jul 26, 2011 at 2:48 PM, Arnaud Lacombe <lacombar@gmail.com> wrote:
> Hi,
>
> On Tue, Jul 26, 2011 at 2:28 PM, Randy Dunlap <rdunlap@xenotime.net> wrote:
>> On Tue, 26 Jul 2011 20:28:05 +0200 Michal Marek wrote:
>>
>>> Dne 26.7.2011 17:04, Randy Dunlap napsal(a):
>>> > On Tue, 26 Jul 2011 15:21:39 +0200 Michal Marek wrote:
>>> >> On 26.7.2011 15:01, Américo Wang wrote:
>>> >>> BTW, the name KCONFIG(CONFIG_NUMA) seems ugly.
>>> >>
>>> >> Suggest a better one :). The proposals so far:
>>> >> config_is_numa() (breaks grep)
>>> >
>>> > explain, please.
>>>
>>> If you grep for CONFIG_FOO usage, you'll miss this alternate syntax.
>>>
>>
>> Ack.
>>
>>>
>>> >> CONFIGURED(CONFIG_NUMA)
>>> >> ENABLED(CONFIG_NUMA)
>>> >> KCONFIG(CONFIG_NUMA)
>>> >
>>> > CONFIG(NUMA) || CONFIG(NUMA_BUILTIN) || CONFIG(NUMA_MODULE)
>>>
>>> same problem.
>>
>> Yes, I sorta got that after I sent the email.
>>
>> I guess I prefer your ENABLED() syntax then.
>>
> we need to be careful about namespace pollution/collision.
>
For the sake of having numbers:

% git grep -w ENABLED . | wc -l
    116
% git grep -w CONFIGURED . | wc -l
     11
% git grep -w KCONFIG . | wc -l
      1

>  - Arnaud
>

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [RFC][PATCH 1/2] kconfig: Introduce KCONFIG(), KCONFIG_BUILTIN() and KCONFIG_MODULE()
  2011-07-27  0:42                     ` Arnaud Lacombe
@ 2011-07-27  4:35                       ` Randy Dunlap
  2011-07-27  8:36                         ` Michal Marek
  0 siblings, 1 reply; 48+ messages in thread
From: Randy Dunlap @ 2011-07-27  4:35 UTC (permalink / raw)
  To: Arnaud Lacombe
  Cc: Michal Marek, Américo Wang, linux-kbuild, sam, linux-kernel,
	plagnioj

On Tue, 26 Jul 2011 20:42:04 -0400 Arnaud Lacombe wrote:

> Hi,
> 
> On Tue, Jul 26, 2011 at 2:48 PM, Arnaud Lacombe <lacombar@gmail.com> wrote:
> > Hi,
> >
> > On Tue, Jul 26, 2011 at 2:28 PM, Randy Dunlap <rdunlap@xenotime.net> wrote:
> >> On Tue, 26 Jul 2011 20:28:05 +0200 Michal Marek wrote:
> >>
> >>> Dne 26.7.2011 17:04, Randy Dunlap napsal(a):
> >>> > On Tue, 26 Jul 2011 15:21:39 +0200 Michal Marek wrote:
> >>> >> On 26.7.2011 15:01, Américo Wang wrote:
> >>> >>> BTW, the name KCONFIG(CONFIG_NUMA) seems ugly.
> >>> >>
> >>> >> Suggest a better one :). The proposals so far:
> >>> >> config_is_numa() (breaks grep)
> >>> >
> >>> > explain, please.
> >>>
> >>> If you grep for CONFIG_FOO usage, you'll miss this alternate syntax.
> >>>
> >>
> >> Ack.
> >>
> >>>
> >>> >> CONFIGURED(CONFIG_NUMA)
> >>> >> ENABLED(CONFIG_NUMA)
> >>> >> KCONFIG(CONFIG_NUMA)
> >>> >
> >>> > CONFIG(NUMA) || CONFIG(NUMA_BUILTIN) || CONFIG(NUMA_MODULE)
> >>>
> >>> same problem.
> >>
> >> Yes, I sorta got that after I sent the email.
> >>
> >> I guess I prefer your ENABLED() syntax then.
> >>
> > we need to be careful about namespace pollution/collision.
> >
> For the sake of having numbers:
> 
> % git grep -w ENABLED . | wc -l
>     116
> % git grep -w CONFIGURED . | wc -l
>      11
> % git grep -w KCONFIG . | wc -l
>       1

OK.  Then I would go back to a predicate like the original patch had,
e.g.:
	IS_ENABLED(CONFIG_NUMA)

I think that using
	KCONFIG(CONFIG_NUMA)
is klunky (a highly technical term).

But Michal can do whatever he likes.

---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [RFC][PATCH 1/2] kconfig: Introduce KCONFIG(), KCONFIG_BUILTIN() and KCONFIG_MODULE()
  2011-07-27  4:35                       ` Randy Dunlap
@ 2011-07-27  8:36                         ` Michal Marek
  2011-07-27 13:31                           ` Arnaud Lacombe
  2011-07-27 16:36                           ` Américo Wang
  0 siblings, 2 replies; 48+ messages in thread
From: Michal Marek @ 2011-07-27  8:36 UTC (permalink / raw)
  To: Randy Dunlap
  Cc: Arnaud Lacombe, Américo Wang, linux-kbuild, sam,
	linux-kernel, plagnioj

On 27.7.2011 06:35, Randy Dunlap wrote:
> On Tue, 26 Jul 2011 20:42:04 -0400 Arnaud Lacombe wrote:
>> On Tue, Jul 26, 2011 at 2:48 PM, Arnaud Lacombe<lacombar@gmail.com>  wrote:
>>> On Tue, Jul 26, 2011 at 2:28 PM, Randy Dunlap<rdunlap@xenotime.net>  wrote:
>>>> I guess I prefer your ENABLED() syntax then.
>>>>
>>> we need to be careful about namespace pollution/collision.
>>>
>> For the sake of having numbers:
>>
>> % git grep -w ENABLED . | wc -l
>>      116
>> % git grep -w CONFIGURED . | wc -l
>>       11
>> % git grep -w KCONFIG . | wc -l
>>        1
>
> OK.  Then I would go back to a predicate like the original patch had,
> e.g.:
> 	IS_ENABLED(CONFIG_NUMA)

Good idea. Is anyone against
IS_ENABLED(CONFIG_FOO)
IS_ENABLED_BUILTIN(CONFIG_FOO)
IS_ENABLED_MODULE(CONFIG_FOO)
?

Michal

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [RFC][PATCH 1/2] kconfig: Introduce KCONFIG(), KCONFIG_BUILTIN() and KCONFIG_MODULE()
  2011-07-27  8:36                         ` Michal Marek
@ 2011-07-27 13:31                           ` Arnaud Lacombe
  2011-07-27 13:38                             ` Michal Marek
  2011-07-27 16:36                           ` Américo Wang
  1 sibling, 1 reply; 48+ messages in thread
From: Arnaud Lacombe @ 2011-07-27 13:31 UTC (permalink / raw)
  To: Michal Marek
  Cc: Randy Dunlap, Américo Wang, linux-kbuild, sam, linux-kernel,
	plagnioj

Hi,

On Wed, Jul 27, 2011 at 4:36 AM, Michal Marek <mmarek@suse.cz> wrote:
> On 27.7.2011 06:35, Randy Dunlap wrote:
>>
>> On Tue, 26 Jul 2011 20:42:04 -0400 Arnaud Lacombe wrote:
>>>
>>> On Tue, Jul 26, 2011 at 2:48 PM, Arnaud Lacombe<lacombar@gmail.com>
>>>  wrote:
>>>>
>>>> On Tue, Jul 26, 2011 at 2:28 PM, Randy Dunlap<rdunlap@xenotime.net>
>>>>  wrote:
>>>>>
>>>>> I guess I prefer your ENABLED() syntax then.
>>>>>
>>>> we need to be careful about namespace pollution/collision.
>>>>
>>> For the sake of having numbers:
>>>
>>> % git grep -w ENABLED . | wc -l
>>>     116
>>> % git grep -w CONFIGURED . | wc -l
>>>      11
>>> % git grep -w KCONFIG . | wc -l
>>>       1
>>
>> OK.  Then I would go back to a predicate like the original patch had,
>> e.g.:
>>        IS_ENABLED(CONFIG_NUMA)
>
> Good idea. Is anyone against
> IS_ENABLED(CONFIG_FOO)
> IS_ENABLED_BUILTIN(CONFIG_FOO)
> IS_ENABLED_MODULE(CONFIG_FOO)
> ?
>
I'm good with the naming, but how would you define those ? I may have
trouble to discern between IS_ENABLED() and IS_ENABLED_BUILTIN().

 - Arnaud

> Michal
>

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [RFC][PATCH 1/2] kconfig: Introduce KCONFIG(), KCONFIG_BUILTIN() and KCONFIG_MODULE()
  2011-07-27 13:31                           ` Arnaud Lacombe
@ 2011-07-27 13:38                             ` Michal Marek
  2011-07-27 15:11                               ` Arnaud Lacombe
  0 siblings, 1 reply; 48+ messages in thread
From: Michal Marek @ 2011-07-27 13:38 UTC (permalink / raw)
  To: Arnaud Lacombe
  Cc: Randy Dunlap, Américo Wang, linux-kbuild, sam, linux-kernel,
	plagnioj

On 27.7.2011 15:31, Arnaud Lacombe wrote:
> Hi,
>
> On Wed, Jul 27, 2011 at 4:36 AM, Michal Marek<mmarek@suse.cz>  wrote:
>> On 27.7.2011 06:35, Randy Dunlap wrote:
>>>
>>> On Tue, 26 Jul 2011 20:42:04 -0400 Arnaud Lacombe wrote:
>>>>
>>>> On Tue, Jul 26, 2011 at 2:48 PM, Arnaud Lacombe<lacombar@gmail.com>
>>>>   wrote:
>>>>>
>>>>> On Tue, Jul 26, 2011 at 2:28 PM, Randy Dunlap<rdunlap@xenotime.net>
>>>>>   wrote:
>>>>>>
>>>>>> I guess I prefer your ENABLED() syntax then.
>>>>>>
>>>>> we need to be careful about namespace pollution/collision.
>>>>>
>>>> For the sake of having numbers:
>>>>
>>>> % git grep -w ENABLED . | wc -l
>>>>      116
>>>> % git grep -w CONFIGURED . | wc -l
>>>>       11
>>>> % git grep -w KCONFIG . | wc -l
>>>>        1
>>>
>>> OK.  Then I would go back to a predicate like the original patch had,
>>> e.g.:
>>>         IS_ENABLED(CONFIG_NUMA)
>>
>> Good idea. Is anyone against
>> IS_ENABLED(CONFIG_FOO)
>> IS_ENABLED_BUILTIN(CONFIG_FOO)
>> IS_ENABLED_MODULE(CONFIG_FOO)
>> ?
>>
> I'm good with the naming, but how would you define those ? I may have
> trouble to discern between IS_ENABLED() and IS_ENABLED_BUILTIN().

IS_ENABLED() would mean not disabled, i.e. either 'y' or 'm'. 
IS_ENABLED_BUILTIN() would mean 'y' and only 'y' and IS_ENABLED_MODULE() 
would mean 'm'. For boolean options, IS_ENABLED() would be equivalent to 
IS_ENABLED_BUILTIN() and IS_ENABLED_MODULE() would be always false.

Michal

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [RFC][PATCH 1/2] kconfig: Introduce KCONFIG(), KCONFIG_BUILTIN() and KCONFIG_MODULE()
  2011-07-25 22:58       ` [RFC][PATCH 1/2] kconfig: Introduce KCONFIG(), KCONFIG_BUILTIN() and KCONFIG_MODULE() Michal Marek
  2011-07-25 22:58           ` Michal Marek
  2011-07-26 13:01         ` [RFC][PATCH 1/2] kconfig: Introduce KCONFIG(), KCONFIG_BUILTIN() and KCONFIG_MODULE() Américo Wang
@ 2011-07-27 15:09         ` Arnaud Lacombe
  2011-07-27 15:16           ` Michal Marek
  2011-07-29 13:51         ` [PATCH] kconfig: Introduce IS_ENABLED(), IS_BUILTIN() and IS_MODULE() Michal Marek
  3 siblings, 1 reply; 48+ messages in thread
From: Arnaud Lacombe @ 2011-07-27 15:09 UTC (permalink / raw)
  To: Michal Marek; +Cc: linux-kbuild, sam, linux-kernel, plagnioj

Hi,

On Mon, Jul 25, 2011 at 6:58 PM, Michal Marek <mmarek@suse.cz> wrote:
> Replace the config_is_*() macros with a variant that allows for grepping
> for usage of CONFIG_* options in the code. Usage:
>
>  if (KCONFIG(CONFIG_NUMA))
>
> or
>
>  #if KCONFIG(CONFIG_NUMA)
>
> The KCONFIG() macro evaluates to 1 if the argument is set (to either 'y'
> or 'm'), KCONFIG_BUILTIN() and KCONFIG_MODULE() test if the respective
> option is 'y' and 'm', respectively.
>
> Signed-off-by: Michal Marek <mmarek@suse.cz>
> ---
>  Makefile                   |    2 +-
>  include/linux/kconfig.h    |   24 +++++++++++++++
>  scripts/kconfig/confdata.c |   70 ++++++++-----------------------------------
>  3 files changed, 38 insertions(+), 58 deletions(-)
>  create mode 100644 include/linux/kconfig.h
>
> diff --git a/Makefile b/Makefile
> index afb8e0d..bd7629b 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -360,7 +360,7 @@ CFLAGS_GCOV = -fprofile-arcs -ftest-coverage
>  LINUXINCLUDE    := -I$(srctree)/arch/$(hdr-arch)/include \
>                    -Iarch/$(hdr-arch)/include/generated -Iinclude \
>                    $(if $(KBUILD_SRC), -I$(srctree)/include) \
> -                   -include include/generated/autoconf.h
> +                   -include $(srctree)/include/linux/kconfig.h
>
>  KBUILD_CPPFLAGS := -D__KERNEL__
>
> diff --git a/include/linux/kconfig.h b/include/linux/kconfig.h
> new file mode 100644
> index 0000000..fe80348
> --- /dev/null
> +++ b/include/linux/kconfig.h
> @@ -0,0 +1,24 @@
> +#ifndef __LINUX_KCONFIG_H
> +#define __LINUX_KCONFIG_H
> +
> +#include <generated/autoconf.h>
> +
> +/*
> + * Evaluates to 1 if CONFIG_option is set to 'y', 0 otherwise
> + */
> +#define KCONFIG_BUILTIN(option) __enabled_ ## option
> +
> +/*
> + * Evaluates to 1 if CONFIG_option is set to 'm', 0 otherwise
> + */
> +#define KCONFIG_MODULE(option) __enabled_ ## option ## _MODULE
> +
> +/*
> + * Evaluates to 1 if CONFIG_option is set to 'y' or 'm', 0 otherwise
> + *
> + */
> +#define KCONFIG(option) \
> +       (__enabled_ ## option || __enabled_ ## option ## _MODULE)
> +
> +
> +#endif /* __LINUX_KCONFIG_H */
> diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
> index df629ec..3bab40a 100644
> --- a/scripts/kconfig/confdata.c
> +++ b/scripts/kconfig/confdata.c
> @@ -495,15 +495,24 @@ header_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg)
>
>                switch (*value) {
>                case 'n':
> -                       return;
> +                       break;
>                case 'm':
>                        suffix = "_MODULE";
>                        /* fall through */
>                default:
> -                       value = "1";
> +                       fprintf(fp, "#define %s%s%s 1\n",
> +                           CONFIG_, sym->name, suffix);
>                }
> -               fprintf(fp, "#define %s%s%s %s\n",
> -                   CONFIG_, sym->name, suffix, value);
> +               /*
> +                * Generate the __enabled_CONFIG_* and
> +                * __enabled_CONFIG_*_MODULE macros for use by the KCONFIG*()
> +                * macros. The _MODULE variant is generated even for booleans
> +                * so that the KCONFIG() macro works.
> +                */
> +               fprintf(fp, "#define __enabled_" CONFIG_ "%s %d\n",
> +                               sym->name, (*value == 'y'));
> +               fprintf(fp, "#define __enabled_" CONFIG_ "%s_MODULE %d\n",
> +                               sym->name, (*value == 'm'));
>                break;
>        }
>        case S_HEX: {
Just to comment on the patch itself, it will certainly not apply
against kbuild/kconfig as I changed header_print_symbol() to fix the
S_HEX prefix issue.

 - Arnaud

> @@ -555,58 +564,6 @@ static struct conf_printer header_printer_cb =
>  };
>
>  /*
> - * Function-style header printer
> - *
> - * This printer is used to generate the config_is_xxx() function-style macros
> - * in `include/generated/autoconf.h'
> - */
> -static void
> -header_function_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg)
> -{
> -       int val = 0;
> -       char c;
> -       char *tmp, *d;
> -
> -       switch (sym->type) {
> -       case S_BOOLEAN:
> -       case S_TRISTATE:
> -               break;
> -       default:
> -               return;
> -       }
> -       if (*value == 'm')
> -               val = 2;
> -       else if (*value == 'y')
> -               val = 1;
> -
> -       d = strdup(CONFIG_);
> -       tmp = d;
> -       while ((c = *d)) {
> -               *d = tolower(c);
> -               d++;
> -       }
> -
> -       fprintf(fp, "#define %sis_", tmp);
> -       free(tmp);
> -
> -       d = strdup(sym->name);
> -       tmp = d;
> -       while ((c = *d)) {
> -               *d = tolower(c);
> -               d++;
> -       }
> -       fprintf(fp, "%s%s() %d\n", tmp, (val > 1) ? "_module" : "",
> -                     val ? 1 : 0);
> -       free(tmp);
> -}
> -
> -static struct conf_printer header_function_printer_cb =
> -{
> -       .print_symbol = header_function_print_symbol,
> -};
> -
> -
> -/*
>  * Tristate printer
>  *
>  * This printer is used when generating the `include/config/tristate.conf' file.
> @@ -997,7 +954,6 @@ int conf_write_autoconf(void)
>                conf_write_symbol(tristate, sym, &tristate_printer_cb, (void *)1);
>
>                conf_write_symbol(out_h, sym, &header_printer_cb, NULL);
> -               conf_write_symbol(out_h, sym, &header_function_printer_cb, NULL);
>        }
>        fclose(out);
>        fclose(tristate);
> --
> 1.7.6
>
>

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [RFC][PATCH 1/2] kconfig: Introduce KCONFIG(), KCONFIG_BUILTIN() and KCONFIG_MODULE()
  2011-07-27 13:38                             ` Michal Marek
@ 2011-07-27 15:11                               ` Arnaud Lacombe
  2011-07-27 15:18                                 ` Michal Marek
  0 siblings, 1 reply; 48+ messages in thread
From: Arnaud Lacombe @ 2011-07-27 15:11 UTC (permalink / raw)
  To: Michal Marek
  Cc: Randy Dunlap, Américo Wang, linux-kbuild, sam, linux-kernel,
	plagnioj

Hi,

On Wed, Jul 27, 2011 at 9:38 AM, Michal Marek <mmarek@suse.cz> wrote:
>> [...]
>> I'm good with the naming, but how would you define those ? I may have
>> trouble to discern between IS_ENABLED() and IS_ENABLED_BUILTIN().
>
> IS_ENABLED() would mean not disabled, i.e. either 'y' or 'm'.
> IS_ENABLED_BUILTIN() would mean 'y' and only 'y' and IS_ENABLED_MODULE()
> would mean 'm'. For boolean options, IS_ENABLED() would be equivalent to
> IS_ENABLED_BUILTIN() and IS_ENABLED_MODULE() would be always false.
>
how would IS_ENABLED() behave on CONFIG_FOO, with FOO being S_STRING
or, say, S_HEX ?

 - Arnaud

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [RFC][PATCH 1/2] kconfig: Introduce KCONFIG(), KCONFIG_BUILTIN() and KCONFIG_MODULE()
  2011-07-27 15:09         ` Arnaud Lacombe
@ 2011-07-27 15:16           ` Michal Marek
  2011-07-27 15:18             ` Arnaud Lacombe
  0 siblings, 1 reply; 48+ messages in thread
From: Michal Marek @ 2011-07-27 15:16 UTC (permalink / raw)
  To: Arnaud Lacombe; +Cc: linux-kbuild, sam, linux-kernel, plagnioj

On 27.7.2011 17:09, Arnaud Lacombe wrote:
> Hi,
>
> On Mon, Jul 25, 2011 at 6:58 PM, Michal Marek<mmarek@suse.cz>  wrote:
>> Replace the config_is_*() macros with a variant that allows for grepping
>> for usage of CONFIG_* options in the code. Usage:
>>
>>   if (KCONFIG(CONFIG_NUMA))
>>
>> or
>>
>>   #if KCONFIG(CONFIG_NUMA)
>>
>> The KCONFIG() macro evaluates to 1 if the argument is set (to either 'y'
>> or 'm'), KCONFIG_BUILTIN() and KCONFIG_MODULE() test if the respective
>> option is 'y' and 'm', respectively.
>>
>> Signed-off-by: Michal Marek<mmarek@suse.cz>
>> ---
>>   Makefile                   |    2 +-
>>   include/linux/kconfig.h    |   24 +++++++++++++++
>>   scripts/kconfig/confdata.c |   70 ++++++++-----------------------------------
>>   3 files changed, 38 insertions(+), 58 deletions(-)
>>   create mode 100644 include/linux/kconfig.h
>>
>> diff --git a/Makefile b/Makefile
>> index afb8e0d..bd7629b 100644
>> --- a/Makefile
>> +++ b/Makefile
>> @@ -360,7 +360,7 @@ CFLAGS_GCOV = -fprofile-arcs -ftest-coverage
>>   LINUXINCLUDE    := -I$(srctree)/arch/$(hdr-arch)/include \
>>                     -Iarch/$(hdr-arch)/include/generated -Iinclude \
>>                     $(if $(KBUILD_SRC), -I$(srctree)/include) \
>> -                   -include include/generated/autoconf.h
>> +                   -include $(srctree)/include/linux/kconfig.h
>>
>>   KBUILD_CPPFLAGS := -D__KERNEL__
>>
>> diff --git a/include/linux/kconfig.h b/include/linux/kconfig.h
>> new file mode 100644
>> index 0000000..fe80348
>> --- /dev/null
>> +++ b/include/linux/kconfig.h
>> @@ -0,0 +1,24 @@
>> +#ifndef __LINUX_KCONFIG_H
>> +#define __LINUX_KCONFIG_H
>> +
>> +#include<generated/autoconf.h>
>> +
>> +/*
>> + * Evaluates to 1 if CONFIG_option is set to 'y', 0 otherwise
>> + */
>> +#define KCONFIG_BUILTIN(option) __enabled_ ## option
>> +
>> +/*
>> + * Evaluates to 1 if CONFIG_option is set to 'm', 0 otherwise
>> + */
>> +#define KCONFIG_MODULE(option) __enabled_ ## option ## _MODULE
>> +
>> +/*
>> + * Evaluates to 1 if CONFIG_option is set to 'y' or 'm', 0 otherwise
>> + *
>> + */
>> +#define KCONFIG(option) \
>> +       (__enabled_ ## option || __enabled_ ## option ## _MODULE)
>> +
>> +
>> +#endif /* __LINUX_KCONFIG_H */
>> diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
>> index df629ec..3bab40a 100644
>> --- a/scripts/kconfig/confdata.c
>> +++ b/scripts/kconfig/confdata.c
>> @@ -495,15 +495,24 @@ header_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg)
>>
>>                 switch (*value) {
>>                 case 'n':
>> -                       return;
>> +                       break;
>>                 case 'm':
>>                         suffix = "_MODULE";
>>                         /* fall through */
>>                 default:
>> -                       value = "1";
>> +                       fprintf(fp, "#define %s%s%s 1\n",
>> +                           CONFIG_, sym->name, suffix);
>>                 }
>> -               fprintf(fp, "#define %s%s%s %s\n",
>> -                   CONFIG_, sym->name, suffix, value);
>> +               /*
>> +                * Generate the __enabled_CONFIG_* and
>> +                * __enabled_CONFIG_*_MODULE macros for use by the KCONFIG*()
>> +                * macros. The _MODULE variant is generated even for booleans
>> +                * so that the KCONFIG() macro works.
>> +                */
>> +               fprintf(fp, "#define __enabled_" CONFIG_ "%s %d\n",
>> +                               sym->name, (*value == 'y'));
>> +               fprintf(fp, "#define __enabled_" CONFIG_ "%s_MODULE %d\n",
>> +                               sym->name, (*value == 'm'));
>>                 break;
>>         }
>>         case S_HEX: {
> Just to comment on the patch itself, it will certainly not apply
> against kbuild/kconfig as I changed header_print_symbol() to fix the
> S_HEX prefix issue.

If course it applies, the "case S_HEX: {" context line you are quoting 
was added by your commit: 
http://git.kernel.org/?p=linux/kernel/git/mmarek/kbuild-2.6.git;a=commitdiff;h=eb4cf5a642f6430cffff7ba5d8d9bd46ea409281

Michal

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [RFC][PATCH 1/2] kconfig: Introduce KCONFIG(), KCONFIG_BUILTIN() and KCONFIG_MODULE()
  2011-07-27 15:11                               ` Arnaud Lacombe
@ 2011-07-27 15:18                                 ` Michal Marek
  0 siblings, 0 replies; 48+ messages in thread
From: Michal Marek @ 2011-07-27 15:18 UTC (permalink / raw)
  To: Arnaud Lacombe
  Cc: Randy Dunlap, Américo Wang, linux-kbuild, sam, linux-kernel,
	plagnioj

On 27.7.2011 17:11, Arnaud Lacombe wrote:
> Hi,
>
> On Wed, Jul 27, 2011 at 9:38 AM, Michal Marek<mmarek@suse.cz>  wrote:
>>> [...]
>>> I'm good with the naming, but how would you define those ? I may have
>>> trouble to discern between IS_ENABLED() and IS_ENABLED_BUILTIN().
>>
>> IS_ENABLED() would mean not disabled, i.e. either 'y' or 'm'.
>> IS_ENABLED_BUILTIN() would mean 'y' and only 'y' and IS_ENABLED_MODULE()
>> would mean 'm'. For boolean options, IS_ENABLED() would be equivalent to
>> IS_ENABLED_BUILTIN() and IS_ENABLED_MODULE() would be always false.
>>
> how would IS_ENABLED() behave on CONFIG_FOO, with FOO being S_STRING
> or, say, S_HEX ?

It would fail to compile, because the helper macros are only defined for 
boolean and tristate symbols.

Michal

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [RFC][PATCH 1/2] kconfig: Introduce KCONFIG(), KCONFIG_BUILTIN() and KCONFIG_MODULE()
  2011-07-27 15:16           ` Michal Marek
@ 2011-07-27 15:18             ` Arnaud Lacombe
  0 siblings, 0 replies; 48+ messages in thread
From: Arnaud Lacombe @ 2011-07-27 15:18 UTC (permalink / raw)
  To: Michal Marek; +Cc: linux-kbuild, sam, linux-kernel, plagnioj

Hi,

On Wed, Jul 27, 2011 at 11:16 AM, Michal Marek <mmarek@suse.cz> wrote:
> On 27.7.2011 17:09, Arnaud Lacombe wrote:
>>
>> Hi,
>>
>> On Mon, Jul 25, 2011 at 6:58 PM, Michal Marek<mmarek@suse.cz>  wrote:
>>>
>>> Replace the config_is_*() macros with a variant that allows for grepping
>>> for usage of CONFIG_* options in the code. Usage:
>>>
>>>  if (KCONFIG(CONFIG_NUMA))
>>>
>>> or
>>>
>>>  #if KCONFIG(CONFIG_NUMA)
>>>
>>> The KCONFIG() macro evaluates to 1 if the argument is set (to either 'y'
>>> or 'm'), KCONFIG_BUILTIN() and KCONFIG_MODULE() test if the respective
>>> option is 'y' and 'm', respectively.
>>>
>>> Signed-off-by: Michal Marek<mmarek@suse.cz>
>>> ---
>>>  Makefile                   |    2 +-
>>>  include/linux/kconfig.h    |   24 +++++++++++++++
>>>  scripts/kconfig/confdata.c |   70
>>> ++++++++-----------------------------------
>>>  3 files changed, 38 insertions(+), 58 deletions(-)
>>>  create mode 100644 include/linux/kconfig.h
>>>
>>> diff --git a/Makefile b/Makefile
>>> index afb8e0d..bd7629b 100644
>>> --- a/Makefile
>>> +++ b/Makefile
>>> @@ -360,7 +360,7 @@ CFLAGS_GCOV = -fprofile-arcs -ftest-coverage
>>>  LINUXINCLUDE    := -I$(srctree)/arch/$(hdr-arch)/include \
>>>                    -Iarch/$(hdr-arch)/include/generated -Iinclude \
>>>                    $(if $(KBUILD_SRC), -I$(srctree)/include) \
>>> -                   -include include/generated/autoconf.h
>>> +                   -include $(srctree)/include/linux/kconfig.h
>>>
>>>  KBUILD_CPPFLAGS := -D__KERNEL__
>>>
>>> diff --git a/include/linux/kconfig.h b/include/linux/kconfig.h
>>> new file mode 100644
>>> index 0000000..fe80348
>>> --- /dev/null
>>> +++ b/include/linux/kconfig.h
>>> @@ -0,0 +1,24 @@
>>> +#ifndef __LINUX_KCONFIG_H
>>> +#define __LINUX_KCONFIG_H
>>> +
>>> +#include<generated/autoconf.h>
>>> +
>>> +/*
>>> + * Evaluates to 1 if CONFIG_option is set to 'y', 0 otherwise
>>> + */
>>> +#define KCONFIG_BUILTIN(option) __enabled_ ## option
>>> +
>>> +/*
>>> + * Evaluates to 1 if CONFIG_option is set to 'm', 0 otherwise
>>> + */
>>> +#define KCONFIG_MODULE(option) __enabled_ ## option ## _MODULE
>>> +
>>> +/*
>>> + * Evaluates to 1 if CONFIG_option is set to 'y' or 'm', 0 otherwise
>>> + *
>>> + */
>>> +#define KCONFIG(option) \
>>> +       (__enabled_ ## option || __enabled_ ## option ## _MODULE)
>>> +
>>> +
>>> +#endif /* __LINUX_KCONFIG_H */
>>> diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
>>> index df629ec..3bab40a 100644
>>> --- a/scripts/kconfig/confdata.c
>>> +++ b/scripts/kconfig/confdata.c
>>> @@ -495,15 +495,24 @@ header_print_symbol(FILE *fp, struct symbol *sym,
>>> const char *value, void *arg)
>>>
>>>                switch (*value) {
>>>                case 'n':
>>> -                       return;
>>> +                       break;
>>>                case 'm':
>>>                        suffix = "_MODULE";
>>>                        /* fall through */
>>>                default:
>>> -                       value = "1";
>>> +                       fprintf(fp, "#define %s%s%s 1\n",
>>> +                           CONFIG_, sym->name, suffix);
>>>                }
>>> -               fprintf(fp, "#define %s%s%s %s\n",
>>> -                   CONFIG_, sym->name, suffix, value);
>>> +               /*
>>> +                * Generate the __enabled_CONFIG_* and
>>> +                * __enabled_CONFIG_*_MODULE macros for use by the
>>> KCONFIG*()
>>> +                * macros. The _MODULE variant is generated even for
>>> booleans
>>> +                * so that the KCONFIG() macro works.
>>> +                */
>>> +               fprintf(fp, "#define __enabled_" CONFIG_ "%s %d\n",
>>> +                               sym->name, (*value == 'y'));
>>> +               fprintf(fp, "#define __enabled_" CONFIG_ "%s_MODULE
>>> %d\n",
>>> +                               sym->name, (*value == 'm'));
>>>                break;
>>>        }
>>>        case S_HEX: {
>>
>> Just to comment on the patch itself, it will certainly not apply
>> against kbuild/kconfig as I changed header_print_symbol() to fix the
>> S_HEX prefix issue.
>
> If course it applies, the "case S_HEX: {" context line you are quoting was
> added by your commit:
> http://git.kernel.org/?p=linux/kernel/git/mmarek/kbuild-2.6.git;a=commitdiff;h=eb4cf5a642f6430cffff7ba5d8d9bd46ea409281
>
@#$... morning... I was looking at the wrong place, sorry.

 - Arnaud

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [RFC][PATCH 1/2] kconfig: Introduce KCONFIG(), KCONFIG_BUILTIN() and KCONFIG_MODULE()
  2011-07-27  8:36                         ` Michal Marek
  2011-07-27 13:31                           ` Arnaud Lacombe
@ 2011-07-27 16:36                           ` Américo Wang
  1 sibling, 0 replies; 48+ messages in thread
From: Américo Wang @ 2011-07-27 16:36 UTC (permalink / raw)
  To: Michal Marek
  Cc: Randy Dunlap, Arnaud Lacombe, linux-kbuild, sam, linux-kernel, plagnioj

On Wed, Jul 27, 2011 at 4:36 PM, Michal Marek <mmarek@suse.cz> wrote:
>
> Good idea. Is anyone against
> IS_ENABLED(CONFIG_FOO)
> IS_ENABLED_BUILTIN(CONFIG_FOO)
> IS_ENABLED_MODULE(CONFIG_FOO)
> ?

How about IS_ENABLED() IS_BUILTIN() IS_MODULE()?

Thanks.

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [PATCH] kconfig: Introduce IS_ENABLED(), IS_BUILTIN() and IS_MODULE()
  2011-07-25 22:58       ` [RFC][PATCH 1/2] kconfig: Introduce KCONFIG(), KCONFIG_BUILTIN() and KCONFIG_MODULE() Michal Marek
                           ` (2 preceding siblings ...)
  2011-07-27 15:09         ` Arnaud Lacombe
@ 2011-07-29 13:51         ` Michal Marek
  2011-07-29 17:43           ` Arnaud Lacombe
                             ` (2 more replies)
  3 siblings, 3 replies; 48+ messages in thread
From: Michal Marek @ 2011-07-29 13:51 UTC (permalink / raw)
  To: linux-kbuild
  Cc: xiyou.wangcong, rdunlap, lacombar, sam, linux-kernel, plagnioj

Replace the config_is_*() macros with a variant that allows for grepping
for usage of CONFIG_* options in the code. Usage:

  if (IS_ENABLED(CONFIG_NUMA))

or

  #if IS_ENABLED(CONFIG_NUMA)

The IS_ENABLED() macro evaluates to 1 if the argument is set (to either 'y'
or 'm'), IS_BUILTIN() tests if the option is 'y' and IS_MODULE() test if
the option is 'm'. Only boolean and tristate options are supported.

Signed-off-by: Michal Marek <mmarek@suse.cz>
---

Everybody happy with the above naming?

Michal

---
 Makefile                   |    2 +-
 include/linux/kconfig.h    |   32 ++++++++++++++++++++
 scripts/kconfig/confdata.c |   71 ++++++++-----------------------------------
 3 files changed, 47 insertions(+), 58 deletions(-)
 create mode 100644 include/linux/kconfig.h

diff --git a/Makefile b/Makefile
index afb8e0d..bd7629b 100644
--- a/Makefile
+++ b/Makefile
@@ -360,7 +360,7 @@ CFLAGS_GCOV	= -fprofile-arcs -ftest-coverage
 LINUXINCLUDE    := -I$(srctree)/arch/$(hdr-arch)/include \
                    -Iarch/$(hdr-arch)/include/generated -Iinclude \
                    $(if $(KBUILD_SRC), -I$(srctree)/include) \
-                   -include include/generated/autoconf.h
+                   -include $(srctree)/include/linux/kconfig.h
 
 KBUILD_CPPFLAGS := -D__KERNEL__
 
diff --git a/include/linux/kconfig.h b/include/linux/kconfig.h
new file mode 100644
index 0000000..067eda0
--- /dev/null
+++ b/include/linux/kconfig.h
@@ -0,0 +1,32 @@
+#ifndef __LINUX_KCONFIG_H
+#define __LINUX_KCONFIG_H
+
+#include <generated/autoconf.h>
+
+/*
+ * Helper macros to use CONFIG_ options in C expressions. Note that
+ * these only work with boolean and tristate options.
+ */
+
+/*
+ * IS_ENABLED(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y' or 'm',
+ * 0 otherwise.
+ *
+ */
+#define IS_ENABLED(option) \
+	(__enabled_ ## option || __enabled_ ## option ## _MODULE)
+
+/*
+ * IS_BUILTIN(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y', 0
+ * otherwise. For boolean options, this is equivalent to
+ * IS_ENABLED(CONFIG_FOO).
+ */
+#define IS_BUILTIN(option) __enabled_ ## option
+
+/*
+ * IS_MODULE(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'm', 0
+ * otherwise.
+ */
+#define IS_MODULE(option) __enabled_ ## option ## _MODULE
+
+#endif /* __LINUX_KCONFIG_H */
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index df629ec..59b667c 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -495,15 +495,25 @@ header_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg)
 
 		switch (*value) {
 		case 'n':
-			return;
+			break;
 		case 'm':
 			suffix = "_MODULE";
 			/* fall through */
 		default:
-			value = "1";
+			fprintf(fp, "#define %s%s%s 1\n",
+			    CONFIG_, sym->name, suffix);
 		}
-		fprintf(fp, "#define %s%s%s %s\n",
-		    CONFIG_, sym->name, suffix, value);
+		/*
+		 * Generate the __enabled_CONFIG_* and
+		 * __enabled_CONFIG_*_MODULE macros for use by the
+		 * IS_{ENABLED,BUILTIN,MODULE} macros. The _MODULE variant is
+		 * generated even for booleans so that the IS_ENABLED() macro
+		 * works.
+		 */
+		fprintf(fp, "#define __enabled_" CONFIG_ "%s %d\n",
+				sym->name, (*value == 'y'));
+		fprintf(fp, "#define __enabled_" CONFIG_ "%s_MODULE %d\n",
+				sym->name, (*value == 'm'));
 		break;
 	}
 	case S_HEX: {
@@ -555,58 +565,6 @@ static struct conf_printer header_printer_cb =
 };
 
 /*
- * Function-style header printer
- *
- * This printer is used to generate the config_is_xxx() function-style macros
- * in `include/generated/autoconf.h' 
- */
-static void
-header_function_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg)
-{
-	int val = 0;
-	char c;
-	char *tmp, *d;
-
-	switch (sym->type) {
-	case S_BOOLEAN:
-	case S_TRISTATE:
-		break;
-	default:
-		return;
-	}
-	if (*value == 'm')
-		val = 2;
-	else if (*value == 'y')
-		val = 1;
-
-	d = strdup(CONFIG_);
-	tmp = d;
-	while ((c = *d)) {
-		*d = tolower(c);
-		d++;
-	}
-
-	fprintf(fp, "#define %sis_", tmp);
-	free(tmp);
-
-	d = strdup(sym->name);
-	tmp = d;
-	while ((c = *d)) {
-		*d = tolower(c);
-		d++;
-	}
-	fprintf(fp, "%s%s() %d\n", tmp, (val > 1) ? "_module" : "",
-		      val ? 1 : 0);
-	free(tmp);
-}
-
-static struct conf_printer header_function_printer_cb =
-{
-	.print_symbol = header_function_print_symbol,
-};
-
-
-/*
  * Tristate printer
  *
  * This printer is used when generating the `include/config/tristate.conf' file.
@@ -997,7 +955,6 @@ int conf_write_autoconf(void)
 		conf_write_symbol(tristate, sym, &tristate_printer_cb, (void *)1);
 
 		conf_write_symbol(out_h, sym, &header_printer_cb, NULL);
-		conf_write_symbol(out_h, sym, &header_function_printer_cb, NULL);
 	}
 	fclose(out);
 	fclose(tristate);
-- 
1.7.6


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* Re: [PATCH] kconfig: Introduce IS_ENABLED(), IS_BUILTIN() and IS_MODULE()
  2011-07-29 13:51         ` [PATCH] kconfig: Introduce IS_ENABLED(), IS_BUILTIN() and IS_MODULE() Michal Marek
@ 2011-07-29 17:43           ` Arnaud Lacombe
  2011-07-29 18:25           ` Randy Dunlap
  2011-08-02 17:33           ` Sam Ravnborg
  2 siblings, 0 replies; 48+ messages in thread
From: Arnaud Lacombe @ 2011-07-29 17:43 UTC (permalink / raw)
  To: Michal Marek
  Cc: linux-kbuild, xiyou.wangcong, rdunlap, sam, linux-kernel, plagnioj

Hi,

On Fri, Jul 29, 2011 at 9:51 AM, Michal Marek <mmarek@suse.cz> wrote:
> Replace the config_is_*() macros with a variant that allows for grepping
> for usage of CONFIG_* options in the code. Usage:
>
>  if (IS_ENABLED(CONFIG_NUMA))
>
> or
>
>  #if IS_ENABLED(CONFIG_NUMA)
>
> The IS_ENABLED() macro evaluates to 1 if the argument is set (to either 'y'
> or 'm'), IS_BUILTIN() tests if the option is 'y' and IS_MODULE() test if
> the option is 'm'. Only boolean and tristate options are supported.
>
> Signed-off-by: Michal Marek <mmarek@suse.cz>
> ---
>
> Everybody happy with the above naming?
>
yes for me.

Reviewed-by: Arnaud Lacombe <lacombar@gmail.com>

 - Arnaud

> Michal
>
> ---
>  Makefile                   |    2 +-
>  include/linux/kconfig.h    |   32 ++++++++++++++++++++
>  scripts/kconfig/confdata.c |   71 ++++++++-----------------------------------
>  3 files changed, 47 insertions(+), 58 deletions(-)
>  create mode 100644 include/linux/kconfig.h
>
> diff --git a/Makefile b/Makefile
> index afb8e0d..bd7629b 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -360,7 +360,7 @@ CFLAGS_GCOV = -fprofile-arcs -ftest-coverage
>  LINUXINCLUDE    := -I$(srctree)/arch/$(hdr-arch)/include \
>                    -Iarch/$(hdr-arch)/include/generated -Iinclude \
>                    $(if $(KBUILD_SRC), -I$(srctree)/include) \
> -                   -include include/generated/autoconf.h
> +                   -include $(srctree)/include/linux/kconfig.h
>
>  KBUILD_CPPFLAGS := -D__KERNEL__
>
> diff --git a/include/linux/kconfig.h b/include/linux/kconfig.h
> new file mode 100644
> index 0000000..067eda0
> --- /dev/null
> +++ b/include/linux/kconfig.h
> @@ -0,0 +1,32 @@
> +#ifndef __LINUX_KCONFIG_H
> +#define __LINUX_KCONFIG_H
> +
> +#include <generated/autoconf.h>
> +
> +/*
> + * Helper macros to use CONFIG_ options in C expressions. Note that
> + * these only work with boolean and tristate options.
> + */
> +
> +/*
> + * IS_ENABLED(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y' or 'm',
> + * 0 otherwise.
> + *
> + */
> +#define IS_ENABLED(option) \
> +       (__enabled_ ## option || __enabled_ ## option ## _MODULE)
> +
> +/*
> + * IS_BUILTIN(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y', 0
> + * otherwise. For boolean options, this is equivalent to
> + * IS_ENABLED(CONFIG_FOO).
> + */
> +#define IS_BUILTIN(option) __enabled_ ## option
> +
> +/*
> + * IS_MODULE(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'm', 0
> + * otherwise.
> + */
> +#define IS_MODULE(option) __enabled_ ## option ## _MODULE
> +
> +#endif /* __LINUX_KCONFIG_H */
> diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
> index df629ec..59b667c 100644
> --- a/scripts/kconfig/confdata.c
> +++ b/scripts/kconfig/confdata.c
> @@ -495,15 +495,25 @@ header_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg)
>
>                switch (*value) {
>                case 'n':
> -                       return;
> +                       break;
>                case 'm':
>                        suffix = "_MODULE";
>                        /* fall through */
>                default:
> -                       value = "1";
> +                       fprintf(fp, "#define %s%s%s 1\n",
> +                           CONFIG_, sym->name, suffix);
>                }
> -               fprintf(fp, "#define %s%s%s %s\n",
> -                   CONFIG_, sym->name, suffix, value);
> +               /*
> +                * Generate the __enabled_CONFIG_* and
> +                * __enabled_CONFIG_*_MODULE macros for use by the
> +                * IS_{ENABLED,BUILTIN,MODULE} macros. The _MODULE variant is
> +                * generated even for booleans so that the IS_ENABLED() macro
> +                * works.
> +                */
> +               fprintf(fp, "#define __enabled_" CONFIG_ "%s %d\n",
> +                               sym->name, (*value == 'y'));
> +               fprintf(fp, "#define __enabled_" CONFIG_ "%s_MODULE %d\n",
> +                               sym->name, (*value == 'm'));
>                break;
>        }
>        case S_HEX: {
> @@ -555,58 +565,6 @@ static struct conf_printer header_printer_cb =
>  };
>
>  /*
> - * Function-style header printer
> - *
> - * This printer is used to generate the config_is_xxx() function-style macros
> - * in `include/generated/autoconf.h'
> - */
> -static void
> -header_function_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg)
> -{
> -       int val = 0;
> -       char c;
> -       char *tmp, *d;
> -
> -       switch (sym->type) {
> -       case S_BOOLEAN:
> -       case S_TRISTATE:
> -               break;
> -       default:
> -               return;
> -       }
> -       if (*value == 'm')
> -               val = 2;
> -       else if (*value == 'y')
> -               val = 1;
> -
> -       d = strdup(CONFIG_);
> -       tmp = d;
> -       while ((c = *d)) {
> -               *d = tolower(c);
> -               d++;
> -       }
> -
> -       fprintf(fp, "#define %sis_", tmp);
> -       free(tmp);
> -
> -       d = strdup(sym->name);
> -       tmp = d;
> -       while ((c = *d)) {
> -               *d = tolower(c);
> -               d++;
> -       }
> -       fprintf(fp, "%s%s() %d\n", tmp, (val > 1) ? "_module" : "",
> -                     val ? 1 : 0);
> -       free(tmp);
> -}
> -
> -static struct conf_printer header_function_printer_cb =
> -{
> -       .print_symbol = header_function_print_symbol,
> -};
> -
> -
> -/*
>  * Tristate printer
>  *
>  * This printer is used when generating the `include/config/tristate.conf' file.
> @@ -997,7 +955,6 @@ int conf_write_autoconf(void)
>                conf_write_symbol(tristate, sym, &tristate_printer_cb, (void *)1);
>
>                conf_write_symbol(out_h, sym, &header_printer_cb, NULL);
> -               conf_write_symbol(out_h, sym, &header_function_printer_cb, NULL);
>        }
>        fclose(out);
>        fclose(tristate);
> --
> 1.7.6
>
>

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH] kconfig: Introduce IS_ENABLED(), IS_BUILTIN() and IS_MODULE()
  2011-07-29 13:51         ` [PATCH] kconfig: Introduce IS_ENABLED(), IS_BUILTIN() and IS_MODULE() Michal Marek
  2011-07-29 17:43           ` Arnaud Lacombe
@ 2011-07-29 18:25           ` Randy Dunlap
  2011-07-29 18:58             ` Arnaud Lacombe
  2011-08-02 17:33           ` Sam Ravnborg
  2 siblings, 1 reply; 48+ messages in thread
From: Randy Dunlap @ 2011-07-29 18:25 UTC (permalink / raw)
  To: Michal Marek
  Cc: linux-kbuild, xiyou.wangcong, lacombar, sam, linux-kernel, plagnioj

On Fri, 29 Jul 2011 15:51:37 +0200 Michal Marek wrote:

> Replace the config_is_*() macros with a variant that allows for grepping
> for usage of CONFIG_* options in the code. Usage:
> 
>   if (IS_ENABLED(CONFIG_NUMA))
> 
> or
> 
>   #if IS_ENABLED(CONFIG_NUMA)
> 
> The IS_ENABLED() macro evaluates to 1 if the argument is set (to either 'y'
> or 'm'), IS_BUILTIN() tests if the option is 'y' and IS_MODULE() test if
> the option is 'm'. Only boolean and tristate options are supported.
> 
> Signed-off-by: Michal Marek <mmarek@suse.cz>
> ---
> 
> Everybody happy with the above naming?

Yes here.

Acked-by: Randy Dunlap <rdunlap@xenotime.net>

These strings are being written to the .config file, right?

> +		/*
> +		 * Generate the __enabled_CONFIG_* and
> +		 * __enabled_CONFIG_*_MODULE macros for use by the
> +		 * IS_{ENABLED,BUILTIN,MODULE} macros. The _MODULE variant is
> +		 * generated even for booleans so that the IS_ENABLED() macro
> +		 * works.
> +		 */
> +		fprintf(fp, "#define __enabled_" CONFIG_ "%s %d\n",
> +				sym->name, (*value == 'y'));
> +		fprintf(fp, "#define __enabled_" CONFIG_ "%s_MODULE %d\n",
> +				sym->name, (*value == 'm'));
>  		break;


---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH] kconfig: Introduce IS_ENABLED(), IS_BUILTIN() and IS_MODULE()
  2011-07-29 18:25           ` Randy Dunlap
@ 2011-07-29 18:58             ` Arnaud Lacombe
  0 siblings, 0 replies; 48+ messages in thread
From: Arnaud Lacombe @ 2011-07-29 18:58 UTC (permalink / raw)
  To: Randy Dunlap
  Cc: Michal Marek, linux-kbuild, xiyou.wangcong, sam, linux-kernel, plagnioj

Hi,

On Fri, Jul 29, 2011 at 2:25 PM, Randy Dunlap <rdunlap@xenotime.net> wrote:
> On Fri, 29 Jul 2011 15:51:37 +0200 Michal Marek wrote:
>
>> Replace the config_is_*() macros with a variant that allows for grepping
>> for usage of CONFIG_* options in the code. Usage:
>>
>>   if (IS_ENABLED(CONFIG_NUMA))
>>
>> or
>>
>>   #if IS_ENABLED(CONFIG_NUMA)
>>
>> The IS_ENABLED() macro evaluates to 1 if the argument is set (to either 'y'
>> or 'm'), IS_BUILTIN() tests if the option is 'y' and IS_MODULE() test if
>> the option is 'm'. Only boolean and tristate options are supported.
>>
>> Signed-off-by: Michal Marek <mmarek@suse.cz>
>> ---
>>
>> Everybody happy with the above naming?
>
> Yes here.
>
> Acked-by: Randy Dunlap <rdunlap@xenotime.net>
>
> These strings are being written to the .config file, right?
>
no, they are written to `include/generated/autoconf.h'

 - Arnaud

>> +             /*
>> +              * Generate the __enabled_CONFIG_* and
>> +              * __enabled_CONFIG_*_MODULE macros for use by the
>> +              * IS_{ENABLED,BUILTIN,MODULE} macros. The _MODULE variant is
>> +              * generated even for booleans so that the IS_ENABLED() macro
>> +              * works.
>> +              */
>> +             fprintf(fp, "#define __enabled_" CONFIG_ "%s %d\n",
>> +                             sym->name, (*value == 'y'));
>> +             fprintf(fp, "#define __enabled_" CONFIG_ "%s_MODULE %d\n",
>> +                             sym->name, (*value == 'm'));
>>               break;
>
>
> ---
> ~Randy
> *** Remember to use Documentation/SubmitChecklist when testing your code ***
>

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH] kconfig: Introduce IS_ENABLED(), IS_BUILTIN() and IS_MODULE()
  2011-07-29 13:51         ` [PATCH] kconfig: Introduce IS_ENABLED(), IS_BUILTIN() and IS_MODULE() Michal Marek
  2011-07-29 17:43           ` Arnaud Lacombe
  2011-07-29 18:25           ` Randy Dunlap
@ 2011-08-02 17:33           ` Sam Ravnborg
  2011-08-02 17:50             ` Arnaud Lacombe
  2 siblings, 1 reply; 48+ messages in thread
From: Sam Ravnborg @ 2011-08-02 17:33 UTC (permalink / raw)
  To: Michal Marek
  Cc: linux-kbuild, xiyou.wangcong, rdunlap, lacombar, linux-kernel, plagnioj

On Fri, Jul 29, 2011 at 03:51:37PM +0200, Michal Marek wrote:
> Replace the config_is_*() macros with a variant that allows for grepping
> for usage of CONFIG_* options in the code. Usage:
> 
>   if (IS_ENABLED(CONFIG_NUMA))
> 
> or
> 
>   #if IS_ENABLED(CONFIG_NUMA)
> 
> The IS_ENABLED() macro evaluates to 1 if the argument is set (to either 'y'
> or 'm'), IS_BUILTIN() tests if the option is 'y' and IS_MODULE() test if
> the option is 'm'. Only boolean and tristate options are supported.
> 
> Signed-off-by: Michal Marek <mmarek@suse.cz>
> ---
> 
> Everybody happy with the above naming?
Naming is good - has my ack.


> 
> ---
>  Makefile                   |    2 +-
>  include/linux/kconfig.h    |   32 ++++++++++++++++++++
>  scripts/kconfig/confdata.c |   71 ++++++++-----------------------------------
>  3 files changed, 47 insertions(+), 58 deletions(-)
>  create mode 100644 include/linux/kconfig.h
> 
> diff --git a/Makefile b/Makefile
> index afb8e0d..bd7629b 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -360,7 +360,7 @@ CFLAGS_GCOV	= -fprofile-arcs -ftest-coverage
>  LINUXINCLUDE    := -I$(srctree)/arch/$(hdr-arch)/include \
>                     -Iarch/$(hdr-arch)/include/generated -Iinclude \
>                     $(if $(KBUILD_SRC), -I$(srctree)/include) \
> -                   -include include/generated/autoconf.h
> +                   -include $(srctree)/include/linux/kconfig.h

If we do it like this then how about adding this to autoconf.h and avoid the extra file,
and the extra flag to gcc?

	Sam

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH] kconfig: Introduce IS_ENABLED(), IS_BUILTIN() and IS_MODULE()
  2011-08-02 17:33           ` Sam Ravnborg
@ 2011-08-02 17:50             ` Arnaud Lacombe
  2011-08-02 19:26               ` Sam Ravnborg
  0 siblings, 1 reply; 48+ messages in thread
From: Arnaud Lacombe @ 2011-08-02 17:50 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: Michal Marek, linux-kbuild, xiyou.wangcong, rdunlap,
	linux-kernel, plagnioj

Hi,

On Tue, Aug 2, 2011 at 1:33 PM, Sam Ravnborg <sam@ravnborg.org> wrote:
> On Fri, Jul 29, 2011 at 03:51:37PM +0200, Michal Marek wrote:
>> Replace the config_is_*() macros with a variant that allows for grepping
>> for usage of CONFIG_* options in the code. Usage:
>>
>>   if (IS_ENABLED(CONFIG_NUMA))
>>
>> or
>>
>>   #if IS_ENABLED(CONFIG_NUMA)
>>
>> The IS_ENABLED() macro evaluates to 1 if the argument is set (to either 'y'
>> or 'm'), IS_BUILTIN() tests if the option is 'y' and IS_MODULE() test if
>> the option is 'm'. Only boolean and tristate options are supported.
>>
>> Signed-off-by: Michal Marek <mmarek@suse.cz>
>> ---
>>
>> Everybody happy with the above naming?
> Naming is good - has my ack.
>
>
>>
>> ---
>>  Makefile                   |    2 +-
>>  include/linux/kconfig.h    |   32 ++++++++++++++++++++
>>  scripts/kconfig/confdata.c |   71 ++++++++-----------------------------------
>>  3 files changed, 47 insertions(+), 58 deletions(-)
>>  create mode 100644 include/linux/kconfig.h
>>
>> diff --git a/Makefile b/Makefile
>> index afb8e0d..bd7629b 100644
>> --- a/Makefile
>> +++ b/Makefile
>> @@ -360,7 +360,7 @@ CFLAGS_GCOV       = -fprofile-arcs -ftest-coverage
>>  LINUXINCLUDE    := -I$(srctree)/arch/$(hdr-arch)/include \
>>                     -Iarch/$(hdr-arch)/include/generated -Iinclude \
>>                     $(if $(KBUILD_SRC), -I$(srctree)/include) \
>> -                   -include include/generated/autoconf.h
>> +                   -include $(srctree)/include/linux/kconfig.h
>
> If we do it like this then how about adding this to autoconf.h and avoid the extra file,
> and the extra flag to gcc?
>
That would be intrusive for non-Linux users of kconfig. You would have
to hardcode a <linux/kconfig.h> in autoconf.h, which mean other
project would have to either mirror the Linux include tree structure,
or modify kconfig for the desired include path, if the feature is
desired at all. As I see it, Linux, through Kbuild, is a user of
kconfig.

I might send a patch to conditionally generate the __enable_<FOO>
stuff so that other project have the choice to use this feature or not
(and avoid namespace utilization if not), but that's low priority.

 - Arnaud

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH] kconfig: Introduce IS_ENABLED(), IS_BUILTIN() and IS_MODULE()
  2011-08-02 17:50             ` Arnaud Lacombe
@ 2011-08-02 19:26               ` Sam Ravnborg
  2011-08-02 19:33                 ` Michal Marek
  0 siblings, 1 reply; 48+ messages in thread
From: Sam Ravnborg @ 2011-08-02 19:26 UTC (permalink / raw)
  To: Arnaud Lacombe
  Cc: Michal Marek, linux-kbuild, xiyou.wangcong, rdunlap,
	linux-kernel, plagnioj

> >
> > If we do it like this then how about adding this to autoconf.h and avoid the extra file,
> > and the extra flag to gcc?
> >
> That would be intrusive for non-Linux users of kconfig. You would have
> to hardcode a <linux/kconfig.h> in autoconf.h, which mean other
> project would have to either mirror the Linux include tree structure,
> or modify kconfig for the desired include path, if the feature is
> desired at all. As I see it, Linux, through Kbuild, is a user of
> kconfig.
The idea was to entirely skip kconfig.h - and include the code in
autoconf.h verbatim - so no extra file.

We could add an option to disable this - if the other kconfig
really require this.

	Sam

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH] kconfig: Introduce IS_ENABLED(), IS_BUILTIN() and IS_MODULE()
  2011-08-02 19:33                 ` Michal Marek
@ 2011-08-02 19:33                   ` Arnaud Lacombe
  0 siblings, 0 replies; 48+ messages in thread
From: Arnaud Lacombe @ 2011-08-02 19:33 UTC (permalink / raw)
  To: Michal Marek
  Cc: Sam Ravnborg, linux-kbuild, xiyou.wangcong, rdunlap,
	linux-kernel, plagnioj

Hi,

On Tue, Aug 2, 2011 at 3:33 PM, Michal Marek <mmarek@suse.cz> wrote:
> Dne 2.8.2011 21:26, Sam Ravnborg napsal(a):
>>>>
>>>> If we do it like this then how about adding this to autoconf.h and avoid the extra file,
>>>> and the extra flag to gcc?
>>>>
>>> That would be intrusive for non-Linux users of kconfig. You would have
>>> to hardcode a <linux/kconfig.h> in autoconf.h, which mean other
>>> project would have to either mirror the Linux include tree structure,
>>> or modify kconfig for the desired include path, if the feature is
>>> desired at all. As I see it, Linux, through Kbuild, is a user of
>>> kconfig.
>> The idea was to entirely skip kconfig.h - and include the code in
>> autoconf.h verbatim - so no extra file.
>
> We could do that. I went for the extra file because it was easier to
> edit a .h file than to edit a .c file that generates a .h file :).
>
seconded :)

 - Arnaud

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH] kconfig: Introduce IS_ENABLED(), IS_BUILTIN() and IS_MODULE()
  2011-08-02 19:26               ` Sam Ravnborg
@ 2011-08-02 19:33                 ` Michal Marek
  2011-08-02 19:33                   ` Arnaud Lacombe
  0 siblings, 1 reply; 48+ messages in thread
From: Michal Marek @ 2011-08-02 19:33 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: Arnaud Lacombe, linux-kbuild, xiyou.wangcong, rdunlap,
	linux-kernel, plagnioj

Dne 2.8.2011 21:26, Sam Ravnborg napsal(a):
>>>
>>> If we do it like this then how about adding this to autoconf.h and avoid the extra file,
>>> and the extra flag to gcc?
>>>
>> That would be intrusive for non-Linux users of kconfig. You would have
>> to hardcode a <linux/kconfig.h> in autoconf.h, which mean other
>> project would have to either mirror the Linux include tree structure,
>> or modify kconfig for the desired include path, if the feature is
>> desired at all. As I see it, Linux, through Kbuild, is a user of
>> kconfig.
> The idea was to entirely skip kconfig.h - and include the code in
> autoconf.h verbatim - so no extra file.

We could do that. I went for the extra file because it was easier to
edit a .h file than to edit a .c file that generates a .h file :).

Michal

^ permalink raw reply	[flat|nested] 48+ messages in thread

end of thread, other threads:[~2011-08-02 19:33 UTC | newest]

Thread overview: 48+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-17 15:35 [PATCH] kconfig: Only generate config_is_xxx for bool and tristate options Michal Marek
2011-05-17 18:05 ` Jean-Christophe PLAGNIOL-VILLARD
2011-05-17 19:44   ` Michal Marek
2011-05-17 19:53 ` Sam Ravnborg
2011-05-18  5:16   ` Jean-Christophe PLAGNIOL-VILLARD
2011-05-18  6:19     ` Sam Ravnborg
2011-05-18  6:27       ` Arnaud Lacombe
2011-05-18  6:23   ` Arnaud Lacombe
2011-07-13 13:22     ` Michal Marek
2011-07-13 15:20       ` Arnaud Lacombe
2011-07-13 20:08       ` Sam Ravnborg
2011-07-19 13:45         ` Michal Marek
2011-07-25 22:58       ` [RFC][PATCH 1/2] kconfig: Introduce KCONFIG(), KCONFIG_BUILTIN() and KCONFIG_MODULE() Michal Marek
2011-07-25 22:58         ` [RFC][PATCH 2/2] mm: Switch NUMA_BUILD and COMPACTION_BUILD to new KCONFIG() syntax Michal Marek
2011-07-25 22:58           ` Michal Marek
2011-07-26 15:19           ` Michal Hocko
2011-07-26 15:19             ` Michal Hocko
2011-07-26 18:34             ` Michal Marek
2011-07-26 18:34               ` Michal Marek
2011-07-26 18:52               ` Michal Hocko
2011-07-26 18:52                 ` Michal Hocko
2011-07-26 13:01         ` [RFC][PATCH 1/2] kconfig: Introduce KCONFIG(), KCONFIG_BUILTIN() and KCONFIG_MODULE() Américo Wang
2011-07-26 13:21           ` Michal Marek
2011-07-26 15:04             ` Randy Dunlap
2011-07-26 18:28               ` Michal Marek
2011-07-26 18:28                 ` Randy Dunlap
2011-07-26 18:48                   ` Arnaud Lacombe
2011-07-27  0:42                     ` Arnaud Lacombe
2011-07-27  4:35                       ` Randy Dunlap
2011-07-27  8:36                         ` Michal Marek
2011-07-27 13:31                           ` Arnaud Lacombe
2011-07-27 13:38                             ` Michal Marek
2011-07-27 15:11                               ` Arnaud Lacombe
2011-07-27 15:18                                 ` Michal Marek
2011-07-27 16:36                           ` Américo Wang
2011-07-27 15:09         ` Arnaud Lacombe
2011-07-27 15:16           ` Michal Marek
2011-07-27 15:18             ` Arnaud Lacombe
2011-07-29 13:51         ` [PATCH] kconfig: Introduce IS_ENABLED(), IS_BUILTIN() and IS_MODULE() Michal Marek
2011-07-29 17:43           ` Arnaud Lacombe
2011-07-29 18:25           ` Randy Dunlap
2011-07-29 18:58             ` Arnaud Lacombe
2011-08-02 17:33           ` Sam Ravnborg
2011-08-02 17:50             ` Arnaud Lacombe
2011-08-02 19:26               ` Sam Ravnborg
2011-08-02 19:33                 ` Michal Marek
2011-08-02 19:33                   ` Arnaud Lacombe
2011-05-25 13:35 ` [PATCH] kconfig: Only generate config_is_xxx for bool and tristate options Michal Marek

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.