2015-08-30 03:08:00 +00:00
|
|
|
/* 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 RING_FIFO_H
|
|
|
|
#define RING_FIFO_H
|
|
|
|
|
2016-12-31 01:00:22 +00:00
|
|
|
#include <mgba-util/common.h>
|
2015-08-30 03:08:00 +00:00
|
|
|
|
2016-12-27 05:01:55 +00:00
|
|
|
CXX_GUARD_START
|
|
|
|
|
2015-08-30 03:08:00 +00:00
|
|
|
struct RingFIFO {
|
|
|
|
void* data;
|
|
|
|
size_t capacity;
|
|
|
|
void* readPtr;
|
|
|
|
void* writePtr;
|
|
|
|
};
|
|
|
|
|
2016-08-15 02:40:24 +00:00
|
|
|
void RingFIFOInit(struct RingFIFO* buffer, size_t capacity);
|
2015-08-30 03:08:00 +00:00
|
|
|
void RingFIFODeinit(struct RingFIFO* buffer);
|
|
|
|
size_t RingFIFOCapacity(const struct RingFIFO* buffer);
|
2018-09-23 20:26:52 +00:00
|
|
|
size_t RingFIFOSize(const struct RingFIFO* buffer);
|
2015-08-30 03:08:00 +00:00
|
|
|
void RingFIFOClear(struct RingFIFO* buffer);
|
|
|
|
size_t RingFIFOWrite(struct RingFIFO* buffer, const void* value, size_t length);
|
|
|
|
size_t RingFIFORead(struct RingFIFO* buffer, void* output, size_t length);
|
|
|
|
|
2016-12-27 05:01:55 +00:00
|
|
|
CXX_GUARD_END
|
|
|
|
|
2015-08-30 03:08:00 +00:00
|
|
|
#endif
|