lumbda/c
russell@unturf.com 269d3be756
c: get-output-string + write-char honor binary data on string ports
Two pre-existing defects in c/builtins.c made (open-output-string)
unusable for binary emit:

- bi_get_output_string ran the buffer through make_string_from_cstr,
  which calls strlen. Any 0x00 in the payload truncated body at
  that byte. Use port's known str_len directly via make_string.

- bi_write_char ignored string-port destinations entirely — it
  pulled AS_PORT(p)->fp (NULL for string ports), fell back to
  stdout, and silently routed gate bytes to terminal output
  instead of the port buffer. Route to port_write_str when target
  port kind is PORT_STRING, matching bi_write_string's behavior.

Surfaced while validating the precise-GC fix against ecdsa's
Phase B emit (writes 56-byte op records full of embedded nulls
through a string-output port, get-output-string at the end).
With these fixes ecdsa's n+1=64 emit drops a 333 MB binary in
42.6 seconds — pre-fix it timed out at 600 s with a 17-byte
header-only file (strlen truncated body at byte 1; the visible
gate bytes had been escaping to stdout the whole time).

Binary roundtrip test (write n bytes alternating x / 0x00 to
output-string port, read back via get-output-string):
  n=10      len=10      ok
  n=1000    len=1000    ok
  n=100000  len=100000  ok

All upstream tests still pass (88/88 c-test, 4/4 regression,
205/205 functional, zoe across tiers).
2026-06-07 17:18:57 -04:00
..
.gitignore rename: uncommonlisp -> lumbda throughout the repo 2026-04-19 10:20:11 -04:00
bench.c c: precise GC tracing for NaN-boxed Values 2026-06-07 17:18:45 -04:00
bignum.c c-tier bignum — arbitrary-precision integers unblock secp256k1 widths 2026-06-06 20:23:37 -04:00
builtins.c c: get-output-string + write-char honor binary data on string ports 2026-06-07 17:18:57 -04:00
eval.c c: precise GC tracing for NaN-boxed Values 2026-06-07 17:18:45 -04:00
gc.c c: precise GC tracing for NaN-boxed Values 2026-06-07 17:18:45 -04:00
jit.c rename: uncommonlisp -> lumbda throughout the repo 2026-04-19 10:20:11 -04:00
jit.h rename: uncommonlisp -> lumbda throughout the repo 2026-04-19 10:20:11 -04:00
lumbda.h c: precise GC tracing for NaN-boxed Values 2026-06-07 17:18:45 -04:00
main.c c: precise GC tracing for NaN-boxed Values 2026-06-07 17:18:45 -04:00
Makefile c: precise GC tracing for NaN-boxed Values 2026-06-07 17:18:45 -04:00
portal.c c: precise GC tracing for NaN-boxed Values 2026-06-07 17:18:45 -04:00
printer.c c-tier bignum — arbitrary-precision integers unblock secp256k1 widths 2026-06-06 20:23:37 -04:00
reader.c c: precise GC tracing for NaN-boxed Values 2026-06-07 17:18:45 -04:00
test.c c: precise GC tracing for NaN-boxed Values 2026-06-07 17:18:45 -04:00
types.c c: precise GC tracing for NaN-boxed Values 2026-06-07 17:18:45 -04:00
vm.c c: precise GC tracing for NaN-boxed Values 2026-06-07 17:18:45 -04:00