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) 2019 Intel Corporation. All rights reserved.
4 *
5 * Author: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
6 */
7
8#ifndef __SOF_COMPILER_ATTRIBUTES_H__
9#define __SOF_COMPILER_ATTRIBUTES_H__
10
11#define __sparse_cache
12#define __sparse_force
13
14#ifndef __packed
15#define __packed __attribute__((packed))
16#endif
17
18#ifndef __unused
19#define __unused __attribute__((unused))
20#endif
21
22#ifndef __maybe_unused
23#define __maybe_unused __attribute__((unused))
24#endif
25
26#ifndef __aligned
27#define __aligned(x) __attribute__((__aligned__(x)))
28#endif
29
30#ifndef __section
31#define __section(x) __attribute__((section(x)))
32#endif
33
34/* The fallthrough attribute is supported since GCC 7.0
35 * and Clang 10.0.0.
36 *
37 * Note that Clang sets __GNUC__ == 4 so the GCC version
38 * test will not be true here, and must go through
39 * the Clang version test.
40 */
41#if ((defined(__GNUC__) && (__GNUC__ >= 7)) || \
42 (defined(__clang__) && (__clang_major__ >= 10))) && !defined(__CHECKER__)
43#define COMPILER_FALLTHROUGH __attribute__((fallthrough))
44#else
45#define COMPILER_FALLTHROUGH /* fallthrough */
46#endif
47
48#endif /* __SOF_COMPILER_ATTRIBUTES_H__ */