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 #ifdef __ZEPHYR__
9 
10 /* Get __sparse_cache and __sparse_force definitions if __CHECKER__ is defined */
11 #include <zephyr/debug/sparse.h>
12 
13 #else
14 
15 #define __sparse_cache
16 #define __sparse_force
17 
18 #ifndef __packed
19 #define __packed __attribute__((packed))
20 #endif
21 
22 #ifndef __unused
23 #define __unused __attribute__((unused))
24 #endif
25 
26 #endif
27 
28 #ifndef __aligned
29 #define __aligned(x) __attribute__((__aligned__(x)))
30 #endif
31 
32 #ifndef __section
33 #define __section(x) __attribute__((section(x)))
34 #endif
35 
36 /* The fallthrough attribute is supported since GCC 7.0
37  * and Clang 10.0.0.
38  *
39  * Note that Clang sets __GNUC__ == 4 so the GCC version
40  * test will not be true here, and must go through
41  * the Clang version test.
42  */
43 #if ((defined(__GNUC__) && (__GNUC__ >= 7)) || \
44      (defined(__clang__) && (__clang_major__ >= 10))) && !defined(__CHECKER__)
45 
46 #define COMPILER_FALLTHROUGH __attribute__((fallthrough))
47 
48 #else
49 
50 #define COMPILER_FALLTHROUGH  /* fallthrough */
51 
52 #endif
53