LispBM
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
heap.h File Reference
#include <string.h>
#include <stdarg.h>
#include "lbm_types.h"
#include "symrepr.h"
#include "stack.h"
#include "lbm_memory.h"
#include "lbm_defines.h"
#include "lbm_channel.h"
Include dependency graph for heap.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  lbm_cons_t
 
struct  lbm_heap_state_t
 
struct  lbm_const_heap_t
 
struct  lbm_array_header_t
 

Macros

#define LBM_ADDRESS_SHIFT   2
 
#define LBM_VAL_SHIFT   4
 
#define LBM_PTR_MASK   0x00000001u
 
#define LBM_PTR_BIT   0x00000001u
 
#define LBM_PTR_VAL_MASK   0x03FFFFFCu
 
#define LBM_PTR_TYPE_MASK   0xFC000000u
 
#define LBM_PTR_NULL   (0x03FFFFFCu >> 2)
 
#define LBM_PTR_TO_CONSTANT_BIT   0x04000000u
 
#define LBM_PTR_TO_CONSTANT_MASK   ~LBM_PTR_TO_CONSTANT_BIT
 
#define LBM_PTR_TO_CONSTANT_SHIFT   26
 
#define ERROR_SYMBOL_MASK   0xFFFFFFF0
 

Typedefs

typedef bool(* const_heap_write_fun) (lbm_uint ix, lbm_uint w)
 

Enumerations

enum  lbm_flash_status { LBM_FLASH_WRITE_OK , LBM_FLASH_FULL , LBM_FLASH_WRITE_ERROR }
 

Functions

void lbm_gc_lock (void)
 
void lbm_gc_unlock (void)
 
int lbm_heap_init (lbm_cons_t *addr, lbm_uint num_cells, lbm_uint gc_stack_size)
 
void lbm_heap_new_gc_time (lbm_uint dur)
 
void lbm_heap_new_freelist_length (void)
 
lbm_uint lbm_heap_num_free (void)
 
lbm_uint lbm_heap_num_allocated (void)
 
lbm_uint lbm_heap_size (void)
 
lbm_uint lbm_heap_size_bytes (void)
 
lbm_value lbm_heap_allocate_cell (lbm_type type, lbm_value car, lbm_value cdr)
 
lbm_value lbm_heap_allocate_list (lbm_uint n)
 
lbm_value lbm_heap_allocate_list_init_va (unsigned int n, va_list valist)
 
lbm_value lbm_heap_allocate_list_init (unsigned int n,...)
 
char * lbm_dec_str (lbm_value val)
 
lbm_char_channel_tlbm_dec_channel (lbm_value val)
 
lbm_uint lbm_dec_custom (lbm_value val)
 
char lbm_dec_as_char (lbm_value a)
 
uint32_t lbm_dec_as_u32 (lbm_value val)
 
int32_t lbm_dec_as_i32 (lbm_value val)
 
float lbm_dec_as_float (lbm_value val)
 
uint64_t lbm_dec_as_u64 (lbm_value val)
 
int64_t lbm_dec_as_i64 (lbm_value val)
 
double lbm_dec_as_double (lbm_value val)
 
lbm_uint lbm_dec_raw (lbm_value v)
 
lbm_value lbm_cons (lbm_value car, lbm_value cdr)
 
lbm_value lbm_car (lbm_value cons)
 
lbm_value lbm_caar (lbm_value c)
 
lbm_value lbm_cadr (lbm_value c)
 
lbm_value lbm_cdr (lbm_value cons)
 
lbm_value lbm_cddr (lbm_value c)
 
int lbm_set_car (lbm_value c, lbm_value v)
 
int lbm_set_cdr (lbm_value c, lbm_value v)
 
int lbm_set_car_and_cdr (lbm_value c, lbm_value car_val, lbm_value cdr_val)
 
lbm_uint lbm_list_length (lbm_value c)
 
