xref: /DragonOS/kernel/src/common/compiler_attributes.h (revision c75089286e9d49cef8d039446bf570c1bd4d2550)
1 #pragma once
2 #include <common/stddef.h>
3 
4 // 当函数的返回值未被使用时,编译器抛出警告信息
5 #define __must_check __attribute__((__warn_unused_result__))
6 #define __force __attribute__((force))
7 // 无返回值的属性
8 #define __noreturn __attribute__((__noreturn__))
9 /*
10  * Optional: only supported since clang >= 14.0
11  *
12  *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-error-function-attribute
13  */
14 #if __has_attribute(__error__)
15 #define __compiletime_error(msg) __attribute__((__error__(msg)))
16 #else
17 #define __compiletime_error(msg)
18 #endif
19 
20 typedef uint8_t __attribute__((__may_alias__)) __u8_alias_t;
21 typedef uint16_t __attribute__((__may_alias__)) __u16_alias_t;
22 typedef uint32_t __attribute__((__may_alias__)) __u32_alias_t;
23 typedef uint64_t __attribute__((__may_alias__)) __u64_alias_t;