koliseo 0.4.9
Loading...
Searching...
No Matches
kls_region.c File Reference
#include "kls_region.h"
#include "koliseo.c"

Functions

const char * kls_reglist_backend_string (KLS_RegList_Alloc_Backend kls_be)
 Returns the string corresponding to passed kls_be.
KLS_Region_List kls_rl_emptyList (void)
bool kls_rl_empty (KLS_Region_List l)
KLS_list_element kls_rl_head (KLS_Region_List l)
KLS_Region_List kls_rl_tail (KLS_Region_List l)
KLS_Region_List kls_rl_cons (Koliseo *kls, KLS_list_element e, KLS_Region_List l)
KLS_region_list_itemkls_list_pop (Koliseo *kls)
KLS_Region_List kls_rl_t_cons (Koliseo_Temp *t_kls, KLS_list_element e, KLS_Region_List l)
void kls_rl_freeList (KLS_Region_List l)
 Frees all values and nodes for passed Region list.
void kls_rl_showList_toFile (KLS_Region_List l, FILE *fp)
void kls_rl_showList (KLS_Region_List l)
bool kls_rl_member (KLS_list_element el, KLS_Region_List l)
int kls_rl_length (KLS_Region_List l)
KLS_Region_List kls_rl_append (Koliseo *kls, KLS_Region_List l1, KLS_Region_List l2)
KLS_Region_List kls_rl_reverse (Koliseo *kls, KLS_Region_List l)
KLS_Region_List kls_rl_copy (Koliseo *kls, KLS_Region_List l)
KLS_Region_List kls_rl_delete (Koliseo *kls, KLS_list_element el, KLS_Region_List l)
KLS_Region_List kls_rl_insord (Koliseo *kls, KLS_list_element el, KLS_Region_List l)
KLS_Region_List kls_rl_insord_p (Koliseo *kls, KLS_list_element el, KLS_Region_List l)
bool kls_rl_isLess (KLS_Region *r1, KLS_Region *r2)
 Compares two regions and returns true if the first one has a smaller size.
bool kls_rl_isEqual (KLS_Region *r1, KLS_Region *r2)
 Compares two regions and returns true if their size is equal.
KLS_Region_List kls_rl_mergeList (Koliseo *kls, KLS_Region_List l1, KLS_Region_List l2)
KLS_Region_List kls_rl_intersect (Koliseo *kls, KLS_Region_List l1, KLS_Region_List l2)
KLS_Region_List kls_rl_diff (Koliseo *kls, KLS_Region_List l1, KLS_Region_List l2)
double kls_usageShare (KLS_Region *r, Koliseo *kls)
 Returns the ratio of memory used by the passed KLS_Region relative to the passed Koliseo as a double.
ptrdiff_t kls_regionSize (KLS_Region *r)
 Return size of a passed KLS_Region.
ptrdiff_t kls_avg_regionSize (Koliseo *kls)
 Return average region size in usage for the passed Koliseo.
void kls_usageReport_toFile (Koliseo *kls, FILE *fp)
 Prints an usage report for the passed Koliseo to the passed file.
void kls_usageReport (Koliseo *kls)
 Print usage report for passed Koliseo to stdout.
ptrdiff_t kls_type_usage (int type, Koliseo *kls)
 Calc memory used by the specific type of KLS_list_element.
ptrdiff_t kls_total_padding (Koliseo *kls)
 Calc memory used as padding for the passed Koliseo.
int kls_get_maxRegions_KLS_BASIC (Koliseo *kls)
 Calcs the max number of possible KLS_PUSH ops when using KLS_BASIC reglist alloc backend.
int kls_temp_get_maxRegions_KLS_BASIC (Koliseo_Temp *t_kls)
 Calcs the max number of possible KLS_PUSH_T ops when using KLS_BASIC reglist alloc backend.
void * kls_push_zero_named (Koliseo *kls, ptrdiff_t size, ptrdiff_t align, ptrdiff_t count, char *name, char *desc)
 Takes a Koliseo pointer, and ptrdiff_t values for size, align and count.
void * kls_temp_push_zero_named (Koliseo_Temp *t_kls, ptrdiff_t size, ptrdiff_t align, ptrdiff_t count, char *name, char *desc)
 Takes a Koliseo_Temp, and ptrdiff_t values for size, align and count.
