PatchworkOS
Loading...
Searching...
No Matches
ring.h File Reference
#include <errno.h>
#include <stdint.h>
#include <string.h>

Go to the source code of this file.

Data Structures

struct  ring_t
 Ring buffer structure. More...
 

Macros

#define RING_CREATE(bufferPtr, bufferSize)    {.buffer = bufferPtr, .size = bufferSize, .readIndex = 0, .writeIndex = 0, .dataLength = 0}
 Create a ring buffer initializer.
 

Functions

static void ring_init (ring_t *ring, void *buffer, uint64_t size)
 Initialize a ring buffer.
 
static uint64_t ring_data_length (const ring_t *ring)
 Get the length of data currently stored in the ring buffer.
 
static uint64_t ring_free_length (const ring_t *ring)
 Get the length of free space in the ring buffer.
 
static uint64_t ring_write (ring_t *ring, const void *buffer, uint64_t count)
 Write data to the ring buffer.
 
static uint64_t ring_read (ring_t *ring, void *buffer, uint64_t count)
 Read data from the ring buffer.
 
static uint64_t ring_read_at (const ring_t *ring, uint64_t offset, void *buffer, uint64_t count)
 Read data from the ring buffer at a specific offset without modifying the read index.
 
static void ring_move_read_forward (ring_t *ring, uint64_t offset)
 Move the read index forward by a specified offset.
 
static uint64_t ring_get_byte (const ring_t *ring, uint64_t offset, uint8_t *byte)
 Get a byte from the ring buffer at a specific offset without modifying the read index.