mgba/include/mgba-util/circle-buffer.h

39 lines
1.4 KiB
C
Raw Permalink Normal View History

/* Copyright (c) 2013-2014 Jeffrey Pfau
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef CIRCLE_BUFFER_H
#define CIRCLE_BUFFER_H
#include <mgba-util/common.h>
2016-12-27 05:01:55 +00:00
CXX_GUARD_START
struct CircleBuffer {
void* data;
2014-07-21 06:56:12 +00:00
size_t capacity;
size_t size;
void* readPtr;
void* writePtr;
};
void CircleBufferInit(struct CircleBuffer* buffer, unsigned capacity);
void CircleBufferDeinit(struct CircleBuffer* buffer);
2014-07-21 06:56:12 +00:00
size_t CircleBufferSize(const struct CircleBuffer* buffer);
size_t CircleBufferCapacity(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 CircleBufferWrite16(struct CircleBuffer* buffer, int16_t value);
int CircleBufferWrite32(struct CircleBuffer* buffer, int32_t value);
2017-04-23 04:41:48 +00:00
size_t CircleBufferWrite(struct CircleBuffer* buffer, const void* input, size_t length);
2013-10-02 09:45:41 +00:00
int CircleBufferRead8(struct CircleBuffer* buffer, int8_t* value);
int CircleBufferRead16(struct CircleBuffer* buffer, int16_t* value);
int CircleBufferRead32(struct CircleBuffer* buffer, int32_t* value);
2014-07-21 06:56:12 +00:00
size_t CircleBufferRead(struct CircleBuffer* buffer, void* output, size_t length);
size_t CircleBufferDump(const struct CircleBuffer* buffer, void* output, size_t length);
2016-12-27 05:01:55 +00:00
CXX_GUARD_END
#endif