code wiki / (root) / nx_itoa_candidate_t228.nx

nx_itoa_candidate_t228.nx

buildroot/runtime/nx_itoa_candidate_t228.nx

4230 B79 linesdepth 2pulls 2 transitivereach 1 importersview sourcekind librarytopic itoa
docsdependenciesstructsconstsfunctions

about

nx_itoa_lib.nx -- THE shared integer->decimal emitter. ONE copy, so the corpus stops retyping it. LIFTED, NEVER COPIED (2026-07-31, debt 1785557603). ccz_cat_num was already correct, already MSB-first, already zero-allocation, and already had 10+ callers -- it was simply IMPRISONED inside nx_crashresume_census_core.nx, a crash-resume census organ. Seven files imported an entire census just to print an integer. That import cost, NOT ignorance of the primitive, is why ~87 sites hand-rolled their own. LAW: WHEN A CORRECT PRIMITIVE IS RETYPED, MEASURE ITS IMPORT COST BEFORE BLAMING DISCOVERABILITY -- people do not retype what is CHEAP to reach. THE LEAK WAS NEVER IN THE PRIMITIVE, IT WAS IN THE MISSING WRAPPER. ccz_cat_num allocates nothing. What every clone hand-rolled was the fd shim around it, e.g. nx_lock_reap_gate.g_putn: let b: *u8 = sys_mmap(32); let e: i64 = ccz_cat_num(b, 0, v); sys_write(1, b, e); return 0 -- one mmap per call, never freed. nxi_fd below is that shim, written ONCE and always freeing. The census now imports THIS file; NishiLang import is transitive (verified: nx_lock_reap_gate imports only nx_syscalls + nx_lock_reap_core, and resolves ccz_cat_num through the core), so all existing callers keep resolving with no edit. LAYERING: lives in runtime/ so BOTH runtime/ and _hdl_build/ can import it. license_tier: ORIGINAL No hw writes (Rule 26).

dependencies 1 imports · 1 importers

nx_syscalls.nx nx_itoa_candidate_t228.nx nx_itoa_gate_t228.nx

imports: nx_syscalls.nx

imported by: nx_itoa_gate_t228.nx

structs

none

consts

27const CCZ_ASCII_0: i64 = 48
28const CCZ_MINUS: i64 = 45
29const CCZ_DEC: i64 = 10
37const NXI_BUF: i64 = 24
38const NXI_STDOUT: i64 = 1
39const NXI_STDERR: i64 = 2

functions

30func ccz_cat_num(buf: *u8, off: i64, v: i64) -> i64
called by 2: nxi_fditg_case calls 1: nxi_buf
43func nxi_fd(fd: i64, v: i64) -> i64
51func nxi_out(v: i64) -> i64 { return nxi_fd(NXI_STDOUT, v) }
calls 1: nxi_fd
52func nxi_err(v: i64) -> i64 { return nxi_fd(NXI_STDERR, v) }
calls 1: nxi_fd
64func nxi_buf(dst: *u8, off: i64, v: i64) -> i64
called by 2: ccz_cat_numitg_case