19 #ifndef BUFFERED_LIFO_H
20 #define BUFFERED_LIFO_H
82 void * elem,
size_t sizeof_payload, uint64_t chunk_size );
93 size_t sizeof_payload, uint64_t chunk_size,
94 void * elem,
int *did_ret );
uint64_t offset
offset in current chunk
struct Buffered_LIFO_chunk * Buffered_LIFO_chunk_pop(struct Buffered_LIFO_chunk *chunk, size_t sizeof_payload, uint64_t chunk_size, void *elem, int *did_ret)
Get an element from the Buffered_LIFO_chunk.
size_t sizeof_payload
Sizeof a payload element.
Structure defining a chunk of LIFO. A buffered lifo consists in several chunks which are stacked in a...
struct Buffered_LIFO_chunk * next
A pointer to the next chunk (NULL if none)
void Buffered_LIFO_head_unlock(struct Buffered_LIFO *lifo)
Unlocks the Buffered_LIFO after a call to Buffered_LIFO_head.
void * Buffered_LIFO_head(struct Buffered_LIFO *lifo)
Get a reference to the head element of the Buffered_LIFO note that as no lock is held this reference ...
void Buffered_LIFO_push(struct Buffered_LIFO *lifo, void *elem)
Push an element of size sizeof_payload in the Buffered_LIFO.
struct Buffered_LIFO_chunk * Buffered_LIFO_chunk_new(size_t sizeof_payload, uint64_t chunk_size, struct Buffered_LIFO_chunk *prev)
Allocates an empty Buffered_LIFO_chunk pointing to prev.
char elems[0]
A dummy pointer to the data which is piggybacked.
void Buffered_LIFO_chunk_release(struct Buffered_LIFO_chunk *chunk, size_t sizeof_payload, void(*free_func)(void *))
Releases a Buffered_LIFO_chunk note that it does not recurses over previous chunks.
volatile unsigned int MALP_Spinlock
The type of spinlocks in MALP.
void * Buffered_LIFO_pop(struct Buffered_LIFO *lifo, void *elem)
Push an element of size sizeof_payload in the Buffered_LIFO.
void Buffered_LIFO_release(struct Buffered_LIFO *lifo, void(*free_func)(void *))
Releases a Buffered_LIFO and all its chunks.
uint64_t chunk_size
Maximum number of elems in a chunk.
void Buffered_LIFO_init(struct Buffered_LIFO *lifo, size_t sizeof_payload, uint64_t chunk_size)
Initializes a Buffered_LIFO ready to contains elems of size sizeof_payload with chunk_size chunks...
void * Buffered_LIFO_chunk_head(struct Buffered_LIFO_chunk *chunk, size_t sizeof_payload)
Get a pointer to the Buffered_LIFO_chunk head eleme (NULL if none)
MALP_Spinlock lock
A spinlock to protect the LIFO.
struct Buffered_LIFO_chunk * Buffered_LIFO_chunk_push(struct Buffered_LIFO_chunk *chunk, void *elem, size_t sizeof_payload, uint64_t chunk_size)
Push a new elem in the Buffered_LIFO_chunk.
void * Buffered_LIFO_head_locked(struct Buffered_LIFO *lifo)
Get a reference to the head element of the Buffered_LIFO but keeps the LIFO locked in order to allow ...
Structure defining buffered LIFO.
struct Buffered_LIFO_chunk * head
A pointer to the first chunk.