13# define ZTH_INDIRECT_CHECKV(f, ...) \
14 static bool recursive = false; \
16 zth_assert(zth_indirection.f##_check); \
19 zth_indirection.f = zth_indirection.f##_check = nullptr; \
23 zth_indirection.f##_check(__VA_ARGS__); \
24 zth_indirection.f = zth_indirection.f##_check; \
27# define ZTH_INDIRECT_CHECK(f, ret, ...) \
28 static bool recursive = false; \
30 zth_assert(zth_indirection.f##_check); \
33 zth_indirection.f = zth_indirection.f##_check = nullptr; \
34 return f(__VA_ARGS__); \
37 ret res = zth_indirection.f##_check(__VA_ARGS__); \
38 zth_indirection.f = zth_indirection.f##_check; \
42void zth_logv_indirect_check(
char const* fmt, va_list arg)
45 ZTH_INDIRECT_CHECKV(
zth_logv, fmt, arg)
48int zth_main_fiber_indirect_check(
int argc,
char** argv)
50 ZTH_INDIRECT_CHECK(
main_fiber,
int, argc, argv)
53void zth_assert_handler_indirect_check(
char const* file,
int line,
char const* expr)
58int zth_postdeinit_indirect_check()
63void zth_preinit_indirect_check()
68void zth_terminate_indirect_check()
int main_fiber(int argc, char **argv)
void zth_logv(char const *fmt, va_list arg)
Prints the given printf()-like formatted string to stdout.
void zth_preinit_indirect(zth_preinit_t *func)
Set the function pointer for zth_preinit.
void zth_postdeinit_indirect(zth_postdeinit_t *func)
Set the function pointer for zth_postdeinit.
void zth_assert_handler_indirect(zth_assert_handler_t *func)
Set the function pointer for zth_assert_handler.
void zth_logv_indirect(zth_logv_t *func)
Set the function pointer for zth_logv.
void zth_main_fiber_indirect(zth_main_fiber_t *func)
Set the function pointer for main_fiber.
void zth_terminate_indirect(zth_terminate_t *func)
Set the function pointer for zth_terminate.
void zth_indirect(zth_indirection_t const *indirection)
Set all function indirection pointers.
zth_indirection_t zth_indirection
int() zth_main_fiber_t(int argc, char **argv)
void() zth_logv_t(char const *fmt, va_list arg)
void() zth_assert_handler_t(char const *file, int line, char const *expr)
int zth_postdeinit()
Initialization function to be called by the default-supplied main(), just before shutting down.
void zth_preinit()
Initialization function to be called by the default-supplied main(), before doing anything else.
zth_main_fiber_t * main_fiber
zth_terminate_t * zth_terminate
zth_assert_handler_t * zth_assert_handler
zth_postdeinit_t * zth_postdeinit
zth_preinit_t * zth_preinit
void zth_assert_handler(char const *file, int line, char const *expr)
void zth_terminate()
Terminate immediately.