#ifndef LICHEN_H #define LICHEN_H #include #include /* --===== random number generation =====-- */ typedef struct li_rand32_t { uint32_t (*rand)(void *); void *state; } li_rand32_t; struct li_xorshift32_t { li_rand32_t generator; uint64_t state; }; // initialize an xorshift32 struct with a specific seed void li_xorshift32_seed(struct li_xorshift32_t *xor, uint32_t seed); // get a pseudo-random number via the xorshift algorithm uint32_t li_xorshift32(void *s); /* --===== generic linked lists =====-- */ typedef struct li_llnode_t { int tag; void *data; struct li_llnode_t *next; } li_llnode_t; li_llnode_t * li_alloc_llnode(); li_llnode_t * li_copy_llnode(li_llnode_t *n); void li_free_llnode(li_llnode_t *n, void (*free_data)(void*)); typedef struct li_ll_t { int tag; size_t count; li_llnode_t *head; li_llnode_t *end; } li_ll_t; // allocate a linked list struct li_ll_t * li_alloc_ll(); // free a linked list void li_free_ll(struct li_ll_t *list, void (*free_data)(void*)); void li_ll_append(struct li_ll_t *list, void *data); void li_ll_prepend(struct li_ll_t *list, void *data); struct li_ll_t * li_copy_list(struct li_ll_t *list); #endif