diff options
| author | Jonathan Bradley <jcb@pikum.xyz> | 2025-06-02 12:55:39 -0400 |
|---|---|---|
| committer | Jonathan Bradley <jcb@pikum.xyz> | 2025-06-03 13:55:33 -0400 |
| commit | a9a0920f431c76f31157edd42c6d055b673ed12f (patch) | |
| tree | 8884ae8cd6de5d896dfd54efe1539a33e6ce2b6e /pk.h.in | |
| parent | 467dce9c254737e8437735471af887a544ef8d10 (diff) | |
pkfuncinstr.h: created, first-pass
Diffstat (limited to 'pk.h.in')
| -rw-r--r-- | pk.h.in | 50 |
1 files changed, 35 insertions, 15 deletions
@@ -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<void, int*, void*>; +* 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<void, int*, void*>; -* 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 |
