buffer.h 611 B

1234567891011121314151617181920
  1. #ifndef BUFFER_H
  2. #define BUFFER_H
  3. struct ring_buffer
  4. {
  5. char* data_ptr;
  6. int max_len;
  7. volatile int read_pos;
  8. volatile int write_pos;
  9. };
  10. struct ring_buffer* alloc_ring_buffer(int len);
  11. void free_ring_buffer(struct ring_buffer* rb);
  12. char* get_ring_buffer_write_ptr(struct ring_buffer* rb, int* max_len);
  13. void move_ring_buffer_write_pos(struct ring_buffer*rb, int len);
  14. char* get_ring_buffer_read_ptr(struct ring_buffer* rb, int* read_len);
  15. void move_ring_buffer_read_pos(struct ring_buffer*rb, int len);
  16. int is_ring_buffer_empty(struct ring_buffer* rb);
  17. void reset_ring_buffer(struct ring_buffer* rb);
  18. #endif