summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorAhmad Fatoum <ahmad@a3f.at>2022-03-02 21:12:15 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2022-03-08 09:57:59 +0100
commitc77ed8d120be90a43845f785a8dc82d490d2bd10 (patch)
treebdd4380ab8bc034b69ecf0e21adc8dd5be5c92cd /include
parent9d6cce28e006798655add3b799ec6adb55b5564c (diff)
downloadbarebox-c77ed8d120be90a43845f785a8dc82d490d2bd10.tar.gz
barebox-c77ed8d120be90a43845f785a8dc82d490d2bd10.tar.xz
compiler: add support for fallthrough attribute
Use of it is enforced in Linux now, so code we'll port may contain it. Import the definition. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Link: https://lore.barebox.org/20220302201215.658986-1-ahmad@a3f.at Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include')
-rw-r--r--include/linux/compiler_types.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h
index aa9cbcac77..bc1b43aab0 100644
--- a/include/linux/compiler_types.h
+++ b/include/linux/compiler_types.h
@@ -112,6 +112,27 @@ struct ftrace_likely_data {
#define __deprecated
#define __deprecated_for_modules
+#ifndef __has_attribute
+#define __has_attribute(...) 0
+#endif
+
+/*
+ * Add the pseudo keyword 'fallthrough' so case statement blocks
+ * must end with any of these keywords:
+ * break;
+ * fallthrough;
+ * continue;
+ * goto <label>;
+ * return [expression];
+ *
+ * gcc: https://gcc.gnu.org/onlinedocs/gcc/Statement-Attributes.html#Statement-Attributes
+ */
+#if __has_attribute(__fallthrough__)
+# define fallthrough __attribute__((__fallthrough__))
+#else
+# define fallthrough do {} while (0) /* fallthrough */
+#endif
+
#endif /* __KERNEL__ */
#endif /* __ASSEMBLY__ */