unsigned int lbm_list_length_pred (lbm_value c, bool *pres, bool(*pred)(lbm_value))
 
lbm_value lbm_list_reverse (lbm_value list)
 
lbm_value lbm_list_destructive_reverse (lbm_value list)
 
lbm_value lbm_list_copy (int *m, lbm_value list)
 
lbm_value lbm_list_append (lbm_value list1, lbm_value list2)
 
lbm_value lbm_list_drop (unsigned int n, lbm_value ls)
 
void lbm_get_heap_state (lbm_heap_state_t *)
 
lbm_uint lbm_get_gc_stack_max (void)
 
lbm_uint lbm_get_gc_stack_size (void)
 
void lbm_gc_state_inc (void)
 
void lbm_nil_freelist (void)
 
int lbm_gc_mark_freelist (void)
 
void lbm_gc_mark_env (lbm_value)
 
void lbm_gc_mark_phase (lbm_value root)
 
void lbm_gc_mark_aux (lbm_uint *data, lbm_uint n)
 
void lbm_gc_mark_roots (lbm_uint *roots, lbm_uint num_roots)
 
int lbm_gc_sweep_phase (void)
 
int lbm_heap_allocate_array (lbm_value *res, lbm_uint size)
 
int lbm_lift_array (lbm_value *value, char *data, lbm_uint num_elt)
 
lbm_int lbm_heap_array_get_size (lbm_value arr)
 
uint8_t * lbm_heap_array_get_data (lbm_value arr)
 
int lbm_heap_explicit_free_array (lbm_value arr)
 
lbm_uint lbm_size_of (lbm_type t)
 
int lbm_const_heap_init (const_heap_write_fun w_fun, lbm_const_heap_t *heap, lbm_uint *addr, lbm_uint num_words)
 
lbm_flash_status lbm_allocate_const_cell (lbm_value *res)
 
lbm_flash_status lbm_write_const_raw (lbm_uint *data, lbm_uint n, lbm_uint *res)
 
lbm_flash_status write_const_cdr (lbm_value cell, lbm_value val)
 
lbm_flash_status write_const_car (lbm_value cell, lbm_value val)
 
lbm_uint lbm_flash_memory_usage (void)
 
static lbm_type lbm_type_of (lbm_value x)
 
static lbm_type lbm_type_of_functional (lbm_value x)
 
static lbm_value lbm_enc_cons_ptr (lbm_uint x)
 
static lbm_uint lbm_dec_ptr (lbm_value p)
 
static lbm_uint lbm_dec_cons_cell_ptr (lbm_value p)
 
static lbm_cons_tlbm_dec_heap (lbm_value p)
 
static lbm_value lbm_set_ptr_type (lbm_value p, lbm_type t)
 
static lbm_value lbm_enc_sym (lbm_uint s)
 
static lbm_value lbm_enc_i (lbm_int x)
 
static lbm_value lbm_enc_u (lbm_uint x)
 
lbm_value lbm_enc_i32 (int32_t x)
 
lbm_value lbm_enc_u32 (uint32_t x)
 
lbm_value lbm_enc_float (float x)
 
lbm_value lbm_enc_i64 (int64_t x)
 
lbm_value lbm_enc_u64 (uint64_t x)
 
lbm_value lbm_enc_double (double x)
 
static lbm_value lbm_enc_char (char x)
 
static lbm_int lbm_dec_i (lbm_value x)
 
static lbm_uint lbm_dec_u (lbm_value x)
 
static char lbm_dec_char (lbm_value x)
 
static lbm_uint lbm_dec_sym (lbm_value x)
 
float lbm_dec_float (lbm_value x)
 
double lbm_dec_double (lbm_value x)
 
static uint32_t lbm_dec_u32 (lbm_value x)
 
uint64_t lbm_dec_u64 (lbm_value x)
 
static int32_t lbm_dec_i32 (lbm_value x)
 
int64_t lbm_dec_i64 (lbm_value x)
 
