ring_buf
Loading...
Searching...
No Matches
Functions
Discontiguous Ring Buffer Access

Functions for discontiguous access to ring buffer data. More...

Collaboration diagram for Discontiguous Ring Buffer Access:

Functions

ring_buf_size_t ring_buf_put (struct ring_buf *buf, const void *data, ring_buf_size_t size)
 Puts non-contiguous bytes into the ring buffer.
 
ring_buf_size_t ring_buf_get (struct ring_buf *buf, void *data, ring_buf_size_t size)
 Gets data from a ring buffer.
 
int ring_buf_put_all (struct ring_buf *buf, const void *data, ring_buf_size_t size)
 Puts all or none.
 
int ring_buf_get_all (struct ring_buf *buf, void *data, ring_buf_size_t size)
 Gets all or none.
 

Detailed Description

Functions for discontiguous access to ring buffer data.

These functions allow for putting and getting data that may span across the end of the ring buffer, handling wrap-around as necessary.

Function Documentation

◆ ring_buf_get()

ring_buf_size_t ring_buf_get ( struct ring_buf buf,
void *  data,
ring_buf_size_t  size 
)

Gets data from a ring buffer.

Copies discontinuous data.

Parameters
bufRing buffer.
dataAddress of copied data, or NULL to ignore.
sizeNumber of bytes to get.
Returns
Number of bytes to acknowledge.

Definition at line 166 of file ring_buf.c.

◆ ring_buf_get_all()

int ring_buf_get_all ( struct ring_buf buf,
void *  data,
ring_buf_size_t  size 
)

Gets all or none.

Gets all the requested data from the ring buffer or gets nothing. Returns an error if there is insufficient data.

Parameters
bufRing buffer.
dataAddress of copied data.
sizeNumber of bytes to get.
Return values
0on success
-EAGAINif insufficient data is available.

Definition at line 191 of file ring_buf.c.

◆ ring_buf_put()

ring_buf_size_t ring_buf_put ( struct ring_buf buf,
const void *  data,
ring_buf_size_t  size 
)

Puts non-contiguous bytes into the ring buffer.

The return value may be less than the given size if the buffer runs out of free space.

Note
Does not automatically acknowledge the space.
Parameters
bufRing buffer.
dataAddress of bytes to put.
sizeNumber of bytes to put.
Returns
Buffer space to acknowledge in bytes.

Definition at line 153 of file ring_buf.c.

◆ ring_buf_put_all()

int ring_buf_put_all ( struct ring_buf buf,
const void *  data,
ring_buf_size_t  size 
)

Puts all or none.

Puts all the given data into the ring buffer or puts nothing. Returns an error if there is insufficient space.

Parameters
bufRing buffer.
dataAddress of bytes to put.
sizeNumber of bytes to put.
Returns
0 on success, -EMSGSIZE if the data will not fit.

Definition at line 181 of file ring_buf.c.