Zephyr API Documentation
2.7.0-rc2
A Scalable Open Source RTOS
|
Macro utilities. More...
#include <sys/util_internal.h>
Go to the source code of this file.
Macros | |
#define | BIT(n) (1UL << (n)) |
Unsigned integer with bit position n set (signed in assembly language). More... | |
#define | BIT64(_n) (1ULL << (_n)) |
64-bit unsigned integer with bit position _n set. More... | |
#define | WRITE_BIT(var, bit, set) ((var) = (set) ? ((var) | BIT(bit)) : ((var) & ~BIT(bit))) |
Set or clear a bit depending on a boolean value. More... | |
#define | BIT_MASK(n) (BIT(n) - 1UL) |
Bit mask with bits 0 through n-1 (inclusive) set, or 0 if n is 0. More... | |
#define | BIT64_MASK(n) (BIT64(n) - 1ULL) |
64-bit bit mask with bits 0 through n-1 (inclusive) set, or 0 if n is 0. More... | |
#define | IS_ENABLED(config_macro) Z_IS_ENABLED1(config_macro) |
Check for macro definition in compiler-visible expressions. More... | |
#define | COND_CODE_1(_flag, _if_1_code, _else_code) Z_COND_CODE_1(_flag, _if_1_code, _else_code) |
Insert code depending on whether _flag expands to 1 or not. More... | |
#define | COND_CODE_0(_flag, _if_0_code, _else_code) Z_COND_CODE_0(_flag, _if_0_code, _else_code) |
Like COND_CODE_1() except tests if _flag is 0. More... | |
#define | IF_ENABLED(_flag, _code) COND_CODE_1(_flag, _code, ()) |
Insert code if _flag is defined and equals 1. More... | |
#define | IS_EMPTY(a) Z_IS_EMPTY_(a, 1, 0,) |
Check if a macro has a replacement expression. More... | |
#define | LIST_DROP_EMPTY(...) Z_LIST_DROP_FIRST(FOR_EACH(Z_LIST_NO_EMPTIES, (), __VA_ARGS__)) |
Remove empty arguments from list. More... | |
#define | EMPTY |
Macro with an empty expansion. More... | |
#define | IDENTITY(V) V |
Macro that expands to its argument. More... | |
#define | GET_ARG_N(N, ...) Z_GET_ARG_##N(__VA_ARGS__) |
Get nth argument from argument list. More... | |
#define | GET_ARGS_LESS_N(N, ...) Z_GET_ARGS_LESS_##N(__VA_ARGS__) |
Strips n first arguments from the argument list. More... | |
#define | UTIL_OR(a, b) COND_CODE_1(UTIL_BOOL(a), (a), (b)) |
Like a || b , but does evaluation and short-circuiting at C preprocessor time. More... | |
#define | UTIL_AND(a, b) COND_CODE_1(UTIL_BOOL(a), (b), (0)) |
Like a && b , but does evaluation and short-circuiting at C preprocessor time. More... | |
#define | UTIL_LISTIFY(LEN, F, ...) UTIL_CAT(Z_UTIL_LISTIFY_, LEN)(F, __VA_ARGS__) |
Generates a sequence of code. More... | |
#define | FOR_EACH(F, sep, ...) Z_FOR_EACH(F, sep, REVERSE_ARGS(__VA_ARGS__)) |
Call a macro F on each provided argument with a given separator between each call. More... | |
#define | FOR_EACH_NONEMPTY_TERM(F, term, ...) |
Like FOR_EACH(), but with a terminator instead of a separator, and drops empty elements from the argument list. More... | |
#define | FOR_EACH_IDX(F, sep, ...) Z_FOR_EACH_IDX(F, sep, REVERSE_ARGS(__VA_ARGS__)) |
Call macro F on each provided argument, with the argument's index as an additional parameter. More... | |
#define | FOR_EACH_FIXED_ARG(F, sep, fixed_arg, ...) Z_FOR_EACH_FIXED_ARG(F, sep, fixed_arg, REVERSE_ARGS(__VA_ARGS__)) |
Call macro F on each provided argument, with an additional fixed argument as a parameter. More... | |
#define | FOR_EACH_IDX_FIXED_ARG(F, sep, fixed_arg, ...) Z_FOR_EACH_IDX_FIXED_ARG(F, sep, fixed_arg, REVERSE_ARGS(__VA_ARGS__)) |
Calls macro F for each variable argument with an index and fixed argument. More... | |
#define | REVERSE_ARGS(...) Z_FOR_EACH_ENGINE(Z_FOR_EACH_EXEC, (,), Z_BYPASS, _, __VA_ARGS__) |
Reverse arguments order. More... | |
#define | NUM_VA_ARGS_LESS_1(...) |
Number of arguments in the variable arguments list minus one. More... | |
#define | MACRO_MAP_CAT(...) MACRO_MAP_CAT_(__VA_ARGS__) |
Mapping macro that pastes results together. More... | |
#define | MACRO_MAP_CAT_N(N, ...) MACRO_MAP_CAT_N_(N, __VA_ARGS__) |
Mapping macro that pastes a fixed number of results together. More... | |
Macro utilities.
Macro utilities are the public interface for C/C++ code and device tree related implementation. In general, C/C++ will include <sys/util.h> instead this file directly. For device tree implementation, this file should be include instead <sys/util_internal.h>