static bool lbm_is_ptr (lbm_value x)
 
static bool lbm_is_cons_rw (lbm_value x)
 
static bool lbm_is_cons (lbm_value x)
 
bool lbm_is_number (lbm_value x)
 
static bool lbm_is_array_r (lbm_value x)
 
static bool lbm_is_array_rw (lbm_value x)
 
static bool lbm_is_channel (lbm_value x)
 
static bool lbm_is_char (lbm_value x)
 
static bool lbm_is_special (lbm_value symrep)
 
static bool lbm_is_closure (lbm_value exp)
 
static bool lbm_is_continuation (lbm_value exp)
 
static bool lbm_is_macro (lbm_value exp)
 
static bool lbm_is_match_binder (lbm_value exp)
 
static bool lbm_is_comma_qualified_symbol (lbm_value exp)
 
static bool lbm_is_symbol (lbm_value exp)
 
static bool lbm_is_symbol_nil (lbm_value exp)
 
static bool lbm_is_symbol_true (lbm_value exp)
 
static bool lbm_is_symbol_eval (lbm_value exp)
 
static bool lbm_is_symbol_merror (lbm_value exp)
 
static bool lbm_is_list (lbm_value x)
 
static bool lbm_is_list_rw (lbm_value x)
 
static bool lbm_is_quoted_list (lbm_value x)
 
static bool lbm_is_error (lbm_value v)
 
static lbm_cons_tlbm_ref_cell (lbm_value addr)
 

Variables

lbm_heap_state_t lbm_heap_state
 
lbm_cons_tlbm_heaps [2]
 

Function Documentation

◆ lbm_caar()

lbm_value lbm_caar ( lbm_value  c)

Accesses the car field the car field of an lbm_cons_t.

Parameters
consValue
Returns
The car of car field or nil.

◆ lbm_cadr()

lbm_value lbm_cadr ( lbm_value  c)

Accesses the car of the cdr of an cons cell

Parameters
cValue
Returns
the cdr field or type error.

◆ lbm_car()

lbm_value lbm_car ( lbm_value  cons)

Accesses the car field of an lbm_cons_t.

Parameters
consValue
Returns
The car field of the lbm_cons_t if cons is a reference to a heap cell. If cons is nil, the return value is nil. If the value is not cons or nil, the return value is enc_sym(SYM_TERROR) for type error.

◆ lbm_cddr()

lbm_value lbm_cddr ( lbm_value  c)

Accesses the cdr of an cdr field of an lbm_cons_t.

Parameters
consValue
Returns
The cdr of the cdr field of the lbm_cons_t if cons is a reference to a heap cell. If cons is nil, the return value is nil. If the value if not cons or nil, the return value is enc_sym(SYM_TERROR) for type error.

◆ lbm_cdr()

lbm_value lbm_cdr ( lbm_value  cons)

Accesses the cdr field of an lbm_cons_t.

Parameters
consValue
Returns
The cdr field of the lbm_cons_t if cons is a reference to a heap cell. If cons is nil, the return value is nil. If the value if not cons or nil, the return value is enc_sym(SYM_TERROR) for type error.

◆ lbm_cons()

lbm_value lbm_cons ( lbm_value  car,
lbm_value  cdr 
)

Allocates an lbm_cons_t cell from the heap and populates it.

Parameters
carThe value to put in the car field of the allocated lbm_cons_t.
cdrThe value to put in the cdr field of the allocated lbm_cons_t.
Returns
A value referencing the lbm_cons_t or enc_sym(SYM_MERROR) if heap is full.

◆ lbm_dec_as_char()

char lbm_dec_as_char ( lbm_value  a)

Decode a numerical value as if it is char

Parameters
valValue to decode
Returns
The value encoded in val casted to a char. Returns 0 if val does not encode a number.

◆ lbm_dec_as_double()

double lbm_dec_as_double ( lbm_value  val)

Decode a numerical value as a float.

