toaruos/base/usr/include/kernel/ringbuffer.h
2018-03-19 11:38:11 +09:00

27 lines
834 B
C

#pragma once
typedef struct {
unsigned char * buffer;
size_t write_ptr;
size_t read_ptr;
size_t size;
volatile int lock[2];
list_t * wait_queue_readers;
list_t * wait_queue_writers;
int internal_stop;
list_t * alert_waiters;
int discard;
} ring_buffer_t;
size_t ring_buffer_unread(ring_buffer_t * ring_buffer);
size_t ring_buffer_size(fs_node_t * node);
size_t ring_buffer_available(ring_buffer_t * ring_buffer);
size_t ring_buffer_read(ring_buffer_t * ring_buffer, size_t size, uint8_t * buffer);
size_t ring_buffer_write(ring_buffer_t * ring_buffer, size_t size, uint8_t * buffer);
ring_buffer_t * ring_buffer_create(size_t size);
void ring_buffer_destroy(ring_buffer_t * ring_buffer);
void ring_buffer_interrupt(ring_buffer_t * ring_buffer);
void ring_buffer_select_wait(ring_buffer_t * ring_buffer, void * process);