|
ring_buf
|
Ring buffer functions. More...

Go to the source code of this file.
Functions | |
| static void | ring_buf_clamp (ring_buf_size_t *clamp, ring_buf_size_t limit) |
| Clamp a value to a specified limit. | |
| static ring_buf_size_t | ring_buf_zone_head (const struct ring_buf_zone *zone) |
| Head index of a zone. | |
| static ring_buf_size_t | ring_buf_zone_tail (const struct ring_buf_zone *zone) |
| Tail index of a zone. | |
| static ring_buf_size_t | ring_buf_zone_claim (const struct ring_buf_zone *zone) |
| Claim size of a zone. | |
| static void | ring_buf_zone_reset (struct ring_buf_zone *zone, ring_buf_ptrdiff_t base) |
| Resets a ring buffer zone. | |
| void | ring_buf_reset (struct ring_buf *buf, ring_buf_ptrdiff_t base) |
| Resets a ring buffer. | |
| ring_buf_size_t | ring_buf_put_claim (struct ring_buf *buf, void **space, ring_buf_size_t size) |
| Claims space for putting data into a ring buffer. | |
| int | ring_buf_put_ack (struct ring_buf *buf, ring_buf_size_t size) |
| Acknowledges space claimed for putting data into a ring buffer. | |
| ring_buf_size_t | ring_buf_get_claim (struct ring_buf *buf, void **space, ring_buf_size_t size) |
| Claims contiguous space for getting. | |
| int | ring_buf_get_ack (struct ring_buf *buf, ring_buf_size_t size) |
| Acknowledges space claimed for getting data from a ring buffer. | |
| ring_buf_size_t | ring_buf_put (struct ring_buf *buf, const void *data, ring_buf_size_t size) |
| Puts non-contiguous bytes into the ring buffer. | |
| ring_buf_size_t | ring_buf_get (struct ring_buf *buf, void *data, ring_buf_size_t size) |
| Gets data from a ring buffer. | |
| int | ring_buf_put_all (struct ring_buf *buf, const void *data, ring_buf_size_t size) |
| Puts all or none. | |
| int | ring_buf_get_all (struct ring_buf *buf, void *data, ring_buf_size_t size) |
| Gets all or none. | |
Ring buffer functions.
Implements ring buffer functions for putting and getting data, including contiguous and discontiguous access methods. Also includes functions for acknowledging put and get operations, as well as resetting the buffer.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Definition in file ring_buf.c.
|
inlinestatic |
Clamp a value to a specified limit.
Clamps the value pointed to by clamp to limit if it exceeds the limit.
| clamp | Pointer to the value to clamp. |
| limit | The limit to clamp the value to. |
Definition at line 45 of file ring_buf.c.
|
inlinestatic |
Claim size of a zone.
The claim size is the difference between head and tail.
| zone | Ring buffer zone. |
Definition at line 80 of file ring_buf.c.
|
inlinestatic |
Head index of a zone.
Used as the wrap size when claiming. The wrap size equals the head relative to the base.
| zone | Ring buffer zone. |
Definition at line 59 of file ring_buf.c.
|
inlinestatic |
Resets a ring buffer zone.
Sets the base, head, and tail of the zone to the specified base index.
| zone | Ring buffer zone. |
| base | Base index for the zone. |
Definition at line 91 of file ring_buf.c.
|
inlinestatic |
Tail index of a zone.
| zone | Ring buffer zone. |
Definition at line 69 of file ring_buf.c.