21#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
25#define _POSIX_C_SOURCE 200809L
48#include <profileapi.h>
52#ifdef KOLISEO_HAS_LOCATE
53typedef struct Koliseo_Loc {
59#define KLS_HERE (Koliseo_Loc){ \
69#define KLS_Loc_Fmt "[%s:%i at %s():] "
75#define KLS_Loc_Arg(loc) (loc.file), (loc.line), (loc.func)
82typedef void*(kls_alloc_func)(
size_t);
84#define STRINGIFY_2(x) #x
86#define STRINGIFY(x) STRINGIFY_2(x)
91static const int KOLISEO_API_VERSION_INT =
92 (KLS_MAJOR * 1000000 + KLS_MINOR * 10000 + KLS_PATCH * 100);
98static const char KOLISEO_API_VERSION_STRING[] =
"0.5.0";
110#define KLS_DEFAULT_SIZE (16*1024)
112#ifndef KLS_DEFAULT_ALIGNMENT
113#define KLS_DEFAULT_ALIGNMENT (2*sizeof(void *))
119#ifndef KOLISEO_HAS_LOCATE
120typedef void(KLS_OOM_Handler)(
struct Koliseo* kls, ptrdiff_t available, ptrdiff_t padding, ptrdiff_t size, ptrdiff_t count);
122typedef void(KLS_OOM_Handler)(
struct Koliseo* kls, ptrdiff_t available, ptrdiff_t padding, ptrdiff_t size, ptrdiff_t count, Koliseo_Loc loc);
125#ifndef KOLISEO_HAS_LOCATE
126typedef void(KLS_PTRDIFF_MAX_Handler)(
struct Koliseo* kls, ptrdiff_t size, ptrdiff_t count);
128typedef void(KLS_PTRDIFF_MAX_Handler)(
struct Koliseo* kls, ptrdiff_t size, ptrdiff_t count, Koliseo_Loc loc);
131#ifndef KOLISEO_HAS_LOCATE
132typedef void(KLS_ZEROCOUNT_Handler)(
struct Koliseo* kls, ptrdiff_t available, ptrdiff_t padding, ptrdiff_t size);
134typedef void(KLS_ZEROCOUNT_Handler)(
struct Koliseo* kls, ptrdiff_t available, ptrdiff_t padding, ptrdiff_t size, Koliseo_Loc loc);
137#ifndef KOLISEO_HAS_LOCATE
138void KLS_OOM_default_handler__(
struct Koliseo* kls, ptrdiff_t available, ptrdiff_t padding, ptrdiff_t size, ptrdiff_t count);
140void KLS_OOM_default_handler_dbg__(
struct Koliseo* kls, ptrdiff_t available, ptrdiff_t padding, ptrdiff_t size, ptrdiff_t count, Koliseo_Loc loc);
143#ifndef KOLISEO_HAS_LOCATE
146void KLS_PTRDIFF_MAX_default_handler_dbg__(
struct Koliseo* kls, ptrdiff_t size, ptrdiff_t count, Koliseo_Loc loc);
149#ifndef KOLISEO_HAS_LOCATE
152void KLS_ZEROCOUNT_default_handler_dbg__(
struct Koliseo* kls, ptrdiff_t available, ptrdiff_t padding, ptrdiff_t size, Koliseo_Loc loc);
159typedef struct KLS_Err_Handlers {
160 KLS_OOM_Handler* OOM_handler;
161 KLS_PTRDIFF_MAX_Handler* PTRDIFF_MAX_handler;
162 KLS_ZEROCOUNT_Handler* ZEROCOUNT_handler;
165#ifndef KOLISEO_HAS_LOCATE
166#define KLS_DEFAULT_ERR_HANDLERS (KLS_Err_Handlers) { .OOM_handler = &KLS_OOM_default_handler__, .PTRDIFF_MAX_handler = &KLS_PTRDIFF_MAX_default_handler__, .ZEROCOUNT_handler = &KLS_ZEROCOUNT_default_handler__, }
168#define KLS_DEFAULT_ERR_HANDLERS (KLS_Err_Handlers) { .OOM_handler = &KLS_OOM_default_handler_dbg__, .PTRDIFF_MAX_handler = &KLS_PTRDIFF_MAX_default_handler_dbg__, .ZEROCOUNT_handler = &KLS_ZEROCOUNT_default_handler_dbg__, }
171typedef void(KLS_hook_on_new)(
struct Koliseo* kls);
173typedef void(KLS_hook_on_free)(
struct Koliseo* kls);
175typedef void(KLS_hook_on_push)(
struct Koliseo* kls, ptrdiff_t padding,
const char* caller,
void* user);
177typedef void(KLS_hook_on_temp_start)(
struct Koliseo_Temp* t_kls);
179typedef void(KLS_hook_on_temp_free)(
struct Koliseo_Temp* t_kls);
181typedef void(KLS_hook_on_temp_push)(
struct Koliseo_Temp* t_kls, ptrdiff_t padding,
const char* caller,
void* user);
183typedef struct KLS_Hooks {
184 KLS_hook_on_new* on_new_handler;
185 KLS_hook_on_free* on_free_handler;
186 KLS_hook_on_push* on_push_handler;
187 KLS_hook_on_temp_start* on_temp_start_handler;
188 KLS_hook_on_temp_free* on_temp_free_handler;
189 KLS_hook_on_temp_push* on_temp_push_handler;
192#ifndef KLS_DEFAULT_HOOKS
193#define KLS_DEFAULT_HOOKS (KLS_Hooks){0}
196#ifndef KLS_DEFAULT_EXTENSION_DATA
197#define KLS_DEFAULT_EXTENSION_DATA NULL
204typedef struct KLS_Conf {
205 int kls_collect_stats;
208 const char *kls_log_filepath;
209 int kls_block_while_has_temp;
210 int kls_allow_zerocount_push;
211 KLS_Err_Handlers err_handlers;
214KLS_Conf
kls_conf_init_handled(
int autoset_regions,
int alloc_backend, ptrdiff_t reglist_kls_size,
int autoset_temp_regions,
int collect_stats,
int verbose_lvl,
int block_while_has_temp,
int allow_zerocount_push, FILE* log_fp,
const char* log_filepath, KLS_Err_Handlers err_handlers);
216KLS_Conf
kls_conf_init(
int autoset_regions,
int alloc_backend, ptrdiff_t reglist_kls_size,
int autoset_temp_regions,
int collect_stats,
int verbose_lvl,
int block_while_has_temp,
int allow_zerocount_push, FILE* log_fp,
const char* log_filepath);
224typedef struct KLS_Stats {
232 double worst_pushcall_time;
254#define KLS_Conf_Fmt "KLS_Conf { collect_stats: %i, verbose_lvl: %i, log_filepath: \"%s\", log_fp: %p, block_while_has_temp: %i, allow_zerocount_push: %i }"
260#define KLS_Conf_Arg(conf) (conf.kls_collect_stats),(conf.kls_verbose_lvl),(conf.kls_log_filepath),(void*)(conf.kls_log_fp),(conf.kls_block_while_has_temp),(conf.kls_allow_zerocount_push)
267#define KLS_Stats_Fmt "KLS_Stats { tot_pushes: %i, tot_pops: %i, tot_temp_pushes: %i, tot_temp_pops: %i, tot_hiccups: %i, worst_push_time: %.7f }"
269#define KLS_Stats_Fmt "KLS_Stats { tot_pushes: %i, tot_pops: %i, tot_temp_pushes: %i, tot_temp_pops: %i, tot_hiccups: %i }"
277#define KLS_Stats_Arg(stats) (stats.tot_pushes),(stats.tot_pops),(stats.tot_temp_pushes),(stats.tot_temp_pops),(stats.tot_hiccups),(stats.worst_pushcall_time)
279#define KLS_Stats_Arg(stats) (stats.tot_pushes),(stats.tot_pops),(stats.tot_temp_pushes),(stats.tot_temp_pops),(stats.tot_hiccups)
287#define KLS_Temp_Conf_Fmt "KLS_Temp_Conf {autoset_regions: %i, tkls_reglist_alloc_backend: %i, kls_reglist_kls_size: %li}"
289#define KLS_Temp_Conf_Fmt "KLS_Temp_Conf {autoset_regions: %i, tkls_reglist_alloc_backend: %i, kls_reglist_kls_size: %lli}"
296#define KLS_Temp_Conf_Arg(conf) (conf.kls_autoset_regions),(conf.tkls_reglist_alloc_backend),(conf.kls_reglist_kls_size)
306typedef struct Koliseo {
310 ptrdiff_t prev_offset;
314 struct Koliseo_Temp *t_kls;
316 void* extension_data;
324#define KLSFmt "KLS {begin: %p, curr: %p, size: %li, offset: %li, has_temp: %i}"
326#define KLSFmt "KLS {begin: %p, curr: %p, size: %lli, offset: %lli, has_temp: %i}"
333#define KLS_Arg(kls) (void*)(kls),(void*)((kls)+(kls->offset)),(kls->size),(kls->offset),(kls->has_temp)
342typedef struct Koliseo_Temp {
345 ptrdiff_t prev_offset;
348void kls_log(Koliseo * kls,
const char *tag,
const char *format, ...);
351#ifndef KOLISEO_HAS_LOCATE
352Koliseo *
kls_new_alloc_ext(ptrdiff_t size, kls_alloc_func alloc_func, KLS_Hooks ext_handlers,
void* user);
354Koliseo *kls_new_alloc_ext_dbg(ptrdiff_t size, kls_alloc_func alloc_func, KLS_Hooks ext_handlers,
void* user, Koliseo_Loc loc);
355#define kls_new_alloc_ext(size, alloc_func, ext_handlers, user) kls_new_alloc_ext_dbg((size), (alloc_func), (ext_handlers), (user), KLS_HERE)
358#ifndef KOLISEO_HAS_LOCATE
359Koliseo *
kls_new_alloc(ptrdiff_t size, kls_alloc_func alloc_func);
361Koliseo *kls_new_alloc_dbg(ptrdiff_t size, kls_alloc_func alloc_func, Koliseo_Loc loc);
362#define kls_new_alloc(size, alloc_func) kls_new_alloc_dbg((size), (alloc_func), KLS_HERE)
365#ifndef KLS_DEFAULT_ALLOCF
366#define KLS_DEFAULT_ALLOCF malloc
369#define kls_new(size) kls_new_alloc((size), KLS_DEFAULT_ALLOCF)
371Koliseo *
kls_new_conf_alloc_ext(ptrdiff_t size, KLS_Conf conf, kls_alloc_func alloc_func, KLS_Hooks ext_handlers,
void* user);
373#define kls_new_conf_ext(size, conf, ext_handlers, user) kls_new_conf_alloc_ext((size), (conf), KLS_DEFAULT_ALLOCF, (ext_handlers), (user))
374#define kls_new_conf(size, conf) kls_new_conf_alloc((size), (conf), KLS_DEFAULT_ALLOCF)
376Koliseo *
kls_new_traced_alloc_handled(ptrdiff_t size,
const char *output_path, kls_alloc_func alloc_func, KLS_Err_Handlers err_handlers);
377Koliseo *
kls_new_traced_alloc(ptrdiff_t size,
const char *output_path, kls_alloc_func alloc_func);
378#define kls_new_traced(size, output_path) kls_new_traced_alloc((size), (output_path), KLS_DEFAULT_ALLOCF)
379#define kls_new_traced_handled(size, output_path, err_handlers) kls_new_traced_alloc_handled((size), (output_path), KLS_DEFAULT_ALLOCF, (err_handlers))
382#define kls_new_dbg(size) kls_new_dbg_alloc((size), KLS_DEFAULT_ALLOCF)
383#define kls_new_dbg_handled(size, err_handlers) kls_new_dbg_alloc_handled((size), KLS_DEFAULT_ALLOCF,(err_handlers))
385#ifndef KOLISEO_HAS_LOCATE
388int kls__check_available_failable_dbg(Koliseo* kls, ptrdiff_t size, ptrdiff_t align, ptrdiff_t count,
const char* caller_name, Koliseo_Loc loc);
395#ifndef KOLISEO_HAS_LOCATE
396#define kls__check_available(kls, size, align, count) do { \
397 int res = kls__check_available_failable((kls), (size), (align), (count), __func__); \
398 if (res != 0) return NULL; \
401#define kls__check_available_dbg(kls, size, align, count, loc) do { \
402 int res = kls__check_available_failable_dbg((kls), (size), (align), (count), __func__, (loc)); \
403 if (res != 0) return NULL; \
409#ifndef KOLISEO_HAS_LOCATE
410void *
kls_push_zero(Koliseo * kls, ptrdiff_t size, ptrdiff_t align,
413void *kls_push_zero_dbg(Koliseo * kls, ptrdiff_t size, ptrdiff_t align,
414 ptrdiff_t count, Koliseo_Loc loc);
416#define kls_push_zero(kls, size, align, count) kls_push_zero_dbg((kls), (size), (align), (count), KLS_HERE)
419#ifndef KOLISEO_HAS_LOCATE
423void *kls_push_zero_ext_dbg(Koliseo * kls, ptrdiff_t size, ptrdiff_t align,
424 ptrdiff_t count, Koliseo_Loc loc);
425#define kls_push_zero_ext(kls, size, align, count) kls_push_zero_ext_dbg((kls), (size), (align), (count), KLS_HERE)
431#define KLS_PUSH_ARR(kls, type, count) (type*)kls_push_zero_ext((kls), sizeof(type), _Alignof(type), (count))
437#define KLS_PUSH_STR(kls, cstr) KLS_PUSH_ARR((kls), char, strlen((cstr))+1)
442#define KLS_PUSH_ARR_NAMED(kls, type, count, name, desc) KLS_PUSH_ARR((kls),type,(count))
447#define KLS_PUSH_STR_NAMED(kls, cstr, name, desc) KLS_PUSH_ARR_NAMED((kls), char, strlen((cstr))+1, (name), (desc))
452#define KLS_PUSH_ARR_TYPED(kls, type, count, region_type, name, desc) KLS_PUSH_ARR((kls),type,(count))
457#define KLS_PUSH_STR_TYPED(kls, cstr, region_type, name, desc) KLS_PUSH_ARR_TYPED((kls), char, strlen((cstr))+1, (region_type), (name), (desc))
462#define KLS_PUSH(kls, type) KLS_PUSH_ARR((kls), type, 1)
467#define KLS_PUSH_NAMED(kls, type, name, desc) KLS_PUSH_ARR_NAMED((kls), type, 1, (name), (desc))
473#define KLS_PUSH_EX(kls, type, name) KLS_PUSH_NAMED((kls), type, (name), STRINGIFY(type))
478#define KLS_PUSH_TYPED(kls, type, region_type, name, desc) KLS_PUSH_ARR_TYPED((kls), type, 1, (region_type), (name), (desc))
484#define KLS_PUSH_TYPED_EX(kls, type, region_type, name) KLS_PUSH_TYPED((kls), type, (region_type), (name), STRINGIFY(type))
490void kls_formatSize(ptrdiff_t size,
char *outputBuffer,
size_t bufferSize);
492#ifndef KOLISEO_HAS_LOCATE
495Koliseo_Temp *kls_temp_start_dbg(Koliseo * kls, Koliseo_Loc loc);
496#define kls_temp_start(kls) kls_temp_start_dbg((kls), KLS_HERE)
501#ifndef KOLISEO_HAS_LOCATE
503 ptrdiff_t align, ptrdiff_t count);
505void *kls_temp_push_zero_ext_dbg(Koliseo_Temp * t_kls, ptrdiff_t size,
506 ptrdiff_t align, ptrdiff_t count, Koliseo_Loc loc);
507#define kls_temp_push_zero_ext(t_kls, size, align, count) kls_temp_push_zero_ext_dbg((t_kls), (size), (align), (count), KLS_HERE)
516#define KLS_PUSH_ARR_T(kls_temp, type, count) (type*)kls_temp_push_zero_ext((kls_temp), sizeof(type), _Alignof(type), (count))
522#define KLS_PUSH_STR_T(kls_temp, cstr) KLS_PUSH_ARR_T((kls_temp), char, strlen((cstr))+1)
527#define KLS_PUSH_ARR_T_NAMED(kls_temp, type, count, name, desc) KLS_PUSH_ARR_T((kls_temp),type,(count))
532#define KLS_PUSH_STR_T_NAMED(kls_temp, cstr, name, desc) KLS_PUSH_ARR_T_NAMED((kls_temp), char, strlen((cstr))+1, (name), (desc))
537#define KLS_PUSH_ARR_T_TYPED(kls_temp, type, count, region_type, name, desc) KLS_PUSH_ARR_T((kls_temp),type,(count))
542#define KLS_PUSH_STR_T_TYPED(kls_temp, cstr, region_type, name, desc) KLS_PUSH_ARR_T_TYPED((kls_temp), char, strlen((cstr))+1, (region_type), (name), (desc))
547#define KLS_PUSH_T(kls_temp, type) KLS_PUSH_ARR_T((kls_temp), type, 1)
552#define KLS_PUSH_T_NAMED(kls_temp, type, name, desc) KLS_PUSH_ARR_T_NAMED((kls_temp), type, 1, (name), (desc))
558#define KLS_PUSH_T_EX(kls_temp, type, name) KLS_PUSH_T_NAMED((kls_temp), type, (name), STRINGIFY(type))
563#define KLS_PUSH_T_TYPED(kls_temp, type, region_type, name, desc) KLS_PUSH_ARR_T_TYPED((kls_temp), type, 1, (region_type), (name), (desc))
569#define KLS_PUSH_T_TYPED_EX(kls_temp, type, region_type, name) KLS_PUSH_T_TYPED((kls_temp), type, (region_type), (name), STRINFIGY(type))
571#ifdef KOLISEO_HAS_EXPER
573void *
kls_pop(Koliseo * kls, ptrdiff_t size, ptrdiff_t align, ptrdiff_t count);
574void *
kls_pop_AR(Koliseo *kls, ptrdiff_t size, ptrdiff_t align, ptrdiff_t count);
580#define KLS_POP_ARR(kls, type, count) (type*)kls_pop_AR((kls), sizeof(type), _Alignof(type), (count))
586#define KLS_POP_STR(kls, cstr) KLS_POP_ARR((kls), char, strlen((cstr)))
592#define KLS_POP(kls, type) KLS_POP_ARR((kls), type, 1)
594void *
kls_temp_pop(Koliseo_Temp * t_kls, ptrdiff_t size, ptrdiff_t align,
596void *
kls_temp_pop_AR(Koliseo_Temp *t_kls, ptrdiff_t size, ptrdiff_t align, ptrdiff_t count);
602#define KLS_POP_ARR_T(kls_temp, type, count) (type*)kls_temp_pop_AR((kls_temp), sizeof(type), _Alignof(type), (count))
608#define KLS_POP_STR_T(kls_temp, cstr) KLS_POP_ARR_T((kls_temp), char, strlen((cstr)))
614#define KLS_POP_T(kls_temp, type) KLS_POP_ARR_T((kls_temp), type, 1)
626#define KLS__STRCPY(dest, source) do {\
627 strcpy((dest), (source));\
635#define KLS_STRDUP(kls, source) kls_strdup((kls), (source))
645#define KLS_STRDUP_T(t_kls, source) kls_t_strdup((t_kls), (source))
650#error "This code requires C11 or later.\n _Alignof() is not available"
char * kls_strdup(Koliseo *kls, char *source)
Function to dupe a C string to a Koliseo, and return a pointer to the allocated string.
Definition koliseo.c:1759
void * kls_temp_pop(Koliseo_Temp *t_kls, ptrdiff_t size, ptrdiff_t align, ptrdiff_t count)
Takes a Koliseo_Temp, and ptrdiff_t values for size, align and count.
Definition koliseo.c:1670
Koliseo_Temp * kls_temp_start(Koliseo *kls)
Starts a new savestate for the passed Koliseo pointer, by initialising its Koliseo_Temp pointer and r...
Definition koliseo.c:1503
void print_dbg_temp_kls(const Koliseo_Temp *t_kls)
Prints header fields from the passed Koliseo_Temp pointer, to stderr.
Definition koliseo.c:1395
void print_temp_kls_2file(FILE *fp, const Koliseo_Temp *t_kls)
Prints header fields from the passed Koliseo_Temp pointer, to the passed FILE pointer.
Definition koliseo.c:1356
char * kls_t_strdup(Koliseo_Temp *t_kls, char *source)
Function to dupe a C string to a Koliseo_Temp, and return a pointer to the allocated string.
Definition koliseo.c:1788
KLS_Stats KLS_STATS_DEFAULT
Definition koliseo.c:40
void kls_log(Koliseo *kls, const char *tag, const char *format,...)
Logs a message to the log_fp FILE field of the passed Koliseo pointer, if its conf....
Definition koliseo.c:292
void kls_temp_end(Koliseo_Temp *tmp_kls)
Ends passed Koliseo_Temp pointer.
Definition koliseo.c:1553
void kls_dbg_features(void)
Prints enabled Koliseo features to stderr.
Definition koliseo.c:228
char ** kls_strdup_arr(Koliseo *kls, size_t count, char **source)
Function to dupe a C string array to a Koliseo, and return a pointer to the allocated array.
Definition koliseo.c:1772
void * kls_temp_push_zero_ext(Koliseo_Temp *t_kls, ptrdiff_t size, ptrdiff_t align, ptrdiff_t count)
Takes a Koliseo_Temp, and ptrdiff_t values for size, align and count.
Definition koliseo.c:1224
void print_dbg_kls(const Koliseo *kls)
Prints header fields from the passed Koliseo pointer, to stderr.
Definition koliseo.c:1342
const char * string_koliseo_version(void)
Returns the constant string representing current version for Koliseo.
Definition koliseo.c:58
Koliseo * kls_new_dbg_alloc(ptrdiff_t size, kls_alloc_func alloc_func)
Takes a ptrdiff_t size and an allocation function pointer, and returns a pointer to the prepared Koli...
Definition koliseo.c:575
ptrdiff_t kls_get_pos(const Koliseo *kls)
Returns the current offset (position of pointer bumper) for the passed Koliseo.
Definition koliseo.c:281
void * kls_temp_pop_AR(Koliseo_Temp *t_kls, ptrdiff_t size, ptrdiff_t align, ptrdiff_t count)
Takes a Koliseo_Temp, and ptrdiff_t values for size, align and count.
Definition koliseo.c:1716
void * kls_pop_AR(Koliseo *kls, ptrdiff_t size, ptrdiff_t align, ptrdiff_t count)
Takes a Koliseo pointer, and ptrdiff_t values for size, align and count.
Definition koliseo.c:1633
Koliseo * kls_new_conf_alloc(ptrdiff_t size, KLS_Conf conf, kls_alloc_func alloc_func)
Takes a ptrdiff_t size, a KLS_Conf to configure the new Koliseo, and an allocation function pointer.
Definition koliseo.c:474
void kls_free(Koliseo *kls)
Calls kls_clear() on the passed Koliseo pointer and the frees the actual Koliseo.
Definition koliseo.c:1449
Koliseo * kls_new_traced_alloc(ptrdiff_t size, const char *output_path, kls_alloc_func alloc_func)
Takes a ptrdiff_t size, a filepath for the trace output file, and an allocation function pointer.
Definition koliseo.c:526
char ** kls_t_strdup_arr(Koliseo_Temp *t_kls, size_t count, char **source)
Function to dupe a C string array to a Koliseo_Temp, and return a pointer to the allocated array.
Definition koliseo.c:1801
Koliseo * kls_new_dbg_alloc_handled(ptrdiff_t size, kls_alloc_func alloc_func, KLS_Err_Handlers err_handlers)
Takes a ptrdiff_t size and an allocation function pointer, and returns a pointer to the prepared Koli...
Definition koliseo.c:543
void * kls_push_zero(Koliseo *kls, ptrdiff_t size, ptrdiff_t align, ptrdiff_t count)
Takes a Koliseo pointer, and ptrdiff_t values for size, align and count.
Definition koliseo.c:1023
int kls__check_available_failable(Koliseo *kls, ptrdiff_t size, ptrdiff_t align, ptrdiff_t count, const char *caller_name)
Takes a Koliseo, a ptrdiff_t size, align and count, and a caller name.
Definition koliseo.c:702
Koliseo * kls_new_alloc(ptrdiff_t size, kls_alloc_func alloc_func)
Takes a ptrdiff_t size and a function pointer to the allocation function.
Definition koliseo.c:419
void * kls_pop(Koliseo *kls, ptrdiff_t size, ptrdiff_t align, ptrdiff_t count)
Takes a Koliseo pointer, and ptrdiff_t values for size, align and count.
Definition koliseo.c:1596
void KLS_PTRDIFF_MAX_default_handler__(struct Koliseo *kls, ptrdiff_t size, ptrdiff_t count)
Definition koliseo.c:102
KLS_Conf KLS_DEFAULT_CONF
Config used by any new Koliseo by default.
Definition koliseo.c:20
void KLS_ZEROCOUNT_default_handler__(Koliseo *kls, ptrdiff_t available, ptrdiff_t padding, ptrdiff_t size)
Used internally for handling zero-count in push calls when no user handler is provided.
Definition koliseo.c:144
Koliseo * kls_new_conf_alloc_ext(ptrdiff_t size, KLS_Conf conf, kls_alloc_func alloc_func, KLS_Hooks ext_handlers, void *user)
Takes a ptrdiff_t size, a KLS_Conf to configure the new Koliseo, and an allocation function pointer.
Definition koliseo.c:446
Koliseo * kls_new_traced_alloc_handled(ptrdiff_t size, const char *output_path, kls_alloc_func alloc_func, KLS_Err_Handlers err_handlers)
Takes a ptrdiff_t size, a filepath for the trace output file, and an allocation function pointer.
Definition koliseo.c:492
KLS_Conf kls_conf_init(int autoset_regions, int alloc_backend, ptrdiff_t reglist_kls_size, int autoset_temp_regions, int collect_stats, int verbose_lvl, int block_while_has_temp, int allow_zerocount_push, FILE *log_fp, const char *log_filepath)
Used to prepare a KLS_Conf without caring about KOLISEO_HAS_REGIONS.
Definition koliseo.c:219
void print_kls_2file(FILE *fp, const Koliseo *kls)
Prints header fields from the passed Koliseo pointer, to the passed FILE pointer.
Definition koliseo.c:1311
KLS_Conf kls_conf_init_handled(int autoset_regions, int alloc_backend, ptrdiff_t reglist_kls_size, int autoset_temp_regions, int collect_stats, int verbose_lvl, int block_while_has_temp, int allow_zerocount_push, FILE *log_fp, const char *log_filepath, KLS_Err_Handlers err_handlers)
Used to prepare a KLS_Conf without caring about KOLISEO_HAS_REGIONS.
Definition koliseo.c:168
Koliseo * kls_new_alloc_ext(ptrdiff_t size, kls_alloc_func alloc_func, KLS_Hooks ext_handlers, void *user)
Takes a ptrdiff_t size and a function pointer to the allocation function.
Definition koliseo.c:338
void kls_clear(Koliseo *kls)
Resets the offset field for the passed Koliseo pointer.
Definition koliseo.c:1429
void * kls_push_zero_ext(Koliseo *kls, ptrdiff_t size, ptrdiff_t align, ptrdiff_t count)
Takes a Koliseo pointer, and ptrdiff_t values for size, align and count.
Definition koliseo.c:1112
void kls_formatSize(ptrdiff_t size, char *outputBuffer, size_t bufferSize)
Converts a ptrdiff_t size to human-readable SI units (modulo 1000).
Definition koliseo.c:1407
void KLS_OOM_default_handler__(Koliseo *kls, ptrdiff_t available, ptrdiff_t padding, ptrdiff_t size, ptrdiff_t count)
Used internally for handling Out-Of-Memory in push calls when no user handler is provided.
Definition koliseo.c:82
int int_koliseo_version(void)
Returns the constant int representing current version for Koliseo.
Definition koliseo.c:67