* [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 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 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 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-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 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 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 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-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: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 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
* 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 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: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
* [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: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
* 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