Sound Open Firmware
Loading...
Searching...
No Matches
compiler_attributes.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-3-Clause
2 *
3 * Copyright(c) 2024 Intel Corporation.
4 */
5
6#ifndef __SOF_COMPILER_ATTRIBUTES_H__
7#define __SOF_COMPILER_ATTRIBUTES_H__
8
9#include <zephyr/toolchain.h>
10
11/* Get __sparse_cache and __sparse_force definitions if __CHECKER__ is defined */
12#include <zephyr/debug/sparse.h>
13
14#ifndef __aligned
15#define __aligned(x) __attribute__((__aligned__(x)))
16#endif
17
18#ifndef __section
19#define __section(x) __attribute__((section(x)))
20#endif
21
22/* The fallthrough attribute is supported since GCC 7.0
23 * and Clang 10.0.0.
24 *
25 * Note that Clang sets __GNUC__ == 4 so the GCC version
26 * test will not be true here, and must go through
27 * the Clang version test.
28 */
29#if ((defined(__GNUC__) && (__GNUC__ >= 7)) || \
30 (defined(__clang__) && (__clang_major__ >= 10))) && !defined(__CHECKER__)
31#define COMPILER_FALLTHROUGH __attribute__((fallthrough))
32#else
33#define COMPILER_FALLTHROUGH /* fallthrough */
34#endif
35
36#endif /* __SOF_COMPILER_ATTRIBUTES_H__ */