code wiki / _hdl_build / nx_ag_lib.nx
nx_ag_lib.nx
buildroot/runtime/_hdl_build/nx_ag_lib.nx
about
nx_ag_lib.nx -- shared gate helpers (atoi / itoa / strlen / single-read) extracted from nx_gated_edit_gate
+ nx_consol_apply_gate, which carried byte-identical copies (rule 15: pattern in 2+ -> shared/). Bodies are
VERBATIM -> behaviour-preserving by construction; proven by re-running the consumer gate GREEN after delegation.
license_tier: ORIGINAL No hw writes (Rule 26). Consumers: nx_gated_edit_gate (+ nx_consol_apply_gate pending NAS sync).
dependencies 1 imports · 2 importers
imports: nx_syscalls.nx
imported by: nx_gated_edit_gate.nxnx_gated_edit_multi_gate.nx
structs
| none |
consts
| none |
functions
| 6 | func ag_atoi(s: *u8) -> i64 { var v: i64 = 0; var i: i64 = 0; while s[i] != (0 as u8) { let c: i64 = s[i] as i64; if c >= 48 { if c <= 57 { v = v * 10 + (c - 48) } } i = i + 1 } return v } |
| 7 | func ag_itoa(dst: *u8, v: i64) -> i64 { var m: i64 = v; let t: *u8 = sys_mmap(24); var k: i64 = 0; if m == 0 { t[0] = 48 as u8; k = 1 } while m > 0 { t[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 } var i: i64 = 0; while i < k { dst[i] = t[k - 1 - i]; i = i + 1 } dst[k] = 0 as u8; return k } |
| 8 | func ag_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 9 | func ag_read(path: *u8, buf: *u8, cap: i64) -> i64 { let fd: i64 = sys_openat_rd(path); if fd < 0 { return 0 - 1 } let n: i64 = sys_read(fd, buf, cap - 1); sys_close(fd); return n } |