|
LispBM
|
#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"

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 |
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_t * | lbm_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_t * | lbm_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_t * | lbm_ref_cell (lbm_value addr) |
Variables | |
| lbm_heap_state_t | lbm_heap_state |
| lbm_cons_t * | lbm_heaps [2] |
Accesses the car field the car field of an lbm_cons_t.
| cons | Value |
Accesses the car of the cdr of an cons cell
| c | Value |
Accesses the car field of an lbm_cons_t.
| cons | Value |
Accesses the cdr of an cdr field of an lbm_cons_t.
| cons | Value |
Accesses the cdr field of an lbm_cons_t.
| cons | Value |
Allocates an lbm_cons_t cell from the heap and populates it.
| car | The value to put in the car field of the allocated lbm_cons_t. |
| cdr | The value to put in the cdr field of the allocated lbm_cons_t. |
| char lbm_dec_as_char | ( | lbm_value | a | ) |
Decode a numerical value as if it is char
| val | Value to decode |
| double lbm_dec_as_double | ( | lbm_value | val | ) |
Decode a numerical value as a float.
| val | Value to decode. |
| float lbm_dec_as_float | ( | lbm_value | val | ) |
Decode a numerical value as a float.
| val | Value to decode. |
| int32_t lbm_dec_as_i32 | ( | lbm_value | val | ) |
Decode a numerical value as a signed integer.
| val | Value to decode |
| int64_t lbm_dec_as_i64 | ( | lbm_value | val | ) |
Decode a numerical value as a 64bit signed integer.
| val | Value to decode |
| uint32_t lbm_dec_as_u32 | ( | lbm_value | val | ) |
Decode a numerical value as if it is unsigned
| val | Value to decode |
| uint64_t lbm_dec_as_u64 | ( | lbm_value | val | ) |
Decode a numerical value as if it is a 64bit unsigned
| val | Value to decode |
| 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.
| val | Value |
| lbm_uint lbm_dec_custom | ( | lbm_value | val | ) |
Decode an lbm_value representing a custom type into a lbm_uint value.
| val | Value. |
| double lbm_dec_double | ( | lbm_value | x | ) |
Decode an lbm_value representing a double.
| x | Value to decode. |
| float lbm_dec_float | ( | lbm_value | x | ) |
Decode an lbm_value representing a float.
| x | Value to decode. |
| int64_t lbm_dec_i64 | ( | lbm_value | x | ) |
Decode an lbm_value representing a 64 bit integert.
| x | Value to decode. |
| char* lbm_dec_str | ( | lbm_value | val | ) |
Decode an lbm_value representing a string into a C string
| val | Value |
| uint64_t lbm_dec_u64 | ( | lbm_value | x | ) |
Decode an lbm_value representing a 64 bit unsigned integer.
| x | Value to decode. |
| lbm_value lbm_enc_double | ( | double | x | ) |
Encode a double into an lbm_value.
| x | double to encode. |
| lbm_value lbm_enc_float | ( | float | x | ) |
Encode a float into an lbm_value.
| x | float value to encode. |
| lbm_value lbm_enc_i32 | ( | int32_t | x | ) |
Encode 32 bit integer into an lbm_value.
| x | Value to encode. |
| lbm_value lbm_enc_i64 | ( | int64_t | x | ) |
Encode a 64 bit integer into an lbm_value.
| x | 64 bit integer to encode. |
| lbm_value lbm_enc_u32 | ( | uint32_t | x | ) |
Encode 32 bit unsigned integer into an lbm_value.
| x | Value to encode. |
| lbm_value lbm_enc_u64 | ( | uint64_t | x | ) |
Encode a 64 bit unsigned integer into an lbm_value.
| x | 64 bit unsigned integer to encode. |
| 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.
| 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.
| data | Array of roots to traverse from. |
| n | Number of elements in roots-array. |
| void lbm_gc_mark_env | ( | lbm_value | ) |
Mark all heap cells reachable from an environment.
| environment. |
| int lbm_gc_mark_freelist | ( | void | ) |
Mark all heap cells that are on the free-list.
| void lbm_gc_mark_phase | ( | lbm_value | root | ) |
Mark heap cells reachable from the lbm_value v.
| root |
| 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.
| roots | pointer to array of roots. |
| num_roots | size of array of roots. |
| void lbm_gc_state_inc | ( | void | ) |
Increment the counter that is counting the number of times GC ran
| int lbm_gc_sweep_phase | ( | void | ) |
Sweep up all non marked heap cells and place them on the free list.
| lbm_uint lbm_get_gc_stack_max | ( | void | ) |
Get the maximum stack level of the GC stack
| lbm_uint lbm_get_gc_stack_size | ( | void | ) |
Get the size of the GC stack.
| void lbm_get_heap_state | ( | lbm_heap_state_t * | ) |
Get a copy of the heap statistics structure.
| A | pointer to an lbm_heap_state_t to populate with the current statistics. |
| 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.
| res | The resulting lbm_value is returned through this argument. |
| size | Array size in number of 32 bit words. |
| type | The type information to encode onto the heap cell. |
Allocate an lbm_cons_t cell from the heap.
| type | A type that can be encoded onto the cell (most often LBM_PTR_TYPE_CONS). |
| car | Value to write into car position of allocated cell. |
| cdr | Value to write into cdr position of allocated cell. |
| lbm_value lbm_heap_allocate_list | ( | lbm_uint | n | ) |
Allocate a list of n heap-cells.
| n | The number of heap-cells to allocate. |
| lbm_value lbm_heap_allocate_list_init | ( | unsigned int | n, |
| ... | |||
| ) |
Allocate a list of n heap-cells and initialize the values.
| n | The length of list to allocate. |
| ... | The values to initialize the list with. |
| 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.
| n | The length of list to allocate. |
| valist | The values in a va_list to initialize the list with. |
| uint8_t* lbm_heap_array_get_data | ( | lbm_value | arr | ) |
Get a pointer to the data of an array.
| arr | lbm_value array to get pointer from. |
| lbm_int lbm_heap_array_get_size | ( | lbm_value | arr | ) |
Get the size of an array value.
| arr | lbm_value array to get size of. |
| int lbm_heap_explicit_free_array | ( | lbm_value | arr | ) |
Explicitly free an array. This function needs to be used with care and knowledge.
| arr | Array value. |
| int lbm_heap_init | ( | lbm_cons_t * | addr, |
| lbm_uint | num_cells, | ||
| lbm_uint | gc_stack_size | ||
| ) |
Initialize heap storage.
| addr | Pointer to an array of lbm_cons_t elements. This array must at least be aligned 4. |
| num_cells | Number of lbm_cons_t elements in the array. |
| gc_stack_size | Size of the gc_stack in number of words. |
| 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.
| void lbm_heap_new_gc_time | ( | lbm_uint | dur | ) |
Add GC time statistics to heap_stats
| dur | Duration as reported by the timestamp callback. |
| lbm_uint lbm_heap_num_allocated | ( | void | ) |
Check how many lbm_cons_t cells are allocated.
| lbm_uint lbm_heap_num_free | ( | void | ) |
Check how many lbm_cons_t cells are on the free-list
| lbm_uint lbm_heap_size | ( | void | ) |
Size of the heap in number of lbm_cons_t cells.
| lbm_uint lbm_heap_size_bytes | ( | void | ) |
Size of the heap in bytes.
|
inlinestatic |
Check if value is an array that can be READ
| x | Value to check. |
| bool lbm_is_number | ( | lbm_value | x | ) |
Check if a value represents a number
| x | Value to check. |
| 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.
| res | lbm_value result pointer for storage of the result array. |
| data | C array. |
| type | The type tag to assign to the resulting LBM array. |
| num_elt | Number of elements in the array. |
A destructive append of two lists
| list1 | A list |
| list2 | A list |
Copy a list
| m | Number of elements to copy or -1 for all. If 1, m will be updated with the length of the list |
| list | A list. |
Reverse a proper list destroying the original.
| list | A list |
Drop values from the head of a list.
| n | Number of values to drop. |
| ls | List to drop values from. |
| lbm_uint lbm_list_length | ( | lbm_value | c | ) |
Calculate the length of a proper list
| c | A list |
Calculate the length of a proper list and evaluate a predicate for each element.
| c | A list |
| pres | Boolean result of predicate, false if predicate is false for any of the elements in the list, otherwise true. |
| pred | Predicate to evaluate for each element of the list. |
Reverse a proper list
| list | A list |
| void lbm_nil_freelist | ( | void | ) |
Set the freelist to NIL. Means that no memory will be available until after a garbage collection.
Update the value stored in the car field of a heap cell.
| c | Value referring to a heap cell. |
| v | Value to replace the car field with. |
Update the value stored in the car and cdr fields of a heap cell.
| c | Value referring to a heap cell. |
| car_val | Value to replace the car field with. |
| cdr_val | Value to replace the cdr field with. |
Update the value stored in the cdr field of a heap cell.
| c | Value referring to a heap cell. |
| v | Value to replace the cdr field with. |
| lbm_uint lbm_size_of | ( | lbm_type | t | ) |
Query the size in bytes of an lbm_type.
| t | Type |