2 * See Documentation/circular-buffers.txt for more information.
5 #ifndef _LINUX_CIRC_BUF_H
6 #define _LINUX_CIRC_BUF_H 1
14 /* Return count in buffer. */
15 #define CIRC_CNT(head,tail,size) (((head) - (tail)) & ((size)-1))
17 /* Return space available, 0..size-1. We always leave one free char
18 as a completely full buffer has head == tail, which is the same as
20 #define CIRC_SPACE(head,tail,size) CIRC_CNT((tail),((head)+1),(size))
22 /* Return count up to the end of the buffer. Carefully avoid
23 accessing head and tail more than once, so they can change
24 underneath us without returning inconsistent results. */
25 #define CIRC_CNT_TO_END(head,tail,size) \
26 ({int end = (size) - (tail); \
27 int n = ((head) + end) & ((size)-1); \
30 /* Return space available up to the end of the buffer. */
31 #define CIRC_SPACE_TO_END(head,tail,size) \
32 ({int end = (size) - 1 - (head); \
33 int n = (end + (tail)) & ((size)-1); \
34 n <= end ? n : end+1;})
36 #endif /* _LINUX_CIRC_BUF_H */
This page took 0.031495 seconds and 5 git commands to generate.