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