DEFINES.H(3)

πŸ“¦
version 1.5.2 Β· 2 versions
, in ubuntu resolute, ubuntu stonking

πŸ’– include/Zycore/Defines.h πŸ’–

okay so bestie, this is a page from the Library Functions Manual, and it's all about include/Zycore/Defines.h β€” the little header of helper macros and platform-detection goodies for Zycore. it's giving foundation energy. ✨


🌈 NAME 🌈

include/Zycore/Defines.h β€” yes that's literally it, that's the name, she's self-titled, main character behavior πŸ’…


✨ SYNOPSIS ✨

#include <assert.h>

πŸŽ€ Macros πŸŽ€

here's the whole roster, no skipping, every single one:

#define ZYAN_MACRO_CONCAT(x,  y)
#define ZYAN_MACRO_CONCAT_EXPAND(x,  y)
#define ZYAN_UNKNOWN_COMPILER
#define ZYAN_UNKNOWN_PLATFORM
#define ZYAN_USER
#define ZYAN_RELEASE
#define ZYAN_DEPRECATED
#define ZYAN_DLLEXPORT
#define ZYAN_DLLIMPORT
#define ZYCORE_EXPORT   ZYAN_DLLIMPORT
#define ZYCORE_NO_EXPORT
#define ZYAN_NO_SANITIZE(what)
#define ZYAN_INLINE   static inline
#define ZYAN_NOINLINE
#define ZYAN_ASSERT(condition)
#define ZYAN_STATIC_ASSERT(x)
#define ZYAN_UNREACHABLE   for(;;)
#define ZYAN_UNUSED(x)
#define ZYAN_FALLTHROUGH
#define ZYAN_BITFIELD(x)
#define ZYAN_REQUIRES_LIBC
#define ZYAN_PRINTF_ATTR(format_index,  first_to_check)
#define ZYAN_WPRINTF_ATTR(format_index,  first_to_check)
#define ZYAN_ARRAY_LENGTH(a)
#define ZYAN_MIN(a,  b)
#define ZYAN_MAX(a,  b)
#define ZYAN_ABS(a)
#define ZYAN_IS_POWER_OF_2(x)
#define ZYAN_IS_ALIGNED_TO(x,  align)
#define ZYAN_ALIGN_UP(x,  align)
#define ZYAN_ALIGN_DOWN(x,  align)
#define ZYAN_DIV64(n,  divisor)
#define ZYAN_NEEDS_BIT(n,  b)
#define ZYAN_BITS_TO_REPRESENT(n)

πŸ¦‹ Detailed Description πŸ¦‹

no cap, it's just: General helper and platform detection macros. that's the whole vibe. πŸ’œ


πŸ‘‘ Macro Definition Documentation πŸ‘‘

alphabetical order, she's organized, we love that for her 🌸

#define ZYAN_ABS( a)

Value:

(((a) < 0) ? -(a) : (a))

