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