[coreboot-gerrit] New patch to review for coreboot: b76dcad */include/kconfig.h: Provides IS_{MODULE, BUILTIN}() macros

Edward O'Callaghan (eocallaghan@alterapraxis.com) gerrit at coreboot.org
Tue Jun 24 11:19:13 CEST 2014


Edward O'Callaghan (eocallaghan at alterapraxis.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/6104

-gerrit

commit b76dcad5d72fdaf11447ef024cf71ac9b3f9ef3f
Author: Edward O'Callaghan <eocallaghan at alterapraxis.com>
Date:   Tue Jun 24 19:15:59 2014 +1000

    */include/kconfig.h: Provides IS_{MODULE,BUILTIN}() macros
    
    Update kconfig.h to be inline with Linux with improved documentation
    clarifying the semantics of these macros.
    
    Change-Id: I95637fc4c2dbc308868171173b7ff53e8a900ac9
    Signed-off-by: Edward O'Callaghan <eocallaghan at alterapraxis.com>
---
 payloads/libpayload/include/kconfig.h | 30 +++++++++++++++++++++++++++---
 src/include/kconfig.h                 | 28 ++++++++++++++++++++++++++--
 2 files changed, 53 insertions(+), 5 deletions(-)

diff --git a/payloads/libpayload/include/kconfig.h b/payloads/libpayload/include/kconfig.h
index 3d7d768..e07f015 100644
--- a/payloads/libpayload/include/kconfig.h
+++ b/payloads/libpayload/include/kconfig.h
@@ -1,7 +1,12 @@
 #ifndef __KCONFIG_H__
 #define __KCONFIG_H__
 
-#include <libpayload-config.h>
+#include <config.h>
+
+/*
+ * Helper macros to use CONFIG_ options in C/CPP expressions. Note that
+ * these only work with boolean and tristate options.
+ */
 
 /*
  * Getting something that works in C and CPP for an arg that may or may
@@ -17,5 +22,24 @@
 #define __config_enabled(arg1_or_junk) ___config_enabled(arg1_or_junk 1, 0, 0)
 #define ___config_enabled(__ignored, val, ...) val
 
-#define IS_ENABLED(option) config_enabled(option)
-#endif
+/*
+ * IS_ENABLED(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y' or 'm',
+ * 0 otherwise.
+ */
+#define IS_ENABLED(option) \
+		(config_enabled(option) || config_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) config_enabled(option)
+
+/*
+ * IS_MODULE(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'm', 0
+ * otherwise.
+ */
+#define IS_MODULE(option) config_enabled(option##_MODULE)
+
+#endif /* __KCONFIG_H__ */
diff --git a/src/include/kconfig.h b/src/include/kconfig.h
index 73106e9..e07f015 100644
--- a/src/include/kconfig.h
+++ b/src/include/kconfig.h
@@ -4,6 +4,11 @@
 #include <config.h>
 
 /*
+ * Helper macros to use CONFIG_ options in C/CPP expressions. Note that
+ * these only work with boolean and tristate options.
+ */
+
+/*
  * Getting something that works in C and CPP for an arg that may or may
  * not be defined is tricky.  Here, if we have "#define CONFIG_BOOGER 1"
  * we match on the placeholder define, insert the "0," for arg1 and generate
@@ -17,5 +22,24 @@
 #define __config_enabled(arg1_or_junk) ___config_enabled(arg1_or_junk 1, 0, 0)
 #define ___config_enabled(__ignored, val, ...) val
 
-#define IS_ENABLED(option) config_enabled(option)
-#endif
+/*
+ * IS_ENABLED(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y' or 'm',
+ * 0 otherwise.
+ */
+#define IS_ENABLED(option) \
+		(config_enabled(option) || config_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) config_enabled(option)
+
+/*
+ * IS_MODULE(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'm', 0
+ * otherwise.
+ */
+#define IS_MODULE(option) config_enabled(option##_MODULE)
+
+#endif /* __KCONFIG_H__ */



More information about the coreboot-gerrit mailing list