📄 ringbuf.h
字号:
#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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -