|
QUEUE_LIB Embedded C library v1.0.0
|
Generic FIFO queue implementation for embedded safety-critical use. More...
#include "queue.h"
Macros | |
| #define | PRIVATE static |
Functions | |
| PRIVATE void | copy_bytes (uint8_t *dst, const uint8_t *src, uint16_t size) |
| Deterministic byte-wise copy of memory. More... | |
| queue_status_t | queue_init (queue_t *q, void *buffer, uint16_t element_size, uint16_t capacity) |
| Initialize a queue. More... | |
| queue_status_t | queue_push (queue_t *q, const void *item) |
| Push an element into the queue. More... | |
| queue_status_t | queue_pop (queue_t *q, void *item) |
| Pop an element from the queue. More... | |
| bool | queue_is_empty (const queue_t *q) |
| Check whether queue is empty. More... | |
| bool | queue_is_full (const queue_t *q) |
| Check whether queue is full. More... | |
Generic FIFO queue implementation for embedded safety-critical use.
Provides deterministic enqueue/dequeue operations on a caller-supplied memory buffer. Implementation uses explicit byte-wise copying and avoids standard library dependencies to ensure deterministic behavior.
MISRA Deviation: DV-QUEUE-001 (Rule 11.4) Controlled cast from void* to uint8_t* for raw byte access. Safe because data is not type-reinterpreted.
copy_bytes(uint8_t*, const uint8_t*, uint16_t) is tested indirectly via DV_QUEUE_001 unit tests, including:| #define PRIVATE static |
| PRIVATE void copy_bytes | ( | uint8_t * | dst, |
| const uint8_t * | src, | ||
| uint16_t | size | ||
| ) |
Deterministic byte-wise copy of memory.
| [out] | dst | Destination buffer. |
| [in] | src | Source buffer. |
| [in] | size | Number of bytes to copy. |
Used internally by queue_push/queue_pop to implement type-agnostic element storage. The PRIVATE macro controls visibility:

| queue_status_t queue_init | ( | queue_t * | q, |
| void * | buffer, | ||
| uint16_t | element_size, | ||
| uint16_t | capacity | ||
| ) |
Initialize a queue.
| [in,out] | q | Pointer to queue control structure. |
| [in] | buffer | Pointer to storage buffer. |
| [in] | element_size | Element size in bytes (>0). |
| [in] | capacity | Number of elements (>0). |
| QUEUE_OK | Successful initialization. |
| QUEUE_ERROR | Invalid parameters. |
| bool queue_is_empty | ( | const queue_t * | q | ) |
Check whether queue is empty.
| [in] | q | Pointer to queue instance. |
| bool queue_is_full | ( | const queue_t * | q | ) |
Check whether queue is full.
| [in] | q | Pointer to queue instance. |
| queue_status_t queue_pop | ( | queue_t * | q, |
| void * | item | ||
| ) |
Pop an element from the queue.
| [in,out] | q | Pointer to queue instance. |
| [out] | item | Pointer to destination buffer. |
| QUEUE_OK | Success. |
| QUEUE_EMPTY | Queue empty. |
| QUEUE_ERROR | Invalid parameters. |

| queue_status_t queue_push | ( | queue_t * | q, |
| const void * | item | ||
| ) |
Push an element into the queue.
| [in,out] | q | Pointer to queue instance. |
| [in] | item | Pointer to data to add (element_size bytes). |
| QUEUE_OK | Success. |
| QUEUE_FULL | Queue full. |
| QUEUE_ERROR | Invalid parameters. |
