QUEUE_LIB Embedded C library v1.0.0
Data Structures | Enumerations | Functions
queue.h File Reference

Deterministic, generic FIFO queue for embedded / safety-critical systems. More...

#include <stdint.h>
#include <stdbool.h>
Include dependency graph for queue.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  queue_t
 FIFO queue control structure. More...
 

Enumerations

enum  queue_status_t { QUEUE_OK = 0U , QUEUE_FULL = 1U , QUEUE_EMPTY = 2U , QUEUE_ERROR = 3U }
 Queue operation status codes. More...
 

Functions

queue_status_t queue_init (queue_t *q, void *buffer, uint16_t buffer_element_size, uint16_t queue_capacity)
 Initialize a queue instance. More...
 
queue_status_t queue_push (queue_t *q, const void *item)
 Push (enqueue) one element into the queue. More...
 
queue_status_t queue_pop (queue_t *q, void *item)
 Pop (dequeue) one element from the queue. More...
 
bool queue_is_empty (const queue_t *q)
 Check if queue is empty. More...
 
bool queue_is_full (const queue_t *q)
 Check if queue is full. More...
 

Detailed Description

Deterministic, generic FIFO queue for embedded / safety-critical systems.

Author
niwciu (niwci.nosp@m.u@gm.nosp@m.ail.c.nosp@m.om)
Version
1.0.3
Date
2025-11-06

This module implements a type-agnostic, deterministic FIFO queue designed for embedded and safety-critical environments (IEC 61508 / ISO 26262).

The implementation:

MISRA Deviation: DV-QUEUE-001 (Rule 11.4) Controlled cast from void* to uint8_t* for raw byte-level copy operations. Safe and justified — no aliasing or type reinterpretation occurs.

Note
The caller is responsible for providing a buffer of at least (element_size × capacity) bytes, properly aligned for the stored element type.
The internal helper copy_bytes(uint8_t*, const uint8_t*, uint16_t) is tested indirectly via unit tests in the DV_QUEUE_001 suite, covering NULL pointers and boundary conditions.