blob: 71e7ff68147c2a6a7f4eb930d43fc98e5615228e [file] [log] [blame]
xiaohu.huange7678d12022-05-10 00:56:48 +08001/*
2 * Copyright (c) 2021-2022 Amlogic, Inc. All rights reserved.
3 *
4 * SPDX-License-Identifier: MIT
5 */
6
7#ifndef __GCC_COMPILER_ATTRIBUTES_H__
8#define __GCC_COMPILER_ATTRIBUTES_H__
9
xiaohu.huang63736972024-02-07 17:53:07 +080010#ifdef __cplusplus
11extern "C" {
12#endif
13
xiaohu.huange7678d12022-05-10 00:56:48 +080014#ifndef __weak
15#define __weak __attribute__((__weak__))
16#endif
17
xiaohu.huang63736972024-02-07 17:53:07 +080018#ifndef __packed
19#define __packed __attribute__((__packed__))
20#endif
21
22#ifndef __has_builtin
23#define __has_builtin(x) (0)
24#endif
25
xiaohu.huange7678d12022-05-10 00:56:48 +080026#ifndef __noinline
27#define __noinline __attribute__((noinline))
28#endif
29
xiaohu.huang63736972024-02-07 17:53:07 +080030#ifndef __inline
31#define __inline inline
32#endif
33
34#ifndef __static_inline
35#define __static_inline static inline
36#endif
37
38#ifndef __static_forceinline
39#define __static_forceinline __attribute__((always_inline)) static inline
40#endif
41
42#ifndef __no_return
43#define __no_return __attribute__((__noreturn__))
44#endif
45
46#ifndef __used
47#define __used __attribute__((used))
48#endif
49
50#ifndef __vector_size
51#define __vector_size(x) __attribute__((vector_size(x)))
52#endif
53
54#ifndef __packed_struct
55#define __packed_struct struct __attribute__((packed, aligned(1)))
56#endif
57
58#ifndef __packed_union
59#define __packed_union union __attribute__((packed, aligned(1)))
60#endif
61
62#ifndef __aligned
63#define __aligned(x) __attribute__((aligned(x)))
64#endif
65
66#ifndef __restrict
67#define __restrict __restrict
68#endif
69
70#ifndef __compiler_barrier
71#define __compiler_barrier() __asm volatile("":::"memory")
72#endif
73
74#ifndef __usually
75#define __usually(exp) __builtin_expect((exp), 1)
76#endif
77
78#ifndef __rarely
79#define __rarely(exp) __builtin_expect((exp), 0)
80#endif
81
82#ifndef __interrupt
83#define __interrupt __attribute__((interrupt))
84#endif
85
86#ifndef __machine_interrupt
87#define __machine_interrupt __attribute__((interrupt ("machine")))
88#endif
89
90#ifndef __supvisor_interrupt
91#define __supvisor_interrupt __attribute__((interrupt ("supervisor")))
92#endif
93
94#ifndef __user_interrupt
95#define __user_interrupt __attribute__((interrupt ("user")))
96#endif
97
98#ifdef __cplusplus
99}
xiaohu.huange7678d12022-05-10 00:56:48 +0800100#endif
101
102#endif /* __GCC_COMPILER_ATTRIBUTES_H__ */