all repos — mgba @ 812d063b73cf9231123e9600160d4f4d0eb7a8cf

mGBA Game Boy Advance Emulator

src/util/ring-fifo.h (view raw)

 1/* Copyright (c) 2013-2014 Jeffrey Pfau
 2 *
 3 * This Source Code Form is subject to the terms of the Mozilla Public
 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 6#ifndef RING_FIFO_H
 7#define RING_FIFO_H
 8
 9#include "util/common.h"
10
11struct RingFIFO {
12	void* data;
13	size_t capacity;
14	size_t maxalloc;
15	void* readPtr;
16	void* writePtr;
17};
18
19void RingFIFOInit(struct RingFIFO* buffer, size_t capacity, size_t maxalloc);
20void RingFIFODeinit(struct RingFIFO* buffer);
21size_t RingFIFOCapacity(const struct RingFIFO* buffer);
22void RingFIFOClear(struct RingFIFO* buffer);
23size_t RingFIFOWrite(struct RingFIFO* buffer, const void* value, size_t length);
24size_t RingFIFORead(struct RingFIFO* buffer, void* output, size_t length);
25
26#endif