code wiki / _hdl_build / nx_gatelib.nx
nx_gatelib.nx
buildroot/runtime/_hdl_build/nx_gatelib.nx
about
nx_gatelib.nx -- the shared substrate under the gate-coverage scanners.
===== WHY THIS EXISTS ============================================
nx_gatescan (does anything test this organ?) and nx_gatequality (how much
of it does that test reach?) are two questions over the same tree, and
they were written as two files that duplicated NINE functions between
them: the directory walk, file read, path join, the .nx and gate-name
predicates, the ends-with helper, the string length helper, and the
gate-to-organ attribution rule.
★I WROTE BOTH COPIES, IN ONE SESSION, WHILE BUILDING TOOLS TO FIND
EXACTLY THIS CLASS OF PROBLEM. The tree walk was already named as debt
twice -- filed rather than fixed, on the reasoning that extracting it
would touch other consumers -- and then the very next organ added a fourth
copy. Naming a debt is not paying it, and a filed debt keeps accruing.
===== THE ATTRIBUTION RULE IS THE REAL REASON TO SHARE =========
The mechanical helpers are cheap to duplicate; the attribution rule is
not. It decides whether a gate named <organ>_<aspect>_test.nx counts as
covering <organ>, and getting it wrong is how the first gatescan run
reported 1019 ungated organs when the true figure was 963. With two
copies, one can be corrected and the other silently left behind -- and the
two tools would then disagree about which organs are gated while both
looked healthy. ★A RULE THAT TWO TOOLS MUST AGREE ON BELONGS IN ONE
PLACE, and that is a stronger reason than the line count.
===== WHAT IS NOT SHARED =========================================
The gates of both consumers keep their own INDEPENDENT re-derivations of
these rules. That is deliberate and is not duplication in the sense that
matters: a gate calling the code under test can only confirm it is
self-consistent, whereas a second implementation agreeing is evidence.
The same reasoning kept nx_arrhenius and nx_stability as separate
Arrhenius implementations -- and that decision is what caught the dead
primitive, so it has already paid for itself once.
license_tier: ORIGINAL
dependencies 3 imports · 10 importers
imports: nx_syscalls.nxnx_eco_graph.nxnx_import_scan.nx
imported by: nx_codewiki.nxnx_codewiki_ask.nxnx_codewiki_gate.nxnx_codewiki_lib.nxnx_dupfunc.nxnx_dupfunc_test.nxnx_gatelib_test.nxnx_gatelib_walkparity_gate.nxnx_gatequality.nxnx_gatescan.nx
structs
| none |
consts
| 43 | const GL_MAGIC_3900: i64 = 3900 |
| 44 | const GL_MAGIC_131072: i64 = 131072 |
| 45 | const GL_MAGIC_1024: i64 = 1024 |
| 47 | const GL_FILECAP: i64 = 262144 |
functions
| 49 | func gl_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 51 | func gl_join(path: *u8, base_n: i64, nm: *u8) -> i64 called by 1: gl_walk |
| 59 | func gl_read(path: *u8, buf: *u8, cap: i64) -> i64 |
| 72 | func gl_isdotdot(nm: *u8) -> i64 called by 1: gl_walk |
| 77 | func gl_is_nx(nm: *u8, n: i64) -> i64 |
| 85 | func gl_ends(name: *u8, n: i64, suf: *u8) -> i64 |
| 94 | func gl_is_gate_name(name: *u8, n: i64) -> i64 |
| 102 | func gl_is_ident(c: i64) -> i64 |
| 121 | func gl_attribute(g: *EcoGraph, name: *u8, n: i64, buf: *u8) -> i64 |
| 144 | func gl_has_token(hay: *u8, hn: i64, name: *u8, nl: i64) -> i64 |
| 177 | func gl_walk(g: *EcoGraph, path: *u8, path_n: i64, filebuf: *u8, aoff: *i64, alen: *i64, called by 7: mainmaingl_walkmainmainmain+1 calls 16: sys_openat_rdsys_mmapsys_getdents64dirent_typedirent_namegl_isdotdot+10 |
| 248 | func gl_extract_funcs(src: *u8, n: i64, names: *u8, offs: *i64, lens: *i64, spans: *i64, cap: i64) -> i64 |
| 296 | func gl_strip_comments(src: *u8, n: i64, dst: *u8) -> i64 |