summaryrefslogtreecommitdiff
path: root/include/linux/kernel.h
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2021-04-13 10:24:08 -0400
committerKent Overstreet <kent.overstreet@gmail.com>2021-04-13 10:24:15 -0400
commit967c8704989f6194dc40ea884b5d0f713d4fb74c (patch)
treed4a317ed7405e3f4174604a6c5450d44e98af923 /include/linux/kernel.h
parentb422ff58ba8eedcfef3b67b66468660f07b0cfc1 (diff)
Update bcachefs sources to 8eca47e4d5 bcachefs: Improved check_directory_structure()
Diffstat (limited to 'include/linux/kernel.h')
-rw-r--r--include/linux/kernel.h43
1 files changed, 42 insertions, 1 deletions
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 4b45306d..44910d32 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -12,7 +12,48 @@
#include <linux/byteorder.h>
#include <linux/compiler.h>
-#define IS_ENABLED(opt) 0
+#define __ARG_PLACEHOLDER_1 0,
+#define __take_second_arg(__ignored, val, ...) val
+
+#define __and(x, y) ___and(x, y)
+#define ___and(x, y) ____and(__ARG_PLACEHOLDER_##x, y)
+#define ____and(arg1_or_junk, y) __take_second_arg(arg1_or_junk y, 0)
+
+#define __or(x, y) ___or(x, y)
+#define ___or(x, y) ____or(__ARG_PLACEHOLDER_##x, y)
+#define ____or(arg1_or_junk, y) __take_second_arg(arg1_or_junk 1, y)
+
+#define __is_defined(x) ___is_defined(x)
+#define ___is_defined(val) ____is_defined(__ARG_PLACEHOLDER_##val)
+#define ____is_defined(arg1_or_junk) __take_second_arg(arg1_or_junk 1, 0)
+
+/*
+ * 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) __is_defined(option)
+
+/*
+ * IS_MODULE(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'm', 0
+ * otherwise.
+ */
+#define IS_MODULE(option) __is_defined(option##_MODULE)
+
+/*
+ * IS_REACHABLE(CONFIG_FOO) evaluates to 1 if the currently compiled
+ * code can call a function defined in code compiled based on CONFIG_FOO.
+ * This is similar to IS_ENABLED(), but returns false when invoked from
+ * built-in code when CONFIG_FOO is set to 'm'.
+ */
+#define IS_REACHABLE(option) __or(IS_BUILTIN(option), \
+ __and(IS_MODULE(option), __is_defined(MODULE)))
+
+/*
+ * IS_ENABLED(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y' or 'm',
+ * 0 otherwise.
+ */
+#define IS_ENABLED(option) __or(IS_BUILTIN(option), IS_MODULE(option))
#define EXPORT_SYMBOL(sym)
#define U8_MAX ((u8)~0U)