diff mbox

[2/3] kconfig: add a function to get the CONFIG_ prefix

Message ID 1350589816-20447-3-git-send-email-yann.morin.1998@free.fr (mailing list archive)
State New, archived
Headers show

Commit Message

Yann E. MORIN Oct. 18, 2012, 7:50 p.m. UTC
Currently, we get the CONFIG_ prefix via the CONFIG_ macro, which means
the CONFIG_ prefix is hard-coded at compile time. This goes against
having a run-time defined CONFIG_ prefix.

Add a function that returns the CONFIG_ prefix to use (but keep the
current hard-coded behavior, to be changed in a later patch).

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
---
 scripts/kconfig/lkc.h |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

Comments

Michal Marek Oct. 19, 2012, 5:01 p.m. UTC | #1
On 18.10.2012 21:50, Yann E. MORIN wrote:
> -#ifndef CONFIG_
> -#define CONFIG_ "CONFIG_"
> +/* Those two defines copied from include/linux/stringify.h */
> +#define __stringify_1(x...)	#x
> +#define __stringify(x...)	__stringify_1(x)
> +static inline const char *CONFIG_prefix(void)
> +{
> +	return __stringify(CONFIG_);

This changes the semantics of the CONFIG_ macro. Previously, a
double-quoted string was accepted, now you have to define it to a token
that is turned into a string. Why don't you keep it as before and just do a

return CONFIG_;

in the function?

Michal
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Yann E. MORIN Oct. 19, 2012, 5:59 p.m. UTC | #2
Michal, All,

On Friday 19 October 2012 Michal Marek wrote:
> On 18.10.2012 21:50, Yann E. MORIN wrote:
> > -#ifndef CONFIG_
> > -#define CONFIG_ "CONFIG_"
> > +/* Those two defines copied from include/linux/stringify.h */
> > +#define __stringify_1(x...)	#x
> > +#define __stringify(x...)	__stringify_1(x)
> > +static inline const char *CONFIG_prefix(void)
> > +{
> > +	return __stringify(CONFIG_);
> 
> This changes the semantics of the CONFIG_ macro. Previously, a
> double-quoted string was accepted, now you have to define it to a token
> that is turned into a string. Why don't you keep it as before and just do a
> 
> return CONFIG_;
> 
> in the function?

Yes, that's as simple as it looks, indeed. /me hides.

Thank you!
Regards,
Yann E. MORIN.
diff mbox

Patch

diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h
index c18f2bd..25862fd 100644
--- a/scripts/kconfig/lkc.h
+++ b/scripts/kconfig/lkc.h
@@ -36,9 +36,17 @@  extern "C" {
 #define _(text) gettext(text)
 #define N_(text) (text)
 
-#ifndef CONFIG_
-#define CONFIG_ "CONFIG_"
+/* Those two defines copied from include/linux/stringify.h */
+#define __stringify_1(x...)	#x
+#define __stringify(x...)	__stringify_1(x)
+static inline const char *CONFIG_prefix(void)
+{
+	return __stringify(CONFIG_);
+}
+#ifdef CONFIG_
+#undef CONFIG_
 #endif
+#define CONFIG_ CONFIG_prefix()
 
 #define TF_COMMAND	0x0001
 #define TF_PARAM	0x0002