summaryrefslogtreecommitdiffstats
path: root/lib/ringbuf.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* *: auto-convert to SPDX License IDsDavid Lamparter2023-02-091-14/+1
| | | | | | Done with a combination of regex'ing and banging my head against a wall. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* Revert "lib: add ringbuf socket read function"Quentin Young2021-04-291-35/+0
| | | | This reverts commit d9d7af1a52d77ed0074ebb72f87678308296e74e.
* *: require semicolon after DEFINE_MTYPE & coDavid Lamparter2021-03-171-1/+1
| | | | | | | | | | | | | | | | | Back when I put this together in 2015, ISO C11 was still reasonably new and we couldn't require it just yet. Without ISO C11, there is no "good" way (only bad hacks) to require a semicolon after a macro that ends with a function definition. And if you added one anyway, you'd get "spurious semicolon" warnings on some compilers... With C11, `_Static_assert()` at the end of a macro will make it so that the semicolon is properly required, consumed, and not warned about. Consistently requiring semicolons after "file-level" macros matches Linux kernel coding style and helps some editors against mis-syntax'ing these macros. Signed-off-by: David Lamparter <equinox@diac24.net>
* lib: add ringbuf socket read functionRafael Zalamena2021-03-051-0/+35
| | | | | | | Implement new ringbuf function to do the proper socket reads without the need of intermediary buffers. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
* *: conform with COMMUNITY.md formatting rules, via 'make indent'Lou Berger2018-03-061-1/+1
| | | | Signed-off-by: Lou Berger <lberger@labn.net>
* lib: fix a few bugs in ring buffersQuentin Young2018-01-031-4/+4
| | | | | | | | | | | | | * Fix rare failure caused when end pointer is at end of buffer memory and a call to ringbuf_get() is made that reads all of the data in the buffer; start pointer was advanced past end pointer, causing some special handling to be skipped * Fix ringbuf_peek() moving start pointer * Fix use after free * Remove extraneous assignment * Update relevant tests Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* lib: add ringbuf_copy()Quentin Young2018-01-031-0/+9
| | | | | | Quick 'n easy way to copy the contents of one ringbuf to another. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* lib: add ringbuf_peek()Quentin Young2017-12-271-1/+21
| | | | | | | | | | | Peek functionality for ring buffers and associated tests. Also: * Slight optimization to avoid 0-byte memcpy() by changing > to >= * Add rv checks for some ringbuf_[put|get] calls that were missing them in the test Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* lib: add ring bufferQuentin Young2017-12-191-0/+104
Simple ring buffer implementation useful for fixed size FIFO queues. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>