void * kls_push_zero_typed (Koliseo *kls, ptrdiff_t size, ptrdiff_t align, ptrdiff_t count, int type, char *name, char *desc)
 Takes a Koliseo pointer, a KLS_Region_Type index, and ptrdiff_t values for size, align and count.
void * kls_temp_push_zero_typed (Koliseo_Temp *t_kls, ptrdiff_t size, ptrdiff_t align, ptrdiff_t count, int type, char *name, char *desc)
 Takes a Koliseo_Temp, a KLS_Region_Type index, and ptrdiff_t values for size, align and count.
void KLS_autoregion_on_new (struct Koliseo *kls)
void KLS_autoregion_on_free (struct Koliseo *kls)
void KLS_autoregion_on_push (struct Koliseo *kls, ptrdiff_t padding, const char *caller, void *user)
void KLS_autoregion_on_temp_start (struct Koliseo_Temp *t_kls)
void KLS_autoregion_on_temp_free (struct Koliseo_Temp *t_kls)
void KLS_autoregion_on_temp_push (struct Koliseo_Temp *t_kls, ptrdiff_t padding, const char *caller, void *user)

Variables

const char * kls_reglist_backend_strings [KLS_REGLIST_TOTAL_BACKENDS]
 Defines strings for KLS_RegList_Alloc_Backend values.

Function Documentation

◆ KLS_autoregion_on_free()

void KLS_autoregion_on_free ( struct Koliseo * kls)

◆ KLS_autoregion_on_new()

void KLS_autoregion_on_new ( struct Koliseo * kls)

◆ KLS_autoregion_on_push()

void KLS_autoregion_on_push ( struct Koliseo * kls,
ptrdiff_t padding,
const char * caller,
void * user )

◆ KLS_autoregion_on_temp_free()

void KLS_autoregion_on_temp_free ( struct Koliseo_Temp * t_kls)

◆ KLS_autoregion_on_temp_push()

void KLS_autoregion_on_temp_push ( struct Koliseo_Temp * t_kls,
ptrdiff_t padding,
const char * caller,
void * user )

◆ KLS_autoregion_on_temp_start()

void KLS_autoregion_on_temp_start ( struct Koliseo_Temp * t_kls)

◆ kls_avg_regionSize()

ptrdiff_t kls_avg_regionSize ( Koliseo * kls)

Return average region size in usage for the passed Koliseo.

Parameters
klsThe Koliseo to check usage for.
Returns
Average region size as ptrdiff_t.

◆ kls_get_maxRegions_KLS_BASIC()

int kls_get_maxRegions_KLS_BASIC ( Koliseo * kls)

Calcs the max number of possible KLS_PUSH ops when using KLS_BASIC reglist alloc backend.

Returns
The max number of push ops possible, or -1 in case of error.

◆ kls_list_pop()

KLS_region_list_item * kls_list_pop ( Koliseo * kls)

◆ kls_push_zero_named()

void * kls_push_zero_named ( Koliseo * kls,
ptrdiff_t size,
ptrdiff_t align,
ptrdiff_t count,
char * name,
char * desc )

Takes a Koliseo pointer, and ptrdiff_t values for size, align and count.

Tries pushing the specified amount of memory to the Koliseo data field, or goes to exit() if the operation fails. Uses the passed name and desc fields to initialise the allocated KLS_Region fields. Notably, it zeroes the memory region.

Parameters
klsThe Koliseo at hand.
sizeThe size for data to push.
alignThe alignment for data to push.
countThe multiplicative quantity to scale data size to push for.
nameThe name to assign to the resulting KLS_Region.
descThe desc to assign to the resulting KLS_Region.
Returns
A void pointer to the start of memory just pushed to the Koliseo.

◆ kls_push_zero_typed()

void * kls_push_zero_typed ( Koliseo * kls,
ptrdiff_t size,
ptrdiff_t align,
ptrdiff_t count,
int type,
char * name,
char * desc )

Takes a Koliseo pointer, a KLS_Region_Type index, and ptrdiff_t values for size, align and count.

Tries pushing the specified amount of memory to the Koliseo data field, or goes to exit() if the operation fails. Uses the passed name and desc fields to initialise the allocated KLS_Region fields. Notably, it zeroes the memory region.

