91 static inline void _turb_push(
tsrb_t *rb, uint8_t c)
96 static inline uint8_t _turb_pop(
tsrb_t *rb)
101 static inline uint8_t _turb_peek(
tsrb_t *rb,
unsigned int idx)
118 retval = _turb_pop(rb);
134 retval = _turb_peek(rb, 0);
151 *dst++ = _turb_pop(rb);
169 while (idx < n && idx != avail) {
170 *dst++ = _turb_peek(rb, idx++);
222 _turb_push(rb, *src++);
thread-safe ringbuffer struct
unsigned writes
total number of writes
unsigned reads
total number of reads
uint8_t * buf
Buffer to operate on.
unsigned int size
Size of buffer, must be power of 2.
Thread-safe ringbuffer interface definition.
static unsigned int turb_free(const tsrb_t *rb)
Get free space in ringbuffer.
static int turb_peek(tsrb_t *rb, uint8_t *dst, size_t n)
Get bytes from ringbuffer, without removing them.
static int turb_add_one(tsrb_t *rb, uint8_t c)
Add a byte to ringbuffer.
static int turb_empty(const tsrb_t *rb)
Test if the tsrb is empty.
static int turb_drop(tsrb_t *rb, size_t n)
Drop bytes from ringbuffer.
static unsigned int turb_avail(const tsrb_t *rb)
Get number of bytes available for reading.
static int turb_get_one(tsrb_t *rb)
Get a byte from ringbuffer.
static int turb_full(const tsrb_t *rb)
Test if the tsrb is full.
static void turb_clear(tsrb_t *rb)
Clear a tsrb.
static int turb_add(tsrb_t *rb, const uint8_t *src, size_t n)
Add bytes to ringbuffer.
static int turb_get(tsrb_t *rb, uint8_t *dst, size_t n)
Get bytes from ringbuffer.
static int turb_peek_one(tsrb_t *rb)
Get a byte from ringbuffer, without removing it.