Commit 80910267
80910267e8c4Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 4 files · +2 added · ~2 modified
Description
Move the allocation-free File/IO handle ops to libspinel_rt.a
Following the sp_gc.c / sp_fiber.c / sp_system.c slimming pattern, move the libc-only File/IO handle ops out of sp_runtime.h into lib/sp_io.c (+ lib/sp_io.h for the sp_File struct and prototypes): File.open, the new IO.pipe support (sp_io_make_pipe / sp_io_fdopen), write, close, closed?, puts, print, flush, eof?, and the fin/scan GC callbacks. They only touch libc plus the external sp_gc_alloc / sp_raise_cls and sp_gc.h's inline sp_mark_string, so they move cleanly and stay perf-neutral (none were inline-hot).
The string-returning readers (gets / read / read_n / path) stay inline in sp_runtime.h: they allocate via the hot static sp_str_alloc, whose per-TU sp_str_heap can't be shared across translation units without externalizing the string heap (a separate, more delicate change). The compiler itself only uses File.read(path) (sp_file_read, also unmoved), so moving the handle ops is bootstrap-safe.
sp_io.c uses _pipe / _O_BINARY (<io.h>/<fcntl.h>) on _WIN32 and pipe / <unistd.h> elsewhere. Wired into libspinel_rt.a + the install set. Gate green (test 861 / bench 57 / optcarrot / self-host fixpoint); IO.pipe + File still work.
Refs #1282.
Co-Authored-By: Claude Opus 4.8 [email protected]
Details
- Commit
- 80910267e8c4
- Parent
- 4f3009ebeb75
MakefilemodifiedView file
@mkdir -p build $(CC) -c -O2 -Wno-all $(SEC_FLAGS) -Ilib lib/sp_net.c -o build/sp_net.obuild/sp_io.o: lib/sp_io.c lib/sp_io.h lib/sp_gc.h lib/sp_types.h @mkdir -p build $(CC) -c -O2 -Wno-all $(SEC_FLAGS) -Ilib lib/sp_io.c -o build/sp_io.oSP_RT_LIB = lib/libspinel_rt.a$(SP_RT_LIB): $(RE_OBJ) build/sp_bigint.o build/sp_crypto.o build/sp_pack.o build/sp_strscan.o build/sp_time.o build/sp_core.o build/sp_net.o build/sp_system.o build/sp_gc.o build/sp_fiber.o$(SP_RT_LIB): $(RE_OBJ) build/sp_bigint.o build/sp_crypto.o build/sp_pack.o build/sp_strscan.o build/sp_time.o build/sp_core.o build/sp_net.o build/sp_system.o build/sp_gc.o build/sp_fiber.o build/sp_io.o ar rcs $@ $^regexp: $(SP_RT_LIB) install -m 644 lib/sp_system.h $(SPNLDIR)/lib/ install -m 644 lib/sp_gc.h $(SPNLDIR)/lib/ install -m 644 lib/sp_fiber.h $(SPNLDIR)/lib/ install -m 644 lib/sp_io.h $(SPNLDIR)/lib/ install -m 644 lib/sp_time.h $(SPNLDIR)/lib/ install -m 644 lib/sp_net.h $(SPNLDIR)/lib/ install -m 644 lib/*.rb $(SPNLDIR)/lib/lib/sp_io.caddedView file
Loading diff…
lib/sp_io.haddedView file
Loading diff…
lib/sp_runtime.hmodifiedView file
Loading diff…