1 #ifndef _LINUX_CIRC_BUF_H
2 #define _LINUX_CIRC_BUF_H 1
10 /* Return count in buffer. */
11 #define CIRC_CNT(head,tail,size) (((head) - (tail)) & ((size)-1))
13 /* Return space available, 0..size-1. We always leave one free char
14 as a completely full buffer has head == tail, which is the same as
16 #define CIRC_SPACE(head,tail,size) CIRC_CNT((tail),((head)+1),(size))
18 /* Return count up to the end of the buffer. Carefully avoid
19 accessing head and tail more than once, so they can change
20 underneath us without returning inconsistent results. */
21 #define CIRC_CNT_TO_END(head,tail,size) \
22 ({int end = (size) - (tail); \
23 int n = ((head) + end) & ((size)-1); \
26 /* Return space available up to the end of the buffer. */
27 #define CIRC_SPACE_TO_END(head,tail,size) \
28 ({int end = (size) - 1 - (head); \
29 int n = (end + (tail)) & ((size)-1); \
30 n <= end ? n : end+1;})
32 #endif /* _LINUX_CIRC_BUF_H */
This page took 0.031201 seconds and 5 git commands to generate.