Library / SDK
MaJerle/lwrb avatar
MaJerle/lwrb

MaJerle/lwrb: a static FIFO for embedded C systems

Lightweight generic ring buffer manager library

1,543 stars355 forksCMIT

At a glance

What is it?
LwRB is an MIT-licensed C11 library for managing static FIFO ring buffers in embedded applications. It emphasizes no dynamic allocation, configurable atomic protection, DMA suitability, and bounded operations.
Who is it for?
Adopt LwRB when an embedded C design needs a statically allocated FIFO with DMA and concurrent-access options, but do not assume it fits unless the external documentation confirms the expected compiler, target, and transfer semantics. Verify the relevant API contracts, atomic configuration, memory alignment, and thread or interrupt model before replacing an existing buffer implementation.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 15 days ago.
What is it written in?
Mainly C, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on October 21, 2026, and from our analysis. They are not legal advice.

Editorial analysis

Why LwRB targets embedded FIFO workloads

LwRB addresses a specific embedded-systems problem: keeping FIFO data in a bounded, statically allocated buffer without introducing dynamic memory allocation. It is intended for C applications that need predictable storage behavior, including systems where memory is fixed at build time or allocation during execution is undesirable. The FIFO ordering is central to the library. Data is added at one end and removed in insertion order from the other, which makes the library relevant to queues, byte streams, and communication paths.

The repository describes LwRB as C11 code that uses `stdint.h` data types and contains no architecture-specific code. That makes it a candidate for embedded projects that value portability, although the README does not document a specific compiler matrix, supported toolchain list, or minimum supported C standard beyond the stated C11 basis. The repository has no homepage listed, but its README points readers to the online documentation at `https://docs.majerle.eu/projects/lwrb/`.

The library is not a general-purpose allocator or file buffer. Its scope is a generic FIFO ring buffer with operations for reading, writing, peeking, skipping, and advancing. That narrower purpose is useful because the surrounding application retains control of the actual storage and the rest of its data-processing environment.

How the static ring buffer moves data

The core design is a FIFO backed by a static array. The README states that data is static and that the implementation uses optimized memory copies rather than loops for reading and writing data to and from memory. In practical terms, the library manages a bounded circular storage region while allowing callers to work with buffered sequences without copying each item through a loop at the application level. The exact public function names and signatures are not included in the repository README, so they are not reproduced here.

LwRB also exposes operations beyond basic FIFO insertion and removal. Peek allows an application to inspect buffered data without removing it. Skip for read moves the read position past data that should be ignored. Advance for write moves the write position, which supports workflows where an external transfer produces data directly into a designated portion of the buffer. These operations make the buffer more than a pair of append and pop calls, although the documentation excerpt does not describe the parameter validation or position semantics in detail.

Byte-sequence search is another documented capability. This is useful when an application needs to locate a marker within buffered data, but the README does not state how unsuccessful searches, partial matches, or searches spanning wrapped regions are handled. Those details would need to come from the linked documentation or source headers.

Concurrency, atomics, and DMA constraints

Concurrency support is designed around an important boundary. The README says that LwRB is thread-safe and interrupt-safe when used as a pipe with single-writer and single-reader entries. That is narrower than a claim of unrestricted multi-writer or multi-reader support. The buffer can therefore fit a typical producer-consumer arrangement, but applications must preserve the stated access model rather than assuming that arbitrary concurrent callers are supported.

By default, the library uses C11 atomic operations to keep reads and writes race-free, including on architectures whose native word is smaller than `size_t`, with AVR named as an example. This configuration can be disabled with `LWRB_DISABLE_ATOMIC`. Disabling atomics may be useful where the target does not provide the required atomic support, but it also removes a stated protection mechanism, so the application's concurrency model must account for that choice.

The README also identifies DMA transfers as a supported use case and describes zero-copy overhead between the buffer and application memory. The precise DMA workflow, alignment requirements, cache behavior, and ownership rules are not documented in the excerpt. Those are implementation-critical details, especially on systems with data or instruction caches. LwRB should not be treated as a universal DMA adapter without checking the linked documentation and the platform's DMA requirements.

