|
ring_buf
|
Ring buffer function prototypes. More...
#include <errno.h>#include <stdbool.h>#include <stddef.h>#include <stdint.h>

Go to the source code of this file.
Data Structures | |
| struct | ring_buf_zone |
| Ring buffer zone. More... | |
| struct | ring_buf |
| Ring buffer instance. More... | |
Macros | |
| #define | EMSGSIZE 115 |
| Message size error code. | |
| #define | RING_BUF_SIZE_MAX ((ring_buf_size_t)PTRDIFF_MIN) |
| Maximum ring buffer size. | |
| #define | RING_BUF_DEFINE_STATIC(_name_, _size_) |
| Defines a static ring buffer. | |
Typedefs | |
| typedef ptrdiff_t | ring_buf_ptrdiff_t |
| Ring buffer pointer difference type. | |
| typedef size_t | ring_buf_size_t |
| Ring buffer size type. | |
Functions | |
| static ring_buf_size_t | ring_buf_used_space (const struct ring_buf *buf) |
| Calculates used space in the ring buffer. | |
| static bool | ring_buf_is_empty (const struct ring_buf *buf) |
| Checks if the ring buffer is empty. | |
| static ring_buf_size_t | ring_buf_free_space (const struct ring_buf *buf) |
| Calculates free space in the ring buffer. | |
| static bool | ring_buf_is_full (const struct ring_buf *buf) |
| Checks if the ring buffer is full. | |
| 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 function prototypes.
Declares 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.h.
| #define EMSGSIZE 115 |
Message size error code.
Error code indicating that a message is too large to fit in a ring buffer.
Definition at line 51 of file ring_buf.h.
| #define RING_BUF_SIZE_MAX ((ring_buf_size_t)PTRDIFF_MIN) |
Maximum ring buffer size.
Defines the maximum size of the ring buffer based on the minimum value of the pointer difference type.
Definition at line 71 of file ring_buf.h.
| typedef ptrdiff_t ring_buf_ptrdiff_t |
Ring buffer pointer difference type.
Signed type used for pointer arithmetic within the ring buffer.
Definition at line 58 of file ring_buf.h.
| typedef size_t ring_buf_size_t |
Ring buffer size type.
Unsigned type used for sizes within the ring buffer.
Definition at line 64 of file ring_buf.h.