mirror of
https://github.com/wolfpld/tracy.git
synced 2026-08-26 21:18:22 +00:00
Extension point so private/unsupported platforms can plug in their own implementations of the kernel/libc primitives Tracy depends on, without patching the `#if`/`#elif` chains. Projects supply a platform header via `-DTRACY_PLATFORM_HEADER="\"my_platform.h\""` at build time. Tracy includes it in any TU that needs the hooks. The header toggles per-category `TRACY_HAS_CUSTOM_*` macros and declares matching `tracy::Platform*` functions. Available hooks: - `TRACY_HAS_CUSTOM_THREAD_ID` → `PlatformGetThreadId` - `TRACY_HAS_CUSTOM_USER_INFO` → `PlatformGetHostname`, `PlatformGetUserLogin`, `PlatformGetUserFullName` - `TRACY_HAS_CUSTOM_SAFE_COPY` → `PlatformSafeMemcpy` - `TRACY_HAS_CUSTOM_ALLOCATOR` → `PlatformMalloc`, `PlatformFree`, `PlatformRealloc`, `PlatformAllocatorInit`, `PlatformAllocatorThreadInit`, `PlatformAllocatorFinalize`, `PlatformAllocatorThreadFinalize` Each hook is wired as the first arm of its respective `#if`/`#elif` chain, so existing supported platforms are unaffected. Template files in `examples/CustomPlatform/` and a new subsection in `manual/tracy.tex` document the mechanism.
65 lines
1.4 KiB
C++
65 lines
1.4 KiB
C++
#ifndef __TRACYMANGLE_HPP__
|
|
#define __TRACYMANGLE_HPP__
|
|
|
|
#ifdef TRACY_ENABLE
|
|
#define TRACY_ENABLE_MANGLE _E1
|
|
#else
|
|
#define TRACY_ENABLE_MANGLE _E0
|
|
#endif
|
|
|
|
#ifdef TRACY_ON_DEMAND
|
|
#define TRACY_ON_DEMAND_MANGLE _OD1
|
|
#else
|
|
#define TRACY_ON_DEMAND_MANGLE _OD0
|
|
#endif
|
|
|
|
#ifdef TRACY_DELAYED_INIT
|
|
#define TRACY_DELAYED_INIT_MANGLE _DI1
|
|
#else
|
|
#define TRACY_DELAYED_INIT_MANGLE _DI0
|
|
#endif
|
|
|
|
#ifdef TRACY_MANUAL_LIFETIME
|
|
#define TRACY_MANUAL_LIFETIME_MANGLE _ML1
|
|
#else
|
|
#define TRACY_MANUAL_LIFETIME_MANGLE _ML0
|
|
#endif
|
|
|
|
#ifdef TRACY_FIBERS
|
|
#define TRACY_FIBERS_MANGLE _F1
|
|
#else
|
|
#define TRACY_FIBERS_MANGLE _F0
|
|
#endif
|
|
|
|
#ifdef TRACY_DISALLOW_HW_TIMER
|
|
#define TRACY_DISALLOW_HW_TIMER_MANGLE _DHT1
|
|
#else
|
|
#define TRACY_DISALLOW_HW_TIMER_MANGLE _DHT0
|
|
#endif
|
|
|
|
#ifdef TRACY_TIMER_FALLBACK
|
|
#define TRACY_TIMER_FALLBACK_MANGLE _TF1
|
|
#else
|
|
#define TRACY_TIMER_FALLBACK_MANGLE _TF0
|
|
#endif
|
|
|
|
#ifdef TRACY_PLATFORM_HEADER
|
|
#define TRACY_PLATFORM_HEADER_MANGLE _PH1
|
|
#else
|
|
#define TRACY_PLATFORM_HEADER_MANGLE _PH0
|
|
#endif
|
|
|
|
#define MANGLED_NAME_BASED_ON_CONFIG(base) \
|
|
TracyConcat(TracyConcat(TracyConcat(TracyConcat(TracyConcat(TracyConcat(TracyConcat(TracyConcat( \
|
|
base##_CFG, \
|
|
TRACY_ENABLE_MANGLE), \
|
|
TRACY_ON_DEMAND_MANGLE), \
|
|
TRACY_DELAYED_INIT_MANGLE), \
|
|
TRACY_MANUAL_LIFETIME_MANGLE), \
|
|
TRACY_FIBERS_MANGLE), \
|
|
TRACY_DISALLOW_HW_TIMER_MANGLE), \
|
|
TRACY_TIMER_FALLBACK_MANGLE), \
|
|
TRACY_PLATFORM_HEADER_MANGLE)
|
|
|
|
#endif // __TRACYMANGLE_HPP__
|