tsrb.h File Reference

Thread-safe ringbuffer interface definition. More...

Detailed Description

Thread-safe ringbuffer interface definition.

Kaspar Schleiser kaspa.nosp@m.r@sc.nosp@m.hleis.nosp@m.er.d.nosp@m.e

Definition in file tsrb.h.

#include <assert.h>
#include <stddef.h>
#include <stdint.h>
#include "irq.h"
+ Include dependency graph for tsrb.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  tsrb
 thread-safe ringbuffer struct More...


#define TSRB_INIT(BUF)   { (BUF), sizeof (BUF), 0, 0 }
 Static initializer.


typedef struct tsrb tsrb_t
 thread-safe ringbuffer struct


static void tsrb_init (tsrb_t *rb, uint8_t *buffer, unsigned bufsize)
 Initialize a tsrb. More...
static void tsrb_clear (tsrb_t *rb)
 Clear a tsrb. More...
static int tsrb_empty (const tsrb_t *rb)
 Test if the tsrb is empty. More...
static unsigned int tsrb_avail (const tsrb_t *rb)
 Get number of bytes available for reading. More...
static int tsrb_full (const tsrb_t *rb)
 Test if the tsrb is full. More...
static unsigned int tsrb_free (const tsrb_t *rb)
 Get free space in ringbuffer. More...
int tsrb_get_one (tsrb_t *rb)
 Get a byte from ringbuffer. More...
int tsrb_peek_one (tsrb_t *rb)
 Get a byte from ringbuffer, without removing it. More...
int tsrb_get (tsrb_t *rb, uint8_t *dst, size_t n)
 Get bytes from ringbuffer. More...
int tsrb_peek (tsrb_t *rb, uint8_t *dst, size_t n)
 Get bytes from ringbuffer, without removing them. More...
int tsrb_drop (tsrb_t *rb, size_t n)
 Drop bytes from ringbuffer. More...
int tsrb_add_one (tsrb_t *rb, uint8_t c)
 Add a byte to ringbuffer. More...
int tsrb_add (tsrb_t *rb, const uint8_t *src, size_t n)
 Add bytes to ringbuffer. More...