Parameters
valValue to decode.
Returns
The value encoded in val casted to a float. Returns 0 if val does not encode a number.

◆ lbm_dec_as_float()

float lbm_dec_as_float ( lbm_value  val)

Decode a numerical value as a float.

Parameters
valValue to decode.
Returns
The value encoded in val casted to a float. Returns 0 if val does not encode a number.

◆ lbm_dec_as_i32()

int32_t lbm_dec_as_i32 ( lbm_value  val)

Decode a numerical value as a signed integer.

Parameters
valValue to decode
Returns
The value encoded in val casted to a signed int. Returns 0 if val does not encode a number.

◆ lbm_dec_as_i64()

int64_t lbm_dec_as_i64 ( lbm_value  val)

Decode a numerical value as a 64bit signed integer.

Parameters
valValue to decode
Returns
The value encoded in val casted to a signed int. Returns 0 if val does not encode a number.

◆ lbm_dec_as_u32()

uint32_t lbm_dec_as_u32 ( lbm_value  val)

Decode a numerical value as if it is unsigned

Parameters
valValue to decode
Returns
The value encoded in val casted to an unsigned int. Returns 0 if val does not encode a number.

◆ lbm_dec_as_u64()

uint64_t lbm_dec_as_u64 ( lbm_value  val)

Decode a numerical value as if it is a 64bit unsigned

Parameters
valValue to decode
Returns
The value encoded in val casted to an unsigned int. Returns 0 if val does not encode a number.

◆ lbm_dec_channel()

lbm_char_channel_t* lbm_dec_channel ( lbm_value  val)

Decode an lbm_value representing a char channel into an lbm_char_channel_t pointer.

Parameters
valValue
Returns
A pointer to an lbm_char_channel_t or NULL if the value does not encode a channel.

◆ lbm_dec_custom()

lbm_uint lbm_dec_custom ( lbm_value  val)

Decode an lbm_value representing a custom type into a lbm_uint value.

Parameters
valValue.
Returns
The custom type payload.

◆ lbm_dec_double()

double lbm_dec_double ( lbm_value  x)

Decode an lbm_value representing a double.

Parameters
xValue to decode.
Returns
decoded float.

◆ lbm_dec_float()

float lbm_dec_float ( lbm_value  x)

Decode an lbm_value representing a float.

Parameters
xValue to decode.
Returns
decoded float.

◆ lbm_dec_i64()

int64_t lbm_dec_i64 ( lbm_value  x)

Decode an lbm_value representing a 64 bit integert.

Parameters
xValue to decode.
Returns
decoded int64_t.

◆ lbm_dec_str()

char* lbm_dec_str ( lbm_value  val)

Decode an lbm_value representing a string into a C string

Parameters
valValue
Returns
allocated list or error symbol

◆ lbm_dec_u64()

uint64_t lbm_dec_u64 ( lbm_value  x)

Decode an lbm_value representing a 64 bit unsigned integer.

Parameters
xValue to decode.
Returns
decoded uint64_t.

◆ lbm_enc_double()

lbm_value lbm_enc_double ( double  x)

Encode a double into an lbm_value.

Parameters
xdouble to encode.
Returns
result encoded value.

◆ lbm_enc_float()

lbm_value lbm_enc_float ( float  x)

Encode a float into an lbm_value.

Parameters
xfloat value to encode.
Returns
result encoded value.

◆ lbm_enc_i32()

lbm_value lbm_enc_i32 ( int32_t  x)

Encode 32 bit integer into an lbm_value.

Parameters
xValue to encode.
Returns
result encoded value.

◆ lbm_enc_i64()

lbm_value lbm_enc_i64 ( int64_t  x)

Encode a 64 bit integer into an lbm_value.

Parameters
x64 bit integer to encode.
Returns
result encoded value.

◆ lbm_enc_u32()

lbm_value lbm_enc_u32 ( uint32_t  x)

Encode 32 bit unsigned integer into an lbm_value.

