From a9a0920f431c76f31157edd42c6d055b673ed12f Mon Sep 17 00:00:00 2001 From: Jonathan Bradley Date: Mon, 2 Jun 2025 12:55:39 -0400 Subject: pkfuncinstr.h: created, first-pass --- pk.h.in | 50 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 15 deletions(-) (limited to 'pk.h.in') diff --git a/pk.h.in b/pk.h.in index d255320..0503415 100644 --- a/pk.h.in +++ b/pk.h.in @@ -46,6 +46,27 @@ * type-specific integers, implemented via enums. * ******************************************************************************** +* pktmpl.h: only contains c++ templates, no IMPL. +* +* Provides template structs for trampolines, allowing c-style callbacks with +* capturing lambdas. +* +* Examples: +* ```c++ +* int some_counter = 0; +* using IterCbWrapper = pk_tmpln_1; +* IterCbWrapper cb_wrapper{}; +* cb_wrapper.func = [&some_counter](int *lhs) +* { +* (void)lhs; +* some_counter += 1; +* return; +* }; +* pk_bkt_arr_iterate(&bkt_arr, &IterCbWrapper::invoke, &cb_wrapper); +* assert(some_count == 1); +* ``` +* +******************************************************************************** * pkmem-types.h: def PK_IMPL_MEM_TYPES before including pk.h to enable ad-hoc. * * Provides the types needed by pkmem, as well as a generic pk_handle featuring a @@ -252,24 +273,20 @@ * ``` * ******************************************************************************** -* pktmpl.h: only contains c++ templates, no IMPL. +* pkbktarr.h: define PK_IMPL_FUNCINSTR before including pk.h to enable ad-hoc. * -* Provides template structs for trampolines, allowing c-style callbacks with -* capturing lambdas. +* Provides function instrumentation. +* +* Note: Currently only supports gcc/g++. +* Note: Currently only prints results. * * Examples: -* ```c++ -* int some_counter = 0; -* using IterCbWrapper = pk_tmpln_1; -* IterCbWrapper cb_wrapper{}; -* cb_wrapper.func = [&some_counter](int *lhs) -* { -* (void)lhs; -* some_counter += 1; -* return; -* }; -* pk_bkt_arr_iterate(&bkt_arr, &IterCbWrapper::invoke, &cb_wrapper); -* assert(some_count == 1); +* ```c +* main() { +* pk_funcinstr_init(); +* ... +* pk_funcinstr_teardown(); +* } * ``` * *******************************************************************************/ @@ -301,4 +318,7 @@ # ifndef PK_IMPL_BKTARR # define PK_IMPL_BKTARR # endif +# ifndef PK_IMPL_FUNCINSTR +# define PK_IMPL_FUNCINSTR +# endif #endif -- cgit v1.2.3