10 Star 15 Fork 5

anolis / fio

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
fifo.h 1.48 KB
一键复制 编辑 原始数据 按行查看 历史
Sitsofe Wheeler 提交于 2018-03-19 05:33 . Refactor #includes and headers
#ifndef FIO_FIFO_H
#define FIO_FIFO_H
/*
* A simple FIFO implementation.
*
* Copyright (C) 2004 Stelian Pop <stelian@popies.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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., 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 */
unsigned int in; /* data is added at offset (in % size) */
unsigned int out; /* data is extracted from off. (out % size) */
};
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;
}
#endif
1
https://gitee.com/anolis/fio.git
git@gitee.com:anolis/fio.git
anolis
fio
fio
an8

搜索帮助