code wiki / _hdl_build / nx_g_pn_lib.nx
nx_g_pn_lib.nx source
↩ module page · 10 lines · 832 B
1// nx_g_pn_lib.nx -- single-responsibility shared helper: g_pn (gate integer writer; handles negatives).
2// This is the SUPERSET variant (funcmine's g_pn x78 majority group). Subset copies lacking the negative
3// branch are DIFFERENT bodies -> the remover's self-check reports them VARIANT and leaves them alone. license_tier: ORIGINAL
4import "nx_syscalls.nx"
5import "nx_itoa_lib.nx" // shared MSB-first emitter (zero-alloc)
6// MIGRATED to the shared emitter (debt 1785563586). The old body mmapped a scratch buffer
7// per call and never freed it. At PAGE granularity that is 4096B leaked PER CALL -- the
8// defect that took 28.5GB of a 36GB host in nx_ts_lumadiff (2MB input, ~3.66M calls).
9// nxi_* is MSB-first, allocates NOTHING, and emits identical bytes including the sign.
10func g_pn(v: i64) -> i64 { nxi_out(v); return 0 }