1 /* 2 * Copyright 2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef RING_BUFFER_H 6 #define RING_BUFFER_H 7 8 9 #include <OS.h> 10 11 12 struct ring_buffer; 13 14 #ifdef __cplusplus 15 extern "C" { 16 #endif 17 18 struct ring_buffer *create_ring_buffer(size_t size); 19 void delete_ring_buffer(struct ring_buffer *buffer); 20 21 void ring_buffer_clear(struct ring_buffer *buffer); 22 size_t ring_buffer_readable(struct ring_buffer *buffer); 23 size_t ring_buffer_writable(struct ring_buffer *buffer); 24 void ring_buffer_flush(struct ring_buffer *buffer, size_t bytes); 25 size_t ring_buffer_read(struct ring_buffer *buffer, uint8 *data, ssize_t length); 26 size_t ring_buffer_write(struct ring_buffer *buffer, const uint8 *data, ssize_t length); 27 ssize_t ring_buffer_user_read(struct ring_buffer *buffer, uint8 *data, ssize_t length); 28 ssize_t ring_buffer_user_write(struct ring_buffer *buffer, const uint8 *data, ssize_t length); 29 30 #ifdef __cplusplus 31 } 32 #endif 33 34 #endif /* RING_BUFFER_H */ 35