Branch data Line data Source code
1 : : // SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
2 : : /* Copyright 2013-2019 IBM Corp. */
3 : :
4 : : #ifndef __COMPILER_H
5 : : #define __COMPILER_H
6 : :
7 : : #ifndef __ASSEMBLY__
8 : :
9 : : #include <stddef.h>
10 : :
11 : : /* Macros for various compiler bits and pieces */
12 : : #define __packed __attribute__((packed))
13 : : #define __align(x) __attribute__((__aligned__(x)))
14 : : #define __unused __attribute__((unused))
15 : : #define __used __attribute__((used))
16 : : #define __section(x) __attribute__((__section__(x)))
17 : : #define __noreturn __attribute__((noreturn))
18 : : /* not __const as this has a different meaning (const) */
19 : : #define __attrconst __attribute__((const))
20 : : #define __warn_unused_result __attribute__((warn_unused_result))
21 : : #define __noinline __attribute__((noinline))
22 : :
23 : : /*
24 : : * GCC 15 introduces errors for "unterminated-string-initialization", mark
25 : : * character arrays that are not intended to be null-terminated as
26 : : * 'nonstring', such as eye-catchers
27 : : */
28 : : #define __nonstring __attribute((nonstring))
29 : :
30 : : #if 0 /* Provided by gcc stddef.h */
31 : : #define offsetof(type,m) __builtin_offsetof(type,m)
32 : : #endif
33 : :
34 : : #define __nomcount __attribute__((no_instrument_function))
35 : :
36 : : /* Compiler barrier */
37 : 0 : static inline void barrier(void)
38 : : {
39 : 0 : asm volatile("" : : : "memory");
40 : 0 : }
41 : :
42 : : #endif /* __ASSEMBLY__ */
43 : :
44 : : /* Stringification macro */
45 : : #define __tostr(x) #x
46 : : #define tostr(x) __tostr(x)
47 : :
48 : :
49 : : #if __GNUC__ >= 11
50 : : /* Compiler workaround to avoid compiler optimization warnings
51 : : * when assigning constant address to pointer and using memory
52 : : * functions such as memcpy and memset
53 : : */
54 : : #define skiboot_constant_addr volatile
55 : : #else
56 : : #define skiboot_constant_addr
57 : : #endif
58 : :
59 : :
60 : : #endif /* __COMPILER_H */
|