Zycore 1.5.2
Zyan Core Library for C
Loading...
Searching...
No Matches
Defines.h File Reference

General helper and platform detection macros. More...

#include <assert.h>
Include dependency graph for Defines.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define ZYAN_MACRO_CONCAT(x, y)
 Concatenates two values using the stringify operator (##).
#define ZYAN_MACRO_CONCAT_EXPAND(x, y)
 Concatenates two values using the stringify operator (##) and expands the value to be used in another macro.
#define ZYAN_HAS_INCLUDE(name)
 Checks if a header can be included.
#define ZYAN_HAS_BUILTIN(symbol)
 Checks if a symbol is a recognized built-in function.
#define ZYAN_UNKNOWN_COMPILER
#define ZYAN_UNKNOWN_PLATFORM
#define ZYAN_USER
#define ZYAN_ARCHITECTURE_WIDTH   32
#define ZYAN_LITTLE_ENDIAN   0
#define ZYAN_BIG_ENDIAN   1
#define ZYAN_ENDIAN   ZYAN_LITTLE_ENDIAN
#define ZYAN_RELEASE
#define ZYAN_DEPRECATED
#define ZYAN_DLLEXPORT
#define ZYAN_DLLIMPORT
#define ZYCORE_EXPORT   ZYAN_DLLIMPORT
 Symbol is exported in shared library builds.
#define ZYCORE_NO_EXPORT
 Symbol is not exported and for internal use only.
#define ZYAN_NO_SANITIZE(what)
#define ZYAN_INLINE   static inline
#define ZYAN_NOINLINE
#define ZYAN_ASSERT(condition)
 Runtime debug assertion.
#define ZYAN_STATIC_ASSERT(x)
 Compiler-time assertion.
#define ZYAN_UNREACHABLE   for(;;)
 Marks the current code path as unreachable.
#define ZYAN_UNUSED(x)
 Marks the specified parameter as unused.
#define ZYAN_FALLTHROUGH
 Intentional fallthrough.
#define ZYAN_BITFIELD(x)
 Declares a bitfield.
#define ZYAN_REQUIRES_LIBC
 Marks functions that require libc (cannot be used with ZYAN_NO_LIBC).
#define ZYAN_PRINTF_ATTR(format_index, first_to_check)
 Decorator for printf-style functions.
#define ZYAN_WPRINTF_ATTR(format_index, first_to_check)
 Decorator for wprintf-style functions.
#define ZYAN_ARRAY_LENGTH(a)
 Returns the length (number of elements) of an array.
#define ZYAN_MIN(a, b)
 Returns the smaller value of a or b.
#define ZYAN_MAX(a, b)
 Returns the bigger value of a or b.
#define ZYAN_ABS(a)
 Returns the absolute value of a.
#define ZYAN_IS_POWER_OF_2(x)
 Checks, if the given value is a power of 2.
#define ZYAN_IS_ALIGNED_TO(x, align)
 Checks, if the given value is properly aligned.
#define ZYAN_ALIGN_UP(x, align)
 Aligns the value to the nearest given alignment boundary (by rounding it up).
#define ZYAN_ALIGN_DOWN(x, align)
 Aligns the value to the nearest given alignment boundary (by rounding it down).
#define ZYAN_DIV64(n, divisor)
 Divide the 64bit integer value by the given divisor.
#define ZYAN_NEEDS_BIT(n, b)
#define ZYAN_BITS_TO_REPRESENT(n)

Detailed Description

General helper and platform detection macros.

Macro Definition Documentation

◆ ZYAN_ABS

#define ZYAN_ABS ( a)
Value:
(((a) < 0) ? -(a) : (a))

Returns the absolute value of a.

Parameters
aThe value.
Returns
The absolute value of a.

◆ ZYAN_ALIGN_DOWN

#define ZYAN_ALIGN_DOWN ( x,
align )
Value:
(((x) - 1) & ~((align) - 1))

Aligns the value to the nearest given alignment boundary (by rounding it down).

Parameters
xThe value.
alignThe desired alignment.
Returns
The aligned value.

Note that this macro only works for powers of 2.

◆ ZYAN_ALIGN_UP

#define ZYAN_ALIGN_UP ( x,
align )
Value:
(((x) + (align) - 1) & ~((align) - 1))

Aligns the value to the nearest given alignment boundary (by rounding it up).

Parameters
xThe value.
alignThe desired alignment.
Returns
The aligned value.

Note that this macro only works for powers of 2.

◆ ZYAN_ARCHITECTURE_WIDTH

#define ZYAN_ARCHITECTURE_WIDTH   32

◆ ZYAN_ARRAY_LENGTH

#define ZYAN_ARRAY_LENGTH ( a)
Value:
(sizeof(a) / sizeof((a)[0]))

Returns the length (number of elements) of an array.

Parameters
aThe name of the array.
Returns
The number of elements of the given array.

◆ ZYAN_ASSERT

#define ZYAN_ASSERT ( condition)
Value:
assert(condition)

Runtime debug assertion.

◆ ZYAN_BIG_ENDIAN

#define ZYAN_BIG_ENDIAN   1

◆ ZYAN_BITFIELD

#define ZYAN_BITFIELD ( x)
Value:
: x

Declares a bitfield.

Parameters
xThe size (in bits) of the bitfield.

◆ ZYAN_BITS_TO_REPRESENT

#define ZYAN_BITS_TO_REPRESENT ( n)
Value:
( \
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) \
)
#define ZYAN_NEEDS_BIT(n, b)
Definition Defines.h:616

◆ ZYAN_DEPRECATED

#define ZYAN_DEPRECATED

◆ ZYAN_DIV64

