code wiki / (root) / nx_libcheck.nx

nx_libcheck.nx

buildroot/runtime/nx_libcheck.nx

17129 B372 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_libcheck.nx -- DUPLICATE-LIBRARY DIVERGENCE DETECTOR. The instrument that would have caught BOTH defects that cost this session real time (seq1423 dual-copy, seq1437 silent revert). THE INSIGHT: when a library exists in two directories, THE COPIES ARE EACH OTHER'S CONTROL. Nothing else needs to be known about them. If they are byte-identical the tree is coherent; the moment they differ, EITHER someone edited one copy and forgot the other (seq207 dual-copy -- organs under runtime/ resolve one, organs under _hdl_build/ resolve the other, so half the ecosystem silently keeps old behaviour) OR one copy was reverted underneath you (seq48/132/140 -- a sibling ships an old lib into buildroot and the NEXT BUILD STILL SUCCEEDS, shipping the old behaviour with RC=0 and no diagnostic anywhere). Both are invisible at build time. Both are one hash comparison away from being obvious. FAIL-CLOSED AND DATA-DRIVEN: divergence is a FAILURE by default. Some same-named files are legitimately DIFFERENT ORGANS -- _hdl_build/nx_fs.nx is a coreutils multitool while the live nx_fs is nx_fsops -- so the exceptions live in a CONF (rule 11), never in this code. An unlisted divergence exits 3. A conf that cannot be read simply means zero exceptions, which fails LOUDER rather than quieter. Run it BEFORE a build that touches a shared lib. Cheap enough to run every time. EXIT: 0 all duplicates identical (or expected) - 2 usage - 3 UNEXPECTED divergence - 4 no duplicates found license_tier: ORIGINAL No hw writes (Rule 26).

dependencies 1 imports · 0 importers

nx_syscalls.nx nx_libcheck.nx

imports: nx_syscalls.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main sys_mmap sys_openat_rd sys_read sys_close lc_cat sys_write sys_getdents64 dirent_reclen dirent_name lc_is_nx lc_len lc_hash sys_openat_rd ↻ sys_mmap ↻ sys_read ↻ sys_close ↻ sys_munmap lc_canon sys_openat_rd ↻ sys_mmap ↻ sys_read ↻ sys_close ↻ sys_munmap ↻ lc_streq lc_num sys_mmap ↻ sys_munmap ↻

structs

none

consts

22const LC_MAXF: i64 = 24576 // runtime/ alone holds 10748 .nx and _hdl_build/ 6726 (measured), so 4096
26const LC_ARENA: i64 = 2097152
27const LC_DBUF: i64 = 262144
28const LC_FBUF: i64 = 2097152
29const LC_PATH: i64 = 1024
30const LC_MSG: i64 = 8192
31const LC_CONF: i64 = 65536
32const LC_FNV_BASIS: i64 = 1469598103934665603
33const LC_FNV_PRIME: i64 = 1099511628211
34const LC_STDOUT: i64 = 1
35const LC_NL: i64 = 10
36const LC_HASH_C: i64 = 35
37const LC_DOT: i64 = 46
38const LC_SLASH: i64 = 47
39const LC_EXIT_USAGE: i64 = 2
40const LC_EXIT_DIVERGED: i64 = 3
41const LC_EXIT_NODUPES: i64 = 4
42const LC_EXIT_INDEXCAP: i64 = 5

functions

44func lc_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
called by 1: lc_is_nx
45func lc_cat(d: *u8, off: i64, s: *u8) -> i64
called by 1: main
50func lc_num(d: *u8, off: i64, v: i64) -> i64
called by 1: main calls 2: sys_mmapsys_munmap
70func lc_canon(path: *u8) -> i64
146func lc_streq(a: *u8, b: *u8) -> i64
called by 1: main
153func lc_is_nx(s: *u8) -> i64
called by 1: main calls 1: lc_len
162func lc_hash(path: *u8, szout: *i64) -> i64
184func main(argc: i64, argv: *i64) -> i64