mgba/src/util/circle-buffer.h

26 lines
864 B
C
Raw Normal View History

#ifndef CIRCLE_BUFFER_H
#define CIRCLE_BUFFER_H
#include "common.h"
struct CircleBuffer {
void* data;
unsigned capacity;
2013-10-03 08:25:51 +00:00
unsigned size;
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);
int CircleBufferWrite32(struct CircleBuffer* buffer, int32_t value);
2013-10-02 09:45:41 +00:00
int CircleBufferRead8(struct CircleBuffer* buffer, int8_t* value);
int CircleBufferRead32(struct CircleBuffer* buffer, int32_t* value);
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);
#endif