|
LispBM
|
#include <stdint.h>#include <stdlib.h>#include <stdio.h>#include "lbm_memory.h"#include "platform_mutex.h"
Macros | |
| #define | FREE_OR_USED 0 |
| #define | END 1 |
| #define | START 2 |
| #define | START_END 3 |
| #define | INIT 0 |
| #define | FREE_LENGTH_CHECK 1 |
| #define | SKIP 2 |
| #define | ALLOC_DONE 0xF00DF00D |
| #define | ALLOC_FAILED 0xDEADBEAF |
| #define | WORD_IX_SHIFT 5 |
| #define | WORD_MOD_MASK 0x1F |
| #define | BITMAP_SIZE_SHIFT 4 |
Variables | |
| static lbm_uint * | bitmap = NULL |
| static lbm_uint * | memory = NULL |
| static lbm_uint | memory_size |
| static lbm_uint | bitmap_size |
| static lbm_uint | memory_base_address = 0 |
| static lbm_uint | memory_num_free = 0 |
| static lbm_uint | memory_min_free = 0 |
| static volatile lbm_uint | memory_reserve_level = 0 |
| static lbm_mutex_t | lbm_mem_mutex |
| static bool | lbm_mem_mutex_initialized |
| static lbm_uint | alloc_offset = 0 |
| #define ALLOC_DONE 0xF00DF00D |
| #define ALLOC_FAILED 0xDEADBEAF |
| #define BITMAP_SIZE_SHIFT 4 |
| #define END 1 |
| #define FREE_LENGTH_CHECK 1 |
| #define FREE_OR_USED 0 |
| #define INIT 0 |
| #define SKIP 2 |
| #define START 2 |
| #define START_END 3 |
| #define WORD_IX_SHIFT 5 |
| #define WORD_MOD_MASK 0x1F |
| void lbm_free | ( | void * | ptr | ) |
Free memory allocated with lbm_malloc
| Pointer | to array to free |
| void* lbm_malloc | ( | size_t | size | ) |
Malloc like interface to lbm_memory
| size | Size in bytes of memory to allocate. |
| void* lbm_malloc_reserve | ( | size_t | size | ) |
Allocate memory potentially from the reserved memory.
| size | Size in bytes of memory to allocate. |
Allocate a number of words from the symbols and arrays memory.
| num_words | Number of words to allocate. |
| int lbm_memory_free | ( | lbm_uint * | ptr | ) |
Free an allocated array in the symbols and arrays memory.
| ptr | Pointer to array to free. |
| lbm_uint lbm_memory_get_reserve | ( | void | ) |
Get the number of words of memory that is treated as reserve.
| bool lbm_memory_init | ( | lbm_uint * | data, |
| lbm_uint | data_size, | ||
| lbm_uint * | bitmap, | ||
| lbm_uint | bitmap_size | ||
| ) |
Initialize the symbols and arrays memory
| data | Pointer to an array of uint32_t for data storage. |
| data_size | The size of the data storage array in number of uint32_t elements. |
| bitmap | Pointer to an array of uint32_t for memory allocator meta-data. |
| bitmap_size | The size of the meta-data in number of uint32_t elements. |
| lbm_uint lbm_memory_longest_free | ( | void | ) |
Find the length of the longest run of consecutire free indices in the LBM memory.
| lbm_uint lbm_memory_maximum_used | ( | void | ) |
Get the maximum of memory usage.
| lbm_uint lbm_memory_num_free | ( | void | ) |
| lbm_uint lbm_memory_num_words | ( | void | ) |
Size of of the symbols and arrays memory in uint32_t chunks.
| int lbm_memory_ptr_inside | ( | lbm_uint * | ptr | ) |
Check if a pointer points into the lbm_memory
| ptr |
| void lbm_memory_set_reserve | ( | lbm_uint | num_words | ) |
Set the size of the memory reserve in words.
| num_words | Number of words to treat as reserve. |
Shrink an allocated array.
| ptr | Pointer to array to shrink |
| n | New smaller size of array |
| void lbm_memory_update_min_free | ( | void | ) |
Update memory usage statistics. called by GC automatically
| void lbm_request_gc | ( | void | ) |
Request that the runtime system performs a garbage collection on its earliers convenience. Can be called from any thread and does NOT require that the evaluator is paused.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |