X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=fifo.h;h=4b775b0bfc1942eb3f7199968e28678a93835796;hp=cfacea996f0309b323b93b67a79f1b89d555dd2b;hb=977b959628585fc20cd0c2cc6e309f7f6f219888;hpb=38470f85fa4acddab4339db9c8805a19bc87578e diff --git a/fifo.h b/fifo.h index cfacea99..4b775b0b 100644 --- a/fifo.h +++ b/fifo.h @@ -1,3 +1,5 @@ +#ifndef FIO_FIFO_H +#define FIO_FIFO_H /* * A simple FIFO implementation. * @@ -18,6 +20,8 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ +#include "minmax.h" + struct fifo { unsigned char *buffer; /* the buffer holding the data */ unsigned int size; /* the size of the allocated buffer */ @@ -35,15 +39,9 @@ static inline unsigned int fifo_len(struct fifo *fifo) return fifo->in - fifo->out; } -#define min(x,y) ({ \ - typeof(x) _x = (x); \ - typeof(y) _y = (y); \ - (void) (&_x == &_y); \ - _x < _y ? _x : _y; }) - -#define max(x,y) ({ \ - typeof(x) _x = (x); \ - typeof(y) _y = (y); \ - (void) (&_x == &_y); \ - _x > _y ? _x : _y; }) +static inline unsigned int fifo_room(struct fifo *fifo) +{ + return fifo->size - fifo->in + fifo->out; +} +#endif