* [PATCH] compiler: add support for fallthrough attribute
@ 2022-03-02 20:12 Ahmad Fatoum
2022-03-03 10:07 ` Sascha Hauer
0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2022-03-02 20:12 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
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>
---
include/linux/compiler_types.h | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h
index aa9cbcac7740..bc1b43aab0dc 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__ */
--
2.34.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] compiler: add support for fallthrough attribute
2022-03-02 20:12 [PATCH] compiler: add support for fallthrough attribute Ahmad Fatoum
@ 2022-03-03 10:07 ` Sascha Hauer
0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2022-03-03 10:07 UTC (permalink / raw)
To: Ahmad Fatoum; +Cc: barebox
On Wed, Mar 02, 2022 at 09:12:15PM +0100, Ahmad Fatoum wrote:
> 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>
> ---
> include/linux/compiler_types.h | 21 +++++++++++++++++++++
> 1 file changed, 21 insertions(+)
Applied, thanks
Sascha
>
> diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h
> index aa9cbcac7740..bc1b43aab0dc 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__ */
> --
> 2.34.1
>
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-03-03 10:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-02 20:12 [PATCH] compiler: add support for fallthrough attribute Ahmad Fatoum
2022-03-03 10:07 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox