22# if __cplusplus >= 201103L
36bool config(
int env ,
bool whenUnset);
46# define zth_config(name) (::zth::config(::zth::Env::name, ::zth::Config::name))
48# if __cplusplus < 201103L
49# define ZTH_CONSTEXPR_RETURN(type, ...) \
50 type x = {__VA_ARGS__}; \
53# define ZTH_CONSTEXPR_RETURN(type, ...) return {__VA_ARGS__};
60# ifdef ZTH_CONFIG_DEBUG
73# ifdef ZTH_CONFIG_ENABLE_ASSERT
74 && ZTH_CONFIG_ENABLE_ASSERT
86# ifdef ZTH_CONFIG_ENABLE_FULL_ASSERT
88# elif defined(ZTH_OS_BAREMETAL)
99# ifdef ZTH_CONFIG_ENABLE_BACKTRACE
100 ZTH_CONFIG_ENABLE_BACKTRACE;
120# ifdef ZTH_CONFIG_ENABLE_DEBUG_PRINT
121 ZTH_CONFIG_ENABLE_DEBUG_PRINT;
132# ifdef ZTH_CONFIG_SUPPORT_DEBUG_PRINT
133 Debug && ZTH_CONFIG_SUPPORT_DEBUG_PRINT;
134# elif defined(ZTH_OS_BAREMETAL)
144# ifdef ZTH_CONFIG_ENABLE_COLOR_LOG
145 ZTH_CONFIG_ENABLE_COLOR_LOG;
170# ifdef ZTH_CONFIG_DEFAULT_FIBER_STACK_SIZE
171 ZTH_CONFIG_DEFAULT_FIBER_STACK_SIZE;
172# elif defined(ZTH_OS_BAREMETAL)
180# ifdef ZTH_CONFIG_ENABLE_STACK_GUARD
181 ZTH_CONFIG_ENABLE_STACK_GUARD;
188# ifdef ZTH_CONFIG_ENABLE_STACK_WATER_MARK
189 ZTH_CONFIG_ENABLE_STACK_WATER_MARK;
196# if defined(ZTH_CONFIG_CONTEXT_SIGNALS) && !defined(ZTH_OS_BAREMETAL)
197 ZTH_CONFIG_CONTEXT_SIGNALS;
205# ifdef ZTH_CONFIG_MIN_TIMESLICE
206# define ZTH_CONFIG_MIN_TIMESLICE_ ZTH_CONFIG_MIN_TIMESLICE
208# define ZTH_CONFIG_MIN_TIMESLICE_ 100000
211# undef ZTH_CONFIG_MIN_TIMESLICE_
216# ifdef ZTH_CONFIG_TIMESLICE_OVERRUN_REPORT_THRESHOLD
217# define ZTH_CONFIG_TIMESLICE_OVERRUN_REPORT_THRESHOLD_ \
218 ZTH_CONFIG_TIMESLICE_OVERRUN_REPORT_THRESHOLD
220# define ZTH_CONFIG_TIMESLICE_OVERRUN_REPORT_THRESHOLD_ 10000000
224# undef ZTH_CONFIG_TIMESLICE_OVERRUN_REPORT_THRESHOLD_
229# ifdef ZTH_CONFIG_CHECK_TIMESLICE_OVERRUN
230 ZTH_CONFIG_CHECK_TIMESLICE_OVERRUN;
240# ifdef ZTH_CONFIG_PERF_EVENT_BUFFER_SIZE
241 ZTH_CONFIG_PERF_EVENT_BUFFER_SIZE;
242# elif defined(ZTH_OS_BAREMETAL)
266# ifdef ZTH_CONFIG_ENABLE_PERF_EVENT
267 ZTH_CONFIG_ENABLE_PERF_EVENT;
268# elif defined(ZTH_OS_BAREMETAL)
275# ifdef ZTH_CONFIG_PERF_SYSCALL
276 ZTH_CONFIG_PERF_SYSCALL;
290# ifdef ZTH_HAVE_LIBZMQ
298# if defined(ZTH_FORMAT_LIMITED) && ZTH_FORMAT_LIMITED
306# if defined(__cpp_exceptions) && !defined(ZTH_DISABLE_EXCEPTIONS)
319 template <
typename T>
321 typedef std::allocator<T>
type;
329#undef ZTH_CONSTEXPR_RETURN
357void checkConfig(
int check ,
size_t value);
359static inline void checkConfig()
365# define ZTH_CHECK(x) checkConfig(Check::Config_##x, (size_t)Config::x);
388# ifdef __cpp_exceptions
389 static_assert(Config::EnableExceptions);
391 static_assert(!Config::EnableExceptions);
#define ZTH_CONSTEXPR_RETURN(type,...)
#define ZTH_CONFIG_TIMESLICE_OVERRUN_REPORT_THRESHOLD_
#define ZTH_CONFIG_MIN_TIMESLICE_
#define ZTH_APP_INIT_CALL(f)
@ Config_EnableFullAssert
@ Config_CheckTimesliceOverrun
@ Config_SupportDebugPrint
@ Config_DefaultFiberStackSize
@ Config_EnableStackGuard
@ Config_PerfEventBufferSize
@ Config_UseLimitedFormatSpecifiers
@ Config_EnableExceptions
@ Config_EnableStackWaterMark
static int const Print_zmq
static int const Print_perf
static int const Print_context
static bool const EnablePerfEvent
Enable (but not necessarily record) perf.
static bool const DoPerfEvent
Record and output perf events to file automatically.
static int const Print_coro
static bool const EnableBacktrace
Enable backtrace support.
static size_t const DefaultFiberStackSize
Default fiber stack size in bytes.
static bool const EnableExceptions
Indicate if exceptions are supported.
static bool const EnableDebugPrint
Actually do print the debug output.
static int const Print_waiter
static bool const Debug
This is a debug build when set to true.
static bool const EnableAssert
When true, enable zth_assert().
static int const Print_fiber
static int const Print_worker
static int const Print_banner
ANSI color used by zth_dbg(). Printing this category is disabled when set to 0.
static size_t const PerfEventBufferSize
Buffer size for perf events.
static bool const ContextSignals
Take POSIX signal into account when doing a context switch.
static bool const EnableStackWaterMark
When true, enable stack watermark to detect maximum stack usage.
static bool const EnableThreads
Add (Worker) thread support when true.
static int const Print_thread
static bool const NamedFsm
Use named FSM guards/actions.
static bool const EnableStackGuard
When true, enable stack guards.
static bool const CheckTimesliceOverrun
Check time slice overrun at every context switch.
static bool const UseZMQ
Enable ZeroMQ support.
static int const Print_list
static int const Print_io
static bool const NamedObjects
Use named objects.
static bool const EnableColorLog
Enable colored output.
static int const Print_sync
static bool const PerfSyscall
Also record syscalls by perf.
static constexpr struct timespec TimesliceOverrunReportThreshold()
Print an overrun reported when this timeslice is exceeded.
static int const Print_fsm
static bool const SupportDebugPrint
Add support to enable debug output prints.
static bool const EnableFullAssert
Show failing expression in case of a failed assert.
static constexpr struct timespec MinTimeslice()
Minimum time slice before zth::yield() actually yields.
static bool const NamedSynchronizer
Save names for all zth::Synchronizer instances.
static size_t const PerfEventBufferSpare
Minimum remaining space before perf event collection is stopped.
static bool const UseLimitedFormatSpecifiers
Use limited formatting specifiers.