6 #ifndef __RINGBUFFER_DECLARED
7 #define __RINGBUFFER_DECLARED
12 #if __has_include(<windows.h>)
13 #if defined(__RINGBUFFER_INTERNAL)
14 #if defined(TEST_UNIT) || defined(TEST_INTEGRATION)
16 #define LINKED_FUNCTION extern
19 #define LINKED_FUNCTION extern __declspec (dllexport)
23 #define LINKED_FUNCTION __declspec (dllimport)
27 #define LINKED_FUNCTION extern
41 struct ringbuffer_context;
93 void *target_array,
const unsigned int element_size,
94 const unsigned int element_count,
const unsigned int initial_read_index,
95 const unsigned int initial_write_index);
140 void *pointer_to_output);
182 const void *pointer_to_input);
189 LINKED_FUNCTION
unsigned int
198 LINKED_FUNCTION
unsigned int
207 LINKED_FUNCTION
unsigned int
248 #undef LINKED_FUNCTION
void ringbuffer_read(ringbuffer_context_t context, void *pointer_to_output)
Copy value from an element pointed by read index, to an intended variable.
void ringbuffer_destroy(ringbuffer_context_t *pointer_to_context)
Clean-up ringbuffer context then NULLify it.
struct ringbuffer_context * ringbuffer_context_t
Points to an allocated memory for ringbuffer module.
Definition: ringbuffer.h:52
ringbuffer_context_t ringbuffer_init(void *target_array, const unsigned int element_size, const unsigned int element_count, const unsigned int initial_read_index, const unsigned int initial_write_index)
Initiate a single instance of ringbuffer management.
void ringbuffer_write(ringbuffer_context_t context, const void *pointer_to_input)
Put value from a variable to an element which pointed by write index.
unsigned int ringbuffer_get_write_index(const ringbuffer_context_t context)
Get the write index, which means position of write cursor of ring buffer.
unsigned int ringbuffer_get_read_index(const ringbuffer_context_t context)
Get the read index, which means position of read cursor of ring buffer.
unsigned int ringbuffer_is_empty(const ringbuffer_context_t context)
Check if the ringbuffer is empty, which indicated by 'read index == write index'.