54 return((
void *)pring);
63 return((
void *)pring);
85 if (nextGet <= nextPut) {
90 memcpy (value, (
void *)&pring->
buffer[nextGet], nbytes);
97 memcpy (value, (
void *)&pring->
buffer[nextGet], count);
99 if (nextGet == size) {
100 int nLeft = nbytes - count;
103 memcpy (value+count, (
void *)&pring->
buffer[0], nLeft);
105 nbytes = count + nLeft;
122 int freeCount, copyCount, topCount, used;
129 if (nextPut < nextGet) {
130 freeCount = nextGet - nextPut -
SLOP;
131 if (nbytes > freeCount) {
136 memcpy ((
void *)&pring->
buffer[nextPut], value, nbytes);
141 freeCount = size - nextPut + nextGet -
SLOP;
142 if (nbytes > freeCount) {
147 copyCount = (nbytes > topCount) ? topCount : nbytes;
149 memcpy ((
void *)&pring->
buffer[nextPut], value, copyCount);
151 nextPut += copyCount;
152 if (nextPut == size) {
153 int nLeft = nbytes - copyCount;
155 memcpy ((
void *)&pring->
buffer[0], value+copyCount, nLeft);
162 if (used < 0) used += pring->
size;
188 if (nextPut < nextGet)
189 return nextGet - nextPut -
SLOP;
191 return pring->
size - nextPut + nextGet -
SLOP;
206 if (used < 0) used += pring->
size;
247 if (used < 0) used += pring->
size;
LIBCOM_API void epicsStdCall epicsRingBytesFlush(epicsRingBytesId id)
Make the ring buffer empty.
LIBCOM_API int epicsStdCall epicsRingBytesSize(epicsRingBytesId id)
Return the size of the ring buffer.
LIBCOM_API int epicsStdCall epicsRingBytesUsedBytes(epicsRingBytesId id)
Return the number of bytes currently stored in the ring buffer.
void const * epicsRingBytesIdConst
Miscellaneous macro definitions.
LIBCOM_API epicsRingBytesId epicsStdCall epicsRingBytesCreate(int size)
Create a new ring buffer.
LIBCOM_API void epicsStdCall epicsRingBytesDelete(epicsRingBytesId id)
Delete the ring buffer and free any associated memory.
LIBCOM_API int epicsStdCall epicsRingBytesHighWaterMark(epicsRingBytesIdConst id)
See how full a ring buffer has been since it was last checked.
LIBCOM_API int epicsStdCall epicsRingBytesFreeBytes(epicsRingBytesId id)
Return the number of free bytes in the ring buffer.
LIBCOM_API epicsRingBytesId epicsStdCall epicsRingBytesLockedCreate(int size)
Create a new ring buffer, secured by a spinlock.
A circular buffer to store bytes.
LIBCOM_API int epicsStdCall epicsRingBytesIsFull(epicsRingBytesId id)
Test if the ring buffer is currently full.
LIBCOM_API int epicsStdCall epicsRingBytesPut(epicsRingBytesId id, char *value, int nbytes)
Write data into the ring buffer.
LIBCOM_API void epicsStdCall epicsRingBytesResetHighWaterMark(epicsRingBytesId id)
Reset the Highwater mark of the ring buffer.
LIBCOM_API void epicsSpinDestroy(epicsSpinId)
LIBCOM_API int epicsStdCall epicsRingBytesGet(epicsRingBytesId id, char *value, int nbytes)
Read data out of the ring buffer.
void * epicsRingBytesId
An identifier for a ring buffer.
LIBCOM_API void epicsSpinLock(epicsSpinId)
LIBCOM_API epicsSpinId epicsSpinCreate(void)
LIBCOM_API void epicsSpinUnlock(epicsSpinId)
LIBCOM_API int epicsStdCall epicsRingBytesIsEmpty(epicsRingBytesId id)
Test if the ring buffer is currently empty.