Various common macros used throughout the codebase
More...
|
file | cdefs.h |
| Definitions for builtin attributes and compiler directives.
|
|
|
#define | __noreturn __attribute__((__noreturn__)) |
| Identify a function that will never return.
|
|
#define | __pure __attribute__((__const__)) |
| Identify a function that has no side effects other than its return, and only uses its arguments for any work.
|
|
#define | __unused __attribute__((__unused__)) |
| Identify a function or variable that may be unused.
|
|
#define | __used __attribute__((used)) |
| Prevent a symbol from being removed from the binary.
|
|
#define | __weak __attribute__((weak)) |
| Identify a function or variable that may be overridden by another symbol.
|
|
#define | __dead2 __noreturn /* BSD compat */ |
| Alias for __noreturn.
|
|
#define | __pure2 __pure /* ditto */ |
| Alias for __pure.
|
|
#define | __likely(exp) |
| Directive to inform the compiler the condition is in the likely path.
|
|
#define | __unlikely(exp) |
| Directive to inform the compiler the condition is in the unlikely path.
|
|
#define | __deprecated __attribute__((deprecated)) |
| Mark something as deprecated.
|
|
#define | __depr(m) |
| Mark something as deprecated, with an informative message.
|
|
#define | __printflike(fmtarg, firstvararg) |
| Identify a function as accepting formatting like printf().
|
|
#define | __scanflike(fmtarg, firstvararg) |
| Identify a function as accepting formatting like scanf().
|
|
#define | __fallthrough /* Fall through */ |
|
#define | __always_inline inline __attribute__((__always_inline__)) |
| Ask the compiler to always inline a given function.
|
|
#define | __no_inline __attribute__((__noinline__)) |
| Ask the compiler to never inline a given function.
|
|
#define | __RESTRICT |
|
#define | __extension__ |
|
#define | inline __inline__ |
|
Various common macros used throughout the codebase
◆ __always_inline
#define __always_inline inline __attribute__((__always_inline__)) |
Ask the compiler to always inline a given function.
◆ __dead2
◆ __depr
Value:__attribute__((deprecated(m)))
Mark something as deprecated, with an informative message.
This should be used to warn users that a function/type/etc will be removed in a future version of KOS and to suggest an alternative that they can use instead.
- Parameters
-
m | A string literal that is included with the warning message at compile time. |
◆ __deprecated
#define __deprecated __attribute__((deprecated)) |
Mark something as deprecated.
This should be used to warn users that a function/type/etc will be removed in a future version of KOS.
◆ __extension__
◆ __fallthrough
#define __fallthrough /* Fall through */ |
◆ __likely
Value:__builtin_expect(!!(exp), 1)
Directive to inform the compiler the condition is in the likely path.
This can be used around conditionals or loops to help inform the compiler which path to optimize for as the common-case.
- Parameters
-
exp | Boolean expression which expected to be true. |
- See also
- __unlikely()
◆ __no_inline
#define __no_inline __attribute__((__noinline__)) |
Ask the compiler to never inline a given function.
◆ __noreturn
#define __noreturn __attribute__((__noreturn__)) |
Identify a function that will never return.
◆ __printflike
#define __printflike |
( |
| fmtarg, |
|
|
| firstvararg ) |
Value: __attribute__((__format__ (__printf__, fmtarg, firstvararg)))
Identify a function as accepting formatting like printf().
Using this macro allows GCC to typecheck calls to printf-like functions, which can aid in finding mistakes.
- Parameters
-
fmtarg | The argument number (1-based) of the format string. |
firstvararg | The argument number of the first vararg (the ...). |
◆ __pure
#define __pure __attribute__((__const__)) |
Identify a function that has no side effects other than its return, and only uses its arguments for any work.
◆ __pure2
#define __pure2 __pure /* ditto */ |
Alias for __pure.
For BSD compatibility.
◆ __RESTRICT
◆ __scanflike
#define __scanflike |
( |
| fmtarg, |
|
|
| firstvararg ) |
Value: __attribute__((__format__ (__scanf__, fmtarg, firstvararg)))
Identify a function as accepting formatting like scanf().
Using this macro allows GCC to typecheck calls to scanf-like functions, which can aid in finding mistakes.
- Parameters
-
fmtarg | The argument number (1-based) of the format string. |
firstvararg | The argument number of the first vararg (the ...). |
◆ __unlikely
#define __unlikely |
( |
| exp | ) |
|
Value:__builtin_expect(!!(exp), 0)
Directive to inform the compiler the condition is in the unlikely path.
This can be used around conditionals or loops to help inform the compiler which path to optimize against as the infrequent-case.
- Parameters
-
exp | Boolean expression which is expected to be false. |
- See also
- __likely()
◆ __unused
#define __unused __attribute__((__unused__)) |
Identify a function or variable that may be unused.
◆ __used
#define __used __attribute__((used)) |
Prevent a symbol from being removed from the binary.
◆ __weak
#define __weak __attribute__((weak)) |
Identify a function or variable that may be overridden by another symbol.
◆ inline
#define inline __inline__ |