fix dependency check logic cause config always disabled
[lunaix-os.git] / lunaix-os / includes / lunaix / ds / fifo.h
1 #ifndef __LUNAIX_FIFO_BUF_H
2 #define __LUNAIX_FIFO_BUF_H
3
4 #include <lunaix/ds/mutex.h>
5 #include <lunaix/types.h>
6
7 #define FIFO_DIRTY 1
8
9 struct fifo_buf
10 {
11     void* data;
12     size_t wr_pos;
13     size_t rd_pos;
14     size_t size;
15     size_t free_len;
16     size_t flags;
17     mutex_t lock;
18 };
19
20 int
21 fifo_backone(struct fifo_buf* fbuf);
22
23 size_t
24 fifo_putone(struct fifo_buf* fbuf, u8_t data);
25
26 size_t
27 fifo_readone_async(struct fifo_buf* fbuf, u8_t* data);
28
29 size_t
30 fifo_readone(struct fifo_buf* fbuf, u8_t* data);
31
32 void
33 fifo_set_rdptr(struct fifo_buf* fbuf, size_t rdptr);
34
35 void
36 fifo_set_wrptr(struct fifo_buf* fbuf, size_t wrptr);
37
38 void
39 fifo_init(struct fifo_buf* buf, void* data_buffer, size_t buf_size, int flags);
40
41 size_t
42 fifo_write(struct fifo_buf* fbuf, void* data, size_t count);
43
44 size_t
45 fifo_read(struct fifo_buf* fbuf, void* buf, size_t count);
46
47 void
48 fifo_clear(struct fifo_buf* fbuf);
49
50 #endif /* __LUNAIX_FIFO_BUF_H */