|
AquilaOS documentation
How it works, and its code
|
Go to the source code of this file.
Data Structures | |
| struct | ringbuf |
| A ring buffer. More... | |
Macros | |
| #define | RING_INDEX(ring, i) |
| #define | RINGBUF_NEW(sz) |
Functions | |
| static struct ringbuf * | ringbuf_new (size_t size) |
| Returns a new ring buffer of size bytes, from kmalloc(), or NULL if there was no memory for it. | |
| static void | ringbuf_free (struct ringbuf *r) |
| Frees a ring buffer that ringbuf_new() made (NULL does nothing). | |
| static size_t | ringbuf_available (struct ringbuf *ring) |
| Returns how many bytes the ring holds. | |
| static size_t | ringbuf_read (struct ringbuf *ring, size_t n, char *buf) |
| Reads up to n bytes from the ring into buf, and returns how many there were. | |
| static size_t | ringbuf_read_noconsume (struct ringbuf *ring, off_t off, size_t n, char *buf) |
| Copies up to n bytes from the ring, starting off bytes from its head, without taking them off it. | |
| static void | ringbuf_discard (struct ringbuf *ring, size_t n) |
| Throws away the first n bytes of the ring, unread (at most what it holds). | |
| static size_t | ringbuf_write (struct ringbuf *ring, size_t n, char *buf) |
| Writes up to n bytes from buf into the ring, as many as there is room for, and returns how many. | |
| static ssize_t | ringbuf_read_iobuf (struct ringbuf *ring, size_t n, struct iobuf *io) |
| Reads up to n bytes from the ring into an iobuf. | |
| static ssize_t | ringbuf_write_iobuf (struct ringbuf *ring, size_t n, struct iobuf *io) |
| Writes up to n bytes from an iobuf into the ring. | |
| static size_t | ringbuf_write_overwrite (struct ringbuf *ring, size_t n, char *buf) |
| Writes n bytes into the ring, throwing away its oldest bytes if it is full (the kernel's messages). | |
| #define RING_INDEX | ( | ring, | |
| i ) |
Definition at line 15 of file ringbuf.h.
Referenced by ringbuf_available(), ringbuf_discard(), ringbuf_read(), ringbuf_read_iobuf(), ringbuf_read_noconsume(), ringbuf_write(), ringbuf_write_iobuf(), and ringbuf_write_overwrite().
| #define RINGBUF_NEW | ( | sz | ) |
Returns how many bytes the ring holds.
Definition at line 68 of file ringbuf.h.
References ringbuf::head, RING_INDEX, ringbuf::size, and ringbuf::tail.
Referenced by ringbuf_discard(), and ringbuf_read_noconsume().
Throws away the first n bytes of the ring, unread (at most what it holds).
Definition at line 113 of file ringbuf.h.
References ringbuf::head, MIN, RING_INDEX, ringbuf_available(), and ringbuf_discard().
Referenced by ack_input(), ring_to_iobuf(), and ringbuf_discard().
|
inlinestatic |
Frees a ring buffer that ringbuf_new() made (NULL does nothing).
Definition at line 52 of file ringbuf.h.
References ringbuf::buf, and kfree().
Returns a new ring buffer of size bytes, from kmalloc(), or NULL if there was no memory for it.
Definition at line 30 of file ringbuf.h.
References ringbuf::buf, ringbuf::head, kfree(), kmalloc(), NULL, ringbuf::size, and ringbuf::tail.
Reads up to n bytes from the ring into buf, and returns how many there were.
Definition at line 75 of file ringbuf.h.
References ringbuf::buf, ringbuf::head, RING_INDEX, ringbuf::size, and ringbuf::tail.
Reads up to n bytes from the ring into an iobuf.
Definition at line 146 of file ringbuf.h.
References ringbuf::buf, ringbuf::head, iobuf_out(), MIN, iobuf::resid, RING_INDEX, ringbuf::size, and ringbuf::tail.
|
inlinestatic |
Copies up to n bytes from the ring, starting off bytes from its head, without taking them off it.
Returns how many were copied.
Definition at line 92 of file ringbuf.h.
References ringbuf::buf, ringbuf::head, MIN, RING_INDEX, and ringbuf_available().
Writes up to n bytes from buf into the ring, as many as there is room for, and returns how many.
Definition at line 121 of file ringbuf.h.
References ringbuf::buf, ringbuf::head, RING_INDEX, ringbuf::size, and ringbuf::tail.
Writes up to n bytes from an iobuf into the ring.
Definition at line 168 of file ringbuf.h.
References ringbuf::buf, ringbuf::head, iobuf_in(), MIN, iobuf::resid, RING_INDEX, ringbuf::size, and ringbuf::tail.
Writes n bytes into the ring, throwing away its oldest bytes if it is full (the kernel's messages).
Returns n.
Definition at line 192 of file ringbuf.h.
References ringbuf::buf, ringbuf::head, RING_INDEX, ringbuf::size, and ringbuf::tail.