returns the absolute value of a. (so like, if it's negative, we flip the attitude πŸ’…)

Parameters

  • a β€” the value.

Returns

  • the absolute value of a.

#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

  • x β€” the value.
  • align β€” the desired alignment.

Returns

  • the aligned value.
⚠️ note that this macro only works for powers of 2, bestie. don't try it on anything else, it will not slay.

#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

  • x β€” the value.
  • align β€” the desired alignment.

Returns

  • the aligned value.
⚠️ again: this macro only works for powers of 2. same rules, same consequences 🫢

#define ZYAN_ARRAY_LENGTH( a)

Value:

(sizeof(a) / sizeof((a)[0]))

returns the length (number of elements) of an array. iconic honestly.

Parameters

  • a β€” the name of the array.

Returns

  • the number of elements of the given array.

#define ZYAN_ASSERT( condition)

Value:

assert(condition)

runtime debug assertion. that's it, that's the whole thing 😌


#define ZYAN_BITFIELD( x)

Value:

: x

declares a bitfield.

Parameters

  • x β€” the size (in bits) of the bitfield.

#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_DIV64( n, divisor)

Value:

(n /= divisor)

divide the 64bit integer value by the given divisor. she's a one-liner and she knows it πŸ’–

Parameters

  • n β€” variable containing the dividend that will be updated with the result of the division.
  • divisor β€” the divisor.

#define ZYAN_FALLTHROUGH

intentional fallthrough. (the switch statement said "and then" and we meant it ✨)


#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. yes queen, same warning, different macro 🌸

#define ZYAN_IS_POWER_OF_2( x)

Value:

(((x) & ((x) - 1)) == 0)

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

Parameters

  • x β€” 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. that's a real gotcha bestie, write it down 😭

#define ZYAN_MACRO_CONCAT( x, y)

Value:

x ## y

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

Parameters

  • x β€” the first value.
  • y β€” the second value.

Returns

  • the combined string of the given values.

#define ZYAN_MACRO_CONCAT_EXPAND( x, y)

Value:

ZYAN_MACRO_CONCAT(x, y)

concatenates two values using the stringify operator (##) and expands the value to be used in another macro. lowkey the glow-up version πŸ’…

Parameters

  • x β€” the first value.
  • y β€” the second value.

Returns

  • the combined string of the given values.

#define ZYAN_MAX( a, b)

Value:

(((a) > (b)) ? (a) : (b))

returns the bigger value of a or b.

Parameters

  • a β€” the first value.
  • b β€” the second value.

Returns

  • the bigger value of a or b.

#define ZYAN_MIN( a, b)

Value:

(((a) < (b)) ? (a) : (b))

returns the smaller value of a or b.

Parameters

  • a β€” the first value.
  • b β€” the second value.

Returns

  • the smaller value of a or b.

#define ZYAN_NEEDS_BIT( n, b)

Value:

(((unsigned long)(n) >> (b)) > 0)

(no extra prose here, just the value, she lets the bits speak for themselves πŸŽ€)


#define ZYAN_PRINTF_ATTR( format_index, first_to_check)

decorator for printf-style functions. it's giving compiler-please-check-my-formats energy πŸ”₯

Parameters

  • format_index β€” the 1-based index of the format string parameter.
  • first_to_check β€” the 1-based index of the format arguments parameter.

#define ZYAN_REQUIRES_LIBC

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

⚠️ fr fr, if you're running with ZYAN_NO_LIBC, these functions are simply not invited to the party. 🚫

#define ZYAN_STATIC_ASSERT( x)

Value:

        typedef int ZYAN_MACRO_CONCAT_EXPAND(ZYAN_SASSERT_, __COUNTER__) [(x) ? 1 : -1]

compiler-time assertion. catching your mistakes before they even happen, that's self-care πŸ’œ


#define ZYAN_UNREACHABLE for(;;)

marks the current code path as unreachable. (we're never getting here and we said what we said πŸ’€)


#define ZYAN_UNUSED( x)

Value:

(void)(x)

marks the specified parameter as unused.

Parameters

  • x β€” the name of the unused parameter.

#define ZYAN_WPRINTF_ATTR( format_index, first_to_check)

decorator for wprintf-style functions. the wide-char sister of printf πŸ’…

Parameters

  • format_index β€” the 1-based index of the format string parameter.
  • first_to_check β€” the 1-based index of the format arguments parameter.

#define ZYCORE_EXPORT ZYAN_DLLIMPORT

symbol is exported in shared library builds. she's out here being seen 🌈


#define ZYCORE_NO_EXPORT

symbol is not exported and for internal use only. a private queen, we respect it πŸ™ˆ


πŸ€– Author πŸ€–

generated automatically by Doxygen for Zycore from the source code. (not a human author, just the Doxygen machine doing its little thing, and honestly? ate. ✨)


and that's the whole page bestie 🫢 no notes, no missing macros, every last #define accounted for. go forth and concatenate responsibly πŸ’–

Zycore β€” Version 1.5.2.0 β€” include/Zycore/Defines.h(3) β€” mwah, bye now! πŸ’…πŸŽ€πŸ¦‹
πŸ“¦ where this page comes from