.TH "include/Zycore/Defines.h" 3 "Version 1.5.0.0" "Zycore" \" -*- nroff -*- .ad l .nh .SH NAME include/Zycore/Defines.h .SH SYNOPSIS .br .PP \fC#include \fP .br .SS "Macros" .in +1c .ti -1c .RI "#define \fBZYAN_MACRO_CONCAT\fP(x, y) x ## y" .br .ti -1c .RI "#define \fBZYAN_MACRO_CONCAT_EXPAND\fP(x, y) \fBZYAN_MACRO_CONCAT\fP(x, y)" .br .ti -1c .RI "#define \fBZYAN_UNKNOWN_COMPILER\fP" .br .ti -1c .RI "#define \fBZYAN_UNKNOWN_PLATFORM\fP" .br .ti -1c .RI "#define \fBZYAN_USER\fP" .br .ti -1c .RI "#define \fBZYAN_RELEASE\fP" .br .ti -1c .RI "#define \fBZYAN_DEPRECATED\fP" .br .ti -1c .RI "#define \fBZYAN_DLLEXPORT\fP" .br .ti -1c .RI "#define \fBZYAN_DLLIMPORT\fP" .br .ti -1c .RI "#define \fBZYCORE_EXPORT\fP ZYAN_DLLIMPORT" .br .ti -1c .RI "#define \fBZYCORE_NO_EXPORT\fP" .br .ti -1c .RI "#define \fBZYAN_NO_SANITIZE\fP(what)" .br .ti -1c .RI "#define \fBZYAN_INLINE\fP static inline" .br .ti -1c .RI "#define \fBZYAN_NOINLINE\fP" .br .ti -1c .RI "#define \fBZYAN_ASSERT\fP(condition) assert(condition)" .br .ti -1c .RI "#define \fBZYAN_STATIC_ASSERT\fP(x) typedef int \fBZYAN_MACRO_CONCAT_EXPAND\fP(ZYAN_SASSERT_, __COUNTER__) [(x) ? 1 : \-1]" .br .ti -1c .RI "#define \fBZYAN_UNREACHABLE\fP for(;;)" .br .ti -1c .RI "#define \fBZYAN_UNUSED\fP(x) (void)(x)" .br .ti -1c .RI "#define \fBZYAN_FALLTHROUGH\fP" .br .ti -1c .RI "#define \fBZYAN_BITFIELD\fP(x) : x" .br .ti -1c .RI "#define \fBZYAN_REQUIRES_LIBC\fP" .br .ti -1c .RI "#define \fBZYAN_PRINTF_ATTR\fP(format_index, first_to_check)" .br .ti -1c .RI "#define \fBZYAN_WPRINTF_ATTR\fP(format_index, first_to_check)" .br .ti -1c .RI "#define \fBZYAN_ARRAY_LENGTH\fP(a) (sizeof(a) / sizeof((a)[0]))" .br .ti -1c .RI "#define \fBZYAN_MIN\fP(a, b) (((a) < (b)) ? (a) : (b))" .br .ti -1c .RI "#define \fBZYAN_MAX\fP(a, b) (((a) > (b)) ? (a) : (b))" .br .ti -1c .RI "#define \fBZYAN_ABS\fP(a) (((a) < 0) ? \-(a) : (a))" .br .ti -1c .RI "#define \fBZYAN_IS_POWER_OF_2\fP(x) (((x) & ((x) \- 1)) == 0)" .br .ti -1c .RI "#define \fBZYAN_IS_ALIGNED_TO\fP(x, align) (((x) & ((align) \- 1)) == 0)" .br .ti -1c .RI "#define \fBZYAN_ALIGN_UP\fP(x, align) (((x) + (align) \- 1) & ~((align) \- 1))" .br .ti -1c .RI "#define \fBZYAN_ALIGN_DOWN\fP(x, align) (((x) \- 1) & ~((align) \- 1))" .br .ti -1c .RI "#define \fBZYAN_DIV64\fP(n, divisor) (n /= divisor)" .br .ti -1c .RI "#define \fBZYAN_NEEDS_BIT\fP(n, b) (((unsigned long)(n) >> (b)) > 0)" .br .ti -1c .RI "#define \fBZYAN_BITS_TO_REPRESENT\fP(n)" .br .in -1c .SH "Detailed Description" .PP General helper and platform detection macros\&. .SH "Macro Definition Documentation" .PP .SS "#define ZYAN_ABS(a) (((a) < 0) ? \-(a) : (a))" Returns the absolute value of \fCa\fP\&. .PP \fBParameters\fP .RS 4 \fIa\fP The value\&. .RE .PP \fBReturns\fP .RS 4 The absolute value of \fCa\fP\&. .RE .PP .SS "#define ZYAN_ALIGN_DOWN(x, align) (((x) \- 1) & ~((align) \- 1))" Aligns the value to the nearest given alignment boundary (by rounding it down)\&. .PP \fBParameters\fP .RS 4 \fIx\fP The value\&. .br \fIalign\fP The desired alignment\&. .RE .PP \fBReturns\fP .RS 4 The aligned value\&. .RE .PP Note that this macro only works for powers of 2\&. .SS "#define ZYAN_ALIGN_UP(x, align) (((x) + (align) \- 1) & ~((align) \- 1))" Aligns the value to the nearest given alignment boundary (by rounding it up)\&. .PP \fBParameters\fP .RS 4 \fIx\fP The value\&. .br \fIalign\fP The desired alignment\&. .RE .PP \fBReturns\fP .RS 4 The aligned value\&. .RE .PP Note that this macro only works for powers of 2\&. .SS "#define ZYAN_ARRAY_LENGTH(a) (sizeof(a) / sizeof((a)[0]))" Returns the length (number of elements) of an array\&. .PP \fBParameters\fP .RS 4 \fIa\fP The name of the array\&. .RE .PP \fBReturns\fP .RS 4 The number of elements of the given array\&. .RE .PP .SS "#define ZYAN_ASSERT(condition) assert(condition)" Runtime debug assertion\&. .SS "#define ZYAN_BITFIELD(x) : x" Declares a bitfield\&. .PP \fBParameters\fP .RS 4 \fIx\fP The size (in bits) of the bitfield\&. .RE .PP .SS "#define ZYAN_BITS_TO_REPRESENT(n)" \fBValue:\fP.PP .nf ( \\ 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) \\ ) .fi .SS "#define ZYAN_DIV64(n, divisor) (n /= divisor)" Divide the 64bit integer value by the given divisor\&. .PP \fBParameters\fP .RS 4 \fIn\fP Variable containing the dividend that will be updated with the result of the division\&. .br \fIdivisor\fP The divisor\&. .RE .PP .SS "#define ZYAN_FALLTHROUGH" Intentional fallthrough\&. .SS "#define ZYAN_IS_ALIGNED_TO(x, align) (((x) & ((align) \- 1)) == 0)" Checks, if the given value is properly aligned\&. .PP Note that this macro only works for powers of 2\&. .SS "#define ZYAN_IS_POWER_OF_2(x) (((x) & ((x) \- 1)) == 0)" Checks, if the given value is a power of 2\&. .PP \fBParameters\fP .RS 4 \fIx\fP The value\&. .RE .PP \fBReturns\fP .RS 4 \fCZYAN_TRUE\fP, if the given value is a power of 2 or \fCZYAN_FALSE\fP, if not\&. .RE .PP Note that this macro always returns \fCZYAN_TRUE\fP for \fCx == 0\fP\&. .SS "#define ZYAN_MACRO_CONCAT(x, y) x ## y" Concatenates two values using the stringify operator (\fC##\fP)\&. .PP \fBParameters\fP .RS 4 \fIx\fP The first value\&. .br \fIy\fP The second value\&. .RE .PP \fBReturns\fP .RS 4 The combined string of the given values\&. .RE .PP .SS "#define ZYAN_MACRO_CONCAT_EXPAND(x, y) \fBZYAN_MACRO_CONCAT\fP(x, y)" Concatenates two values using the stringify operator (\fC##\fP) and expands the value to be used in another macro\&. .PP \fBParameters\fP .RS 4 \fIx\fP The first value\&. .br \fIy\fP The second value\&. .RE .PP \fBReturns\fP .RS 4 The combined string of the given values\&. .RE .PP .SS "#define ZYAN_MAX(a, b) (((a) > (b)) ? (a) : (b))" Returns the bigger value of \fCa\fP or \fCb\fP\&. .PP \fBParameters\fP .RS 4 \fIa\fP The first value\&. .br \fIb\fP The second value\&. .RE .PP \fBReturns\fP .RS 4 The bigger value of \fCa\fP or \fCb\fP\&. .RE .PP .SS "#define ZYAN_MIN(a, b) (((a) < (b)) ? (a) : (b))" Returns the smaller value of \fCa\fP or \fCb\fP\&. .PP \fBParameters\fP .RS 4 \fIa\fP The first value\&. .br \fIb\fP The second value\&. .RE .PP \fBReturns\fP .RS 4 The smaller value of \fCa\fP or \fCb\fP\&. .RE .PP .SS "#define ZYAN_PRINTF_ATTR(format_index, first_to_check)" Decorator for \fCprintf\fP-style functions\&. .PP \fBParameters\fP .RS 4 \fIformat_index\fP The 1-based index of the format string parameter\&. .br \fIfirst_to_check\fP The 1-based index of the format arguments parameter\&. .RE .PP .SS "#define ZYAN_REQUIRES_LIBC" Marks functions that require libc (cannot be used with \fCZYAN_NO_LIBC\fP)\&. .SS "#define ZYAN_STATIC_ASSERT(x) typedef int \fBZYAN_MACRO_CONCAT_EXPAND\fP(ZYAN_SASSERT_, __COUNTER__) [(x) ? 1 : \-1]" Compiler-time assertion\&. .SS "#define ZYAN_UNREACHABLE for(;;)" Marks the current code path as unreachable\&. .SS "#define ZYAN_UNUSED(x) (void)(x)" Marks the specified parameter as unused\&. .PP \fBParameters\fP .RS 4 \fIx\fP The name of the unused parameter\&. .RE .PP .SS "#define ZYAN_WPRINTF_ATTR(format_index, first_to_check)" Decorator for \fCwprintf\fP-style functions\&. .PP \fBParameters\fP .RS 4 \fIformat_index\fP The 1-based index of the format string parameter\&. .br \fIfirst_to_check\fP The 1-based index of the format arguments parameter\&. .RE .PP .SS "#define ZYCORE_EXPORT ZYAN_DLLIMPORT" Symbol is exported in shared library builds\&. .SS "#define ZYCORE_NO_EXPORT" Symbol is not exported and for internal use only\&. .SH "Author" .PP Generated automatically by Doxygen for Zycore from the source code\&.