Root/
1 | /* |
2 | * See Documentation/circular-buffers.txt for more information. |
3 | */ |
4 | |
5 | #ifndef _LINUX_CIRC_BUF_H |
6 | #define _LINUX_CIRC_BUF_H 1 |
7 | |
8 | struct circ_buf { |
9 | char *buf; |
10 | int head; |
11 | int tail; |
12 | }; |
13 | |
14 | /* Return count in buffer. */ |
15 | #define CIRC_CNT(head,tail,size) (((head) - (tail)) & ((size)-1)) |
16 | |
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 |
19 | empty. */ |
20 | #define CIRC_SPACE(head,tail,size) CIRC_CNT((tail),((head)+1),(size)) |
21 | |
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); \ |
28 | n < end ? n : end;}) |
29 | |
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;}) |
35 | |
36 | #endif /* _LINUX_CIRC_BUF_H */ |
37 |
Branches:
ben-wpan
ben-wpan-stefan
javiroman/ks7010
jz-2.6.34
jz-2.6.34-rc5
jz-2.6.34-rc6
jz-2.6.34-rc7
jz-2.6.35
jz-2.6.36
jz-2.6.37
jz-2.6.38
jz-2.6.39
jz-3.0
jz-3.1
jz-3.11
jz-3.12
jz-3.13
jz-3.15
jz-3.16
jz-3.18-dt
jz-3.2
jz-3.3
jz-3.4
jz-3.5
jz-3.6
jz-3.6-rc2-pwm
jz-3.9
jz-3.9-clk
jz-3.9-rc8
jz47xx
jz47xx-2.6.38
master
Tags:
od-2011-09-04
od-2011-09-18
v2.6.34-rc5
v2.6.34-rc6
v2.6.34-rc7
v3.9