Parameters
xValue to encode.
Returns
result encoded value.

◆ lbm_enc_u64()

lbm_value lbm_enc_u64 ( uint64_t  x)

Encode a 64 bit unsigned integer into an lbm_value.

Parameters
x64 bit unsigned integer to encode.
Returns
result encoded value.

◆ lbm_gc_lock()

void lbm_gc_lock ( void  )

Lock GC mutex Locks a mutex during GC marking when using the pointer reversal algorithm. Does nothing when using stack based GC mark.

◆ lbm_gc_mark_aux()

void lbm_gc_mark_aux ( lbm_uint *  data,
lbm_uint  n 
)

Performs lbm_gc_mark_phase on all the values of an array. This function is similar to lbm_gc_mark_roots but performs extra checks to not traverse into non-standard values. TODO: Check if this function is really needed.

Parameters
dataArray of roots to traverse from.
nNumber of elements in roots-array.

◆ lbm_gc_mark_env()

void lbm_gc_mark_env ( lbm_value  )

Mark all heap cells reachable from an environment.

Parameters
environment.

◆ lbm_gc_mark_freelist()

int lbm_gc_mark_freelist ( void  )

Mark all heap cells that are on the free-list.

Returns
1 on success or 0 if the free-list is corrupted.

◆ lbm_gc_mark_phase()

void lbm_gc_mark_phase ( lbm_value  root)

Mark heap cells reachable from the lbm_value v.

Parameters
root

◆ lbm_gc_mark_roots()

void lbm_gc_mark_roots ( lbm_uint *  roots,
lbm_uint  num_roots 
)

Performs lbm_gc_mark_phase on all the values in the roots array.

Parameters
rootspointer to array of roots.
num_rootssize of array of roots.

◆ lbm_gc_state_inc()

void lbm_gc_state_inc ( void  )

Increment the counter that is counting the number of times GC ran

◆ lbm_gc_sweep_phase()

int lbm_gc_sweep_phase ( void  )

Sweep up all non marked heap cells and place them on the free list.

Returns
1

◆ lbm_get_gc_stack_max()

lbm_uint lbm_get_gc_stack_max ( void  )

Get the maximum stack level of the GC stack

Returns
maximum value the gc stack sp reached so far.

◆ lbm_get_gc_stack_size()

lbm_uint lbm_get_gc_stack_size ( void  )

Get the size of the GC stack.

Returns
the size of the gc stack.

◆ lbm_get_heap_state()

void lbm_get_heap_state ( lbm_heap_state_t )

Get a copy of the heap statistics structure.

Parameters
Apointer to an lbm_heap_state_t to populate with the current statistics.

◆ lbm_heap_allocate_array()

int lbm_heap_allocate_array ( lbm_value res,
lbm_uint  size 
)

Allocate an array in symbols and arrays memory (lispbm_memory.h) and create a heap cell that refers to this array.

Parameters
resThe resulting lbm_value is returned through this argument.
sizeArray size in number of 32 bit words.
typeThe type information to encode onto the heap cell.
Returns
1 for success of 0 for failure.

◆ lbm_heap_allocate_cell()

lbm_value lbm_heap_allocate_cell ( lbm_type  type,
lbm_value  car,
lbm_value  cdr 
)

Allocate an lbm_cons_t cell from the heap.

Parameters
typeA type that can be encoded onto the cell (most often LBM_PTR_TYPE_CONS).
carValue to write into car position of allocated cell.
cdrValue to write into cdr position of allocated cell.
Returns
An lbm_value referring to a cons_cell or enc_sym(SYM_MERROR) in case the heap is full.

◆ lbm_heap_allocate_list()

lbm_value lbm_heap_allocate_list ( lbm_uint  n)

Allocate a list of n heap-cells.

Parameters
nThe number of heap-cells to allocate.
Returns
A list of heap-cells of Memory error if unable to allocate.

◆ lbm_heap_allocate_list_init()

