koliseo 0.5.10
Loading...
Searching...
No Matches
koliseo.h
Go to the documentation of this file.
1// jgabaut @ github.com/jgabaut
2// SPDX-License-Identifier: GPL-3.0-only
3/*
4 Copyright (C) 2023-2026 jgabaut
5
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, version 3 of the License.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>.
17*/
18
19#ifndef KOLISEO_H_
20
21#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) //We need C11
22#define KLS_ALIGNOF _Alignof
23#elif defined(__cplusplus)
24#define KLS_ALIGNOF alignof
25#else
26#error "This code requires C11 or later.\n _Alignof() is not available"
27#endif // __STDC_VERSION__ && __STDC_VERSION__ >= 201112L //We need C11
28
29#define KOLISEO_H_
30
31#if defined(__cplusplus)
32extern "C" {
33#endif // __cplusplus
34
35#ifndef _WIN32
36#define _POSIX_C_SOURCE 200809L
37#endif
38
39#include <stdio.h>
40#include <stdint.h>
41#include <stddef.h>
42#include <stdlib.h>
43#include <stdarg.h>
44#include <assert.h>
45#include <string.h>
46#include <time.h>
47#include <stdbool.h>
48
49#ifdef KLS_DEBUG_CORE
50#include <time.h>
51
52/*
53#ifndef KOLISEO_HAS_LOCATE
54#define KOLISEO_HAS_LOCATE // Used for enabling caller location arguments for some APIs.
55#endif // KOLISEO_HAS_LOCATE
56*/
57
58#ifdef _WIN32
59#include <profileapi.h> //Used for QueryPerformanceFrequency(), QueryPerformanceCounter()
60#endif
61#endif //KLS_DEBUG_CORE
62
63#ifdef KOLISEO_HAS_LOCATE
64typedef struct Koliseo_Loc {
65 const char* file;
66 const int line;
67 const char* func;
68} Koliseo_Loc;
69
70#define KLS_HERE (Koliseo_Loc){ \
71 .file = __FILE__, \
72 .line = __LINE__, \
73 .func = __func__, \
74}
75
80#define KLS_Loc_Fmt "[%s:%i at %s():] "
81
86#define KLS_Loc_Arg(loc) (loc.file), (loc.line), (loc.func)
87#endif // KOLISEO_HAS_LOCATE
88
89#define KLS_MAJOR 0
90#define KLS_MINOR 5
91#define KLS_PATCH 10
92
93typedef void*(kls_alloc_func)(size_t);
94typedef void(kls_free_func)(void*);
95
96#define STRINGIFY_2(x) #x
97
98#define STRINGIFY(x) STRINGIFY_2(x)
99
100#define KLS_MAX(a, b) ((a) > (b) ? (a) : (b))
101
105static const int KOLISEO_API_VERSION_INT =
106 (KLS_MAJOR * 1000000 + KLS_MINOR * 10000 + KLS_PATCH * 100);
108
112static const char KOLISEO_API_VERSION_STRING[] = "0.5.10";
113
117const char *string_koliseo_version(void);
118
122int int_koliseo_version(void);
123
124#define KLS_DEFAULT_SIZE (16*1024)
125
126#ifndef KLS_DEFAULT_ALIGNMENT
127#define KLS_DEFAULT_ALIGNMENT (2*sizeof(void *))
128#endif
129
130struct Koliseo_Temp; //Forward declaration for Koliseo itself
131struct Koliseo; //Forward declaration for KLS_OOM_Handler
132
133#ifndef KOLISEO_HAS_LOCATE
134typedef void(KLS_OOM_Handler)(struct Koliseo* kls, ptrdiff_t available, ptrdiff_t padding, ptrdiff_t size, ptrdiff_t count);
135#else
136typedef void(KLS_OOM_Handler)(struct Koliseo* kls, ptrdiff_t available, ptrdiff_t padding, ptrdiff_t size, ptrdiff_t count, Koliseo_Loc loc);
137#endif
138
139#ifndef KOLISEO_HAS_LOCATE
140typedef void(KLS_PTRDIFF_MAX_Handler)(struct Koliseo* kls, ptrdiff_t size, ptrdiff_t count);
141#else
142typedef void(KLS_PTRDIFF_MAX_Handler)(struct Koliseo* kls, ptrdiff_t size, ptrdiff_t count, Koliseo_Loc loc);
143#endif
144
145#ifndef KOLISEO_HAS_LOCATE
146typedef void(KLS_ZEROCOUNT_Handler)(struct Koliseo* kls, ptrdiff_t available, ptrdiff_t padding, ptrdiff_t size);
147#else
148typedef void(KLS_ZEROCOUNT_Handler)(struct Koliseo* kls, ptrdiff_t available, ptrdiff_t padding, ptrdiff_t size, Koliseo_Loc loc);
149#endif
150
151#ifndef KOLISEO_HAS_LOCATE
152void KLS_OOM_default_handler__(struct Koliseo* kls, ptrdiff_t available, ptrdiff_t padding, ptrdiff_t size, ptrdiff_t count);
153#else
154void KLS_OOM_default_handler_dbg__(struct Koliseo* kls, ptrdiff_t available, ptrdiff_t padding, ptrdiff_t size, ptrdiff_t count, Koliseo_Loc loc);
155#endif
156
157#ifndef KOLISEO_HAS_LOCATE
158void KLS_PTRDIFF_MAX_default_handler__(struct Koliseo* kls, ptrdiff_t size, ptrdiff_t count);
159#else
160void KLS_PTRDIFF_MAX_default_handler_dbg__(struct Koliseo* kls, ptrdiff_t size, ptrdiff_t count, Koliseo_Loc loc);
161#endif
162
163#ifndef KOLISEO_HAS_LOCATE
164void KLS_ZEROCOUNT_default_handler__(struct Koliseo* kls, ptrdiff_t available, ptrdiff_t padding, ptrdiff_t size);
165#else
166void KLS_ZEROCOUNT_default_handler_dbg__(struct Koliseo* kls, ptrdiff_t available, ptrdiff_t padding, ptrdiff_t size, Koliseo_Loc loc);
167#endif
168
178
179#ifndef KOLISEO_HAS_LOCATE
180#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__, }
181#else
182#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__, }
183#endif // KOLISEO_HAS_LOCATE
184
185typedef void(KLS_hook_on_new)(struct Koliseo* kls);
186
187typedef void(KLS_hook_on_free)(struct Koliseo* kls);
188
189typedef void(KLS_hook_on_push)(struct Koliseo* kls, ptrdiff_t padding, const char* caller, void* user);
190
191typedef void(KLS_hook_on_temp_start)(struct Koliseo_Temp* t_kls);
192
193typedef void(KLS_hook_on_temp_free)(struct Koliseo_Temp* t_kls);
194
195typedef void(KLS_hook_on_temp_push)(struct Koliseo_Temp* t_kls, ptrdiff_t padding, const char* caller, void* user);
196
205
213#ifndef KLS_DEFAULT_HOOKS
214#define KLS_DEFAULT_HOOKS &(KLS_Hooks){0}
215#endif // KLS_DEFAULT_HOOKS
216
223#ifndef KLS_DEFAULT_EXTENSION_DATA
224#define KLS_DEFAULT_EXTENSION_DATA NULL
225#endif // KLS_DEFAULT_EXTENSION_DATA
226
241
242KLS_Conf kls_conf_init_handled(int collect_stats, int verbose_lvl, int block_while_has_temp, int allow_zerocount_push, int growable, FILE* log_fp, const char* log_filepath, KLS_Err_Handlers err_handlers);
243
244KLS_Conf kls_conf_init(int collect_stats, int verbose_lvl, int block_while_has_temp, int allow_zerocount_push, int growable, FILE* log_fp, const char* log_filepath);
245
246void kls_dbg_features(void);
247
252typedef struct KLS_Stats {
259#ifdef KLS_DEBUG_CORE
261#endif
263
270
277
282#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 }"
283
288#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)
289
294#ifdef KLS_DEBUG_CORE
295#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 }"
296#else
297#define KLS_Stats_Fmt "KLS_Stats { tot_pushes: %i, tot_pops: %i, tot_temp_pushes: %i, tot_temp_pops: %i, tot_hiccups: %i }"
298#endif // KLS_DEBUG_CORE
299
304#ifdef KLS_DEBUG_CORE
305#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)
306#else
307#define KLS_Stats_Arg(stats) (stats.tot_pushes),(stats.tot_pops),(stats.tot_temp_pushes),(stats.tot_temp_pops),(stats.tot_hiccups)
308#endif // KLS_DEBUG_CORE
309
316#ifndef KLS_MAX_EXTENSIONS
317#define KLS_MAX_EXTENSIONS 1
318#endif // KLS_MAX_EXTENSIONS
319
328#ifndef KLS_DEFAULT_EXTENSIONS_LEN
329#define KLS_DEFAULT_EXTENSIONS_LEN 0
330#endif // KLS_MAX_EXTENSIONS
331
355
360#ifndef _WIN32
361#define KLSFmt "KLS {begin: %p, curr: %p, size: %li, offset: %li, has_temp: %i}"
362#else
363#define KLSFmt "KLS {begin: %p, curr: %p, size: %lli, offset: %lli, has_temp: %i}"
364#endif
365
370#define KLS_Arg(kls) (void*)(kls),(void*)((kls)+(kls->offset)),(kls->size),(kls->offset),(kls->has_temp)
371
379typedef struct Koliseo_Temp {
381 ptrdiff_t offset;
382 ptrdiff_t prev_offset;
384
401
411
412void kls_log(Koliseo * kls, const char *tag, const char *format, ...);
413ptrdiff_t kls_get_pos(const Koliseo * kls);
414
415#ifndef KOLISEO_HAS_LOCATE
416Koliseo *kls_new_alloc_ext(ptrdiff_t size, kls_alloc_func alloc_func, kls_free_func free_func, KLS_Hooks* ext_handlers, void** user, size_t ext_len);
417#else
418Koliseo *kls_new_alloc_ext_dbg(ptrdiff_t size, kls_alloc_func alloc_func, kls_free_func free_func, KLS_Hooks* ext_handlers, void** user, size_t ext_len, Koliseo_Loc loc);
419#define kls_new_alloc_ext(size, alloc_func, free_func, ext_handlers, user, ext_len) kls_new_alloc_ext_dbg((size), (alloc_func), (free_func), (ext_handlers), (user), (ext_len), KLS_HERE)
420#endif // KOLISEO_HAS_LOCATE
421
422#ifndef KOLISEO_HAS_LOCATE
423Koliseo *kls_new_alloc(ptrdiff_t size, kls_alloc_func alloc_func, kls_free_func free_func);
424#else
425Koliseo *kls_new_alloc_dbg(ptrdiff_t size, kls_alloc_func alloc_func, kls_free_func free_func, Koliseo_Loc loc);
426#define kls_new_alloc(size, alloc_func, free_func) kls_new_alloc_dbg((size), (alloc_func), (free_func), KLS_HERE)
427#endif // KOLISEO_HAS_LOCATE
428
429#ifndef KLS_DEFAULT_ALLOCF
430#define KLS_DEFAULT_ALLOCF malloc
431#endif
432
433#ifndef KLS_DEFAULT_FREEF
434#define KLS_DEFAULT_FREEF free
435#endif
436
437Koliseo* kls_new(ptrdiff_t size);
438//bool kls_set_conf(Koliseo* kls, KLS_Conf conf);
439Koliseo *kls_new_conf_alloc_ext(ptrdiff_t size, KLS_Conf conf, kls_alloc_func alloc_func, kls_free_func free_func, KLS_Hooks* ext_handlers, void** user, size_t ext_len);
441Koliseo *kls_new_conf_ext(ptrdiff_t size, KLS_Conf conf, KLS_Hooks* ext_handlers, void** user, size_t ext_len);
442Koliseo *kls_new_conf(ptrdiff_t size, KLS_Conf conf);
443
444Koliseo *kls_new_traced_alloc_handled_ext(ptrdiff_t size, const char *output_path, kls_alloc_func alloc_func, kls_free_func free_func, KLS_Err_Handlers err_handlers, KLS_Hooks* ext_handlers, void** user, size_t ext_len);
445Koliseo *kls_new_traced_alloc_handled(ptrdiff_t size, const char *output_path, kls_alloc_func alloc_func, kls_free_func free_func, KLS_Err_Handlers err_handlers);
446Koliseo *kls_new_traced_ext(ptrdiff_t size, const char *output_path, KLS_Hooks* ext_handlers, void** user, size_t ext_len);
447Koliseo *kls_new_traced_alloc(ptrdiff_t size, const char *output_path, kls_alloc_func alloc_func, kls_free_func free_func);
448Koliseo *kls_new_traced(ptrdiff_t size, const char* output_path);
449Koliseo *kls_new_traced_handled(ptrdiff_t size, const char* output_path, KLS_Err_Handlers err_handlers);
450
451Koliseo *kls_new_dbg_alloc_handled_ext(ptrdiff_t size, kls_alloc_func alloc_func, kls_free_func free_func, KLS_Err_Handlers err_handlers, KLS_Hooks* ext_handlers, void** user, size_t ext_len);
452Koliseo *kls_new_dbg_alloc_handled(ptrdiff_t size, kls_alloc_func alloc_func, kls_free_func free_func, KLS_Err_Handlers err_handlers);
453Koliseo *kls_new_dbg_ext(ptrdiff_t size, KLS_Hooks* ext_handlers, void** user, size_t ext_len);
454Koliseo *kls_new_dbg_alloc(ptrdiff_t size, kls_alloc_func alloc_func, kls_free_func free_func);
455Koliseo *kls_new_dbg(ptrdiff_t size);
456Koliseo *kls_new_dbg_handled(ptrdiff_t size, KLS_Err_Handlers err_handlers);
457
458#ifndef KOLISEO_HAS_LOCATE
459void* kls__handle_push_result(Koliseo* kls, KLS_Push_Result r, ptrdiff_t size, ptrdiff_t align, ptrdiff_t count, ptrdiff_t padding, const char* caller_name);
460#else
461void* kls__handle_push_result_dbg(Koliseo* kls, KLS_Push_Result r, ptrdiff_t size, ptrdiff_t align, ptrdiff_t count, ptrdiff_t padding, const char* caller_name, Koliseo_Loc loc);
462#endif // KOLISEO_HAS_LOCATE
463
464#ifndef KOLISEO_HAS_LOCATE
465KLS_Push_Result kls__advance(Koliseo* kls, ptrdiff_t size, ptrdiff_t align, ptrdiff_t count, ptrdiff_t* padding, const char* caller_name);
466#else
467KLS_Push_Result kls__advance_dbg(Koliseo* kls, ptrdiff_t size, ptrdiff_t align, ptrdiff_t count, ptrdiff_t* padding, const char* caller_name, Koliseo_Loc loc);
468#endif // KOLISEO_HAS_LOCATE
469
470#ifndef KOLISEO_HAS_LOCATE
471KLS_Push_Result kls__temp_advance(Koliseo_Temp* t_kls, ptrdiff_t size, ptrdiff_t align, ptrdiff_t count, ptrdiff_t* padding, const char* caller_name);
472#else
473KLS_Push_Result kls__temp_advance_dbg(Koliseo_Temp* t_kls, ptrdiff_t size, ptrdiff_t align, ptrdiff_t count, ptrdiff_t* padding, const char* caller_name, Koliseo_Loc loc);
474#endif // KOLISEO_HAS_LOCATE
475
476#ifndef KOLISEO_HAS_LOCATE
477KLS_Push_Error kls__check_available_failable(Koliseo* kls, ptrdiff_t size, ptrdiff_t align, ptrdiff_t count, const char* caller_name);
478#else
479KLS_Push_Error kls__check_available_failable_dbg(Koliseo* kls, ptrdiff_t size, ptrdiff_t align, ptrdiff_t count, const char* caller_name, Koliseo_Loc loc);
480#endif // KOLISEO_HAS_LOCATE
481
487#ifndef KOLISEO_HAS_LOCATE
488#define kls__check_available(kls, size, align, count) do { \
489 int res = kls__check_available_failable((kls), (size), (align), (count), __func__); \
490 if (res != 0) return NULL; \
491} while(0)
492#else
493#define kls__check_available_dbg(kls, size, align, count, loc) do { \
494 int res = kls__check_available_failable_dbg((kls), (size), (align), (count), __func__, (loc)); \
495 if (res != 0) return NULL; \
496} while(0)
497#endif // KOLISEO_HAS_LOCATE
498
499//void* kls_push(Koliseo* kls, ptrdiff_t size, ptrdiff_t align, ptrdiff_t count);
500
501#ifndef KOLISEO_HAS_LOCATE
502void *kls_push_zero(Koliseo * kls, ptrdiff_t size, ptrdiff_t align,
503 ptrdiff_t count);
504#else
505void *kls_push_zero_dbg(Koliseo * kls, ptrdiff_t size, ptrdiff_t align,
506 ptrdiff_t count, Koliseo_Loc loc);
507
508#define kls_push_zero(kls, size, align, count) kls_push_zero_dbg((kls), (size), (align), (count), KLS_HERE)
509#endif // KOLISEO_HAS_LOCATE
510
511#ifndef KOLISEO_HAS_LOCATE
512void *kls_push_zero_ext(Koliseo * kls, ptrdiff_t size, ptrdiff_t align,
513 ptrdiff_t count);
514#else
515void *kls_push_zero_ext_dbg(Koliseo * kls, ptrdiff_t size, ptrdiff_t align,
516 ptrdiff_t count, Koliseo_Loc loc);
517#define kls_push_zero_ext(kls, size, align, count) kls_push_zero_ext_dbg((kls), (size), (align), (count), KLS_HERE)
518#endif // KOLISEO_HAS_LOCATE
519
520#ifndef KOLISEO_HAS_LOCATE
521char* kls_vsprintf(Koliseo* kls, const char* fmt, va_list args);
522#else
523char* kls_vsprintf_dbg(Koliseo* kls, Koliseo_Loc loc, const char* fmt, va_list args);
524#define kls_vsprintf(kls, fmt, args) kls_vsprintf_dbg((kls), KLS_HERE, (fmt), (args))
525#endif // KOLISEO_HAS_LOCATE
526
527#ifndef KOLISEO_HAS_LOCATE
528char* kls_sprintf(Koliseo* kls, const char* fmt, ...);
529#else
530char* kls_sprintf_dbg(Koliseo* kls, Koliseo_Loc loc, const char* fmt, ...);
531#define kls_sprintf(kls, fmt, ...) kls_sprintf_dbg((kls), KLS_HERE, (fmt), __VA_ARGS__)
532#endif // KOLISEO_HAS_LOCATE
533
534#ifndef KOLISEO_HAS_LOCATE
535void *kls_repush(Koliseo *kls, void* old, ptrdiff_t size, ptrdiff_t align,
536 ptrdiff_t old_count, ptrdiff_t new_count);
537#else
538void *kls_repush_dbg(Koliseo *kls, void* old, ptrdiff_t size, ptrdiff_t align,
539 ptrdiff_t old_count, ptrdiff_t new_count, Koliseo_Loc loc);
540#define kls_repush(kls, old, size, align, old_count, new_count) kls_repush_dbg((kls), (old), (size), (align), (old_count), (new_count), KLS_HERE)
541#endif // KOLISEO_HAS_LOCATE
542
543#ifndef KOLISEO_HAS_LOCATE
544void *kls_temp_repush(Koliseo_Temp *t_kls, void* old, ptrdiff_t size, ptrdiff_t align,
545 ptrdiff_t old_count, ptrdiff_t new_count);
546#else
547void *kls_temp_repush_dbg(Koliseo_Temp *t_kls, void* old, ptrdiff_t size, ptrdiff_t align,
548 ptrdiff_t old_count, ptrdiff_t new_count, Koliseo_Loc loc);
549#define kls_temp_repush(t_kls, old, size, align, old_count, new_count) kls_temp_repush_dbg((t_kls), (old), (size), (align), (old_count), (new_count), KLS_HERE)
550#endif // KOLISEO_HAS_LOCATE
551
555#define KLS_PUSH_ARR(kls, type, count) (type*)kls_push_zero_ext((kls), sizeof(type), KLS_ALIGNOF(type), (count))
556
560#define KLS_SPRINTF(kls, fmt, ...) kls_sprintf((kls), (fmt), __VA_ARGS__)
561
566#define KLS_PUSH_STR(kls, cstr) KLS_PUSH_ARR((kls), char, strlen((cstr))+1)
567
571#define KLS_REPUSH(kls, old, type, old_count, new_count) (type*)kls_repush((kls), (old), sizeof(type), KLS_ALIGNOF(type), (old_count), (new_count))
572
576#define KLS_REPUSH_T(t_kls, old, type, old_count, new_count) (type*)kls_temp_repush((t_kls), (old), sizeof(type), KLS_ALIGNOF(type), (old_count), (new_count))
577
581#define KLS_PUSH_ARR_NAMED(kls, type, count, name, desc) KLS_PUSH_ARR((kls),type,(count))
582
586#define KLS_PUSH_STR_NAMED(kls, cstr, name, desc) KLS_PUSH_ARR_NAMED((kls), char, strlen((cstr))+1, (name), (desc))
587
591#define KLS_PUSH_ARR_TYPED(kls, type, count, region_type, name, desc) KLS_PUSH_ARR((kls),type,(count))
592
596#define KLS_PUSH_STR_TYPED(kls, cstr, region_type, name, desc) KLS_PUSH_ARR_TYPED((kls), char, strlen((cstr))+1, (region_type), (name), (desc))
597
601#define KLS_PUSH(kls, type) KLS_PUSH_ARR((kls), type, 1)
602
606#define KLS_PUSH_NAMED(kls, type, name, desc) KLS_PUSH_ARR_NAMED((kls), type, 1, (name), (desc))
607
612#define KLS_PUSH_EX(kls, type, name) KLS_PUSH_NAMED((kls), type, (name), STRINGIFY(type))
613
617#define KLS_PUSH_TYPED(kls, type, region_type, name, desc) KLS_PUSH_ARR_TYPED((kls), type, 1, (region_type), (name), (desc))
618
623#define KLS_PUSH_TYPED_EX(kls, type, region_type, name) KLS_PUSH_TYPED((kls), type, (region_type), (name), STRINGIFY(type))
624
625void kls_clear(Koliseo * kls);
626void kls_free(Koliseo * kls);
627void print_kls_2file(FILE * fp, const Koliseo * kls);
628void print_dbg_kls(const Koliseo * kls);
629void kls_formatSize(ptrdiff_t size, char *outputBuffer, size_t bufferSize);
630
631#ifndef KOLISEO_HAS_LOCATE
633#else
634Koliseo_Temp *kls_temp_start_dbg(Koliseo * kls, Koliseo_Loc loc);
635#define kls_temp_start(kls) kls_temp_start_dbg((kls), KLS_HERE)
636#endif // KOLISEO_HAS_LOCATE
637//bool kls_temp_set_conf(Koliseo_Temp* t_kls, KLS_Temp_Conf conf);
638void kls_temp_end(Koliseo_Temp * tmp_kls);
639
640#ifndef KOLISEO_HAS_LOCATE
641void *kls_temp_push_zero_ext(Koliseo_Temp * t_kls, ptrdiff_t size,
642 ptrdiff_t align, ptrdiff_t count);
643#else
644void *kls_temp_push_zero_ext_dbg(Koliseo_Temp * t_kls, ptrdiff_t size,
645 ptrdiff_t align, ptrdiff_t count, Koliseo_Loc loc);
646#define kls_temp_push_zero_ext(t_kls, size, align, count) kls_temp_push_zero_ext_dbg((t_kls), (size), (align), (count), KLS_HERE)
647#endif // KOLISEO_HAS_LOCATE
648
649#ifndef KOLISEO_HAS_LOCATE
650char* kls_temp_vsprintf(Koliseo_Temp* kls_t, const char* fmt, va_list args);
651#else
652char* kls_temp_vsprintf_dbg(Koliseo_Temp* kls_t, Koliseo_Loc loc, const char* fmt, va_list args);
653#define kls_temp_vsprintf(t_kls, fmt, args) kls_temp_vsprintf_dbg((t_kls), KLS_HERE, (fmt), (args))
654#endif // KOLISEO_HAS_LOCATE
655
656#ifndef KOLISEO_HAS_LOCATE
657char* kls_temp_sprintf(Koliseo_Temp* kls_t, const char* fmt, ...);
658#else
659char* kls_temp_sprintf_dbg(Koliseo_Temp* kls_t, Koliseo_Loc loc, const char* fmt, ...);
660#define kls_temp_sprintf(t_kls, fmt, ...) kls_temp_sprintf_dbg((t_kls), KLS_HERE, (fmt), __VA_ARGS__)
661#endif // KOLISEO_HAS_LOCATE
662
663void print_temp_kls_2file(FILE * fp, const Koliseo_Temp * t_kls);
664void print_dbg_temp_kls(const Koliseo_Temp * t_kls);
665
669#define KLS_PUSH_ARR_T(kls_temp, type, count) (type*)kls_temp_push_zero_ext((kls_temp), sizeof(type), KLS_ALIGNOF(type), (count))
670
674#define KLS_SPRINTF_T(kls_temp, fmt, ...) kls_temp_sprintf((kls_temp), (fmt), __VA_ARGS__)
675
680#define KLS_PUSH_STR_T(kls_temp, cstr) KLS_PUSH_ARR_T((kls_temp), char, strlen((cstr))+1)
681
685#define KLS_PUSH_ARR_T_NAMED(kls_temp, type, count, name, desc) KLS_PUSH_ARR_T((kls_temp),type,(count))
686
690#define KLS_PUSH_STR_T_NAMED(kls_temp, cstr, name, desc) KLS_PUSH_ARR_T_NAMED((kls_temp), char, strlen((cstr))+1, (name), (desc))
691
695#define KLS_PUSH_ARR_T_TYPED(kls_temp, type, count, region_type, name, desc) KLS_PUSH_ARR_T((kls_temp),type,(count))
696
700#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))
701
705#define KLS_PUSH_T(kls_temp, type) KLS_PUSH_ARR_T((kls_temp), type, 1)
706
710#define KLS_PUSH_T_NAMED(kls_temp, type, name, desc) KLS_PUSH_ARR_T_NAMED((kls_temp), type, 1, (name), (desc))
711
716#define KLS_PUSH_T_EX(kls_temp, type, name) KLS_PUSH_T_NAMED((kls_temp), type, (name), STRINGIFY(type))
717
721#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))
722
727#define KLS_PUSH_T_TYPED_EX(kls_temp, type, region_type, name) KLS_PUSH_T_TYPED((kls_temp), type, (region_type), (name), STRINFIGY(type))
728
729#ifdef KOLISEO_HAS_EXPER
730
731void *kls_pop(Koliseo * kls, ptrdiff_t size, ptrdiff_t align, ptrdiff_t count);
732void *kls_pop_AR(Koliseo *kls, ptrdiff_t size, ptrdiff_t align, ptrdiff_t count);
733
738#define KLS_POP_ARR(kls, type, count) (type*)kls_pop_AR((kls), sizeof(type), KLS_ALIGNOF(type), (count))
739
744#define KLS_POP_STR(kls, cstr) KLS_POP_ARR((kls), char, strlen((cstr)))
745
750#define KLS_POP(kls, type) KLS_POP_ARR((kls), type, 1)
751
752void *kls_temp_pop(Koliseo_Temp * t_kls, ptrdiff_t size, ptrdiff_t align,
753 ptrdiff_t count);
754void *kls_temp_pop_AR(Koliseo_Temp *t_kls, ptrdiff_t size, ptrdiff_t align, ptrdiff_t count);
755
760#define KLS_POP_ARR_T(kls_temp, type, count) (type*)kls_temp_pop_AR((kls_temp), sizeof(type), KLS_ALIGNOF(type), (count))
761
766#define KLS_POP_STR_T(kls_temp, cstr) KLS_POP_ARR_T((kls_temp), char, strlen((cstr)))
767
772#define KLS_POP_T(kls_temp, type) KLS_POP_ARR_T((kls_temp), type, 1)
773
774char* kls_strdup(Koliseo* kls, char* source);
775char** kls_strdup_arr(Koliseo* kls, size_t count, char** source);
776
784#define KLS__STRCPY(dest, source) do {\
785 strcpy((dest), (source));\
786} while (0)
787
788/*
789 * Macro to dupe a C string to a passed Koliseo, returns a pointer to the allocated string.
790 * Unsafe, do not use.
791 * @see kls_strdup()
792 */
793#define KLS_STRDUP(kls, source) kls_strdup((kls), (source))
794
795char* kls_t_strdup(Koliseo_Temp* t_kls, char* source);
796char** kls_t_strdup_arr(Koliseo_Temp* t_kls, size_t count, char** source);
797
798/*
799 * Macro to dupe a C string to a passed Koliseo_Temp, returns a pointer to the allocated string.
800 * Unsafe, do not use.
801 * @see kls_t_strdup()
802 */
803#define KLS_STRDUP_T(t_kls, source) kls_t_strdup((t_kls), (source))
804
805#endif // KOLISEO_HAS_EXPER
806
807#if defined(__cplusplus)
808}
809#endif // __cplusplus
810#endif //KOLISEO_H_
811
KLS_Stats KLS_STATS_DEFAULT
Default KLS_Stats values, used by kls_new().
Definition koliseo.c:41
KLS_Conf KLS_DEFAULT_CONF
Config used by any new Koliseo by default.
Definition koliseo.c:20
void kls_free_func(void *)
Used to select a free function for the arena's backing memory.
Definition koliseo.h:94
Koliseo * kls_new_traced(ptrdiff_t size, const char *output_path)
Takes a ptrdiff_t size and a filepath for the trace output file.
Definition koliseo.c:842
Koliseo * kls_new(ptrdiff_t size)
Takes a ptrdiff_t size.
Definition koliseo.c:650
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:2329
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:2240
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:2052
void KLS_hook_on_new(struct Koliseo *kls)
Used to pass an extension handler for kls_new_alloc().
Definition koliseo.h:185
void print_dbg_temp_kls(const Koliseo_Temp *t_kls)
Prints header fields from the passed Koliseo_Temp pointer, to stderr.
Definition koliseo.c:1930
void KLS_OOM_default_handler__(struct Koliseo *kls, ptrdiff_t available, ptrdiff_t padding, ptrdiff_t size, ptrdiff_t count)
Used by default when no handler is passed.
Definition koliseo.c:92
void * kls_temp_repush(Koliseo_Temp *t_kls, void *old, ptrdiff_t size, ptrdiff_t align, ptrdiff_t old_count, ptrdiff_t new_count)
Takes a Koliseo_Temp pointer, and a void pointer to the old allocation, ptrdiff_t values for size,...
Definition koliseo.c:1737
Koliseo * kls_new_dbg_alloc(ptrdiff_t size, kls_alloc_func alloc_func, kls_free_func free_func)
Takes a ptrdiff_t size, an allocation function pointer and a free function pointer,...
Definition koliseo.c:943
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:1891
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:2358
Koliseo * kls_new_traced_alloc_handled(ptrdiff_t size, const char *output_path, kls_alloc_func alloc_func, kls_free_func free_func, KLS_Err_Handlers err_handlers)
Takes a ptrdiff_t size, a filepath for the trace output file, an allocation function pointer and a fr...
Definition koliseo.c:789
void KLS_OOM_Handler(struct Koliseo *kls, ptrdiff_t available, ptrdiff_t padding, ptrdiff_t size, ptrdiff_t count)
Used to pass an error handler for Out-Of-Memory error.
Definition koliseo.h:134
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:483
Koliseo * kls_new_traced_alloc_handled_ext(ptrdiff_t size, const char *output_path, kls_alloc_func alloc_func, kls_free_func free_func, KLS_Err_Handlers err_handlers, KLS_Hooks *ext_handlers, void **user, size_t ext_len)
Takes a ptrdiff_t size, a filepath for the trace output file, an allocation function pointer and a fr...
Definition koliseo.c:753
void KLS_hook_on_temp_start(struct Koliseo_Temp *t_kls)
Used to pass an extension handler for kls_temp_start().
Definition koliseo.h:191
char * kls_vsprintf(Koliseo *kls, const char *fmt, va_list args)
Definition koliseo.c:1475
void kls_temp_end(Koliseo_Temp *tmp_kls)
Ends passed Koliseo_Temp pointer.
Definition koliseo.c:2108
void kls_dbg_features(void)
Prints enabled Koliseo features to stderr.
Definition koliseo.c:235
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:2342
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:1528
#define KLS_MAX_EXTENSIONS
DEPRECATED: Support for multiple extension will be dropped in the next release.
Definition koliseo.h:317
void print_dbg_kls(const Koliseo *kls)
Prints header fields from the passed Koliseo pointer, to stderr.
Definition koliseo.c:1877
const char * string_koliseo_version(void)
Returns current koliseo version as a string.
Definition koliseo.c:59
void * kls_repush(Koliseo *kls, void *old, ptrdiff_t size, ptrdiff_t align, ptrdiff_t old_count, ptrdiff_t new_count)
Takes a Koliseo pointer, and a void pointer to the old allocation, ptrdiff_t values for size,...
Definition koliseo.c:1617
KLS_Push_Result kls__advance(Koliseo *kls, ptrdiff_t size, ptrdiff_t align, ptrdiff_t count, ptrdiff_t *padding, const char *caller_name)
Takes a Koliseo pointer, and ptrdiff_t values for size, align and count.
Definition koliseo.c:1100
char * kls_temp_vsprintf(Koliseo_Temp *kls_t, const char *fmt, va_list args)
Definition koliseo.c:1563
ptrdiff_t kls_get_pos(const Koliseo *kls)
Returns the current offset (position of pointer bumper) for the passed Koliseo.
Definition koliseo.c:288
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:2286
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:2203
void KLS_ZEROCOUNT_Handler(struct Koliseo *kls, ptrdiff_t available, ptrdiff_t padding, ptrdiff_t size)
Used to pass an error handler for zero-count push call error.
Definition koliseo.h:146
void kls_free(Koliseo *kls)
Calls kls_clear() on the passed Koliseo pointer and the frees the actual Koliseo.
Definition koliseo.c:1985
KLS_Conf kls_conf_init_handled(int collect_stats, int verbose_lvl, int block_while_has_temp, int allow_zerocount_push, int growable, 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:178
Koliseo * kls_new_traced_ext(ptrdiff_t size, const char *output_path, KLS_Hooks *ext_handlers, void **user, size_t ext_len)
Takes a ptrdiff_t size and a filepath for the trace output file.
Definition koliseo.c:806
#define KLS_MINOR
Represents current minor release.
Definition koliseo.h:90
char * kls_temp_sprintf(Koliseo_Temp *kls_t, const char *fmt,...)
Takes a Koliseo_Temp pointer, and a format cstring, plus varargs.
Definition koliseo.c:1589
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:2371
void KLS_ZEROCOUNT_default_handler__(struct Koliseo *kls, ptrdiff_t available, ptrdiff_t padding, ptrdiff_t size)
Used by default when no handler is passed.
Definition koliseo.c:154
Koliseo * kls_new_dbg_alloc_handled(ptrdiff_t size, kls_alloc_func alloc_func, kls_free_func free_func, KLS_Err_Handlers err_handlers)
Takes a ptrdiff_t size, an allocation function pointer and a free function pointer,...
Definition koliseo.c:911
#define KLS_PATCH
Represents current patch release.
Definition koliseo.h:91
void * kls_alloc_func(size_t)
Used to select an allocation function for the arena's backing memory.
Definition koliseo.h:93
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:1391
Koliseo * kls_new_alloc(ptrdiff_t size, kls_alloc_func alloc_func, kls_free_func free_func)
Takes a ptrdiff_t size and a function pointer to the allocation function.
Definition koliseo.c:626
Koliseo * kls_new_dbg(ptrdiff_t size)
Takes a ptrdiff_t size and returns a pointer to the prepared Koliseo.
Definition koliseo.c:958
void KLS_hook_on_free(struct Koliseo *kls)
Used to pass an extension handler for kls_free().
Definition koliseo.h:187
Koliseo * kls_new_traced_alloc(ptrdiff_t size, const char *output_path, kls_alloc_func alloc_func, kls_free_func free_func)
Takes a ptrdiff_t size, a filepath for the trace output file, an allocation function pointer and a fr...
Definition koliseo.c:825
char * kls_sprintf(Koliseo *kls, const char *fmt,...)
Takes a Koliseo pointer, and a format cstring, plus varargs.
Definition koliseo.c:1500
void KLS_hook_on_temp_push(struct Koliseo_Temp *t_kls, ptrdiff_t padding, const char *caller, void *user)
Used to pass an extension handler for kls_temp_push().
Definition koliseo.h:195
Koliseo * kls_new_conf_alloc_ext(ptrdiff_t size, KLS_Conf conf, kls_alloc_func alloc_func, kls_free_func free_func, KLS_Hooks *ext_handlers, void **user, size_t ext_len)
Takes a ptrdiff_t size, a KLS_Conf to configure the new Koliseo, an allocation function pointer and a...
Definition koliseo.c:671
Koliseo * kls_new_traced_handled(ptrdiff_t size, const char *output_path, KLS_Err_Handlers err_handlers)
Takes a ptrdiff_t size and a filepath for the trace output file.
Definition koliseo.c:859
Koliseo * kls_new_conf_alloc(ptrdiff_t size, KLS_Conf conf, kls_alloc_func alloc_func, kls_free_func kls_free_func)
Takes a ptrdiff_t size, a KLS_Conf to configure the new Koliseo, an allocation function pointer and a...
Definition koliseo.c:700
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:2166
void KLS_hook_on_temp_free(struct Koliseo_Temp *t_kls)
Used to pass an extension handler for kls_temp_end().
Definition koliseo.h:193
void KLS_PTRDIFF_MAX_default_handler__(struct Koliseo *kls, ptrdiff_t size, ptrdiff_t count)
Used by default when no handler is passed.
Definition koliseo.c:112
void KLS_hook_on_push(struct Koliseo *kls, ptrdiff_t padding, const char *caller, void *user)
Used to pass an extension handler for kls_push().
Definition koliseo.h:189
KLS_Push_Error
Defines the result for kls__check_available_failable().
Definition koliseo.h:390
@ KLS_PUSH_NEGATIVE_COUNT
Definition koliseo.h:395
@ KLS_PUSH_ZEROCOUNT
Definition koliseo.h:396
@ KLS_PUSH_ALIGN_NOT_POW2
Definition koliseo.h:394
@ KLS_PUSH_WITH_TEMP_ACTIVE
Definition koliseo.h:397
@ KLS_PUSH_OOM
Definition koliseo.h:399
@ KLS_PUSH_PTRDIFF_MAX
Definition koliseo.h:398
@ KLS_PUSH_SIZE_LT1
Definition koliseo.h:392
@ KLS_PUSH_ALIGN_LT1
Definition koliseo.h:393
@ KLS_PUSH_OK
Definition koliseo.h:391
KLS_Conf kls_conf_init(int collect_stats, int verbose_lvl, int block_while_has_temp, int allow_zerocount_push, int growable, FILE *log_fp, const char *log_filepath)
Used to prepare a KLS_Conf without caring about KOLISEO_HAS_REGIONS.
Definition koliseo.c:226
KLS_Push_Error 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:1200
KLS_Push_Result kls__temp_advance(Koliseo_Temp *t_kls, ptrdiff_t size, ptrdiff_t align, ptrdiff_t count, ptrdiff_t *padding, const char *caller_name)
Takes a Koliseo_Temp, and ptrdiff_t values for size, align and count.
Definition koliseo.c:1260
void * kls__handle_push_result(Koliseo *kls, KLS_Push_Result r, ptrdiff_t size, ptrdiff_t align, ptrdiff_t count, ptrdiff_t padding, const char *caller_name)
Definition koliseo.c:294
Koliseo * kls_new_dbg_ext(ptrdiff_t size, KLS_Hooks *ext_handlers, void **user, size_t ext_len)
Takes a ptrdiff_t size.
Definition koliseo.c:926
Koliseo * kls_new_alloc_ext(ptrdiff_t size, kls_alloc_func alloc_func, kls_free_func free_func, KLS_Hooks *ext_handlers, void **user, size_t ext_len)
Takes a ptrdiff_t size and a function pointer to the allocation function.
Definition koliseo.c:529
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:1846
Koliseo * kls_new_dbg_alloc_handled_ext(ptrdiff_t size, kls_alloc_func alloc_func, kls_free_func free_func, KLS_Err_Handlers err_handlers, KLS_Hooks *ext_handlers, void **user, size_t ext_len)
Takes a ptrdiff_t size, an allocation function pointer and a free function pointer,...
Definition koliseo.c:877
Koliseo * kls_new_dbg_handled(ptrdiff_t size, KLS_Err_Handlers err_handlers)
Takes a ptrdiff_t size and returns a pointer to the prepared Koliseo.
Definition koliseo.c:973
void KLS_PTRDIFF_MAX_Handler(struct Koliseo *kls, ptrdiff_t size, ptrdiff_t count)
Used to pass an error handler for count > (PTRDIFF_MAX / size) error.
Definition koliseo.h:140
void kls_clear(Koliseo *kls)
Resets the offset field for the passed Koliseo pointer.
Definition koliseo.c:1964
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:1424
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:1942
#define KLS_MAJOR
Represents current major release.
Definition koliseo.h:89
int int_koliseo_version(void)
Returns current koliseo version as an integer.
Definition koliseo.c:68
Koliseo * kls_new_conf(ptrdiff_t size, KLS_Conf conf)
Takes a ptrdiff_t size and a KLS_Conf to configure the new Koliseo.
Definition koliseo.c:733
Koliseo * kls_new_conf_ext(ptrdiff_t size, KLS_Conf conf, KLS_Hooks *ext_handlers, void **user, size_t ext_len)
Takes a ptrdiff_t size and a KLS_Conf to configure the new Koliseo.
Definition koliseo.c:717
Defines flags for Koliseo.
Definition koliseo.h:231
int kls_growable
If set to 1, make the Koliseo grow when a out of memory for a push call.
Definition koliseo.h:238
int kls_collect_stats
If set to 1, make the Koliseo collect performance stats.
Definition koliseo.h:232
int kls_allow_zerocount_push
If set to 1, make the Koliseo accept push calls with a count of 0.
Definition koliseo.h:237
int kls_block_while_has_temp
If set to 1, make the Koliseo reject push calls while it has an open Koliseo_Temp.
Definition koliseo.h:236
int kls_verbose_lvl
If > 0, makes the Koliseo try to acquire kls_log_fp from kls_log_filepath.
Definition koliseo.h:233
KLS_Err_Handlers err_handlers
Used to pass custom error handlers for push calls.
Definition koliseo.h:239
const char * kls_log_filepath
String representing the path to the Koliseo logfile.
Definition koliseo.h:235
FILE * kls_log_fp
FILE pointer used by the Koliseo to print its kls_log() output.
Definition koliseo.h:234
Defines the handlers used for errors in push calls.
Definition koliseo.h:173
KLS_OOM_Handler * OOM_handler
Pointer to handler for Out-Of-Memory errors in push calls.
Definition koliseo.h:174
KLS_ZEROCOUNT_Handler * ZEROCOUNT_handler
Pointer to handler for zero-count errors in push calls.
Definition koliseo.h:176
KLS_PTRDIFF_MAX_Handler * PTRDIFF_MAX_handler
Pointer to handler for count > (PTRDIFF_MAX / size) errors in push calls.
Definition koliseo.h:175
Definition koliseo.h:197
KLS_hook_on_temp_start * on_temp_start_handler
Used to pass custom start handler for kls_temp_start calls.
Definition koliseo.h:201
KLS_hook_on_free * on_free_handler
Used to pass custom free handler for kls_free calls.
Definition koliseo.h:199
KLS_hook_on_temp_free * on_temp_free_handler
Used to pass custom free handler for kls_temp_end calls.
Definition koliseo.h:202
KLS_hook_on_push * on_push_handler
Used to pass custom push handler for kls_push calls.
Definition koliseo.h:200
KLS_hook_on_new * on_new_handler
Used to pass custom new handler for kls_new_alloc calls.
Definition koliseo.h:198
KLS_hook_on_temp_push * on_temp_push_handler
Used to pass custom push handler for kls_temp_push calls.
Definition koliseo.h:203
Defines the result for kls__advance() and kls__temp_advance().
Definition koliseo.h:407
KLS_Push_Error error
Definition koliseo.h:409
void * p
Definition koliseo.h:408
Defines a stat struct for Koliseo.
Definition koliseo.h:252
int tot_pops
Total POP calls done.
Definition koliseo.h:255
double worst_pushcall_time
Longest time taken by a PUSH call.
Definition koliseo.h:260
int tot_temp_pushes
Total PUSH_T calls done.
Definition koliseo.h:254
int tot_pushes
Total PUSH calls done.
Definition koliseo.h:253
int tot_hiccups
Total hiccups encountered.
Definition koliseo.h:258
int tot_logcalls
Total kls_log() calls done.
Definition koliseo.h:257
int tot_temp_pops
Total POP_T calls done.
Definition koliseo.h:256
Represents a savestate for a Koliseo.
Definition koliseo.h:379
ptrdiff_t offset
Current position of memory pointer.
Definition koliseo.h:381
ptrdiff_t prev_offset
Previous position of memory pointer.
Definition koliseo.h:382
Koliseo * kls
Reference to the actual Koliseo we're saving.
Definition koliseo.h:380
Represents the initialised arena allocator struct.
Definition koliseo.h:340
ptrdiff_t size
Size of data field.
Definition koliseo.h:342
ptrdiff_t offset
Current position of memory pointer.
Definition koliseo.h:343
ptrdiff_t prev_offset
Previous position of memory pointer.
Definition koliseo.h:344
KLS_Conf conf
Contains flags to change the Koliseo behaviour.
Definition koliseo.h:346
void * extension_data[KLS_MAX_EXTENSIONS]
Points to data for extensions.
Definition koliseo.h:350
struct Koliseo_Temp * t_kls
Points to related active Kolieo_Temp, when has_temp == 1.
Definition koliseo.h:348
char * data
Points to data field.
Definition koliseo.h:341
size_t hooks_len
Length for hooks and extension_data.
Definition koliseo.h:351
struct Koliseo * next
Points to the next Koliseo when conf.kls_growable == 1.
Definition koliseo.h:353
int has_temp
When == 1, a Koliseo_Temp is currently active on this Koliseo.
Definition koliseo.h:345
KLS_Stats stats
Contains stats for Koliseo performance analysis.
Definition koliseo.h:347
KLS_Hooks hooks[KLS_MAX_EXTENSIONS]
Contains handlers for extensions.
Definition koliseo.h:349
kls_free_func * free_func
Points to the free function for the arena's backing memory.
Definition koliseo.h:352