Parameters
klsThe Koliseo at hand.
sizeThe size for data to push.
alignThe alignment for data to push.
countThe multiplicative quantity to scale data size to push for.
typeThe type index for pushed KLS_Region.
nameThe name to assign to the resulting KLS_Region.
descThe desc to assign to the resulting KLS_Region.
Returns
A void pointer to the start of memory just pushed to the Koliseo.

◆ kls_regionSize()

ptrdiff_t kls_regionSize ( KLS_Region * r)

Return size of a passed KLS_Region.

Sugar.

Parameters
rThe KLS_Region.
Returns
Region size as ptrdiff_t.

◆ kls_reglist_backend_string()

const char * kls_reglist_backend_string ( KLS_RegList_Alloc_Backend kls_be)

Returns the string corresponding to passed kls_be.

See also
KLS_RegList_Alloc_Backend
kls_reglist_backend_strings

◆ kls_rl_append()

KLS_Region_List kls_rl_append ( Koliseo * kls,
KLS_Region_List l1,
KLS_Region_List l2 )

◆ kls_rl_cons()

KLS_Region_List kls_rl_cons ( Koliseo * kls,
KLS_list_element e,
KLS_Region_List l )

◆ kls_rl_copy()

KLS_Region_List kls_rl_copy ( Koliseo * kls,
KLS_Region_List l )

◆ kls_rl_delete()

KLS_Region_List kls_rl_delete ( Koliseo * kls,
KLS_list_element el,
KLS_Region_List l )

◆ kls_rl_diff()

KLS_Region_List kls_rl_diff ( Koliseo * kls,
KLS_Region_List l1,
KLS_Region_List l2 )

◆ kls_rl_empty()

bool kls_rl_empty ( KLS_Region_List l)

◆ kls_rl_emptyList()

KLS_Region_List kls_rl_emptyList ( void )

◆ kls_rl_freeList()

void kls_rl_freeList ( KLS_Region_List l)

Frees all values and nodes for passed Region list.

Should only be used internally for operations with ALLOC_LIBC for allocation backend.

Parameters
lThe list to free (allocated by using malloc).

◆ kls_rl_head()

◆ kls_rl_insord()

KLS_Region_List kls_rl_insord ( Koliseo * kls,
KLS_list_element el,
KLS_Region_List l )

◆ kls_rl_insord_p()

KLS_Region_List kls_rl_insord_p ( Koliseo * kls,
KLS_list_element el,
KLS_Region_List l )

◆ kls_rl_intersect()

KLS_Region_List kls_rl_intersect ( Koliseo * kls,
KLS_Region_List l1,
KLS_Region_List l2 )

◆ kls_rl_isEqual()

bool kls_rl_isEqual ( KLS_Region * r1,
KLS_Region * r2 )

Compares two regions and returns true if their size is equal.

Parameters
r1The first KLS_Region
r2The second KLS_Region
Returns
True if first region size is equal than second region size.

◆ kls_rl_isLess()

bool kls_rl_isLess ( KLS_Region * r1,
KLS_Region * r2 )

Compares two regions and returns true if the first one has a smaller size.

Parameters
r1The KLS_Region expected to be smaller
r2The KLS_Region expected to be bigger
Returns
True if first region size is less than second region size.

◆ kls_rl_length()

int kls_rl_length ( KLS_Region_List l)

◆ kls_rl_member()

bool kls_rl_member ( KLS_list_element el,
KLS_Region_List l )

◆ kls_rl_mergeList()

KLS_Region_List kls_rl_mergeList ( Koliseo * kls,
KLS_Region_List l1,
KLS_Region_List l2 )

◆ kls_rl_reverse()

KLS_Region_List kls_rl_reverse ( Koliseo * kls,
KLS_Region_List l )

◆ kls_rl_showList()

void kls_rl_showList ( KLS_Region_List l)

◆ kls_rl_showList_toFile()

void kls_rl_showList_toFile ( KLS_Region_List l,
FILE * fp )

◆ kls_rl_t_cons()

KLS_Region_List kls_rl_t_cons ( Koliseo_Temp * t_kls,
KLS_list_element e,
KLS_Region_List l )

◆ kls_rl_tail()

KLS_Region_List kls_rl_tail ( KLS_Region_List l)