#define ZYAN_DIV64 ( n,
divisor )
Value:
((n) /= (divisor))

Divide the 64bit integer value by the given divisor.

Parameters
nVariable containing the dividend that will be updated with the result of the division.
divisorThe divisor.

◆ ZYAN_DLLEXPORT

#define ZYAN_DLLEXPORT

◆ ZYAN_DLLIMPORT

#define ZYAN_DLLIMPORT

◆ ZYAN_ENDIAN

#define ZYAN_ENDIAN   ZYAN_LITTLE_ENDIAN

◆ ZYAN_FALLTHROUGH

#define ZYAN_FALLTHROUGH

Intentional fallthrough.

◆ ZYAN_HAS_BUILTIN

#define ZYAN_HAS_BUILTIN ( symbol)
Value:
0

Checks if a symbol is a recognized built-in function.

Parameters
symbolFunction name.
Returns
True if symbol is known, false otherwise.

◆ ZYAN_HAS_INCLUDE

#define ZYAN_HAS_INCLUDE ( name)
Value:
0

Checks if a header can be included.

Parameters
nameHeader file name.
Returns
True if header exists, false if it doesn't or it's not possible to check.

◆ ZYAN_INLINE

#define ZYAN_INLINE   static inline

◆ ZYAN_IS_ALIGNED_TO

#define ZYAN_IS_ALIGNED_TO ( x,
align )
Value:
(((x) & ((align) - 1)) == 0)

Checks, if the given value is properly aligned.

Note that this macro only works for powers of 2.

◆ ZYAN_IS_POWER_OF_2

#define ZYAN_IS_POWER_OF_2 ( x)
Value:
(((x) & ((x) - 1)) == 0)

Checks, if the given value is a power of 2.

Parameters
xThe 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.

◆ ZYAN_LITTLE_ENDIAN

#define ZYAN_LITTLE_ENDIAN   0

◆ ZYAN_MACRO_CONCAT

#define ZYAN_MACRO_CONCAT ( x,
y )
Value:
x ## y

Concatenates two values using the stringify operator (##).

Parameters
xThe first value.
yThe second value.
Returns
The combined string of the given values.

◆ ZYAN_MACRO_CONCAT_EXPAND

#define ZYAN_MACRO_CONCAT_EXPAND ( x,
y )
Value:
#define ZYAN_MACRO_CONCAT(x, y)
Concatenates two values using the stringify operator (##).
Definition Defines.h:47

Concatenates two values using the stringify operator (##) and expands the value to be used in another macro.

Parameters
xThe first value.
yThe second value.
Returns
The combined string of the given values.

◆ ZYAN_MAX

#define ZYAN_MAX ( a,
b )
Value:
(((a) > (b)) ? (a) : (b))

Returns the bigger value of a or b.

Parameters
aThe first value.
bThe second value.
Returns
The bigger value of a or b.

◆ ZYAN_MIN

#define ZYAN_MIN ( a,
b )
Value:
(((a) < (b)) ? (a) : (b))

Returns the smaller value of a or b.

Parameters
aThe first value.
bThe second value.
Returns
The smaller value of a or b.

◆ ZYAN_NEEDS_BIT

#define ZYAN_NEEDS_BIT ( n,
b )
Value:
(((unsigned long)(n) >> (b)) > 0)

◆ ZYAN_NO_SANITIZE

#define ZYAN_NO_SANITIZE ( what)

◆ ZYAN_NOINLINE

#define ZYAN_NOINLINE

◆ ZYAN_PRINTF_ATTR

#define ZYAN_PRINTF_ATTR ( format_index,
first_to_check )

Decorator for printf-style functions.

Parameters
format_indexThe 1-based index of the format string parameter.
first_to_checkThe 1-based index of the format arguments parameter.

◆ ZYAN_RELEASE

#define ZYAN_RELEASE

◆ ZYAN_REQUIRES_LIBC

#define ZYAN_REQUIRES_LIBC

Marks functions that require libc (cannot be used with ZYAN_NO_LIBC).

◆ ZYAN_STATIC_ASSERT

#define ZYAN_STATIC_ASSERT ( x)
Value:
typedef int ZYAN_MACRO_CONCAT_EXPAND(ZYAN_SASSERT_, __COUNTER__) [(x) ? 1 : -1]
#define ZYAN_MACRO_CONCAT_EXPAND(x, y)
Concatenates two values using the stringify operator (##) and expands the value to be used in another...
Definition Defines.h:58

Compiler-time assertion.

◆ ZYAN_UNKNOWN_COMPILER

#define ZYAN_UNKNOWN_COMPILER

◆ ZYAN_UNKNOWN_PLATFORM

#define ZYAN_UNKNOWN_PLATFORM

◆ ZYAN_UNREACHABLE

#define ZYAN_UNREACHABLE   for(;;)

Marks the current code path as unreachable.

◆ ZYAN_UNUSED

#define ZYAN_UNUSED ( x)
Value:
(void)(x)

Marks the specified parameter as unused.

Parameters
xThe name of the unused parameter.

◆ ZYAN_USER

#define ZYAN_USER

◆ ZYAN_WPRINTF_ATTR

#define ZYAN_WPRINTF_ATTR ( format_index,
first_to_check )

Decorator for wprintf-style functions.

Parameters
format_indexThe 1-based index of the format string parameter.
first_to_checkThe 1-based index of the format arguments parameter.

◆ ZYCORE_EXPORT

#define ZYCORE_EXPORT   ZYAN_DLLIMPORT

Symbol is exported in shared library builds.

◆ ZYCORE_NO_EXPORT

#define ZYCORE_NO_EXPORT

Symbol is not exported and for internal use only.