X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=fifo.h;h=749136530a2c5410867f10caf672c155949daa2f;hp=6a9115d48e4561702325b1921da191444b95f9eb;hb=45054cbec0e624de3b79a795d7dfe1c64cdea934;hpb=e28875637094451a3c5ec4071f964c1a02dd8f5b diff --git a/fifo.h b/fifo.h index 6a9115d4..74913653 100644 --- a/fifo.h +++ b/fifo.h @@ -28,21 +28,31 @@ struct fifo { struct fifo *fifo_alloc(unsigned int); unsigned int fifo_put(struct fifo *, void *, unsigned int); unsigned int fifo_get(struct fifo *, void *, unsigned int); +void fifo_free(struct fifo *); static inline unsigned int fifo_len(struct fifo *fifo) { return fifo->in - fifo->out; } +static inline unsigned int fifo_room(struct fifo *fifo) +{ + return fifo->size - fifo->in + fifo->out; +} + +#ifndef min #define min(x,y) ({ \ typeof(x) _x = (x); \ typeof(y) _y = (y); \ (void) (&_x == &_y); \ _x < _y ? _x : _y; }) +#endif +#ifndef max #define max(x,y) ({ \ typeof(x) _x = (x); \ typeof(y) _y = (y); \ (void) (&_x == &_y); \ _x > _y ? _x : _y; }) +#endif