nx_varcensus_lib.nx
buildroot/runtime/nx_varcensus_lib.nx
about
nx_varcensus_lib.nx -- the VaM corpus census's DATA-DRIVEN pieces, importable by the CLI (nx_varcensus) and its gate.
(1) a growable byte ARENA -- tables store OFFSETS into it, so growth (a bigger mapping plus a copy) never leaves a
dangling pointer; an i64 vector rides the same arena in 8-byte cells.
(2) a growable string COUNTER -- FNV-1a, open addressing, the slot table doubled at half load; entries are kept in
FIRST-SEEN ORDER so a report reads in the order the corpus was walked (and the walk itself is sorted).
(3) the RULES conf (the classifier is DATA, never code). Rows, TAB separated, '#' comments:
role|format <TAB> <class> <TAB> <kind> <TAB> <pattern> [<TAB> <kind> <TAB> <pattern>] both conditions must hold
screen <TAB> <reason letter A-Z> <TAB> class <TAB> <role class> a member of that class sets the reason
screen <TAB> <reason letter A-Z> <TAB> namecontains <TAB> <token> the package id contains the token
deptag <TAB> <tag> <TAB> prefix <TAB> <dependency id prefix> a direct dependency with that prefix
kinds: dirent (name ends with a slash) | exact | prefix | suffix | contains. Matching is on LOWERCASED names and
lowercased patterns. Within one axis the FIRST matching rule wins, and a member no rule matches lands in the implicit
class `other` of that axis -- so each axis is a PARTITION of the members by construction, and the census asserts the
sum. A row this parser does not understand is an ERROR counted with its line number: a malformed rules file cannot
produce a census (the CLI refuses), because a silently skipped rule moves members into `other` with no trace.
license_tier: ORIGINAL No hw writes (Rule 26).
dependencies 1 imports · 3 importers
imports: nx_syscalls.nx
imported by: nx_varcensus.nxnx_varcensus_candidate_t139.nxnx_varcensus_gate.nx
structs
| none |
consts
| 20 | const VCL_PAD: i64 = 16 |
| 21 | const VCL_ARENA_INIT: i64 = 65536 |
| 22 | const VCL_CELL: i64 = 8 |
| 23 | const VCL_A_PTR: i64 = 0 |
| 24 | const VCL_A_USED: i64 = 1 |
| 25 | const VCL_A_CAP: i64 = 2 |
| 26 | const VCL_A_N: i64 = 3 |
| 28 | const VCL_TAB: i64 = 9 |
| 29 | const VCL_LF: i64 = 10 |
| 30 | const VCL_CR: i64 = 13 |
| 31 | const VCL_SPACE: i64 = 32 |
| 32 | const VCL_HASHMARK: i64 = 35 |
| 33 | const VCL_SLASH: i64 = 47 |
| 34 | const VCL_DOT: i64 = 46 |
| 35 | const VCL_UPPER_A: i64 = 65 |
| 36 | const VCL_UPPER_Z: i64 = 90 |
| 37 | const VCL_CASE_OFF: i64 = 32 |
| 38 | const VCL_ASCII_0: i64 = 48 |
| 39 | const VCL_DEC: i64 = 10 |
| 42 | const VCL_FNV_BASIS: i64 = 2166136261 |
| 43 | const VCL_FNV_PRIME: i64 = 16777619 |
| 44 | const VCL_U32_MASK: i64 = 0xffffffff |
| 45 | const VCL_SLOTS_INIT: i64 = 256 |
| 46 | const VCL_E_W: i64 = 4 |
| 47 | const VCL_E_HASH: i64 = 0 |
| 48 | const VCL_E_KOFF: i64 = 1 |
| 49 | const VCL_E_KLEN: i64 = 2 |
| 50 | const VCL_E_COUNT: i64 = 3 |
| 51 | const VCL_C_SLOTS: i64 = 0 |
| 52 | const VCL_C_CAP: i64 = 1 |
| 53 | const VCL_C_NENT: i64 = 2 |
| 54 | const VCL_C_ENTS: i64 = 3 |
| 55 | const VCL_C_KEYS: i64 = 4 |
| 56 | const VCL_C_N: i64 = 5 |
| 59 | const VCL_K_NONE: i64 = 0 |
| 60 | const VCL_K_DIRENT: i64 = 1 |
| 61 | const VCL_K_EXACT: i64 = 2 |
| 62 | const VCL_K_PREFIX: i64 = 3 |
| 63 | const VCL_K_SUFFIX: i64 = 4 |
| 64 | const VCL_K_CONTAINS: i64 = 5 |
| 65 | const VCL_AX_ROLE: i64 = 0 |
| 66 | const VCL_AX_FORMAT: i64 = 1 |
| 67 | const VCL_AX_N: i64 = 2 |
| 68 | const VCL_R_W: i64 = 8 |
| 69 | const VCL_R_AXIS: i64 = 0 |
| 70 | const VCL_R_CLASS: i64 = 1 |
| 71 | const VCL_R_K1: i64 = 2 |
| 72 | const VCL_R_P1: i64 = 3 |
| 73 | const VCL_R_L1: i64 = 4 |
| 74 | const VCL_R_K2: i64 = 5 |
| 75 | const VCL_R_P2: i64 = 6 |
| 76 | const VCL_R_L2: i64 = 7 |
| 77 | const VCL_S_W: i64 = 4 |
| 78 | const VCL_S_BIT: i64 = 0 |
| 79 | const VCL_S_KIND: i64 = 1 |
| 80 | const VCL_S_ARG: i64 = 2 |
| 81 | const VCL_S_LEN: i64 = 3 |
| 82 | const VCL_SK_CLASS: i64 = 1 |
| 83 | const VCL_SK_NAME: i64 = 2 |
| 84 | const VCL_T_W: i64 = 3 |
| 85 | const VCL_T_TAG: i64 = 0 |
| 86 | const VCL_T_P: i64 = 1 |
| 87 | const VCL_T_L: i64 = 2 |
| 88 | const VCL_REASONS: i64 = 26 |
| 89 | const VCL_MAX_FIELDS: i64 = 8 |
| 91 | const VCL_RS_RULES: i64 = 0 |
| 92 | const VCL_RS_NRULES: i64 = 1 |
| 93 | const VCL_RS_STR: i64 = 2 |
| 94 | const VCL_RS_CLASS_ROLE: i64 = 3 |
| 95 | const VCL_RS_CLASS_FORMAT: i64 = 4 |
| 96 | const VCL_RS_OTHER_ROLE: i64 = 5 |
| 97 | const VCL_RS_OTHER_FORMAT: i64 = 6 |
| 98 | const VCL_RS_SCREEN: i64 = 7 |
| 99 | const VCL_RS_NSCREEN: i64 = 8 |
| 100 | const VCL_RS_DEPTAG: i64 = 9 |
| 101 | const VCL_RS_NDEPTAG: i64 = 10 |
| 102 | const VCL_RS_TAGS: i64 = 11 |
| 103 | const VCL_RS_ERRORS: i64 = 12 |
| 104 | const VCL_RS_FIRST_ERR_LINE: i64 = 13 |
| 105 | const VCL_RS_N: i64 = 16 |
| 106 | const VCL_OTHER: *u8 = "other" |
functions
| 108 | func vcl_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 109 | func vcl_lc(c: i64) -> i64 { if c >= VCL_UPPER_A { if c <= VCL_UPPER_Z { return c + VCL_CASE_OFF } } return c } |
| 110 | func vcl_lower(src: *u8, n: i64, out: *u8) -> i64 |
| 116 | func vcl_eq(a: *u8, ao: i64, b: *u8, bo: i64, n: i64) -> i64 |
| 123 | func vcl_arena_new(init: i64) -> *i64 |
| 132 | func vcl_arena_reserve(a: *i64, extra: i64) -> i64 |
| 148 | func vcl_at(a: *i64, off: i64) -> *u8 { return (a[VCL_A_PTR] + off) as *u8 } |
| 149 | func vcl_used(a: *i64) -> i64 { return a[VCL_A_USED] } |
| 151 | func vcl_put(a: *i64, src: *u8, so: i64, n: i64) -> i64 |
| 162 | func vcl_app(a: *i64, src: *u8, so: i64, n: i64) -> i64 |
| 171 | func vcl_apps(a: *i64, s: *u8) -> i64 { return vcl_app(a, s, 0, vcl_slen(s)) } |
| 172 | func vcl_appc(a: *i64, c: i64) -> i64 called by 16: vc_counter_sorted_tsvvc_walkvc_kvvc_app_countsvc_counter_tsvvc_census+10 calls 1: vcl_arena_reserve |
| 179 | func vcl_appn(a: *i64, v: i64) -> i64 called by 13: vc_counter_sorted_tsvvc_walkvc_kvvc_app_countsvc_counter_tsvvc_census+7 calls 1: vcl_arena_reserve |
| 195 | func vcl_appclean(a: *i64, src: *u8, so: i64, n: i64) -> i64 called by 9: vc_counter_sorted_tsvvc_walkvc_counter_tsvvc_censusvc_counter_sorted_tsvvc_walk+3 calls 1: vcl_arena_reserve |
| 208 | func vcl_push(a: *i64, v: i64) -> i64 |
| 215 | func vcl_vec_n(a: *i64) -> i64 { return a[VCL_A_USED] / VCL_CELL } |
| 216 | func vcl_vec_at(a: *i64, i: i64) -> i64 { let cell: *i64 = (a[VCL_A_PTR] + i * VCL_CELL) as *i64; return cell[0] } |
| 219 | func vcl_hash(s: *u8, so: i64, n: i64) -> i64 |
| 229 | func vcl_counter_new() -> *i64 |
| 238 | func vcl_ent(c: *i64, idx: i64) -> *i64 |
| 242 | func vcl_counter_n(c: *i64) -> i64 { return c[VCL_C_NENT] } |
| 243 | func vcl_counter_count(c: *i64, idx: i64) -> i64 { let e: *i64 = vcl_ent(c, idx); return e[VCL_E_COUNT] } called by 9: vc_rank_beforevc_counter_sorted_tsvvc_counter_tsvvc_censusvc_rank_beforevc_counter_sorted_tsv+3 calls 1: vcl_ent |
| 244 | func vcl_counter_key(c: *i64, idx: i64) -> *u8 { let e: *i64 = vcl_ent(c, idx); return vcl_at(c[VCL_C_KEYS] as *i64, e[VCL_E_KOFF]) } |
| 245 | func vcl_counter_klen(c: *i64, idx: i64) -> i64 { let e: *i64 = vcl_ent(c, idx); return e[VCL_E_KLEN] } called by 4: vc_counter_sorted_tsvvc_counter_tsvvc_counter_sorted_tsvvc_counter_tsv calls 1: vcl_ent |
| 246 | func vcl_counter_rehash(c: *i64, ncap: i64) -> i64 |
| 264 | func vcl_counter_add(c: *i64, src: *u8, so: i64, n: i64, inc: i64) -> i64 |
| 296 | func vcl_counter_find(c: *i64, src: *u8, so: i64, n: i64) -> i64 |
| 315 | func vcl_kind(src: *u8, so: i64, n: i64) -> i64 |
| 325 | func vcl_field_is(src: *u8, so: i64, n: i64, lit: *u8) -> i64 |
| 330 | func vcl_put_lower(str: *i64, src: *u8, so: i64, n: i64) -> i64 |
| 335 | func vcl_rules_err(rs: *i64, line: i64) -> i64 called by 1: vcl_rules_parse |
| 342 | func vcl_rules_parse(text: *u8, n: i64) -> *i64 called by 3: vc_censusvc_censusmain calls 13: sys_mmapvcl_arena_newvcl_counter_newvcl_field_isvcl_kindvcl_counter_add+7 |
| 495 | func vcl_nclasses(rs: *i64, axis: i64) -> i64 |
| 499 | func vcl_class_name(rs: *i64, axis: i64, idx: i64) -> *u8 |
| 505 | func vcl_match(kind: i64, name: *u8, nl: i64, pat: *u8, pl: i64) -> i64 |
| 520 | func vcl_classify(rs: *i64, axis: i64, name: *u8, nl: i64) -> i64 |
| 545 | func vcl_screen(rs: *i64, role_counts: *i64, id_lc: *u8, idl: i64) -> i64 |
| 569 | func vcl_deptag(rs: *i64, dep_lc: *u8, dl: i64) -> i64 |
| 584 | func vcl_app_reasons(a: *i64, mask: i64) -> i64 |