Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2003 |
| 4 | * Gerry Hamel, geh@ti.com, Texas Instruments |
wdenk | 232c150 | 2004-03-12 00:14:09 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #ifndef __CIRCBUF_H__ |
| 8 | #define __CIRCBUF_H__ |
| 9 | |
| 10 | typedef struct circbuf { |
| 11 | unsigned int size; /* current number of bytes held */ |
| 12 | unsigned int totalsize; /* number of bytes allocated */ |
| 13 | |
| 14 | char *top; /* pointer to current buffer start */ |
| 15 | char *tail; /* pointer to space for next element */ |
| 16 | |
| 17 | char *data; /* all data */ |
| 18 | char *end; /* end of data buffer */ |
| 19 | } circbuf_t; |
| 20 | |
| 21 | int buf_init (circbuf_t * buf, unsigned int size); |
| 22 | int buf_free (circbuf_t * buf); |
| 23 | int buf_pop (circbuf_t * buf, char *dest, unsigned int len); |
| 24 | int buf_push (circbuf_t * buf, const char *src, unsigned int len); |
| 25 | |
| 26 | #endif |