circbuf.h 705 B

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