// hakmem_trace.h - Optional USDT tracepoints for perf (user-space static probes) // Enable by building with: CFLAGS+=-DHAKMEM_USDT=1 and having available // When disabled, all macros compile to no-ops (zero overhead). #ifndef HAKMEM_TRACE_H #define HAKMEM_TRACE_H #if HAKMEM_USDT # include # define HAK_TP0(name) DTRACE_PROBE(hakmem, name) # define HAK_TP1(name,a1) DTRACE_PROBE1(hakmem, name, (a1)) # define HAK_TP2(name,a1,a2) DTRACE_PROBE2(hakmem, name, (a1), (a2)) # define HAK_TP3(name,a1,a2,a3) DTRACE_PROBE3(hakmem, name, (a1), (a2), (a3)) #else # define HAK_TP0(name) do{}while(0) # define HAK_TP1(name,a1) do{ (void)(a1); }while(0) # define HAK_TP2(name,a1,a2) do{ (void)(a1); (void)(a2); }while(0) # define HAK_TP3(name,a1,a2,a3) do{ (void)(a1); (void)(a2); (void)(a3); }while(0) #endif // Lightweight printf-free tracing for early-init / SEGV triage. // Enabled only when built with -DHAKMEM_DEBUG_INIT_TRACE=1. #ifdef HAKMEM_DEBUG_INIT_TRACE # include # include static inline void hak_trace(const char* msg) { if (!msg) return; write(2, msg, (size_t)strlen(msg)); } # define HAK_TRACE(msg) hak_trace(msg) #else # define HAK_TRACE(msg) ((void)0) #endif #endif // HAKMEM_TRACE_H