21 .kls_collect_stats = 0,
23 .kls_block_while_has_temp = 1,
24 .kls_allow_zerocount_push = 0,
27 .kls_log_filepath =
"",
29#ifndef KOLISEO_HAS_LOCATE
34 .OOM_handler = &KLS_OOM_default_handler_dbg__,
35 .PTRDIFF_MAX_handler = &KLS_PTRDIFF_MAX_default_handler_dbg__,
36 .ZEROCOUNT_handler = &KLS_ZEROCOUNT_default_handler_dbg__,
49 .worst_pushcall_time = -1,
61 return KOLISEO_API_VERSION_STRING;
70 return KOLISEO_API_VERSION_INT;
82#ifndef KOLISEO_HAS_LOCATE
85void KLS_OOM_default_handler_dbg__(
Koliseo* kls, ptrdiff_t available, ptrdiff_t padding, ptrdiff_t size, ptrdiff_t count, Koliseo_Loc loc)
88#ifndef KOLISEO_HAS_LOCATE
90 "[KLS] Out of memory. size*count [%td] was bigger than available-padding [%td].\n",
91 size * count, available - padding);
94 "[KLS] " KLS_Loc_Fmt
"Out of memory. size*count [%td] was bigger than available-padding [%td].\n",
96 size * count, available - padding);
102#ifndef KOLISEO_HAS_LOCATE
105void KLS_PTRDIFF_MAX_default_handler_dbg__(
struct Koliseo* kls, ptrdiff_t size, ptrdiff_t count, Koliseo_Loc loc)
109#ifndef KOLISEO_HAS_LOCATE
111 "[KLS] count [%td] was bigger than PTRDIFF_MAX/size [%li].\n",
112 count, PTRDIFF_MAX / size);
115 "[KLS] " KLS_Loc_Fmt
"count [%td] was bigger than PTRDIFF_MAX/size [%li].\n",
117 count, PTRDIFF_MAX / size);
120#ifndef KOLISEO_HAS_LOCATE
122 "[KLS] count [%td] was bigger than PTRDIFF_MAX/size [%lli].\n",
123 count, PTRDIFF_MAX / size);
126 "[KLS] " KLS_Loc_Fmt
"count [%td] was bigger than PTRDIFF_MAX/size [%lli].\n",
128 count, PTRDIFF_MAX / size);
144#ifndef KOLISEO_HAS_LOCATE
147void KLS_ZEROCOUNT_default_handler_dbg__(
Koliseo* kls, ptrdiff_t available, ptrdiff_t padding, ptrdiff_t size, Koliseo_Loc loc)
150#ifndef KOLISEO_HAS_LOCATE
152 "[KLS] Doing a zero-count push. size [%td] padding [%td] available [%td].\n",
153 size, padding, available);
156 "[KLS] " KLS_Loc_Fmt
"Doing a zero-count push. size [%td] padding [%td] available [%td].\n",
158 size, padding, available);
183#ifndef KOLISEO_HAS_LOCATE
193#ifndef KOLISEO_HAS_LOCATE
203#ifndef KOLISEO_HAS_LOCATE
217KLS_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)
220 return kls_conf_init_handled(collect_stats, verbose_lvl, block_while_has_temp, allow_zerocount_push, growable, log_fp, log_filepath, err_handlers);
228#ifdef KOLISEO_HAS_LOCATE
229 bool kls_locate =
true;
231 bool kls_locate =
false;
234 bool kls_debug =
true;
236 bool kls_debug =
false;
238#ifdef KOLISEO_HAS_EXPER
239 bool kls_exper =
true;
241 bool kls_exper =
false;
248 int total_enabled = 0;
249 for (
int i=0; i<3; i++) {
254 fprintf(stderr,
"[KLS] Enabled features: {");
255 if (total_enabled == 0) {
256 fprintf(stderr,
"none}\n");
260 fprintf(stderr,
"debug%s", (total_enabled > 1 ?
", " :
""));
264 fprintf(stderr,
"locate%s", (total_enabled > 1 ?
", " :
""));
268 fprintf(stderr,
"exper");
270 fprintf(stderr,
"}\n");
293 fprintf(stderr,
"[KLS] %s(): Passed kls was NULL.\n", __func__);
299 va_start(args, format);
302 "[KLS] %s(): Failed opening file to print logs.\n",
305 time_t now = time(0);
306 const struct tm *mytime = localtime(&now);
307 char timeheader[500];
308 if (strftime(timeheader,
sizeof timeheader,
"%X", mytime)) {
309 fprintf(fp,
"[%-10.10s] [%s] [", tag, timeheader);
310 vfprintf(fp, format, args);
335#ifndef KOLISEO_HAS_LOCATE
341 if (size < (ptrdiff_t)
sizeof(
Koliseo)) {
342#ifndef KOLISEO_HAS_LOCATE
344 "[ERROR] at %s(): invalid requested kls size (%td). Min accepted is: (%td).\n",
345 __func__, size, (ptrdiff_t)
sizeof(
Koliseo));
348 "[ERROR] " KLS_Loc_Fmt
"%s(): invalid requested kls size (%td). Min accepted is: (%td).\n",
349 KLS_Loc_Arg(loc), __func__, size, (ptrdiff_t)
sizeof(
Koliseo));
354 void *p = alloc_func(size);
363 kls->
offset =
sizeof(*kls);
372 for (
size_t i=0; i < kls->
hooks_len; i++) {
373 kls->
hooks[i] = ext_handlers[i];
375 for (
size_t i=0; i < kls->
hooks_len; i++) {
385 kls_log(kls,
"KLS",
"API Level { %i } -> Allocated (%s) for new KLS.",
387 kls_log(kls,
"KLS",
"KLS offset: { %p }.", kls);
388 kls_log(kls,
"KLS",
"Allocation begin offset: { %p }.",
392 for (
size_t i=0; i < kls->
hooks_len; i++) {
399#ifndef KOLISEO_HAS_LOCATE
400 fprintf(stderr,
"[KLS] Failed %s() call.\n", __func__);
402 fprintf(stderr,
"[KLS] " KLS_Loc_Fmt
"Failed %s() call.\n", KLS_Loc_Arg(loc), __func__);
430#ifndef KOLISEO_HAS_LOCATE
436#ifndef KOLISEO_HAS_LOCATE
479 bool conf_res = kls_set_conf(k, conf);
482 "[ERROR] [%s()]: Failed to set config for new Koliseo.\n",
561#ifndef KLS_DEBUG_CORE
563 "[WARN] %s(): KLS_DEBUG_CORE is not defined. No tracing allowed.\n",
567 .kls_collect_stats = 1,.kls_verbose_lvl =
568 1,.kls_log_filepath = output_path,
569#ifndef KOLISEO_HAS_LOCATE
573 .err_handlers.OOM_handler = (err_handlers.
OOM_handler != NULL ? err_handlers.
OOM_handler : &KLS_OOM_default_handler_dbg__),
684#ifndef KLS_DEBUG_CORE
686 "[WARN] %s(): KLS_DEBUG_CORE is not defined. No debugging support.\n",
690 .kls_collect_stats = 1,.kls_verbose_lvl = 0,
691#ifndef KOLISEO_HAS_LOCATE
695 .err_handlers.OOM_handler = ( err_handlers.
OOM_handler != NULL ? err_handlers.
OOM_handler : &KLS_OOM_default_handler_dbg__),
792 fprintf(stderr,
"[ERROR] [%s()]: Passed Koliseo was NULL.\n", __func__);
801#ifdef KLS_SETCONF_DEBUG
803 "[%s()]: Preliminary set of conf.kls_log_fp to stderr.",
811 "[ERROR] at %s(): passed OOM_handler is NULL. Using default.\n",
814#ifdef KLS_SETCONF_DEBUG
816 "[%s()]: Passed OOM_handler was NULL, using default.",
820#ifndef KOLISEO_HAS_LOCATE
829 "[ERROR] at %s(): passed PTRDIFF_MAX_handler is NULL. Using default.\n",
832#ifdef KLS_SETCONF_DEBUG
834 "[%s()]: Passed PTRDIFF_MAX_handler was NULL, using default.",
838#ifndef KOLISEO_HAS_LOCATE
845#ifndef KLS_DEBUG_CORE
848 "[WARN] [%s()]: KLS_DEBUG_CORE is not defined. Stats may not be collected in full.\n",
856#ifdef KLS_SETCONF_DEBUG
858 "[%s()]: kls->conf.kls_log_fp was not NULL. Overriding it.",
871 "[ERROR] [%s()]: Failed opening logfile at {\"%s\"} [write].\n",
875 fprintf(log_fp,
"%s",
"");
881 "[ERROR] [%s()]: Failed opening logfile at {\"%s\"} [append].\n",
891static bool kls__try_grow(
Koliseo* kls, ptrdiff_t needed);
905#ifndef KOLISEO_HAS_LOCATE
908int kls__check_available_failable_dbg(
Koliseo* kls, ptrdiff_t size, ptrdiff_t align, ptrdiff_t count,
const char* caller_name, Koliseo_Loc loc)
912 assert(caller_name != NULL);
914#ifndef KOLISEO_HAS_LOCATE
916 "[KLS] %s(): count [%td] was < 0.\n",
921 "[KLS] " KLS_Loc_Fmt
"%s(): count [%td] was < 0.\n",
929#ifndef KOLISEO_HAS_LOCATE
931 "[KLS] %s(): size [%td] was < 1.\n",
936 "[KLS] " KLS_Loc_Fmt
"%s(): size [%td] was < 1.\n",
944#ifndef KOLISEO_HAS_LOCATE
946 "[KLS] %s(): align [%td] was < 1.\n",
951 "[KLS] " KLS_Loc_Fmt
"%s(): align [%td] was < 1.\n",
958 if (! ((align & (align - 1)) == 0)) {
959#ifndef KOLISEO_HAS_LOCATE
961 "[KLS] %s(): align [%td] was not a power of 2.\n",
966 "[KLS] " KLS_Loc_Fmt
"%s(): align [%td] was not a power of 2.\n",
974 while (current->
next != NULL) {
975 current = current->
next;
977 const ptrdiff_t available = current->
size - current->
offset;
978 const ptrdiff_t padding = -current->
offset & (align - 1);
979 bool ZEROCOUNT_happened =
false;
980 bool ZEROCOUNT_handled =
false;
983 ZEROCOUNT_happened =
true;
985#ifndef KOLISEO_HAS_LOCATE
990 ZEROCOUNT_handled =
true;
992#ifndef KOLISEO_HAS_LOCATE
994 "[KLS] %s(): Doing a zero-count push. size [%td] padding [%td] available [%td].\n",
996 size, padding, available);
999 "[KLS] " KLS_Loc_Fmt
"%s(): Doing a zero-count push. size [%td] padding [%td] available [%td].\n",
1002 size, padding, available);
1008#ifdef KLS_DEBUG_CORE
1009 kls_log(current,
"DEBUG",
"Accepting zero-count push: conf.kls_allow_zerocount_push was 1");
1014 if (ZEROCOUNT_happened && ZEROCOUNT_handled) {
1015#ifdef KLS_DEBUG_CORE
1016 kls_log(current,
"DEBUG",
"Requested a zero-count push while kls_allow_zerocount_push is not 1, but the error handler returned instead of exiting.");
1018#ifndef KOLISEO_HAS_LOCATE
1020 "[KLS] %s(): Doing a zero-count push. size [%td] padding [%td] available [%td].\n",
1022 size, padding, available);
1025 "[KLS] " KLS_Loc_Fmt
"%s(): Doing a zero-count push. size [%td] padding [%td] available [%td].\n",
1028 size, padding, available);
1034 bool OOM_happened =
false;
1035 bool OOM_handled =
false;
1036 bool PTRDIFF_MAX_happened =
false;
1037 bool PTRDIFF_MAX_handled =
false;
1038 if (count > PTRDIFF_MAX / size || available - padding < size * count) {
1039 if (count > PTRDIFF_MAX / size) {
1040 PTRDIFF_MAX_happened =
true;
1042#ifndef KOLISEO_HAS_LOCATE
1047 PTRDIFF_MAX_handled =
true;
1050#ifndef KOLISEO_HAS_LOCATE
1052 "[KLS] %s(): count [%td] was bigger than PTRDIFF_MAX/size [%li].\n",
1054 count, PTRDIFF_MAX / size);
1057 "[KLS] " KLS_Loc_Fmt
"%s(): count [%td] was bigger than PTRDIFF_MAX/size [%li].\n",
1060 count, PTRDIFF_MAX / size);
1063#ifndef KOLISEO_HAS_LOCATE
1065 "[KLS] %s(): count [%td] was bigger than PTRDIFF_MAX/size [%lli].\n",
1067 count, PTRDIFF_MAX / size);
1070 "[KLS] " KLS_Loc_Fmt
"%s(): count [%td] was bigger than PTRDIFF_MAX/size [%lli].\n",
1073 count, PTRDIFF_MAX / size);
1078 if (current->
conf.
kls_growable == 1 && kls__try_grow(current, size + count + padding)) {
1081 OOM_happened =
true;
1083#ifndef KOLISEO_HAS_LOCATE
1090#ifndef KOLISEO_HAS_LOCATE
1092 "[KLS] %s(): Out of memory. size*count [%td] was bigger than available-padding [%td].\n",
1094 size * count, available - padding);
1097 "[KLS] " KLS_Loc_Fmt
"%s(): Out of memory. size*count [%td] was bigger than available-padding [%td].\n",
1100 size * count, available - padding);
1104 if (PTRDIFF_MAX_happened) {
1106#ifndef KOLISEO_HAS_LOCATE
1107 fprintf(stderr,
"[KLS] %s(): PTRDIFF_MAX fault happened and was handled.\n", caller_name);
1108#ifdef KLS_DEBUG_CORE
1109 kls_log(current,
"DEBUG",
"%s(): PTRDIFF_MAX fault happened and was handled.", caller_name);
1112 fprintf(stderr,
"[KLS] " KLS_Loc_Fmt
"%s(): PTRDIFF_MAX fault happened and was handled.\n", KLS_Loc_Arg(loc), caller_name);
1113#ifdef KLS_DEBUG_CORE
1114 kls_log(current,
"DEBUG", KLS_Loc_Fmt
"%s(): PTRDIFF_MAX fault happened and was handled.", KLS_Loc_Arg(loc), caller_name);
1119 }
else if (OOM_happened) {
1121#ifndef KOLISEO_HAS_LOCATE
1122 fprintf(stderr,
"[KLS] %s(): OOM fault happened and was handled.\n", caller_name);
1123#ifdef KLS_DEBUG_CORE
1124 kls_log(current,
"DEBUG",
"%s(): OOM fault happened and was handled.", caller_name);
1127 fprintf(stderr,
"[KLS] " KLS_Loc_Fmt
"%s(): OOM fault happened and was handled.\n", KLS_Loc_Arg(loc), caller_name);
1128#ifdef KLS_DEBUG_CORE
1129 kls_log(current,
"DEBUG", KLS_Loc_Fmt
"%s(): OOM fault happened and was handled.", KLS_Loc_Arg(loc), caller_name);
1135#ifndef KOLISEO_HAS_LOCATE
1136 fprintf(stderr,
"[KLS] Failed %s() call.\n", caller_name);
1138 fprintf(stderr,
"[KLS] " KLS_Loc_Fmt
"Failed %s() call.\n", KLS_Loc_Arg(loc), caller_name);
1146bool kls__try_grow(
Koliseo* kls, ptrdiff_t needed)
1148 ptrdiff_t new_size =
KLS_MAX(kls->
size * 2, needed);
1150 kls_log(kls,
"DEBUG",
"%s(): growing Koliseo, new size: {%td}", __func__, new_size);
1151 if (!new_kls)
return false;
1152 kls->
next = new_kls;
1168#ifdef KLS_DEBUG_CORE
1170 struct timespec start_time, end_time;
1171 clock_gettime(CLOCK_MONOTONIC, &start_time);
1173 LARGE_INTEGER start_time, end_time, frequency;
1174 QueryPerformanceFrequency(&frequency);
1175 QueryPerformanceCounter(&start_time);
1180 fprintf(stderr,
"[ERROR] [%s()]: Passed Koliseo was NULL.\n", __func__);
1184 fprintf(stderr,
"[ERROR] [%s()]: Passed Koliseo has an open Koliseo_Temp session.\n", __func__);
1185#ifdef KLS_DEBUG_CORE
1186 kls_log(kls,
"ERROR",
"[%s()]: Passed Koliseo has an open Koliseo_Temp session.", __func__);
1191#ifndef KOLISEO_HAS_LOCATE
1194 kls__check_available_dbg(kls, size, align, count, KLS_HERE);
1197 while (current->
next != NULL) {
1198 current = current->
next;
1200 ptrdiff_t padding = -current->
offset & (align - 1);
1201 char *p = current->
data + current->
offset + padding;
1203 current->
offset += padding + size * count;
1208#ifdef KLS_DEBUG_CORE
1209 kls_log(current,
"KLS",
"Curr offset: { %p }.", current + current->
offset);
1210 kls_log(current,
"KLS",
"API Level { %i } -> Pushed size (%s) for KLS.",
1217 clock_gettime(CLOCK_MONOTONIC, &end_time);
1218 double elapsed_time =
1219 (end_time.tv_sec - start_time.tv_sec) + (end_time.tv_nsec -
1220 start_time.tv_nsec) / 1e9;
1222 QueryPerformanceCounter(&end_time);
1223 double elapsed_time =
1224 (double)(end_time.QuadPart -
1225 start_time.QuadPart) / frequency.QuadPart;
1247#ifndef KOLISEO_HAS_LOCATE
1251void *kls_push_zero_dbg(
Koliseo *kls, ptrdiff_t size, ptrdiff_t align,
1252 ptrdiff_t count, Koliseo_Loc loc)
1256#ifdef KLS_DEBUG_CORE
1258 struct timespec start_time, end_time;
1259 clock_gettime(CLOCK_MONOTONIC, &start_time);
1261 LARGE_INTEGER start_time, end_time, frequency;
1262 QueryPerformanceFrequency(&frequency);
1263 QueryPerformanceCounter(&start_time);
1268 fprintf(stderr,
"[ERROR] [%s()]: Passed Koliseo was NULL.\n", __func__);
1272#ifndef KOLISEO_HAS_LOCATE
1273 fprintf(stderr,
"[ERROR] [%s()]: Passed Koliseo has an open Koliseo_Temp session.\n", __func__);
1275 fprintf(stderr,
"[ERROR] " KLS_Loc_Fmt
"[%s()]: Passed Koliseo has an open Koliseo_Temp session.\n", KLS_Loc_Arg(loc), __func__);
1276 kls_log(kls,
"ERROR", KLS_Loc_Fmt
"[%s()]: Passed Koliseo has an open Koliseo_Temp session.", KLS_Loc_Arg(loc), __func__);
1281#ifndef KOLISEO_HAS_LOCATE
1284 kls__check_available_dbg(kls, size, align, count, loc);
1287 while (current->
next != NULL) {
1288 current = current->
next;
1290 ptrdiff_t padding = -current->
offset & (align - 1);
1291 char *p = current->
data + current->
offset + padding;
1293 memset(p, 0, size * count);
1295 current->
offset += padding + size * count;
1300#ifdef KLS_DEBUG_CORE
1301 kls_log(current,
"KLS",
"Curr offset: { %p }.", current + current->
offset);
1302 kls_log(current,
"KLS",
"API Level { %i } -> Pushed zeroes, size (%s) for KLS.",
1309 clock_gettime(CLOCK_MONOTONIC, &end_time);
1310 double elapsed_time =
1311 (end_time.tv_sec - start_time.tv_sec) + (end_time.tv_nsec -
1312 start_time.tv_nsec) / 1e9;
1314 QueryPerformanceCounter(&end_time);
1315 double elapsed_time =
1316 (double)(end_time.QuadPart -
1317 start_time.QuadPart) / frequency.QuadPart;
1339#ifndef KOLISEO_HAS_LOCATE
1343void *kls_push_zero_ext_dbg(
Koliseo *kls, ptrdiff_t size, ptrdiff_t align,
1344 ptrdiff_t count, Koliseo_Loc loc)
1348#ifdef KLS_DEBUG_CORE
1350 struct timespec start_time, end_time;
1351 clock_gettime(CLOCK_MONOTONIC, &start_time);
1353 LARGE_INTEGER start_time, end_time, frequency;
1354 QueryPerformanceFrequency(&frequency);
1355 QueryPerformanceCounter(&start_time);
1360 fprintf(stderr,
"[ERROR] [%s()]: Passed Koliseo was NULL.\n", __func__);
1364#ifndef KOLISEO_HAS_LOCATE
1365 fprintf(stderr,
"[ERROR] [%s()]: Passed Koliseo has an open Koliseo_Temp session.\n", __func__);
1367 fprintf(stderr,
"[ERROR] " KLS_Loc_Fmt
"[%s()]: Passed Koliseo has an open Koliseo_Temp session.\n", KLS_Loc_Arg(loc), __func__);
1368 kls_log(kls,
"ERROR", KLS_Loc_Fmt
"[%s()]: Passed Koliseo has an open Koliseo_Temp session.", KLS_Loc_Arg(loc), __func__);
1374#ifndef KOLISEO_HAS_LOCATE
1377 kls__check_available_dbg(kls, size, align, count, loc);
1380 while (current->
next != NULL) {
1381 current = current->
next;
1383 ptrdiff_t padding = -current->
offset & (align - 1);
1384 char *p = current->
data + current->
offset + padding;
1386 memset(p, 0, size * count);
1388 current->
offset += padding + size * count;
1390 for (
size_t i=0; i < kls->
hooks_len; i++) {
1417#ifdef KLS_DEBUG_CORE
1418 kls_log(current,
"KLS",
"Curr offset: { %p }.", current + current->
offset);
1419 kls_log(current,
"KLS",
"API Level { %i } -> Pushed zeroes, size (%s) for KLS.",
1426 clock_gettime(CLOCK_MONOTONIC, &end_time);
1427 double elapsed_time =
1428 (end_time.tv_sec - start_time.tv_sec) + (end_time.tv_nsec -
1429 start_time.tv_nsec) / 1e9;
1431 QueryPerformanceCounter(&end_time);
1432 double elapsed_time =
1433 (double)(end_time.QuadPart -
1434 start_time.QuadPart) / frequency.QuadPart;
1457#ifndef KOLISEO_HAS_LOCATE
1459 ptrdiff_t align, ptrdiff_t count)
1461void *kls_temp_push_zero_ext_dbg(
Koliseo_Temp *t_kls, ptrdiff_t size,
1462 ptrdiff_t align, ptrdiff_t count, Koliseo_Loc loc)
1466#ifdef KLS_DEBUG_CORE
1468 struct timespec start_time, end_time;
1469 clock_gettime(CLOCK_MONOTONIC, &start_time);
1471 LARGE_INTEGER start_time, end_time, frequency;
1472 QueryPerformanceFrequency(&frequency);
1473 QueryPerformanceCounter(&start_time);
1477 if (t_kls == NULL) {
1478 fprintf(stderr,
"[ERROR] [%s()]: Passed Koliseo_Temp was NULL.\n",
1484 fprintf(stderr,
"[ERROR] [%s()]: Referred Koliseo was NULL.\n",
1488#ifndef KOLISEO_HAS_LOCATE
1491 kls__check_available_dbg(kls, size, align, count, loc);
1494 while (current->
next != NULL) {
1495 current = current->
next;
1497 ptrdiff_t padding = -current->
offset & (align - 1);
1498 char *p = current->
data + current->
offset + padding;
1500 memset(p, 0, size * count);
1502 current->
offset += padding + size * count;
1504 for (
size_t i=0; i < kls->
hooks_len; i++) {
1515#ifdef KLS_DEBUG_CORE
1518 clock_gettime(CLOCK_MONOTONIC, &end_time);
1519 double elapsed_time =
1520 (end_time.tv_sec - start_time.tv_sec) + (end_time.tv_nsec -
1521 start_time.tv_nsec) / 1e9;
1523 QueryPerformanceCounter(&end_time);
1524 double elapsed_time =
1525 (double)(end_time.QuadPart -
1526 start_time.QuadPart) / frequency.QuadPart;
1532 kls_log(current,
"KLS",
"Curr offset: { %p }.", current + current->
offset);
1534 "API Level { %i } -> Pushed zeroes, size (%s) for Temp_KLS.",
1554 fprintf(stderr,
"print_kls_2file(): fp was NULL.\n");
1558 fprintf(fp,
"[KLS] kls was NULL.\n");
1565 fprintf(fp,
"\n[KLS] Size: { %td }\n", kls->
size);
1566 char human_size[200];
1567 char curr_size[200];
1569 fprintf(fp,
"[KLS] Size (Human): { %s }\n", human_size);
1571 fprintf(fp,
"[KLS] Used (Human): { %s }\n", curr_size);
1572 fprintf(fp,
"[KLS] Offset: { %td }\n", kls->
offset);
1573 fprintf(fp,
"[KLS] Prev_Offset: { %td }\n", kls->
prev_offset);
1585 fprintf(stderr,
"[ERROR] [%s()]: Passed Koliseo was NULL.\n", __func__);
1599 fprintf(stderr,
"print_temp_kls_2file(): fp was NULL.\n");
1602 if (t_kls == NULL) {
1603 fprintf(fp,
"[KLS_T] t_kls was NULL.");
1604 }
else if (t_kls->
kls == NULL) {
1605 fprintf(fp,
"[KLS_T] [%s()]: Referred Koliseo was NULL.\n", __func__);
1609 fprintf(fp,
"\n[KLS_T] Temp Size: { %td }\n",
1611 fprintf(fp,
"\n[KLS_T] Refer Size: { %td }\n", kls->
size);
1612 char human_size[200];
1613 char curr_size[200];
1615 sizeof(human_size));
1616 fprintf(fp,
"[KLS_T] Temp Size Human: { %s }\n", human_size);
1618 fprintf(fp,
"[KLS_T] Refer Size Human: { %s }\n", human_size);
1620 fprintf(fp,
"[KLS_T] Inner Used (Human): { %s }\n", curr_size);
1622 fprintf(fp,
"[KLS_T] Temp Used (Human): { %s }\n", curr_size);
1623 fprintf(fp,
"[KLS_T] Inner Offset: { %td }\n", kls->
offset);
1624 fprintf(fp,
"[KLS_T] Temp Offset: { %td }\n", t_kls->
offset);
1625 fprintf(fp,
"[KLS_T] Inner Prev_Offset: { %td }\n", kls->
prev_offset);
1626 fprintf(fp,
"[KLS_T] Temp Prev_Offset: { %td }\n\n",
1649 const char *units[] =
1650 {
"bytes",
"KB",
"MB",
"GB",
"TB",
"PB",
"EB",
"ZB",
"YB" };
1651 const int numUnits =
sizeof(units) /
sizeof(units[0]);
1654 double sizeValue = (double)size;
1656 while (sizeValue >= 1000 && unitIndex < numUnits - 1) {
1661 snprintf(outputBuffer, bufferSize,
"%.2f %s", sizeValue, units[unitIndex]);
1672 fprintf(stderr,
"[ERROR] [%s()]: Passed Koliseo was NULL.\n", __func__);
1677 kls->
offset =
sizeof(*kls);
1678#ifdef KLS_DEBUG_CORE
1679 kls_log(kls,
"KLS",
"API Level { %i } -> Cleared offsets for KLS.",
1692 fprintf(stderr,
"[ERROR] [%s()]: Passed Koliseo was NULL.\n", __func__);
1698 current->
next = NULL;
1699 for (
size_t i=0; i < current->
hooks_len; i++) {
1706#ifdef KLS_DEBUG_CORE
1708 "API Level { %i } -> KLS had an active Koliseo_Temp.",
1714#ifdef KLS_DEBUG_CORE
1715 kls_log(current,
"KLS",
"API Level { %i } -> Freeing KLS.",
1720#ifdef KLS_DEBUG_CORE
1721 kls_log(current,
"KLS",
"Closing kls log file. Path: {\"%s\"}.",
1725 if (close_res != 0) {
1727 "[ERROR] %s(): Failed fclose() on log_fp. Path: {\"%s\"}.",
1733 "[INFO] %s(): kls->conf.kls_log_fp is %s. Not closing it.\n",
1740 "[ERROR] %s(): free function was NULL.\n", __func__);
1755#ifndef KOLISEO_HAS_LOCATE
1762 fprintf(stderr,
"[ERROR] [%s()]: Passed Koliseo was NULL.\n", __func__);
1766 while (current->
next != NULL) {
1767 current = current->
next;
1771 "[ERROR] [%s()]: Passed Koliseo->has_temp is not 0. {%i}\n",
1773#ifdef KLS_DEBUG_CORE
1774 kls_log(current,
"ERROR",
"[%s()]: Passed Koliseo->has_temp != 0 . {%i}",
1783 ptrdiff_t off = current->
offset;
1789#ifdef KLS_DEBUG_CORE
1795 current->
t_kls = tmp;
1796 for (
size_t i=0; i < kls->
hooks_len; i++) {
1802#ifdef KLS_DEBUG_CORE
1803 kls_log(current,
"KLS",
"Prepared new Temp KLS.");
1814 if (tmp_kls == NULL) {
1815 fprintf(stderr,
"[ERROR] [%s()]: Passed Koliseo_Temp was NULL.\n",
1821 if (kls_ref == NULL) {
1822 fprintf(stderr,
"[ERROR] [%s()]: Referred Koliseo was NULL.\n",
1827 for (
size_t i=0; i < kls_ref->
hooks_len; i++) {
1834#ifdef KLS_DEBUG_CORE
1835 kls_log(kls_ref,
"KLS",
"Ended Temp KLS.");
1844 if (to_free != NULL) {
1856#ifdef KOLISEO_HAS_EXPER
1868 fprintf(stderr,
"[ERROR] [%s()]: Passed Koliseo was NULL.\n", __func__);
1871 ptrdiff_t padding = -kls->
offset & (align - 1);
1872 if (count > PTRDIFF_MAX / size
1873 || (kls->
size + kls->
offset) < (size * count)) {
1874 fprintf(stderr,
"[KLS] Failed %s() call.\n", __func__);
1878 char *p = kls->
data + kls->
offset - padding - size * count;
1880 kls->
offset -= padding + size * count;
1881#ifdef KLS_DEBUG_CORE
1882 kls_log(kls,
"KLS",
"API Level { %i } -> Popped (%li) for KLS.",
1905 fprintf(stderr,
"[ERROR] [%s()]: Passed Koliseo was NULL.\n", __func__);
1908 ptrdiff_t padding = -kls->
offset & (align - 1);
1909 if (count > PTRDIFF_MAX / size
1910 || (kls->
size + kls->
offset) < (size * count)) {
1911 fprintf(stderr,
"[KLS] Failed %s() call.\n", __func__);
1915 char *p = kls->
data + kls->
offset - padding - size * count;
1917 kls->
offset -= padding + size * count;
1918#ifdef KLS_DEBUG_CORE
1919 kls_log(kls,
"KLS",
"API Level { %i } -> Popped (%li) for KLS.",
1942 if (t_kls == NULL) {
1943 fprintf(stderr,
"[ERROR] [%s()]: Passed Koliseo_Temp was NULL.\n",
1949 fprintf(stderr,
"[ERROR] [%s()]: Referred Koliseo was NULL.\n",
1953 ptrdiff_t padding = -kls->
offset & (align - 1);
1954 if (count > PTRDIFF_MAX / size
1955 || (kls->
size + kls->
offset) < (size * count)) {
1956 fprintf(stderr,
"[KLS] Failed %s() call.\n", __func__);
1960 char *p = kls->
data + kls->
offset - padding - size * count;
1962 kls->
offset -= padding + size * count;
1963#ifdef KLS_DEBUG_CORE
1964 kls_log(kls,
"KLS",
"Curr offset: { %p }.", kls + kls->
offset);
1965 kls_log(kls,
"KLS",
"API Level { %i } -> Popped (%li) for Temp_KLS.",
1987 if (t_kls == NULL) {
1988 fprintf(stderr,
"[ERROR] [%s()]: Passed Koliseo_Temp was NULL.\n",
1994 fprintf(stderr,
"[ERROR] [%s()]: Referred Koliseo was NULL.\n",
1998 ptrdiff_t padding = -kls->
offset & (align - 1);
1999 if (count > PTRDIFF_MAX / size
2000 || (kls->
size + kls->
offset) < (size * count)) {
2001 fprintf(stderr,
"[KLS] Failed %s() call.\n", __func__);
2005 char *p = kls->
data + kls->
offset - padding - size * count;
2007 kls->
offset -= padding + size * count;
2008#ifdef KLS_DEBUG_CORE
2009 kls_log(kls,
"KLS",
"Curr offset: { %p }.", kls + kls->
offset);
2010 kls_log(kls,
"KLS",
"API Level { %i } -> Popped (%li) for Temp_KLS.",
2043 char** strings = NULL;
2045 for (
int i=0; i < count; i++) {
2072 char** strings = NULL;
2074 for (
int i=0; i < count; i++) {
#define KLS_DEFAULT_HOOKS
Definition kls_region.h:162
#define KLS_DEFAULT_EXTENSIONS_LEN
Definition kls_region.h:173
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:647
Koliseo * kls_new(ptrdiff_t size)
Takes a ptrdiff_t size.
Definition koliseo.c:455
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:2028
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:1939
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:1756
void print_dbg_temp_kls(const Koliseo_Temp *t_kls)
Prints header fields from the passed Koliseo_Temp pointer, to stderr.
Definition koliseo.c:1635
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:748
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:1596
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:2057
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:594
KLS_Stats KLS_STATS_DEFAULT
Default KLS_Stats values, used by kls_new().
Definition koliseo.c:41
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:290
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:558
void kls_temp_end(Koliseo_Temp *tmp_kls)
Ends passed Koliseo_Temp pointer.
Definition koliseo.c:1812
void kls_dbg_features(void)
Prints enabled Koliseo features to stderr.
Definition koliseo.c:226
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:2041
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:1458
void print_dbg_kls(const Koliseo *kls)
Prints header fields from the passed Koliseo pointer, to stderr.
Definition koliseo.c:1582
const char * string_koliseo_version(void)
Returns the constant string representing current version for Koliseo.
Definition koliseo.c:59
ptrdiff_t kls_get_pos(const Koliseo *kls)
Returns the current offset (position of pointer bumper) for the passed Koliseo.
Definition koliseo.c:279
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:1985
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:1902
void kls_free(Koliseo *kls)
Calls kls_clear() on the passed Koliseo pointer and the frees the actual Koliseo.
Definition koliseo.c:1689
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:169
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:611
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:2070
void * kls_push(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:1165
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:716
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:1248
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:431
Koliseo * kls_new_dbg(ptrdiff_t size)
Takes a ptrdiff_t size and returns a pointer to the prepared Koliseo.
Definition koliseo.c:763
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:906
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:630
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:476
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:664
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:1865
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:103
KLS_Conf KLS_DEFAULT_CONF
Config used by any new Koliseo by default.
Definition koliseo.c:20
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:217
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:145
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:731
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:336
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:1551
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:682
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:778
void kls_clear(Koliseo *kls)
Resets the offset field for the passed Koliseo pointer.
Definition koliseo.c:1669
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:1340
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:1647
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:83
Koliseo * kls_new_conf_alloc(ptrdiff_t size, KLS_Conf conf, kls_alloc_func alloc_func, kls_free_func free_func)
Takes a ptrdiff_t size, a KLS_Conf to configure the new Koliseo, an allocation function pointer and a...
Definition koliseo.c:505
int int_koliseo_version(void)
Returns the constant int representing current version for Koliseo.
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:538
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:522
void kls_free_func(void *)
Used to select a free function for the arena's backing memory.
Definition koliseo.h:83
#define KLS_PUSH_STR_T(kls_temp, cstr)
Macro to request memory for a C string from a Koliseo_Temp.
Definition koliseo.h:555
#define KLS_Stats_Fmt
Defines a format string for KLS_Stats.
Definition koliseo.h:284
#define KLS_PUSH_STR(kls, cstr)
Macro to request memory for a C string from a Koliseo.
Definition koliseo.h:470
#define KLS_Conf_Arg(conf)
Defines a format macro for KLS_Conf args.
Definition koliseo.h:277
#define KLS_DEFAULT_FREEF
Defines the default free function.
Definition koliseo.h:394
#define KLS_DEFAULT_ALLOCF
Defines the default allocation function.
Definition koliseo.h:390
#define KLS_PUSH(kls, type)
Macro used to request memory from a Koliseo.
Definition koliseo.h:495
#define KLS__STRCPY(dest, source)
Macro to copy a C string from a source buffer to a destination buffer.
Definition koliseo.h:659
#define KLS_DEFAULT_EXTENSION_DATA
Defines default hooks that are loaded on kls_new() variants lacking explicit set of KLS_Hooks.
Definition koliseo.h:213
void * kls_alloc_func(size_t)
Used to select an allocation function for the arena's backing memory.
Definition koliseo.h:82
#define KLS_MAX(a, b)
Definition koliseo.h:89
#define KLS_STRDUP(kls, source)
Definition koliseo.h:668
#define KLS_Stats_Arg(stats)
Defines a format macro for KLS_Stats args.
Definition koliseo.h:294
#define KLS_Conf_Fmt
Defines a format string for KLS_Conf.
Definition koliseo.h:271
#define kls__check_available(kls, size, align, count)
Macro to return NULL on errors from kls__check_available_failable.
Definition koliseo.h:429
#define KLS_PUSH_ARR_T(kls_temp, type, count)
Macro used to request memory for an array of type values from a Koliseo_Temp.
Definition koliseo.h:549
#define KLS_STRDUP_T(t_kls, source)
Definition koliseo.h:678
#define KLS_DEFAULT_ERR_HANDLERS
Definition koliseo.h:169
#define KLS_PUSH_ARR(kls, type, count)
Macro used to request memory for an array of type values from a Koliseo.
Definition koliseo.h:464
Defines flags for Koliseo.
Definition koliseo.h:220
int kls_growable
If set to 1, make the Koliseo grow when a out of memory for a push call.
Definition koliseo.h:227
int kls_collect_stats
If set to 1, make the Koliseo collect performance stats.
Definition koliseo.h:221
int kls_allow_zerocount_push
If set to 1, make the Koliseo accept push calls with a count of 0.
Definition koliseo.h:226
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:225
int kls_verbose_lvl
If > 0, makes the Koliseo try to acquire kls_log_fp from kls_log_filepath.
Definition koliseo.h:222
KLS_Err_Handlers err_handlers
Used to pass custom error handlers for push calls.
Definition koliseo.h:228
const char * kls_log_filepath
String representing the path to the Koliseo logfile.
Definition koliseo.h:224
FILE * kls_log_fp
FILE pointer used by the Koliseo to print its kls_log() output.
Definition koliseo.h:223
Defines the handlers used for errors in push calls.
Definition koliseo.h:162
KLS_OOM_Handler * OOM_handler
Pointer to handler for Out-Of-Memory errors in push calls.
Definition koliseo.h:163
KLS_ZEROCOUNT_Handler * ZEROCOUNT_handler
Pointer to handler for zero-count errors in push calls.
Definition koliseo.h:165
KLS_PTRDIFF_MAX_Handler * PTRDIFF_MAX_handler
Pointer to handler for count > (PTRDIFF_MAX / size) errors in push calls.
Definition koliseo.h:164
KLS_hook_on_temp_start * on_temp_start_handler
Used to pass custom start handler for kls_temp_start calls.
Definition koliseo.h:190
KLS_hook_on_free * on_free_handler
Used to pass custom free handler for kls_free calls.
Definition koliseo.h:188
KLS_hook_on_temp_free * on_temp_free_handler
Used to pass custom free handler for kls_temp_end calls.
Definition koliseo.h:191
KLS_hook_on_push * on_push_handler
Used to pass custom push handler for kls_push calls.
Definition koliseo.h:189
KLS_hook_on_new * on_new_handler
Used to pass custom new handler for kls_new_alloc calls.
Definition koliseo.h:187
KLS_hook_on_temp_push * on_temp_push_handler
Used to pass custom push handler for kls_temp_push calls.
Definition koliseo.h:192
Defines a stat struct for Koliseo.
Definition koliseo.h:241
int tot_pops
Total POP calls done.
Definition koliseo.h:244
double worst_pushcall_time
Longest time taken by a PUSH call.
Definition koliseo.h:249
int tot_temp_pushes
Total PUSH_T calls done.
Definition koliseo.h:243
int tot_pushes
Total PUSH calls done.
Definition koliseo.h:242
int tot_hiccups
Total hiccups encountered.
Definition koliseo.h:247
int tot_temp_pops
Total POP_T calls done.
Definition koliseo.h:245
Represents a savestate for a Koliseo.
Definition koliseo.h:366
ptrdiff_t offset
Current position of memory pointer.
Definition koliseo.h:368
ptrdiff_t prev_offset
Previous position of memory pointer.
Definition koliseo.h:369
Koliseo * kls
Reference to the actual Koliseo we're saving.
Definition koliseo.h:367
Represents the initialised arena allocator struct.
Definition koliseo.h:327
ptrdiff_t size
Size of data field.
Definition koliseo.h:329
ptrdiff_t offset
Current position of memory pointer.
Definition koliseo.h:330
ptrdiff_t prev_offset
Previous position of memory pointer.
Definition koliseo.h:331
KLS_Conf conf
Contains flags to change the Koliseo behaviour.
Definition koliseo.h:333
void * extension_data[KLS_MAX_EXTENSIONS]
Points to data for extensions.
Definition koliseo.h:337
struct Koliseo_Temp * t_kls
Points to related active Kolieo_Temp, when has_temp == 1.
Definition koliseo.h:335
char * data
Points to data field.
Definition koliseo.h:328
size_t hooks_len
Length for hooks and extension_data.
Definition koliseo.h:338
struct Koliseo * next
Points to the next Koliseo when conf.kls_growable == 1.
Definition koliseo.h:340
int has_temp
When == 1, a Koliseo_Temp is currently active on this Koliseo.
Definition koliseo.h:332
KLS_Stats stats
Contains stats for Koliseo performance analysis.
Definition koliseo.h:334
KLS_Hooks hooks[KLS_MAX_EXTENSIONS]
Contains handlers for extensions.
Definition koliseo.h:336
kls_free_func * free_func
Points to the free function for the arena's backing memory.
Definition koliseo.h:339