blob: a6eddc959f91263dc66b20939af876727503e5fb [file] [log] [blame]
Kévin Redon9a12d682018-07-08 13:21:16 +02001/* Ring buffer
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
16 */
Christina Quast4db82e02015-04-11 18:14:41 +020017#ifndef SIMTRACE_RINGBUF_H
18#define SIMTRACE_RINGBUF_H
19
20#include <stdint.h>
21#include <stdbool.h>
22#include <sys/types.h>
23
Kévin Redonbf6b1b12018-07-03 16:03:17 +020024#define RING_BUFLEN 512
Christina Quast4db82e02015-04-11 18:14:41 +020025
26typedef struct ringbuf {
Harald Welte7dd3dfd2016-03-03 12:32:04 +010027 uint8_t buf[RING_BUFLEN];
28 size_t ird;
29 size_t iwr;
Christina Quast4db82e02015-04-11 18:14:41 +020030} ringbuf;
31
Harald Welte7dd3dfd2016-03-03 12:32:04 +010032void rbuf_reset(volatile ringbuf * rb);
33uint8_t rbuf_read(volatile ringbuf * rb);
34uint8_t rbuf_peek(volatile ringbuf * rb);
Harald Welte05cc7f62018-07-04 04:39:40 +020035int rbuf_write(volatile ringbuf * rb, uint8_t item);
Harald Welte7dd3dfd2016-03-03 12:32:04 +010036bool rbuf_is_empty(volatile ringbuf * rb);
37bool rbuf_is_full(volatile ringbuf * rb);
Christina Quast4db82e02015-04-11 18:14:41 +020038
39#endif /* end of include guard: SIMTRACE_RINGBUF_H */