HIPC  0.5
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
queue.h
Go to the documentation of this file.
1 #ifndef HIPC_QUEUE_H
2 #define HIPC_QUEUE_H
3 
4 #include <stddef.h>
5 
6 struct HIPC_queue {
7  void *buf_p;
8  size_t item_size;
9  size_t n_slot;
10  volatile size_t head;
11  volatile size_t tail;
12 };
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 
18  extern void hipcQueueInit(struct HIPC_queue *const que_p,
19  void *const buf_p,
20  const size_t item_size, const size_t n_slot);
21  extern size_t hipcQueueItemSize(struct HIPC_queue *const que_p);
22  extern void *hipcQueueEmpty(struct HIPC_queue *const que_p);
23  extern void hipcQueuePop(struct HIPC_queue *const que_p);
24  extern void *hipcQueueFull(struct HIPC_queue const *const que_p);
25  extern void hipcQueuePush(struct HIPC_queue *const que_p);
26  extern void hipcQueueClear(struct HIPC_queue *const que_p);
27 
28 #ifdef __cplusplus
29 }
30 #endif
31 #endif
void hipcQueueClear(struct HIPC_queue *const que_p)
Clears a queue.
Definition: queue.c:108
volatile size_t tail
Definition: queue.h:11
void hipcQueueInit(struct HIPC_queue *const que_p, void *const buf_p, const size_t item_size, const size_t n_slot)
Initializes a queue.
Definition: queue.c:12
void hipcQueuePop(struct HIPC_queue *const que_p)
Pops an item and releases a slot.
Definition: queue.c:61
size_t item_size
Definition: queue.h:8
void hipcQueuePush(struct HIPC_queue *const que_p)
Pushes an item and occupies a slot.
Definition: queue.c:93
volatile size_t head
Definition: queue.h:10
size_t n_slot
Definition: queue.h:9
void * hipcQueueEmpty(struct HIPC_queue *const que_p)
Returns an address of the head item if it exists.
Definition: queue.c:44
void * buf_p
Definition: queue.h:7
void * hipcQueueFull(struct HIPC_queue const *const que_p)
Returns an address of an empty slot if it exists.
Definition: queue.c:76
size_t hipcQueueItemSize(struct HIPC_queue *const que_p)
Gets item size.
Definition: queue.c:32