1 
2 #ifndef __CDEFS_H__
3 #define __CDEFS_H__
4 
5 #include <stddef.h>
6 
7 #define PACKED		__attribute__((__packed__))
8 #define PERCORE		__attribute__((section(".data.percore")))
9 
10 #define INLINE		inline
11 #define ALWAYS_INLINE	__attribute__((__always_inline__))
12 
13 #define NO_RETURN	__attribute__((noreturn))
14 #define UNREACHABLE	__builtin_unreachable
15 
16 #define UNUSED		__attribute__((unused))
17 
18 #define ROUNDUP(_x, _n) (((_x) + (_n) - 1) & ~((_n) - 1))
19 
20 #define __MALLOC	__attribute__((__malloc__))
21 
22 #if __has_extension(c_thread_safety_attributes)
23 #define __NO_LOCK_ANALYSIS	__attribute__((no_thread_safety_analysis))
24 #define __LOCKABLE		__attribute__((lockable))
25 #define __LOCK_EX(_x)		__attribute__((exclusive_lock_function(_x)))
26 #define __TRYLOCK_EX(_x)	__attribute__((exclusive_trylock_function(_x)))
27 #define __UNLOCK_EX(_x)		__attribute__((unlock_function(_x)))
28 #define __LOCK_EX_ASSERT(_x)	__attribute__((assert_exclusive_lock(_x)))
29 #define __GUARDED_BY(_x)	__attribute__((guarded_by(_x)))
30 #else
31 #define __NO_LOCK_ANALYSIS
32 #define __LOCKABLE
33 #define __LOCK_EX(_x)
34 #define __TRYLOCK_EX(_x)
35 #define __UNLOCK_EX(_x)
36 #define __LOCK_EX_ASSERT(_x)
37 #define __GUARDED_BY(_x)
38 #endif
39 
40 #define __hidden	__attribute__((__visibility__("hidden")))
41 
42 #define __printflike(_fmt, _var) __attribute__((__format__(__printf__, _fmt, _var)))
43 
44 #endif /* __CDEFS_H__ */
45 
46