Ring Buffer with Overwrite Mode
Implement a ring buffer for a debug trace log that never blocks the producer: when full, the oldest entry is discarded to make room for the newest.
Constraints
- Capacity is 16 entries of uint32_t.
- `void trace_push(uint32_t value)` never fails.
- `int trace_pop(uint32_t *out)` returns 0 on success, -1 when empty.
- On overwrite, the read index must advance so the buffer stays consistent.
- Must report the correct count after overwrites.
- No dynamic memory.
1#include <stdint.h>2 3#define TRACE_CAP 164 5void trace_push(uint32_t value);6int trace_pop(uint32_t *out);7int trace_count(void);