code wiki / _hdl_build / nx_adopt_lib.nx

nx_adopt_lib.nx

buildroot/runtime/_hdl_build/nx_adopt_lib.nx

6052 B121 linesdepth 2pulls 2 transitivereach 1 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_adopt_lib.nx -- PURE core of the ADOPTION CENSUS (operator priority, seq1410). THE LAW THIS ENFORCES: **THIS ECOSYSTEM'S BOTTLENECK IS NOT BUILDING PRIMITIVES, IT IS ADOPTING THEM.** Measured three times on 2026-07-30 alone: cpu-feature-detect existed with a KAT and was registered nowhere (seq1359) · ss_close existed with 133 openers and 1 closer (seq1347) · nx_hw_cpu_count exists, is CORRECT (sched_getaffinity, cgroup-safe), and has ZERO external callers in 19,823 files (seq1410) while nx_torrent_get hardcodes MAXP=32. A build-only definition of done is why. ==> A ZERO-CALLER CAPABILITY PRIMITIVE IS A RED DEFECT, NOT A COMPLETED FEATURE. ★SCALE IS THE DESIGN PROBLEM, and the answer is the same one seq1318 taught: the naive census greps the corpus ONCE PER PRIMITIVE = O(primitives x corpus) = ~50 GB of scanning for 500 primitives. Instead we walk the corpus TWICE -- pass A collects definitions into a hash table, pass B counts every identifier against it with O(1) lookups -- so the cost is O(corpus), independent of how many primitives exist. LAW (third application today): ONE PASS OVER THE DATA, THEN ANSWER EVERY QUESTION FROM IT. Rule 15: nx_funcmine already proved this shape (bucket-chained, O(files+funcs)). Its helpers live inside an organ with a main(), so they cannot be imported -- THAT is why they are re-declared here, in a LIB, so the next consumer imports instead of copying. nx_funcmine should migrate onto this lib. license_tier: ORIGINAL Pure. No hw writes (Rule 26).

dependencies 1 imports · 1 importers

nx_syscalls.nx nx_adopt_lib.nx nx_adopt.nx

imports: nx_syscalls.nx

imported by: nx_adopt.nx

structs

none

consts

22const AD_FNV_OFF: i64 = 1469598103934665603
23const AD_FNV_PRIME: i64 = 1099511628211
24const AD_EMPTY: i64 = 0

functions

27func ad_isid(c: i64) -> i64
called by 2: mainad_id_start
36func ad_id_start(c: i64) -> i64
called by 1: main calls 1: ad_isid
41func ad_ends_nx(nm: *u8) -> i64
called by 1: main
51func ad_fnv(buf: *u8, s: i64, e: i64) -> i64
called by 1: main
60func ad_slot(h: i64, cap: i64) -> i64
called by 1: main
67func ad_next(slot: i64, cap: i64) -> i64 { return (slot + 1) & (cap - 1) }
called by 1: main
70func ad_name_eq(arena: *u8, noff: i64, nlen: i64, buf: *u8, s: i64, e: i64) -> i64
called by 1: main
81func ad_is_adopted(external: i64) -> i64
called by 2: mainad_is_debt
107func ad_is_public(arena: *u8, noff: i64, nlen: i64) -> i64
called by 1: main
117func ad_is_debt(external: i64, is_public: i64) -> i64
called by 1: main calls 1: ad_is_adopted