lbm_value lbm_heap_allocate_list_init ( unsigned int  n,
  ... 
)

Allocate a list of n heap-cells and initialize the values.

Parameters
nThe length of list to allocate.
...The values to initialize the list with.
Returns
allocated list or error symbol.

◆ lbm_heap_allocate_list_init_va()

lbm_value lbm_heap_allocate_list_init_va ( unsigned int  n,
va_list  valist 
)

Allocate a list of n heap-cells and initialize the values. \pram ls The result list is passed through this ptr.

Parameters
nThe length of list to allocate.
valistThe values in a va_list to initialize the list with.
Returns
True of False depending on success of allocation.

◆ lbm_heap_array_get_data()

uint8_t* lbm_heap_array_get_data ( lbm_value  arr)

Get a pointer to the data of an array.

Parameters
arrlbm_value array to get pointer from.
Returns
NULL or valid pointer.

◆ lbm_heap_array_get_size()

lbm_int lbm_heap_array_get_size ( lbm_value  arr)

Get the size of an array value.

Parameters
arrlbm_value array to get size of.
Returns
-1 for failure or length of array.

◆ lbm_heap_explicit_free_array()

int lbm_heap_explicit_free_array ( lbm_value  arr)

Explicitly free an array. This function needs to be used with care and knowledge.

Parameters
arrArray value.

◆ lbm_heap_init()

int lbm_heap_init ( lbm_cons_t addr,
lbm_uint  num_cells,
lbm_uint  gc_stack_size 
)

Initialize heap storage.

Parameters
addrPointer to an array of lbm_cons_t elements. This array must at least be aligned 4.
num_cellsNumber of lbm_cons_t elements in the array.
gc_stack_sizeSize of the gc_stack in number of words.
Returns
1 on success or 0 for failure.

◆ lbm_heap_new_freelist_length()

void lbm_heap_new_freelist_length ( void  )

Add a new free_list length to the heap_stats. Calculates a new freelist length and updates the GC statistics.

◆ lbm_heap_new_gc_time()

void lbm_heap_new_gc_time ( lbm_uint  dur)

Add GC time statistics to heap_stats

Parameters
durDuration as reported by the timestamp callback.

◆ lbm_heap_num_allocated()

lbm_uint lbm_heap_num_allocated ( void  )

Check how many lbm_cons_t cells are allocated.

Returns
Number of lbm_cons_t cells that are currently allocated.

◆ lbm_heap_num_free()

lbm_uint lbm_heap_num_free ( void  )

Check how many lbm_cons_t cells are on the free-list

Returns
Number of free lbm_cons_t cells.

◆ lbm_heap_size()

lbm_uint lbm_heap_size ( void  )

Size of the heap in number of lbm_cons_t cells.

Returns
Size of the heap in number of lbm_cons_t cells.

◆ lbm_heap_size_bytes()

lbm_uint lbm_heap_size_bytes ( void  )

Size of the heap in bytes.

Returns
Size of heap in bytes.

◆ lbm_is_array_r()

static bool lbm_is_array_r ( lbm_value  x)
inlinestatic

Check if value is an array that can be READ

Parameters
xValue to check.
Returns
true if x represents a readable array and false otherwise.

◆ lbm_is_number()

bool lbm_is_number ( lbm_value  x)

Check if a value represents a number

Parameters
xValue to check.
Returns
true is x represents a number and false otherwise.

◆ lbm_lift_array()

int lbm_lift_array ( lbm_value value,
char *  data,
lbm_uint  num_elt 
)

Convert a C array into an lbm array. If the C array is allocated in LBM MEMORY the lifetime of the array will be managed by GC.

Parameters
reslbm_value result pointer for storage of the result array.
dataC array.
typeThe type tag to assign to the resulting LBM array.
num_eltNumber of elements in the array.
Returns
1 for success and 0 for failure.

◆ lbm_list_append()

lbm_value lbm_list_append ( lbm_value  list1,
lbm_value  list2 
)