◆ kls_temp_get_maxRegions_KLS_BASIC()

int kls_temp_get_maxRegions_KLS_BASIC ( Koliseo_Temp * t_kls)

Calcs the max number of possible KLS_PUSH_T ops when using KLS_BASIC reglist alloc backend.

Returns
The max number of temp push ops possible, or -1 in case of error.

◆ kls_temp_push_zero_named()

void * kls_temp_push_zero_named ( Koliseo_Temp * t_kls,
ptrdiff_t size,
ptrdiff_t align,
ptrdiff_t count,
char * name,
char * desc )

Takes a Koliseo_Temp, and ptrdiff_t values for size, align and count.

Tries pushing the specified amount of memory to the referred Koliseo data field, or goes to exit() if the operation fails. Uses the passed name and desc fields to initialise the allocated KLS_Region fields. Notably, it zeroes the memory region.

Parameters
t_klsThe Koliseo_Temp at hand.
sizeThe size for data to push.
alignThe alignment for data to push.
countThe multiplicative quantity to scale data size to push for.
nameThe name to assign to the resulting KLS_Region.
descThe desc to assign to the resulting KLS_Region.
Returns
A void pointer to the start of memory just pushed to the Koliseo.

◆ kls_temp_push_zero_typed()

void * kls_temp_push_zero_typed ( Koliseo_Temp * t_kls,
ptrdiff_t size,
ptrdiff_t align,
ptrdiff_t count,
int type,
char * name,
char * desc )

Takes a Koliseo_Temp, a KLS_Region_Type index, and ptrdiff_t values for size, align and count.

Tries pushing the specified amount of memory to the referred Koliseo data field, or goes to exit() if the operation fails. Uses the passed name and desc fields to initialise the allocated KLS_Region fields. Notably, it zeroes the memory region.

Parameters
t_klsThe Koliseo_Temp at hand.
sizeThe size for data to push.
alignThe alignment for data to push.
countThe multiplicative quantity to scale data size to push for.
typeThe type index for pushed KLS_Region.
nameThe name to assign to the resulting KLS_Region.
descThe desc to assign to the resulting KLS_Region.
Returns
A void pointer to the start of memory just pushed to the referred Koliseo.

◆ kls_total_padding()

ptrdiff_t kls_total_padding ( Koliseo * kls)

Calc memory used as padding for the passed Koliseo.

See also
KLS_Region_List
Parameters
klsThe Koliseo to check total padding for.
Returns
The total padding size as ptrdiff_t.

◆ kls_type_usage()

ptrdiff_t kls_type_usage ( int type,
Koliseo * kls )

Calc memory used by the specific type of KLS_list_element.

See also
KLS_Region_List
Parameters
typeThe integer corresponding to element->type
klsThe Koliseo to check usage for.
Returns
The used memory size as ptrdiff_t.

◆ kls_usageReport()

void kls_usageReport ( Koliseo * kls)

Print usage report for passed Koliseo to stdout.

See also
kls_usageReport_toFile()
Parameters
klsThe Koliseo to print info for.

◆ kls_usageReport_toFile()

void kls_usageReport_toFile ( Koliseo * kls,
FILE * fp )

Prints an usage report for the passed Koliseo to the passed file.

See also
kls_usageShare()
Parameters
klsThe Koliseo to check.
fpThe file pointer to print to.

◆ kls_usageShare()

double kls_usageShare ( KLS_Region * r,
Koliseo * kls )

Returns the ratio of memory used by the passed KLS_Region relative to the passed Koliseo as a double.

Parameters
rThe KLS_Region to check relative size for.
klsThe Koliseo to check on.
Returns
A double representing percentage usage.

Variable Documentation

◆ kls_reglist_backend_strings

const char* kls_reglist_backend_strings[KLS_REGLIST_TOTAL_BACKENDS]
Initial value:
= {
[KLS_REGLIST_ALLOC_KLS_BASIC] = "KLS_BASIC",
}
@ KLS_REGLIST_ALLOC_KLS_BASIC
Definition kls_region.h:56
@ KLS_REGLIST_ALLOC_LIBC
Definition kls_region.h:55

Defines strings for KLS_RegList_Alloc_Backend values.

See also
KLS_RegList_Alloc_Backend
kls_reglist_backend_string()