33#define CTX_LOG(FMT, ...) DBG("CTX", FMT __VA_OPT__(, ) __VA_ARGS__)
35#define CTX_LOG(FMT, ...)
104 hmap_key_t k = {.data = (
void *)name, .len = strlen(name)};
srn_context_t * srn_context_make(srn_engine_t *engine)
Make an empty context, by allocating a new memory block.
int srn_context_release(srn_context_t *ctx)
void * srn_allocate(const srn_context_t *ctx, size_t size, size_t alignment)
void srn_release(const srn_context_t *ctx, void *ptr)
size_t srn_block_id_t
The block id is effectively just an index in the blocks array in srn_mm_t.
void srn_mm_release_block(srn_mm_t *mm, srn_block_id_t id)
Release the given block id and free the memory for later allocations.
void * srn_mm_allocate_in_block_aligned(srn_mm_t *mm, srn_block_id_t block_id, size_t size, size_t alignment)
Allocate memory on a block with the given block_id.
srn_block_id_t srn_mm_allocate_block(srn_mm_t *mm)
Allocate a new block in the memory manager and return its ID.
void * hmap_lookup(srn_context_t *ctx, const hmap_t *hmap, const hmap_key_t *k, void *default_value)
Lookup the given k in the given hmap and return the value if it's been found.
hmap_t hmap_insert(srn_context_t *ctx, const hmap_t *hmap, hmap_key_t *k, void *v)
Insert the given key k with the value v in the given hash hmap and return the new map.
hmap_key_t * hmap_make_key(srn_context_t *ctx, void *data, size_t len)
Create a new key out of the given data, with the given len.
This is an implementation of Compressed Hash-Array Mapped Prefix-tree, which is a bit-partitioned,...
#define srn_mm_allocate_in_block(mm, id, T)
size_t srn_string_length(const srn_string_t *s)
Note: For key equality we use the memcpy function.
srn_engine_t * engine
Long term state of the compiler.
srn_block_id_t block_id
Where to allocate memory from.
struct srn_context_t * parent
Engine is a structure to own the long living and main pieces of the compiler.
srn_mm_t * mm
Memory manager.
uint8_t buffer[]
The buffer that holds the WTF8 sequence.
#define PANIC_IF_NULL(ptr)
static void srn_spinlock_lock(srn_spinlock_t *lock)
static void srn_spinlock_unlock(srn_spinlock_t *lock)