spinn_common 7.2.2
Support code for SpiNNaker applications.
|
Fast circular buffer. More...
#include <stdint.h>
#include <stdbool.h>
Go to the source code of this file.
Data Structures | |
struct | _circular_buffer |
Implementation of a circular buffer. More... | |
Typedefs | |
typedef _circular_buffer * | circular_buffer |
The public interface type is a pointer to the implementation. | |
Functions | |
static uint32_t | _circular_buffer_next (circular_buffer buffer, uint32_t current) |
Get the index of the next position in the buffer from the given value. | |
static bool | _circular_buffer_not_empty (circular_buffer buffer) |
Get whether the buffer is not empty. | |
static bool | _circular_buffer_not_full (circular_buffer buffer, uint32_t next) |
Get whether the buffer is able to accept more values. | |
circular_buffer | circular_buffer_initialize (uint32_t size) |
Create a new FIFO circular buffer of at least the given size. For efficiency, the buffer can be bigger than requested. | |
static bool | circular_buffer_add (circular_buffer buffer, uint32_t item) |
Add an item to an existing buffer. | |
static bool | circular_buffer_get_next (circular_buffer buffer, uint32_t *item) |
Get the next item from an existing buffer. | |
static bool | circular_buffer_advance_if_next_equals (circular_buffer buffer, uint32_t item) |
Advance the buffer if the next item is equal to the given value. | |
static uint32_t | circular_buffer_size (circular_buffer buffer) |
Get the size of the buffer. | |
static uint32_t | circular_buffer_get_n_buffer_overflows (circular_buffer buffer) |
Get the number of overflows that have occurred when adding to the buffer. | |
static void | circular_buffer_clear (circular_buffer buffer) |
Clear the circular buffer. | |
void | circular_buffer_print_buffer (circular_buffer buffer) |
Print the contents of the buffer. | |
static uint32_t | circular_buffer_input (circular_buffer buffer) |
Get the input index. | |
static uint32_t | circular_buffer_output (circular_buffer buffer) |
Get the output index. | |
static uint32_t | circular_buffer_real_size (circular_buffer buffer) |
Get the buffer size. | |
static uint32_t | circular_buffer_value_at_index (circular_buffer buffer, uint32_t index) |
Get the buffer contents at a particular index. | |
Fast circular buffer.
struct _circular_buffer |
Implementation of a circular buffer.
|
inlinestatic |
Get the index of the next position in the buffer from the given value.
[in] | buffer | The buffer. |
[in] | current | The index to get the next one after. |
|
inlinestatic |
Get whether the buffer is not empty.
[in] | buffer | The buffer. |
|
inlinestatic |
Get whether the buffer is able to accept more values.
[in] | buffer | The buffer. |
[in] | next | The next position in the buffer |
circular_buffer circular_buffer_initialize | ( | uint32_t | size | ) |
Create a new FIFO circular buffer of at least the given size. For efficiency, the buffer can be bigger than requested.
[in] | size | The minimum number of elements in the buffer to be created |
|
inlinestatic |
Add an item to an existing buffer.
[in] | buffer | The buffer struct to add to |
[in] | item | The item to add. |
|
inlinestatic |
Get the next item from an existing buffer.
[in] | buffer | The buffer to get the next item from. |
[out] | item | The retrieved item. |
|
inlinestatic |
Advance the buffer if the next item is equal to the given value.
[in] | buffer | The buffer to advance |
[in] | item | The item to check |
|
inlinestatic |
Get the size of the buffer.
[in] | buffer | The buffer to get the size of |
|
inlinestatic |
Get the number of overflows that have occurred when adding to the buffer.
[in] | buffer | The buffer to check for overflows |
|
inlinestatic |
Clear the circular buffer.
[in] | buffer | The buffer to clear |
void circular_buffer_print_buffer | ( | circular_buffer | buffer | ) |
Print the contents of the buffer.
Do not use if the sark IO_BUF
is being used for binary data.
[in] | buffer | The buffer to print |
|
inlinestatic |
Get the input index.
[in] | buffer | The buffer. |
|
inlinestatic |
Get the output index.
[in] | buffer | The buffer. |
|
inlinestatic |
Get the buffer size.
[in] | buffer | The buffer. |
|
inlinestatic |
Get the buffer contents at a particular index.
[in] | buffer | The buffer. |
[in] | index | The index to use. Note that the index is not limited to the size of the buffer. |