123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- #pragma once
- #include <stdint.h>
- struct kfifo_t
- {
- uint32_t total_size;
- uint32_t size;
- uint32_t in_offset;
- uint32_t out_offset;
- void *buffer;
- } __attribute__((aligned(sizeof(long))));
- #define kfifo_reset(fifo) (void)({ \
- (fifo)->size = 0; \
- (fifo)->in_offset = 0; \
- (fifo)->out_offset = 0; \
- })
- #define kfifo_reset_out(fifo) (void)({ \
- (fifo)->size = 0; \
- (fifo)->out_offset = (fifo)->in_offset; \
- })
- #define kfifo_total_size(fifo) ((fifo)->total_size)
- #define kfifo_size(fifo) ((fifo)->size)
- #define kfifo_empty(fifo) (((fifo)->size == 0) ? 1 : 0)
- #define kfifo_full(fifo) (((fifo)->size == (fifo)->total_size) ? 1 : 0)
- int kfifo_alloc(struct kfifo_t *fifo, uint32_t size, uint64_t reserved);
- void kfifo_free_alloc(struct kfifo_t* fifo);
- void kfifo_init(struct kfifo_t *fifo, void *buffer, uint32_t size);
- uint32_t kfifo_in(struct kfifo_t *fifo, const void *from, uint32_t size);
- uint32_t kfifo_out(struct kfifo_t *fifo, void *to, uint32_t size);
- uint32_t kfifo_out_peek(struct kfifo_t *fifo, void *to, uint32_t size);
|