]> Git Repo - qemu.git/blob - include/qemu/fifo8.h
Merge remote-tracking branch 'kwolf/for-anthony' into staging
[qemu.git] / include / qemu / fifo8.h
1 #ifndef FIFO_H
2 #define FIFO_H
3
4 #include "migration/vmstate.h"
5
6 typedef struct {
7     /* All fields are private */
8     uint8_t *data;
9     uint32_t capacity;
10     uint32_t head;
11     uint32_t num;
12 } Fifo8;
13
14 /**
15  * fifo8_create:
16  * @fifo: struct Fifo8 to initialise with new FIFO
17  * @capacity: capacity of the newly created FIFO
18  *
19  * Create a FIFO of the specified size. Clients should call fifo8_destroy()
20  * when finished using the fifo. The FIFO is initially empty.
21  */
22
23 void fifo8_create(Fifo8 *fifo, uint32_t capacity);
24
25 /**
26  * fifo8_destroy:
27  * @fifo: FIFO to cleanup
28  *
29  * Cleanup a FIFO created with fifo8_create(). Frees memory created for FIFO
30   *storage. The FIFO is no longer usable after this has been called.
31  */
32
33 void fifo8_destroy(Fifo8 *fifo);
34
35 /**
36  * fifo8_push:
37  * @fifo: FIFO to push to
38  * @data: data byte to push
39  *
40  * Push a data byte to the FIFO. Behaviour is undefined if the FIFO is full.
41  * Clients are responsible for checking for fullness using fifo8_is_full().
42  */
43
44 void fifo8_push(Fifo8 *fifo, uint8_t data);
45
46 /**
47  * fifo8_pop:
48  * @fifo: fifo to pop from
49  *
50  * Pop a data byte from the FIFO. Behaviour is undefined if the FIFO is empty.
51  * Clients are responsible for checking for emptyness using fifo8_is_empty().
52  *
53  * Returns: The popped data byte.
54  */
55
56 uint8_t fifo8_pop(Fifo8 *fifo);
57
58 /**
59  * fifo8_reset:
60  * @fifo: FIFO to reset
61  *
62  * Reset a FIFO. All data is discarded and the FIFO is emptied.
63  */
64
65 void fifo8_reset(Fifo8 *fifo);
66
67 /**
68  * fifo8_is_empty:
69  * @fifo: FIFO to check
70  *
71  * Check if a FIFO is empty.
72  *
73  * Returns: True if the fifo is empty, false otherwise.
74  */
75
76 bool fifo8_is_empty(Fifo8 *fifo);
77
78 /**
79  * fifo8_is_full:
80  * @fifo: FIFO to check
81  *
82  * Check if a FIFO is full.
83  *
84  * Returns: True if the fifo is full, false otherwise.
85  */
86
87 bool fifo8_is_full(Fifo8 *fifo);
88
89 extern const VMStateDescription vmstate_fifo8;
90
91 #define VMSTATE_FIFO8(_field, _state) {                              \
92     .name       = (stringify(_field)),                               \
93     .size       = sizeof(Fifo8),                                     \
94     .vmsd       = &vmstate_fifo8,                                    \
95     .flags      = VMS_STRUCT,                                        \
96     .offset     = vmstate_offset_value(_state, _field, Fifo8),       \
97 }
98
99 #endif /* FIFO_H */
This page took 0.025848 seconds and 4 git commands to generate.