Interrupt-Safe Ring Buffer
A 64-byte buffer the UART interrupt fills and main() drains.
Volatile indices, no locks, no malloc.
12 3 /* power of two: wrap is a mask */4 5static uint8_t buf[RB_SIZE];6static volatile uint8_t head, tail;7 8/* Runs in the UART RX interrupt. */9int rb_push(uint8_t d)10{11 uint8_t next = (head + 1u) & (RB_SIZE - 1u);12 if (next == tail) return -1; /* full */13 buf[head] = d;14 head = next; /* publish after the write */15 return 0;16}17 18int rb_pop(uint8_t *d)19{20 21}