Circular integer buffer interface.
More...
Circular integer buffer interface.
This structure provides an organizational interface and combined with an memory array forms a circular buffer.
- Author
- Kaspar Schleiser kaspa.nosp@m.r@sc.nosp@m.hleis.nosp@m.er.d.nosp@m.e
Definition in file cib.h.
Go to the source code of this file.
◆ CIB_INIT
#define CIB_INIT |
( |
|
SIZE | ) |
{ 0, 0, (SIZE)-1 } |
Initialize cib_t to a given size.
- Parameters
-
[in] | SIZE | Size of the buffer, must not exceed (UINT_MAX + 1) / 2. Should be equal to 0 or power of 2. |
Definition at line 47 of file cib.h.
◆ cib_avail()
static unsigned int cib_avail |
( |
const cib_t * |
cib | ) |
|
|
inlinestatic |
Calculates difference between cib_put() and cib_get() accesses.
- Parameters
-
[in] | cib | the cib_t to check. Must not be NULL. |
- Returns
- How often cib_get() can be called before
cib
is empty.
Definition at line 74 of file cib.h.
◆ cib_full()
static unsigned int cib_full |
( |
const cib_t * |
cib | ) |
|
|
inlinestatic |
Check if cib is full.
- Parameters
-
[in] | cib | the cib_t to check. Must not be NULL. |
- Returns
- 1 if cib_put() would return "-1", 0 otherwise
Definition at line 86 of file cib.h.
◆ cib_get()
static int cib_get |
( |
cib_t *__restrict |
cib | ) |
|
|
inlinestatic |
Get the index of the next item in buffer.
- Parameters
-
[in,out] | cib | corresponding cib to buffer. Must not be NULL. |
- Returns
- index of next item, -1 if the buffer is empty
Definition at line 98 of file cib.h.
◆ cib_get_unsafe()
static int cib_get_unsafe |
( |
cib_t * |
cib | ) |
|
|
inlinestatic |
Get the index of the next item in buffer.
Unsafe version, must not be called if buffer is empty!
- Parameters
-
[in,out] | cib | corresponding cib to buffer. Must not be NULL. |
- Returns
- index of next item
Definition at line 132 of file cib.h.
◆ cib_init()
static void cib_init |
( |
cib_t *__restrict |
cib, |
|
|
unsigned int |
size |
|
) |
| |
|
inlinestatic |
Initialize cib
to 0 and set buffer size to size
.
- Parameters
-
[out] | cib | Buffer to initialize. Must not be NULL. |
[in] | size | Size of the buffer, must not exceed (UINT_MAX + 1) / 2. Should be equal to 0 or power of 2. |
Definition at line 58 of file cib.h.
◆ cib_peek()
static int cib_peek |
( |
cib_t *__restrict |
cib | ) |
|
|
inlinestatic |
Get the index of the next item in buffer without removing it.
- Parameters
-
[in,out] | cib | corresponding cib to buffer. Must not be NULL. |
- Returns
- index of next item, -1 if the buffer is empty
Definition at line 114 of file cib.h.
◆ cib_put()
static int cib_put |
( |
cib_t *__restrict |
cib | ) |
|
|
inlinestatic |
Get index for item in buffer to put to.
- Parameters
-
[in,out] | cib | corresponding cib to buffer. Must not be NULL. |
- Returns
- index of item to put to, -1 if the buffer is full
Definition at line 144 of file cib.h.
◆ cib_put_unsafe()
static int cib_put_unsafe |
( |
cib_t * |
cib | ) |
|
|
inlinestatic |
Get index for item in buffer to put to.
Unsafe version, must not be called if buffer is full!
- Parameters
-
[in,out] | cib | corresponding cib to buffer. Must not be NULL. |
- Returns
- index of item to put to
Definition at line 165 of file cib.h.