2013-10-02 06:56:10 +00:00
|
|
|
#ifndef CIRCLE_BUFFER_H
|
|
|
|
#define CIRCLE_BUFFER_H
|
|
|
|
|
2014-04-03 06:50:20 +00:00
|
|
|
#include "common.h"
|
2013-10-02 06:56:10 +00:00
|
|
|
|
|
|
|
struct CircleBuffer {
|
|
|
|
void* data;
|
|
|
|
unsigned capacity;
|
2013-10-03 08:25:51 +00:00
|
|
|
unsigned size;
|
2013-10-02 06:56:10 +00:00
|
|
|
void* readPtr;
|
|
|
|
void* writePtr;
|
|
|
|
};
|
|
|
|
|
|
|
|
void CircleBufferInit(struct CircleBuffer* buffer, unsigned capacity);
|
|
|
|
void CircleBufferDeinit(struct CircleBuffer* buffer);
|
|
|
|
unsigned CircleBufferSize(const struct CircleBuffer* buffer);
|
2014-07-08 07:02:39 +00:00
|
|
|
void CircleBufferClear(struct CircleBuffer* buffer);
|
2013-10-03 08:25:51 +00:00
|
|
|
int CircleBufferWrite8(struct CircleBuffer* buffer, int8_t value);
|
2013-10-02 06:56:10 +00:00
|
|
|
int CircleBufferWrite32(struct CircleBuffer* buffer, int32_t value);
|
2013-10-02 09:45:41 +00:00
|
|
|
int CircleBufferRead8(struct CircleBuffer* buffer, int8_t* value);
|
2013-10-02 06:56:10 +00:00
|
|
|
int CircleBufferRead32(struct CircleBuffer* buffer, int32_t* value);
|
2014-01-15 11:43:56 +00:00
|
|
|
int CircleBufferRead(struct CircleBuffer* buffer, void* output, size_t length);
|
2014-07-08 07:02:39 +00:00
|
|
|
int CircleBufferDump(const struct CircleBuffer* buffer, void* output, size_t length);
|
2013-10-02 06:56:10 +00:00
|
|
|
|
|
|
|
#endif
|