-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathringbuffer.h
More file actions
39 lines (27 loc) · 965 Bytes
/
ringbuffer.h
File metadata and controls
39 lines (27 loc) · 965 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//
// Ringbuffer routines tailored to my particular needs.
// Copyright(C) 2012 Robert Sexton
//
#ifndef __STDINT_H__
#include <stdint.h>
#endif
/// If the counts are both bigger than this, we'll adjust.
#define RB_COUNT_OVERFLOW 0x40000000
typedef struct {
uint32_t iWrite;
uint32_t iRead;
uint32_t Dropped; /// Record dropped characters
uint32_t ResetCount; /// How many times we
uint8_t* Buf; // Pointer to the storage area.
uint32_t BufSize; // Length of the storage area
uint32_t BufMask; // Used for masking the index.
} RINGBUF;
void ringbuffer_init(RINGBUF*, uint8_t*, int);
uint32_t ringbuffer_used(RINGBUF*);
uint32_t ringbuffer_free(RINGBUF*);
int32_t ringbuffer_addchar(RINGBUF*, uint8_t);
int ringbuffer_getchar(RINGBUF*);
uint8_t *ringbuffer_getbulkpointer(RINGBUF*);
int32_t ringbuffer_getbulkcount(RINGBUF*);
void ringbuffer_bulkremove(RINGBUF*, int count);
int ringbuffer_reset_count(RINGBUF*);