Speed up Frame printing to (finally) solve missing AVCLAN bus frames

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Allen Hill
2026-08-13 17:34:15 -07:00
parent 66dd441610
commit 0bef565564
4 changed files with 226 additions and 30 deletions
+19 -2
View File
@@ -3,6 +3,8 @@
#pragma once
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
@@ -11,10 +13,25 @@ extern "C" {
// functions. Assumptions/invariants:
// - stdin MUST be non-blocking (ie. getchar() returns EOF immediately when
// empty). Necessary to avoid stalling the REPL poll loop.
// - stdout is *raw* — no '\n' -> "\r\n" translation: bare LF and binary frame
// payloads (fwrite) are emitted verbatim
// - stdout is *raw*. There is no '\n' -> "\r\n" translation. The port does not
// change a bare LF or a binary frame payload. Writes through
// <stdio.h> and writes through stdio_write_nonblock() must reach the same
// stream, in order.
void stdio_init(void);
// Queue a buffer onto stdout--if it has space, or return false.
//
// If stdout cannot accept all `len` bytes now, the function queues
// a "\n!\n" indicator onto stdout, overwriting the last 3 chars if stdout is
// full. The caller must not assume that the buffer went out.
//
// A port MUST emit that indicator for every dropped buffer, and MUST be able to
// emit it even if stdout is full. A reader detects the loss as a line that
// holds only '!'. In the overwrite case the buffer in front of that line is
// truncated, so a reader MUST tolerate one malformed buffer there. The return
// value is useful only for diagnostics.
bool stdio_write_nonblock(const void *buf, size_t len);
#ifdef __cplusplus
}
#endif