ringbuf.h
来自「C语言编写的监控中心终端程序。基于GPRS上传收发数据功能」· C头文件 代码 · 共 72 行
H
72 行
#ifndef __RINGBUF_H
#define __RINGBUF_H
#include "config.h"
/*
** ring buffer control
**
** ..uuudddddd...
** B R W
**
*/
#if 0
static inline int WRAPl(int r, int s) {return (r < 0) ? (r + s) : r;}
static inline int WRAPr(int r, int s) {return (r >= s) ? (r - s) : r;}
#endif
#ifdef ENABLE_INLINE
static inline int WRAPl(int r, int s)
{
return (r < 0) ? (r + s) : r;
}
static inline int WRAPr(int r, int s)
{
return (r >= s) ? (r - s) : r;
}
#else
#define WRAPl(r, s) (((r) < 0 ) ? ((r) + (s)) : (r))
#define WRAPr(r, s) (((r) >= (s)) ? ((r) - (s)) : (r))
#endif
static inline int RingBufferSize_CD(int Wp, int Rp, int L)
{
int S = Wp - Rp;
if (S < 0)
S += L;
S = (S * 288) / 1024; // because CD_MOVE width is 288 and original is 1024
return S;
}
static inline int RingBufferFree_CD(int Wp, int Bp, int L)
{
int F = Bp - Wp;
if (F <= 0)
F += L;
F = (F * 288) / 1024; // because CD_MOVE width is 288 and original is 1024
return F;
}
static inline int RingBufferSize(int Wp, int Rp, int L)
{
int S = Wp - Rp;
if (S < 0)
S += L;
return S;
}
static inline int RingBufferFree(int Wp, int Bp, int L)
{
int F = Bp - Wp;
if (F <= 0)
F += L;
return F;
}
#endif __RINGBUF_H
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?