Ginga  0.13.6
 All Classes Namespaces Functions Variables
RingBuffer.h
1 #ifndef HAVE_RING_BUFFER__
2 #define HAVE_RING_BUFFER__
3 
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
7 
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <unistd.h>
11 #include <sys/mman.h>
12 #include <string.h>
13 #include <pthread.h>
14 
15 // Posix Ring Buffer implementation
16 //
17 
18 #define report_exceptional_condition() abort ()
19 
21 {
22  void *address;
23 
24  unsigned long count_bytes;
25  unsigned long write_offset_bytes;
26  unsigned long read_offset_bytes;
27 };
28 
29 void ring_buffer_create (struct ring_buffer *buffer, unsigned long order);
30 
31 void ring_buffer_free (struct ring_buffer *buffer);
32 
33 void *ring_buffer_write_address (struct ring_buffer *buffer);
34 
35 void ring_buffer_write_advance (struct ring_buffer *buffer, unsigned long count_bytes);
36 
37 void *ring_buffer_read_address (struct ring_buffer *buffer);
38 
39 void ring_buffer_read_advance (struct ring_buffer *buffer, unsigned long count_bytes);
40 
41 unsigned long ring_buffer_count_bytes (struct ring_buffer *buffer);
42 
43 unsigned long ring_buffer_count_free_bytes (struct ring_buffer *buffer);
44 
45 void ring_buffer_clear (struct ring_buffer *buffer);
46 
47 
48 #ifdef __cplusplus
49 };
50 #endif
51 
52 #endif /* HAVE_RING_BUFFER__ */
Definition: RingBuffer.h:20