Files
HardwareAdapter/controller/ringbuffer.h

22 lines
484 B
C
Raw Normal View History

2025-05-25 16:01:05 +02:00
#include <stddef.h>
#ifdef RINGBUFFER_THREAD_SAFE
#include <pthread.h>
2025-05-25 16:01:05 +02:00
#endif
2025-05-20 22:23:19 +02:00
struct ringBuffer {
void *buffer;
2025-05-21 22:39:32 +02:00
int blocks;
size_t blockSize;
void *reader;
void *writer;
2025-05-25 15:27:00 +02:00
#ifdef RINGBUFFER_THREAD_SAFE
pthread_mutex_t mutex;
2025-05-25 15:27:00 +02:00
#endif
2025-05-20 22:23:19 +02:00
};
2025-05-21 22:39:32 +02:00
void ringBufferCreate(int blocks, size_t blockSize, struct ringBuffer *out);
2025-05-20 22:23:19 +02:00
void ringBufferDestroy(struct ringBuffer *buf);
int ringBufferRead(struct ringBuffer *buf, void *out);
void ringBufferWrite(struct ringBuffer *buf, void *in);