Zephyr API Documentation 4.0.0-rc2
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
util_macro.h File Reference

Macro utilities. More...

Go to the source code of this file.

Macros

#define BIT(n)
 Unsigned integer with bit position n set (signed in assembly language).
 
#define BIT64(_n)
 64-bit unsigned integer with bit position _n set.
 
#define WRITE_BIT(var, bit, set)
 Set or clear a bit depending on a boolean value.
 
#define BIT_MASK(n)
 Bit mask with bits 0 through n-1 (inclusive) set, or 0 if n is 0.
 
#define BIT64_MASK(n)
 64-bit bit mask with bits 0 through n-1 (inclusive) set, or 0 if n is 0.
 
#define IS_POWER_OF_TWO(x)
 Check if a x is a power of two.
 
#define IS_SHIFTED_BIT_MASK(m, s)
 Check if bits are set continuously from the specified bit.
 
#define IS_BIT_MASK(m)
 Check if bits are set continuously from the LSB.
 
#define LSB_GET(value)
 Extract the Least Significant Bit from value.
 
#define FIELD_GET(mask, value)
 Extract a bitfield element from value corresponding to the field mask mask.
 
#define FIELD_PREP(mask, value)
 Prepare a bitfield element using value with mask representing its field position and width.
 
#define IS_ENABLED(config_macro)
 Check for macro definition in compiler-visible expressions.
 
#define COND_CODE_1(_flag, _if_1_code, _else_code)
 Insert code depending on whether _flag expands to 1 or not.
 
#define COND_CODE_0(_flag, _if_0_code, _else_code)
 Like COND_CODE_1() except tests if _flag is 0.
 
#define IF_ENABLED(_flag, _code)
 Insert code if _flag is defined and equals 1.
 
#define IF_DISABLED(_flag, _code)
 Insert code if _flag is not defined as 1.
 
#define IS_EMPTY(...)
 Check if a macro has a replacement expression.
 
#define IS_EQ(a, b)
 Like a == b, but does evaluation and short-circuiting at C preprocessor time.
 
#define LIST_DROP_EMPTY(...)
 Remove empty arguments from list.
 
#define EMPTY
 Macro with an empty expansion.
 
#define IDENTITY(V)
 Macro that expands to its argument.
 
#define GET_ARG_N(N, ...)
 Get nth argument from argument list.
 
#define GET_ARGS_LESS_N(N, ...)
 Strips n first arguments from the argument list.
 
#define UTIL_OR(a, b)
 Like a || b, but does evaluation and short-circuiting at C preprocessor time.
 
#define UTIL_AND(a, b)
 Like a && b, but does evaluation and short-circuiting at C preprocessor time.
 
#define UTIL_INC(x)
 UTIL_INC(x) for an integer literal x from 0 to 4095 expands to an integer literal whose value is x+1.
 
#define UTIL_DEC(x)
 UTIL_DEC(x) for an integer literal x from 0 to 4095 expands to an integer literal whose value is x-1.
 
#define UTIL_X2(y)
 UTIL_X2(y) for an integer literal y from 0 to 4095 expands to an integer literal whose value is 2y.
 
#define LISTIFY(LEN, F, sep, ...)
 Generates a sequence of code with configurable separator.
 
#define FOR_EACH(F, sep, ...)
 Call a macro F on each provided argument with a given separator between each call.
 
#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.
 
#define FOR_EACH_IDX(F, sep, ...)
 Call macro F on each provided argument, with the argument's index as an additional parameter.
 
#define FOR_EACH_FIXED_ARG(F, sep, fixed_arg, ...)
 Call macro F on each provided argument, with an additional fixed argument as a parameter.
 
#define FOR_EACH_IDX_FIXED_ARG(F, sep, fixed_arg, ...)
 Calls macro F for each variable argument with an index and fixed argument.
 
#define REVERSE_ARGS(...)
 Reverse arguments order.
 
#define NUM_VA_ARGS_LESS_1(...)
 Number of arguments in the variable arguments list minus one.
 
#define NUM_VA_ARGS(...)
 Number of arguments in the variable arguments list.
 
#define MACRO_MAP_CAT(...)
 Mapping macro that pastes results together.
 
#define MACRO_MAP_CAT_N(N, ...)
 Mapping macro that pastes a fixed number of results together.
 

Detailed Description

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>