A destructive append of two lists

Parameters
list1A list
list2A list
Returns
list1 with list2 appended at the end.

◆ lbm_list_copy()

lbm_value lbm_list_copy ( int *  m,
lbm_value  list 
)

Copy a list

Warning
This is a dangerous function that should be used carefully. Cyclic structures on the heap may lead to the function not terminating.
Parameters
mNumber of elements to copy or -1 for all. If 1, m will be updated with the length of the list
listA list.
Returns
Reversed list or enc_sym(SYM_MERROR) if heap is full.

◆ lbm_list_destructive_reverse()

lbm_value lbm_list_destructive_reverse ( lbm_value  list)

Reverse a proper list destroying the original.

Warning
This is a dangerous function that should be used carefully. Cyclic structures on the heap may lead to the function not terminating.
Parameters
listA list
Returns
The list reversed

◆ lbm_list_drop()

lbm_value lbm_list_drop ( unsigned int  n,
lbm_value  ls 
)

Drop values from the head of a list.

Parameters
nNumber of values to drop.
lsList to drop values from.
Returns
The list with the n first elements removed.

◆ lbm_list_length()

lbm_uint lbm_list_length ( lbm_value  c)

Calculate the length of a proper list

Warning
This is a dangerous function that should be used carefully. Cyclic structures on the heap may lead to the function not terminating.
Parameters
cA list
Returns
The length of the list. Unless the value is a cyclic structure on the heap, this function will terminate.

◆ lbm_list_length_pred()

unsigned int lbm_list_length_pred ( lbm_value  c,
bool *  pres,
bool(*)(lbm_value pred 
)

Calculate the length of a proper list and evaluate a predicate for each element.

Warning
This is a dangerous function that should be used carefully. Cyclic structures on the heap may lead to the function not terminating.
Parameters
cA list
presBoolean result of predicate, false if predicate is false for any of the elements in the list, otherwise true.
predPredicate to evaluate for each element of the list.

◆ lbm_list_reverse()

lbm_value lbm_list_reverse ( lbm_value  list)

Reverse a proper list

Warning
This is a dangerous function that should be used carefully. Cyclic structures on the heap may lead to the function not terminating.
Parameters
listA list
Returns
The list reversed or enc_sym(SYM_MERROR) if heap is full.

◆ lbm_nil_freelist()

void lbm_nil_freelist ( void  )

Set the freelist to NIL. Means that no memory will be available until after a garbage collection.

◆ lbm_set_car()

int lbm_set_car ( lbm_value  c,
lbm_value  v 
)

Update the value stored in the car field of a heap cell.

Parameters
cValue referring to a heap cell.
vValue to replace the car field with.
Returns
1 on success and 0 if the c value does not refer to a heap cell.

◆ lbm_set_car_and_cdr()

int lbm_set_car_and_cdr ( lbm_value  c,
lbm_value  car_val,
lbm_value  cdr_val 
)

Update the value stored in the car and cdr fields of a heap cell.

Parameters
cValue referring to a heap cell.
car_valValue to replace the car field with.
cdr_valValue to replace the cdr field with.
Returns
1 on success and 0 if the c value does not refer to a heap cell.

◆ lbm_set_cdr()

int lbm_set_cdr ( lbm_value  c,
lbm_value  v 
)

Update the value stored in the cdr field of a heap cell.

Parameters
cValue referring to a heap cell.
vValue to replace the cdr field with.
Returns
1 on success and 0 if the c value does not refer to a heap cell.

◆ lbm_size_of()

lbm_uint lbm_size_of ( lbm_type  t)

Query the size in bytes of an lbm_type.

Parameters
tType
Returns
Size in bytes of type or 0 if the type represents a composite.

◆ lbm_type_of()

static lbm_type lbm_type_of ( lbm_value  x)
inlinestatic

Query the type information of a value.

Parameters
xValue to check the type of.
Returns
The type information.