#defineZYAN_ABS(a)(((a)<0)?-(a):(a))
Returns the absolute value of a.
Parametersa The value.
Returns
The absolute value of a.
#defineZYAN_ALIGN_DOWN(x,align)(((x)-1)&~((align)-1))
Aligns the value to the nearest given alignment boundary (by rounding it down).
Parametersx The value.
align The desired alignment.
Returns
The aligned value.
Note that this macro only works for powers of 2.
#defineZYAN_ALIGN_UP(x,align)(((x)+(align)-1)&~((align)-1))
Aligns the value to the nearest given alignment boundary (by rounding it up).
Parametersx The value.
align The desired alignment.
Returns
The aligned value.
Note that this macro only works for powers of 2.
#defineZYAN_ARRAY_LENGTH(a)(sizeof(a)/sizeof((a)[0]))
Returns the length (number of elements) of an array.
Parametersa The name of the array.
Returns
The number of elements of the given array.
#defineZYAN_ASSERT(condition)assert(condition)
Runtime debug assertion.
#defineZYAN_BITFIELD(x):x
Declares a bitfield.
Parametersx The size (in bits) of the bitfield.
#defineZYAN_BITS_TO_REPRESENT(n)Value:.PP
( \
ZYAN_NEEDS_BIT(n, 0) + ZYAN_NEEDS_BIT(n, 1) + \
ZYAN_NEEDS_BIT(n, 2) + ZYAN_NEEDS_BIT(n, 3) + \
ZYAN_NEEDS_BIT(n, 4) + ZYAN_NEEDS_BIT(n, 5) + \
ZYAN_NEEDS_BIT(n, 6) + ZYAN_NEEDS_BIT(n, 7) + \
ZYAN_NEEDS_BIT(n, 8) + ZYAN_NEEDS_BIT(n, 9) + \
ZYAN_NEEDS_BIT(n, 10) + ZYAN_NEEDS_BIT(n, 11) + \
ZYAN_NEEDS_BIT(n, 12) + ZYAN_NEEDS_BIT(n, 13) + \
ZYAN_NEEDS_BIT(n, 14) + ZYAN_NEEDS_BIT(n, 15) + \
ZYAN_NEEDS_BIT(n, 16) + ZYAN_NEEDS_BIT(n, 17) + \
ZYAN_NEEDS_BIT(n, 18) + ZYAN_NEEDS_BIT(n, 19) + \
ZYAN_NEEDS_BIT(n, 20) + ZYAN_NEEDS_BIT(n, 21) + \
ZYAN_NEEDS_BIT(n, 22) + ZYAN_NEEDS_BIT(n, 23) + \
ZYAN_NEEDS_BIT(n, 24) + ZYAN_NEEDS_BIT(n, 25) + \
ZYAN_NEEDS_BIT(n, 26) + ZYAN_NEEDS_BIT(n, 27) + \
ZYAN_NEEDS_BIT(n, 28) + ZYAN_NEEDS_BIT(n, 29) + \
ZYAN_NEEDS_BIT(n, 30) + ZYAN_NEEDS_BIT(n, 31) \
)
#defineZYAN_DIV64(n,divisor)(n/=divisor)
Divide the 64bit integer value by the given divisor.
Parametersn Variable containing the dividend that will be updated with the result of the division.
divisor The divisor.
#defineZYAN_FALLTHROUGH
Intentional fallthrough.
#defineZYAN_IS_ALIGNED_TO(x,align)(((x)&((align)-1))==0)
Checks, if the given value is properly aligned.
Note that this macro only works for powers of 2.
#defineZYAN_IS_POWER_OF_2(x)(((x)&((x)-1))==0)
Checks, if the given value is a power of 2.
Parametersx The value.
Returns
ZYAN_TRUE, if the given value is a power of 2 or ZYAN_FALSE, if not.
Note that this macro always returns ZYAN_TRUE for x == 0.
#defineZYAN_MACRO_CONCAT(x,y)x##y
Concatenates two values using the stringify operator (##).
Parametersx The first value.
y The second value.
Returns
The combined string of the given values.
#defineZYAN_MACRO_CONCAT_EXPAND(x,y)ZYAN_MACRO_CONCAT(x,y)
Concatenates two values using the stringify operator (##) and expands the value to be used in another
macro.
Parametersx The first value.
y The second value.
Returns
The combined string of the given values.
#defineZYAN_MAX(a,b)(((a)>(b))?(a):(b))
Returns the bigger value of a or b.
Parametersa The first value.
b The second value.
Returns
The bigger value of a or b.
#defineZYAN_MIN(a,b)(((a)<(b))?(a):(b))
Returns the smaller value of a or b.
Parametersa The first value.
b The second value.
Returns
The smaller value of a or b.
#defineZYAN_PRINTF_ATTR(format_index,first_to_check)
Decorator for printf-style functions.
Parametersformat_index The 1-based index of the format string parameter.
first_to_check The 1-based index of the format arguments parameter.
#defineZYAN_REQUIRES_LIBC
Marks functions that require libc (cannot be used with ZYAN_NO_LIBC).
#defineZYAN_STATIC_ASSERT(x)typedefintZYAN_MACRO_CONCAT_EXPAND(ZYAN_SASSERT_,__COUNTER__)[(x)?1:-1]
Compiler-time assertion.
#defineZYAN_UNREACHABLEfor(;;)
Marks the current code path as unreachable.
#defineZYAN_UNUSED(x)(void)(x)
Marks the specified parameter as unused.
Parametersx The name of the unused parameter.
#defineZYAN_WPRINTF_ATTR(format_index,first_to_check)
Decorator for wprintf-style functions.
Parametersformat_index The 1-based index of the format string parameter.
first_to_check The 1-based index of the format arguments parameter.
#defineZYCORE_EXPORTZYAN_DLLIMPORT
Symbol is exported in shared library builds.
#defineZYCORE_NO_EXPORT
Symbol is not exported and for internal use only.