Bounded operations and optional buffer customization

LwRB can optionally enforce all-or-nothing reads and writes. That is a meaningful distinction from an operation that may transfer only part of the requested data. For a FIFO with fixed capacity, callers may need to know whether a request fits before committing to it. The README does not say how these modes interact with wraparound, DMA, or concurrent readers and writers, so the exact contract should be verified before relying on partial-transfer behavior.

The library supports optional per-buffer custom user argument storage. This appears to provide a place for application-specific metadata associated with a buffer, rather than forcing every caller to maintain a separate lookup table. The README does not define the size, ownership, or initialization semantics of that storage in this excerpt.

Event notification support is also listed. The README does not provide a notification API, callback contract, or explanation of whether notifications are blocking, interrupt-driven, or optional at initialization. Consequently, the existence of the feature is clear, but its operational cost and required setup cannot be confirmed from the README alone. These omissions are normal reasons to inspect the API documentation before integration.

Installing LwRB and beginning a first use

The repository README does not provide installation commands, package-manager instructions, or a copy-and-paste first example. It directs users to the online documentation instead:

text
https://docs.majerle.eu/projects/lwrb/

That block is the documentation URL shown in the README, not an installation command. The repository includes a `CMakeLists.txt`, `CMakePresets.json`, and a `library.json` file, but the excerpt does not show the target names, installation commands, or configuration steps needed to build a consumer application. Inventing those details would risk producing an example that does not match the project.

A first use therefore begins with the linked documentation and the repository's public headers or source files under `lwrb/`. The documented capabilities to verify are static storage initialization, basic FIFO reads and writes, then any additional features required by the application. The README does not document a `make` command, a package name, a port, or a complete API snippet, so no installation or code example is presented beyond the verified documentation URL.

Maintenance, licensing, and adoption boundaries

The repository is not archived, and its last push was on 2026-10-08. The recent release list includes `v3.3.0` on 2026-08-13, `v3.2.0` on 2024-06-22, and `v3.1.0` on 2023-12-21. These dates indicate recent project activity in the recorded history, but they do not establish compatibility with every target or guarantee the cost of future upgrades.

LwRB uses the MIT license, which is described in the README as user-friendly. Consumers must account for the license text and notices in their own distribution. This article does not interpret the license or provide legal advice. Upgrade planning should instead examine the differences between releases, API or configuration changes, and the effect of changing `LWRB_DISABLE_ATOMIC` or DMA-related usage.

The strongest fit is an embedded C project with fixed memory, FIFO semantics, and a need for DMA-friendly or interrupt-aware buffer access. The wrong fit is a project expecting dynamic storage, unrestricted concurrent writers, transparent file persistence, or a documented high-level installation workflow. The unavailable details are precisely the ones that can determine whether adoption is safe.

Editorial conclusion

Adopt LwRB when an embedded C design needs a statically allocated FIFO with DMA and concurrent-access options, but do not assume it fits unless the external documentation confirms the expected compiler, target, and transfer semantics. Verify the relevant API contracts, atomic configuration, memory alignment, and thread or interrupt model before replacing an existing buffer implementation.

Frequently asked questions

Does MaJerle/lwrb use dynamic memory allocation?

No. The README states that LwRB uses no dynamic memory allocation and keeps data in a static array.

Is MaJerle/lwrb safe for interrupt-driven FIFO access?

The README says it is thread-safe and interrupt-safe when used as a pipe with single-writer and single-reader entries. It does not claim unrestricted multi-writer or multi-reader use.

Does MaJerle/lwrb support DMA transfers?

The README lists DMA transfers as suitable and states that it supports zero-copy overhead between the buffer and application memory. Detailed DMA setup and platform requirements are not provided in the README excerpt.

Official sources

  1. Issues
  2. License: MIT
  3. MaJerle/lwrb on GitHub
  4. README
  5. Releases
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/majerle-lwrb.svg)](https://hysenlabs.com/projects/majerle-lwrb)

Was this useful?