47#define CIB_INIT(SIZE) { 0, 0, (SIZE)-1 }
61 assert(!(size & (size - 1)));
116 return (
int)(cib->read_count++ & cib->mask);
140 return (cib->read_count + offset) & cib->mask;
220 if ((
int)avail <= (
int)cib->mask) {
221 return (
int)(cib->write_count++ & cib->mask);
POSIX.1-2008 compliant version of the assert macro.
#define assert(cond)
abort the program if assertion is false
static int cib_peek(cib_t *__restrict cib)
Get the index of the next item in buffer without removing it.
static unsigned int cib_size(const cib_t *cib)
Returns the total capacity (size parameter of cib_init()) of a cib_t.
static int cib_get_unsafe(cib_t *cib)
Get the index of the next item in buffer.
static int cib_peek_at(cib_t *__restrict cib, unsigned offset)
Get the index of an item in the buffer without removing anything.
static int cib_peek_unsafe(cib_t *__restrict cib)
Get the index of the next item in buffer without removing it.
#define CIB_INIT(SIZE)
Initialize cib_t to a given size.
static unsigned int cib_full(const cib_t *cib)
Check if cib is full.
static int cib_get(cib_t *__restrict cib)
Get the index of the next item in buffer.
static int cib_peek_at_unsafe(cib_t *__restrict cib, unsigned offset)
Get the index of an item in the buffer without removing anything.
static int cib_put_unsafe(cib_t *cib)
Get index for item in buffer to put to.
static int cib_put(cib_t *__restrict cib)
Get index for item in buffer to put to.
static void cib_init(cib_t *__restrict cib, unsigned int size)
Initialize cib to 0 and set buffer size to size.
static unsigned int cib_avail(const cib_t *cib)
Calculates difference between cib_put() and cib_get() accesses.
circular integer buffer structure
unsigned int mask
Size of buffer -1, i.e.
unsigned int write_count
number of (successful) write accesses
unsigned int read_count
number of (successful) read accesses