cib.h¶
Circular integer buffer interface.
This structure provides an organizational interface and combined with an memory array forms a circular buffer.
-
void
cib_init
(cib_t *__restrict cib, unsigned int size)¶ Initialize
cib
to 0 and set buffer size tosize
.Parameters
cib: Buffer to initialize. Must not be NULL. size: Size of the buffer, must not exceed MAXINT/2. Should be equal to 0 or power of 2.
-
unsigned int
cib_avail
(const cib_t * cib)¶ Calculates difference between
cib.h::cib_put()
andcib.h::cib_get()
accesses.Parameters
cib: the cib_t to check. Must not be NULL. Return values
- How often
cib.h::cib_get()
can be called beforecib
is empty.
- How often
-
unsigned int
cib_full
(const cib_t * cib)¶ Check if cib is full.
Parameters
cib: the cib_t to check. Must not be NULL. Return values
- 1 if
cib.h::cib_put()
would return “-1”, 0 otherwise
- 1 if
-
int
cib_get
(cib_t *__restrict cib)¶ Get the index of the next item in buffer.
Parameters
cib: corresponding cib to buffer. Must not be NULL. Return values
- index of next item, -1 if the buffer is empty
-
int
cib_peek
(cib_t *__restrict cib)¶ Get the index of the next item in buffer without removing it.
Parameters
cib: corresponding cib to buffer. Must not be NULL. Return values
- index of next item, -1 if the buffer is empty
-
int
cib_get_unsafe
(cib_t * cib)¶ Get the index of the next item in buffer.
Unsafe version, must not be called if buffer is empty!
Parameters
cib: corresponding cib to buffer. Must not be NULL. Return values
- index of next item
-
int
cib_put
(cib_t *__restrict cib)¶ Get index for item in buffer to put to.
Parameters
cib: corresponding cib to buffer. Must not be NULL. Return values
- index of item to put to, -1 if the buffer is full