From c2b9be12f577fd2232fb34118f5be0e66b66f650 Mon Sep 17 00:00:00 2001 From: Kai Vehmanen Date: Wed, 18 Sep 2024 15:31:29 +0300 Subject: [PATCH] rtos: branch compiler_attributes.h for XTOS and Zephyr Introduce a separate file for Zephyr compiler_attributes.h and move all Zephyr-specific definitions to this file. This is a prerequisite to build with CONFIG_SOF_ZEPHYR_STRICT_HEADERS=y. Link: https://github.com/thesofproject/sof/issues/9015 Signed-off-by: Kai Vehmanen --- xtos/include/sof/compiler_attributes.h | 18 +++--------- zephyr/include/sof/compiler_attributes.h | 36 ++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 14 deletions(-) create mode 100644 zephyr/include/sof/compiler_attributes.h diff --git a/xtos/include/sof/compiler_attributes.h b/xtos/include/sof/compiler_attributes.h index 30ccaff1fe15..1b28e5ebad50 100644 --- a/xtos/include/sof/compiler_attributes.h +++ b/xtos/include/sof/compiler_attributes.h @@ -5,14 +5,8 @@ * Author: Karol Trzcinski */ -#ifdef __ZEPHYR__ - -#include - -/* Get __sparse_cache and __sparse_force definitions if __CHECKER__ is defined */ -#include - -#else +#ifndef __SOF_COMPILER_ATTRIBUTES_H__ +#define __SOF_COMPILER_ATTRIBUTES_H__ #define __sparse_cache #define __sparse_force @@ -25,8 +19,6 @@ #define __unused __attribute__((unused)) #endif -#endif - #ifndef __aligned #define __aligned(x) __attribute__((__aligned__(x))) #endif @@ -44,11 +36,9 @@ */ #if ((defined(__GNUC__) && (__GNUC__ >= 7)) || \ (defined(__clang__) && (__clang_major__ >= 10))) && !defined(__CHECKER__) - #define COMPILER_FALLTHROUGH __attribute__((fallthrough)) - #else - #define COMPILER_FALLTHROUGH /* fallthrough */ - #endif + +#endif /* __SOF_COMPILER_ATTRIBUTES_H__ */ diff --git a/zephyr/include/sof/compiler_attributes.h b/zephyr/include/sof/compiler_attributes.h new file mode 100644 index 000000000000..0003c05234fb --- /dev/null +++ b/zephyr/include/sof/compiler_attributes.h @@ -0,0 +1,36 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * + * Copyright(c) 2024 Intel Corporation. + */ + +#ifndef __SOF_COMPILER_ATTRIBUTES_H__ +#define __SOF_COMPILER_ATTRIBUTES_H__ + +#include + +/* Get __sparse_cache and __sparse_force definitions if __CHECKER__ is defined */ +#include + +#ifndef __aligned +#define __aligned(x) __attribute__((__aligned__(x))) +#endif + +#ifndef __section +#define __section(x) __attribute__((section(x))) +#endif + +/* The fallthrough attribute is supported since GCC 7.0 + * and Clang 10.0.0. + * + * Note that Clang sets __GNUC__ == 4 so the GCC version + * test will not be true here, and must go through + * the Clang version test. + */ +#if ((defined(__GNUC__) && (__GNUC__ >= 7)) || \ + (defined(__clang__) && (__clang_major__ >= 10))) && !defined(__CHECKER__) +#define COMPILER_FALLTHROUGH __attribute__((fallthrough)) +#else +#define COMPILER_FALLTHROUGH /* fallthrough */ +#endif + +#endif /* __SOF_COMPILER_ATTRIBUTES_H__ */