ringbuffer.h 834 B

1234567891011121314151617181920212223242526
  1. #pragma once
  2. typedef struct {
  3. unsigned char * buffer;
  4. size_t write_ptr;
  5. size_t read_ptr;
  6. size_t size;
  7. volatile int lock[2];
  8. list_t * wait_queue_readers;
  9. list_t * wait_queue_writers;
  10. int internal_stop;
  11. list_t * alert_waiters;
  12. int discard;
  13. } ring_buffer_t;
  14. size_t ring_buffer_unread(ring_buffer_t * ring_buffer);
  15. size_t ring_buffer_size(fs_node_t * node);
  16. size_t ring_buffer_available(ring_buffer_t * ring_buffer);
  17. size_t ring_buffer_read(ring_buffer_t * ring_buffer, size_t size, uint8_t * buffer);
  18. size_t ring_buffer_write(ring_buffer_t * ring_buffer, size_t size, uint8_t * buffer);
  19. ring_buffer_t * ring_buffer_create(size_t size);
  20. void ring_buffer_destroy(ring_buffer_t * ring_buffer);
  21. void ring_buffer_interrupt(ring_buffer_t * ring_buffer);
  22. void ring_buffer_select_wait(ring_buffer_t * ring_buffer, void * process);