19#ifndef _CIRCULAR_BUFFER_H_
20#define _CIRCULAR_BUFFER_H_
66 return next != buffer->
output;
163 return buffer->
input;
static bool circular_buffer_get_next(circular_buffer buffer, uint32_t *item)
Get the next item from an existing buffer.
Definition circular_buffer.h:97
uint32_t overflows
The number of times an insertion has failed due to the buffer being full.
Definition circular_buffer.h:35
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.
Definition circular_buffer.h:48
static uint32_t circular_buffer_value_at_index(circular_buffer buffer, uint32_t index)
Get the buffer contents at a particular index.
Definition circular_buffer.h:186
static uint32_t circular_buffer_input(circular_buffer buffer)
Get the input index.
Definition circular_buffer.h:162
_circular_buffer * circular_buffer
The public interface type is a pointer to the implementation.
Definition circular_buffer.h:41
uint32_t buffer_size
The size of the buffer. One less than a power of two.
Definition circular_buffer.h:28
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.
Definition circular_buffer.h:138
uint32_t input
The index of the next position in the buffer to write to.
Definition circular_buffer.h:32
static uint32_t circular_buffer_output(circular_buffer buffer)
Get the output index.
Definition circular_buffer.h:170
static bool circular_buffer_add(circular_buffer buffer, uint32_t item)
Add an item to an existing buffer.
Definition circular_buffer.h:79
static bool _circular_buffer_not_empty(circular_buffer buffer)
Get whether the buffer is not empty.
Definition circular_buffer.h:56
uint32_t buffer[]
The buffer itself.
Definition circular_buffer.h:37
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 bigge...
Definition circular_buffer.c:47
static void circular_buffer_clear(circular_buffer buffer)
Clear the circular buffer.
Definition circular_buffer.h:145
void circular_buffer_print_buffer(circular_buffer buffer)
Print the contents of the buffer.
Definition circular_buffer.c:68
uint32_t output
The index of the next position in the buffer to read from.
Definition circular_buffer.h:30
static uint32_t circular_buffer_size(circular_buffer buffer)
Get the size of the buffer.
Definition circular_buffer.h:128
static bool _circular_buffer_not_full(circular_buffer buffer, uint32_t next)
Get whether the buffer is able to accept more values.
Definition circular_buffer.h:64
static uint32_t circular_buffer_real_size(circular_buffer buffer)
Get the buffer size.
Definition circular_buffer.h:177
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.
Definition circular_buffer.h:113
Implementation of a circular buffer.
Definition circular_buffer.h:26