Skip to content

Repository files navigation

micoring

CILicense: MIT

micoring is a fixed-capacity ring buffer for caller-owned storage.

The default build is portable single-context C99. An optional MRING_CONCURRENCY_SPSC_ATOMIC configuration supports one producer and one consumer with release/acquire publication on supported compiler backends. The library does not perform internal locking, does not allocate, and does not provide pointer-borrow APIs.

Highlights

  • Caller-owned fixed storage
  • Sized initialization with overflow checks
  • Copy-based push, pop, peek, and peek_at
  • Batch push/pop with exact transferred counts
  • Stable public ABI based on fixed-width integers and size_t
  • CMake package export and add_subdirectory support

Quick Start

#include"mring.h"#include<stdint.h>typedefstruct {
uint16_tid;
uint16_tstate;
uint32_treading;
} sample_t;
staticuint8_tstorage[8U*sizeof(sample_t)];
staticmring_tring;
intapp_init(void)
{
returnmring_init(&ring, storage, sizeof(storage), 8U, sizeof(sample_t));
}

Concurrency Model

  • MRING_CONCURRENCY_SINGLE_CONTEXT: default. One execution context owns one ring instance at a time. Any task/thread/ISR/core sharing requires external serialization.
  • MRING_CONCURRENCY_SPSC_ATOMIC: optional. One producer owns push; one consumer owns pop and peek. Generic snapshot queries are still quiescent or externally synchronized operations.
  • mring_push_overwrite() is not a concurrent SPSC primitive. In atomic mode it returns MRING_ERR_UNSUPPORTED.

Build

CMake

cmake -S . -B build -DMRING_BUILD_TESTS=ON -DMRING_CONCURRENCY_MODE=single-context
cmake --build build
ctest --test-dir build

Make

make

CC, CPPFLAGS, CFLAGS, and LDFLAGS are honored.

Documentation

Release Policy

Releases are tag-based. The repository workflow only creates GitHub releases for pushed tags matching v*; branch pushes do not create releases.

About

A minimalist C99 library for generic, ISR-safe ring buffers in embedded systems. Aimed at zero-allocation usage, SPSC scenarios, and predictable behavior on microcontrollers.

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages