X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=fifo.h;h=61cc5a87bd473d939dc3ebe06f46f0cccb0f7fc1;hp=6a9115d48e4561702325b1921da191444b95f9eb;hb=d480f6c78e5594219d309800eaad71e29923ca68;hpb=e28875637094451a3c5ec4071f964c1a02dd8f5b diff --git a/fifo.h b/fifo.h index 6a9115d4..61cc5a87 100644 --- a/fifo.h +++ b/fifo.h @@ -1,3 +1,5 @@ +#ifndef FIO_FIFO_H +#define FIO_FIFO_H /* * A simple FIFO implementation. * @@ -15,9 +17,10 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ + struct fifo { unsigned char *buffer; /* the buffer holding the data */ unsigned int size; /* the size of the allocated buffer */ @@ -28,21 +31,16 @@ 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; } -#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