sovereign-intelligence
Front door to Drake Stapleton's sovereign stack.
Brought by drakestapleton
sovereign-intelligence / compiler / rebuild.om
| 1 | om2 |
| 2 | note compiler/rebuild.om: after /si has fetched the projects, rebuild each layer of the stack from |
| 3 | note source and compare it with what is published, layer by layer from the seed upward. Pure seeded |
| 4 | note Omega. Table-driven: the layers, their repositories and their commands are the rows of |
| 5 | note layers.tsv beside repos.tsv; this program holds no layer, repository or command of its own. |
| 6 | note |
| 7 | note Build with the seeded compiler (compiler/README.md names the pins): |
| 8 | note omc < compiler/rebuild.om > rebuild && chmod +x rebuild |
| 9 | note Run: |
| 10 | note rebuild check LAYERS |
| 11 | note rebuild run LAYERS REPOS DIR WORK [hw=yes] [wrap=WORDS] |
| 12 | note LAYERS layers.tsv: the line "layers TAB N" (N from 2 to 999), the header line |
| 13 | note "layer TAB repo TAB needs TAB command TAB artifact TAB compare", then one row per step: |
| 14 | note layer 1..N, rows in layer order, every layer from 1 to N with at least one row |
| 15 | note repo a project name; its commit is the head repos.tsv gives it |
| 16 | note needs any; aarch64-linux; macos (this is a Linux program, so always NOT_RUN); or |
| 17 | note pci:VVVV:DDDD, a hardware row: it runs only with hw=yes and a PCI device |
| 18 | note VVVV:DDDD under /sys/bus/pci/devices, else NOT_RUN, never PASS |
| 19 | note command the repository's own documented command, run by /bin/sh -c in its clone, |
| 20 | note or - when it has none (NOT_RUN no documented rebuild command) |
| 21 | note artifact the file the command builds, a path in the clone, or - |
| 22 | note compare a path in the clone whose bytes at the commit the artifact must equal, or - |
| 23 | note REPOS repos.tsv: each project's commit is its head there |
| 24 | note DIR the directory /si fetched into, one clone per project named as in repos.tsv |
| 25 | note WORK an existing directory: a log per row, layer-L-R.log (R the row number), and the |
| 26 | note files git writes |
| 27 | note check validates LAYERS and prints "rebuild: table ok: N layers, R rows". run validates it the |
| 28 | note same way, then takes the rows in order and prints one line per row: |
| 29 | note PASS | layer L | repo | commit C | rc 0 | sha256 S | log G | cmd COMMAND |
| 30 | note FAIL <why> | layer L | ... a clone not at its commit, a command exiting nonzero, a |
| 31 | note missing artifact, or an artifact whose sha256 differs from |
| 32 | note the committed file's |
| 33 | note NOT_RUN <why> | layer L | ... needs not met here, no documented command, not fetched |
| 34 | note and last "REBUILD pass=P fail=F not_run=N rows=R layers=L". Exit 0 when no row FAILs and every |
| 35 | note row of layers 1 and 2 PASSes, else 1. A refused table: exit 1, one stderr line starting |
| 36 | note "rebuild: " and nothing run. A usage error: exit 2. |
| 37 | note A command runs with stdin /dev/null and stdout and stderr in its log. Exec hands a child an |
| 38 | note empty environment, so the command gets HOME, PATH, USER, LOGNAME, LANG, LC_ALL, TMPDIR, |
| 39 | note CARGO_HOME and RUSTUP_HOME copied from this program's own, where set, through /usr/bin/env. |
| 40 | note wrap=WORDS puts WORDS, split at spaces, between those and /bin/sh, for example a CPU pool: |
| 41 | note wrap=flock /path/pool.lock taskset -c 4,5. |
| 42 | note SHA-256 (fn kinit to fn finish) is copied unchanged from compiler/gate.om, which copied it |
| 43 | note from omega-mv om/sha256/sha256-om2.om at f4df82394e35893dcf1354dda69a2fe028d94bc1 |
| 44 | note (Apache-2.0, FIPS 180-4). |
| 45 | |
| 46 | text tpre "rebuild: " |
| 47 | text tnl "\n" |
| 48 | text tusage "usage: rebuild check LAYERS | rebuild run LAYERS REPOS DIR WORK [hw=yes] [wrap=WORDS]\n" |
| 49 | text tcheck "check" |
| 50 | text trun "run" |
| 51 | text thw "hw=yes" |
| 52 | text twrap "wrap=" |
| 53 | text targ "cannot read a command-line argument" |
| 54 | text topen "cannot open " |
| 55 | text tbig "file over its buffer: " |
| 56 | text tnodir "WORK is not a directory: " |
| 57 | text tlay "layers\t" |
| 58 | text thdr "layer\trepo\tneeds\tcommand\tartifact\tcompare" |
| 59 | text mfirst "the first line must be layers TAB N, N from 2 to 999" |
| 60 | text mhdr "the second line must be the header layer TAB repo TAB needs TAB command TAB artifact TAB compare" |
| 61 | text mcols "a row needs 6 tab-separated fields: line " |
| 62 | text mlayer "layer is not a number from 1 to the declared count: line " |
| 63 | text morder "rows are not in layer order: line " |
| 64 | text mnorow1 "layer " |
| 65 | text mnorow2 " has no row" |
| 66 | text mrepo "bad repo name (letters, digits, . _ -, not starting with .): line " |
| 67 | text mneeds "needs is not any, aarch64-linux, macos or pci:VVVV:DDDD (lowercase hex): line " |
| 68 | text mcmd "command is empty, over 1024 bytes or has a control byte: line " |
| 69 | text mpath "artifact or compare is not - or a relative path without .. or control bytes: line " |
| 70 | text mcmp "compare needs an artifact: line " |
| 71 | text mmany "more than 4096 rows at line " |
| 72 | text tok1 "rebuild: table ok: " |
| 73 | text tok2 " layers, " |
| 74 | text tok3 " rows\n" |
| 75 | text nany "any" |
| 76 | text na64 "aarch64-linux" |
| 77 | text nmac "macos" |
| 78 | text npci "pci:" |
| 79 | text tdash "-" |
| 80 | text rmac "macOS only; this runner is a Linux program" |
| 81 | text ra64 "needs AArch64 Linux" |
| 82 | text rhw "hardware row; runs only with hw=yes, in an authorized hardware window" |
| 83 | text rchip "hardware row; no PCI device " |
| 84 | text rchip2 " here" |
| 85 | text rcmd "no documented rebuild command" |
| 86 | text rlist "not in repos.tsv, so /si does not fetch it" |
| 87 | text rbadh "the repos.tsv head is not 40 lowercase hex digits" |
| 88 | text rfetch "not fetched: no clone in DIR" |
| 89 | text rhead "clone is not at the repos.tsv commit; it is at " |
| 90 | text runk "clone HEAD cannot be read" |
| 91 | text rexit "command exited nonzero" |
| 92 | text rio "cannot write its log in WORK" |
| 93 | text rpkt "command, wrap and environment exceed one exec packet (4096 bytes, 64 records)" |
| 94 | text rart "artifact missing: " |
| 95 | text rcom "no committed file at the commit: " |
| 96 | text rdiff "artifact differs from committed " |
| 97 | text tsp " " |
| 98 | text vpass "PASS" |
| 99 | text vfail "FAIL " |
| 100 | text vnrun "NOT_RUN " |
| 101 | text bl " | layer " |
| 102 | text br " | " |
| 103 | text bc " | commit " |
| 104 | text brc " | rc " |
| 105 | text bsha " | sha256 " |
| 106 | text blog " | log " |
| 107 | text bcmd " | cmd " |
| 108 | text sum1 "REBUILD pass=" |
| 109 | text sum2 " fail=" |
| 110 | text sum3 " not_run=" |
| 111 | text sum4 " rows=" |
| 112 | text sum5 " layers=" |
| 113 | text tself "/proc/self/exe" |
| 114 | text tpcid "/sys/bus/pci/devices" |
| 115 | text tvend "/vendor" |
| 116 | text tdev "/device" |
| 117 | text tnull "/dev/null" |
| 118 | text tlogp "/layer-" |
| 119 | text tlog ".log" |
| 120 | text tcom ".committed" |
| 121 | text tgit "/git.out" |
| 122 | text xenv "/usr/bin/env" |
| 123 | text xsh "/bin/sh" |
| 124 | text xc "-c" |
| 125 | text xgit "git" |
| 126 | text xrp "rev-parse" |
| 127 | text xhead "HEAD" |
| 128 | text xcf "cat-file" |
| 129 | text xblob "blob" |
| 130 | text e1 "HOME=" |
| 131 | text e2 "PATH=" |
| 132 | text e3 "USER=" |
| 133 | text e4 "LOGNAME=" |
| 134 | text e5 "LANG=" |
| 135 | text e6 "LC_ALL=" |
| 136 | text e7 "TMPDIR=" |
| 137 | text e8 "CARGO_HOME=" |
| 138 | text e9 "RUSTUP_HOME=" |
| 139 | text hexd "0123456789abcdef" |
| 140 | |
| 141 | note tb: the layers table; rp: repos.tsv |
| 142 | global tb uchar 1048576 |
| 143 | global tbn ulong 1 |
| 144 | global rp uchar 4194304 |
| 145 | global rpn ulong 1 |
| 146 | note rows, 12 cells each: layer, repo offset and length, needs (1 any, 2 aarch64-linux, 3 macos, |
| 147 | note 4 pci), command, artifact and compare offsets and lengths (4..9), line number (10), needs |
| 148 | note offset (11). nlay: the declared layer count; prevl: the layer of the row before |
| 149 | global row ulong 49152 |
| 150 | global nrow ulong 1 |
| 151 | global nlay ulong 1 |
| 152 | global prevl ulong 1 |
| 153 | note pb: the path being built; dir: DIR; wk: WORK; wr: the wrap words; cd: the clone of the row |
| 154 | global pb uchar 8192 |
| 155 | global pbn ulong 1 |
| 156 | global dir uchar 4096 |
| 157 | global dirn ulong 1 |
| 158 | global wk uchar 4096 |
| 159 | global wkn ulong 1 |
| 160 | global wr uchar 4096 |
| 161 | global wrn ulong 1 |
| 162 | global cd uchar 8192 |
| 163 | global cdn ulong 1 |
| 164 | note av: the packed argv of a child (u16 count, then u16 length and bytes per record); ovf is 1 |
| 165 | note when a record did not fit. ev: the environment records handed on, packed the same way |
| 166 | global av uchar 8192 |
| 167 | global avp ulong 1 |
| 168 | global avc ulong 1 |
| 169 | global ovf ulong 1 |
| 170 | global ev uchar 4096 |
| 171 | global evn ulong 1 |
| 172 | global evc ulong 1 |
| 173 | note st: a child's wait status; gb: small file reads; db: directory entries |
| 174 | global st uchar 4 |
| 175 | global gb uchar 4096 |
| 176 | global gbn ulong 1 |
| 177 | global db uchar 32768 |
| 178 | note the current row: its commit (cm, cmn 40 when known), exit status (crc, hrc 1 when run), |
| 179 | note artifact, log and committed sha256 in hex (hx, hl, hc; hsa and hlg 1 when known) |
| 180 | global cm uchar 40 |
| 181 | global cmn ulong 1 |
| 182 | global crc ulong 1 |
| 183 | global hrc ulong 1 |
| 184 | global hx uchar 64 |
| 185 | global hl uchar 64 |
| 186 | global hc uchar 64 |
| 187 | global hsa ulong 1 |
| 188 | global hlg ulong 1 |
| 189 | global dg uchar 32 |
| 190 | note tally: PASS, FAIL and NOT_RUN rows; l12: rows of layers 1 and 2 that did not PASS; |
| 191 | note a64: 1 when this program is an AArch64 ELF; hw: 1 with hw=yes |
| 192 | global tally ulong 3 |
| 193 | global l12 ulong 1 |
| 194 | global a64 ulong 1 |
| 195 | global hw ulong 1 |
| 196 | |
| 197 | text tslash "/" |
| 198 | text tcolon ":" |
| 199 | text tempty "" |
| 200 | |
| 201 | note K[0..63]: the first 32 bits of the fractional parts of the cube roots of the first 64 primes. |
| 202 | note Copied mechanically from seed/qualification/om2/fixtures/sha256-k.dec (tool-computed, never typed). |
| 203 | fn kinit k edit uint 64 to void |
| 204 | put k 0 0x428a2f98 |
| 205 | put k 1 0x71374491 |
| 206 | put k 2 0xb5c0fbcf |
| 207 | put k 3 0xe9b5dba5 |
| 208 | put k 4 0x3956c25b |
| 209 | put k 5 0x59f111f1 |
| 210 | put k 6 0x923f82a4 |
| 211 | put k 7 0xab1c5ed5 |
| 212 | put k 8 0xd807aa98 |
| 213 | put k 9 0x12835b01 |
| 214 | put k 10 0x243185be |
| 215 | put k 11 0x550c7dc3 |
| 216 | put k 12 0x72be5d74 |
| 217 | put k 13 0x80deb1fe |
| 218 | put k 14 0x9bdc06a7 |
| 219 | put k 15 0xc19bf174 |
| 220 | put k 16 0xe49b69c1 |
| 221 | put k 17 0xefbe4786 |
| 222 | put k 18 0x0fc19dc6 |
| 223 | put k 19 0x240ca1cc |
| 224 | put k 20 0x2de92c6f |
| 225 | put k 21 0x4a7484aa |
| 226 | put k 22 0x5cb0a9dc |
| 227 | put k 23 0x76f988da |
| 228 | put k 24 0x983e5152 |
| 229 | put k 25 0xa831c66d |
| 230 | put k 26 0xb00327c8 |
| 231 | put k 27 0xbf597fc7 |
| 232 | put k 28 0xc6e00bf3 |
| 233 | put k 29 0xd5a79147 |
| 234 | put k 30 0x06ca6351 |
| 235 | put k 31 0x14292967 |
| 236 | put k 32 0x27b70a85 |
| 237 | put k 33 0x2e1b2138 |
| 238 | put k 34 0x4d2c6dfc |
| 239 | put k 35 0x53380d13 |
| 240 | put k 36 0x650a7354 |
| 241 | put k 37 0x766a0abb |
| 242 | put k 38 0x81c2c92e |
| 243 | put k 39 0x92722c85 |
| 244 | put k 40 0xa2bfe8a1 |
| 245 | put k 41 0xa81a664b |
| 246 | put k 42 0xc24b8b70 |
| 247 | put k 43 0xc76c51a3 |
| 248 | put k 44 0xd192e819 |
| 249 | put k 45 0xd6990624 |
| 250 | put k 46 0xf40e3585 |
| 251 | put k 47 0x106aa070 |
| 252 | put k 48 0x19a4c116 |
| 253 | put k 49 0x1e376c08 |
| 254 | put k 50 0x2748774c |
| 255 | put k 51 0x34b0bcb5 |
| 256 | put k 52 0x391c0cb3 |
| 257 | put k 53 0x4ed8aa4a |
| 258 | put k 54 0x5b9cca4f |
| 259 | put k 55 0x682e6ff3 |
| 260 | put k 56 0x748f82ee |
| 261 | put k 57 0x78a5636f |
| 262 | put k 58 0x84c87814 |
| 263 | put k 59 0x8cc70208 |
| 264 | put k 60 0x90befffa |
| 265 | put k 61 0xa4506ceb |
| 266 | put k 62 0xbef9a3f7 |
| 267 | put k 63 0xc67178f2 |
| 268 | end |
| 269 | |
| 270 | note H(0): the first 32 bits of the fractional parts of the square roots of the first 8 primes |
| 271 | note (fixtures/sha256-iv.dec). |
| 272 | fn iv s edit uint 8 to void |
| 273 | put s 0 0x6a09e667 |
| 274 | put s 1 0xbb67ae85 |
| 275 | put s 2 0x3c6ef372 |
| 276 | put s 3 0xa54ff53a |
| 277 | put s 4 0x510e527f |
| 278 | put s 5 0x9b05688c |
| 279 | put s 6 0x1f83d9ab |
| 280 | put s 7 0x5be0cd19 |
| 281 | end |
| 282 | |
| 283 | note Message schedule of the block m[o .. o+64). w is fresh: its incoming contents are never read. |
| 284 | note The compiler proves that every get of w reads an element written earlier in this function |
| 285 | note (error 27 otherwise): w[0..16) are the block's big-endian words, w[16..64) the FIPS recurrence. |
| 286 | fn sched w edit uint 64 fresh m view uchar * o ulong to void |
| 287 | q = ulong 0 |
| 288 | x = uint 0 |
| 289 | y = uint 0 |
| 290 | for i ulong 16 unroll |
| 291 | q = add o mul i 4 |
| 292 | x = uint get m q |
| 293 | x = or shl x 8 uint get m add q 1 |
| 294 | x = or shl x 8 uint get m add q 2 |
| 295 | put w i or shl x 8 uint get m add q 3 |
| 296 | end |
| 297 | for i ulong 48 unroll |
| 298 | x = get w add i 1 |
| 299 | y = get w add i 14 |
| 300 | x = add add get w i get w add i 9 xor xor rotr x 7 rotr x 18 shr x 3 |
| 301 | put w add i 16 add x xor xor rotr y 17 rotr y 19 shr y 10 |
| 302 | end |
| 303 | end |
| 304 | |
| 305 | note The 64 rounds on the chaining value s. One round body, emitted 64 times by unroll; i is a constant |
| 306 | note in each copy, so get kt i and get w i need no run-time check. uint arithmetic wraps mod 2^32. |
| 307 | note Ch(e,f,g) = (e and f) xor (not e and g) is written g xor (e and (f xor g)); Maj(a,b,c) = |
| 308 | note (a and b) xor (a and c) xor (b and c) is written (a and b) or (c and (a or b)). Both are bitwise |
| 309 | note identities. h first becomes T1, then T1 + T2, which is the next a; the names then shift by one. |
| 310 | note The sums are built a term per line and each Sigma in two lines through t: 12 names are live, and |
| 311 | note omc hands out 16 registers with no spilling (error 12 under compiler-s1/s2 for longer lines). |
| 312 | fn rounds s edit uint 8 w view uint 64 kt view uint 64 to void |
| 313 | a = get s 0 |
| 314 | b = get s 1 |
| 315 | c = get s 2 |
| 316 | d = get s 3 |
| 317 | e = get s 4 |
| 318 | f = get s 5 |
| 319 | g = get s 6 |
| 320 | h = get s 7 |
| 321 | t = uint 0 |
| 322 | for i ulong 64 unroll |
| 323 | h = add h get kt i |
| 324 | h = add h get w i |
| 325 | t = xor rotr e 6 rotr e 11 |
| 326 | t = xor t rotr e 25 |
| 327 | h = add h t |
| 328 | h = add h xor g and e xor f g |
| 329 | d = add d h |
| 330 | t = xor rotr a 2 rotr a 13 |
| 331 | t = xor t rotr a 22 |
| 332 | h = add h t |
| 333 | t = and c or a b |
| 334 | h = add h or and a b t |
| 335 | t = h |
| 336 | h = g |
| 337 | g = f |
| 338 | f = e |
| 339 | e = d |
| 340 | d = c |
| 341 | c = b |
| 342 | b = a |
| 343 | a = t |
| 344 | end |
| 345 | put s 0 add get s 0 a |
| 346 | put s 1 add get s 1 b |
| 347 | put s 2 add get s 2 c |
| 348 | put s 3 add get s 3 d |
| 349 | put s 4 add get s 4 e |
| 350 | put s 5 add get s 5 f |
| 351 | put s 6 add get s 6 g |
| 352 | put s 7 add get s 7 h |
| 353 | end |
| 354 | |
| 355 | note One block m[o .. o+64) into s. sched and rounds stay calls: inlined, their names would share |
| 356 | note one 16-register frame with this function's parameters (no spilling, error 12). |
| 357 | fn compress s edit uint 8 w edit uint 64 kt view uint 64 m view uchar * o ulong to void |
| 358 | sched w m o |
| 359 | rounds s w kt |
| 360 | end |
| 361 | |
| 362 | note The whole blocks of m (len m is a multiple of 64 and at most 2^25, so under 2^19 passes). |
| 363 | fn run s edit uint 8 w edit uint 64 kt view uint 64 m view uchar * to void |
| 364 | for j ulong shr len m 6 |
| 365 | compress s w kt m shl j 6 |
| 366 | end |
| 367 | end |
| 368 | |
| 369 | note The whole blocks of m (len m a multiple of 64). A rolled loop traps 4 after 1000000 passes |
| 370 | note (OMEGESE.md section 2; omc s_for), so m is cut into runs of 2^25 bytes (2^19 blocks): |
| 371 | note len m = top * 2^44 + mid * 2^25 + rest, and no loop passes 2^20 times. top reaches 1000000 |
| 372 | note only above 1.7e19 bytes, which no AArch64 address space holds. |
| 373 | fn blocks s edit uint 8 w edit uint 64 kt view uint 64 m view uchar * to void |
| 374 | q = ulong 0 |
| 375 | for a ulong shr len m 44 |
| 376 | for b ulong 0x80000 |
| 377 | run s w kt part m q 0x2000000 |
| 378 | q = add q 0x2000000 |
| 379 | end |
| 380 | end |
| 381 | for b ulong and shr len m 25 0x7ffff |
| 382 | run s w kt part m q 0x2000000 |
| 383 | q = add q 0x2000000 |
| 384 | end |
| 385 | run s w kt part m q sub len m q |
| 386 | end |
| 387 | |
| 388 | note Pad the k pending bytes already in p (k < 64; p was all zero past them): 0x80, zeros, and the |
| 389 | note 64-bit big-endian bit length of the n-byte message in the last 8 bytes of one or two blocks. |
| 390 | fn finish s edit uint 8 w edit uint 64 kt view uint 64 p edit uchar 128 k ulong n ulong to void |
| 391 | put p k 0x80 |
| 392 | e = ulong 64 |
| 393 | if ge k 56 |
| 394 | e = 128 |
| 395 | end |
| 396 | bits = shl n 3 |
| 397 | for i ulong 8 unroll |
| 398 | put p sub e add i 1 uchar and shr bits mul i 8 0xff |
| 399 | end |
| 400 | compress s w kt view p 0 |
| 401 | if eq e 128 |
| 402 | compress s w kt view p 64 |
| 403 | end |
| 404 | end |
| 405 | |
| 406 | |
| 407 | fn say t view uchar * to void |
| 408 | w = write 1 t 0 len t |
| 409 | end |
| 410 | fn sayn v ulong to void |
| 411 | d = new uchar 24 0 |
| 412 | x = v |
| 413 | k = ulong 0 |
| 414 | while or gt x 0 eq k 0 bound 24 |
| 415 | put d k uchar add rem x 10 48 |
| 416 | k = add k 1 |
| 417 | x = div x 10 |
| 418 | end |
| 419 | while gt k 0 bound 24 |
| 420 | k = sub k 1 |
| 421 | w = write 1 d k 1 |
| 422 | end |
| 423 | end |
| 424 | fn die t view uchar * to void |
| 425 | w = write 2 tpre 0 len tpre |
| 426 | w = write 2 t 0 len t |
| 427 | w = write 2 tnl 0 1 |
| 428 | exit 1 |
| 429 | end |
| 430 | fn badline t view uchar * ln ulong to void |
| 431 | say tpre |
| 432 | say t |
| 433 | sayn ln |
| 434 | say tnl |
| 435 | exit 1 |
| 436 | end |
| 437 | fn patharg a ulong to void |
| 438 | n = argread a pb 0 8192 |
| 439 | if le n 0 |
| 440 | die targ |
| 441 | end |
| 442 | put pbn 0 ulong n |
| 443 | end |
| 444 | fn pc t view uchar * to void |
| 445 | put pbn 0 0 |
| 446 | pa t |
| 447 | end |
| 448 | fn pa t view uchar * to void |
| 449 | p = get pbn 0 |
| 450 | for i ulong len t |
| 451 | put pb add p i get t i |
| 452 | end |
| 453 | put pbn 0 add p len t |
| 454 | end |
| 455 | fn pt o ulong n ulong to void |
| 456 | p = get pbn 0 |
| 457 | for i ulong n |
| 458 | put pb add p i get tb add o i |
| 459 | end |
| 460 | put pbn 0 add p n |
| 461 | end |
| 462 | fn pn v ulong to void |
| 463 | d = new uchar 24 0 |
| 464 | x = v |
| 465 | k = ulong 0 |
| 466 | while or gt x 0 eq k 0 bound 24 |
| 467 | put d k uchar add rem x 10 48 |
| 468 | k = add k 1 |
| 469 | x = div x 10 |
| 470 | end |
| 471 | while gt k 0 bound 24 |
| 472 | k = sub k 1 |
| 473 | p = get pbn 0 |
| 474 | put pb p get d k |
| 475 | put pbn 0 add p 1 |
| 476 | end |
| 477 | end |
| 478 | fn eqt o ulong n ulong t view uchar * to bool |
| 479 | if ne n len t |
| 480 | ret false |
| 481 | end |
| 482 | for i ulong n |
| 483 | if ne get tb add o i get t i |
| 484 | ret false |
| 485 | end |
| 486 | end |
| 487 | ret true |
| 488 | end |
| 489 | fn num o ulong n ulong to ulong |
| 490 | v = ulong 0 |
| 491 | if eq n 0 |
| 492 | ret 0 |
| 493 | end |
| 494 | for i ulong n |
| 495 | c = get tb add o i |
| 496 | if or lt c 48 gt c 57 |
| 497 | ret 0 |
| 498 | end |
| 499 | v = add mul v 10 ulong sub c 48 |
| 500 | if gt v 999 |
| 501 | ret 0 |
| 502 | end |
| 503 | end |
| 504 | ret v |
| 505 | end |
| 506 | fn nam o ulong n ulong to bool |
| 507 | if eq n 0 |
| 508 | ret false |
| 509 | end |
| 510 | if eq get tb o 46 |
| 511 | ret false |
| 512 | end |
| 513 | for i ulong n |
| 514 | c = get tb add o i |
| 515 | ok = and ge c 65 le c 90 |
| 516 | ok = or ok and ge c 97 le c 122 |
| 517 | ok = or ok and ge c 48 le c 57 |
| 518 | ok = or ok or eq c 46 or eq c 45 eq c 95 |
| 519 | if not ok |
| 520 | ret false |
| 521 | end |
| 522 | end |
| 523 | ret true |
| 524 | end |
| 525 | fn rel o ulong n ulong to bool |
| 526 | if eq n 0 |
| 527 | ret false |
| 528 | end |
| 529 | if eq get tb o 47 |
| 530 | ret false |
| 531 | end |
| 532 | for i ulong n |
| 533 | c = get tb add o i |
| 534 | if or lt c 33 gt c 126 |
| 535 | ret false |
| 536 | end |
| 537 | if eq c 46 |
| 538 | if lt add i 1 n |
| 539 | if eq get tb add add o i 1 46 |
| 540 | ret false |
| 541 | end |
| 542 | end |
| 543 | end |
| 544 | end |
| 545 | ret true |
| 546 | end |
| 547 | fn hexchar c uchar to bool |
| 548 | ret or and ge c 48 le c 57 and ge c 97 le c 102 |
| 549 | end |
| 550 | fn needs o ulong n ulong to ulong |
| 551 | if eqt o n nany |
| 552 | ret 1 |
| 553 | end |
| 554 | if eqt o n na64 |
| 555 | ret 2 |
| 556 | end |
| 557 | if eqt o n nmac |
| 558 | ret 3 |
| 559 | end |
| 560 | if ne n 13 |
| 561 | ret 0 |
| 562 | end |
| 563 | if not eqt o 4 npci |
| 564 | ret 0 |
| 565 | end |
| 566 | if ne get tb add o 8 58 |
| 567 | ret 0 |
| 568 | end |
| 569 | for i ulong 9 |
| 570 | if ne i 4 |
| 571 | if not hexchar get tb add add o 4 i |
| 572 | ret 0 |
| 573 | end |
| 574 | end |
| 575 | end |
| 576 | ret 4 |
| 577 | end |
| 578 | fn parserow s ulong e ulong ln ulong to void |
| 579 | fs = new ulong 6 0 |
| 580 | fnn = new ulong 6 0 |
| 581 | if true |
| 582 | f = ulong 0 |
| 583 | q = s |
| 584 | x = s |
| 585 | while le q e bound 1048577 |
| 586 | endf = eq q e |
| 587 | if not endf |
| 588 | endf = eq get tb q 9 |
| 589 | end |
| 590 | if endf |
| 591 | if ge f 6 |
| 592 | badline mcols ln |
| 593 | end |
| 594 | put fs f x |
| 595 | put fnn f sub q x |
| 596 | f = add f 1 |
| 597 | x = add q 1 |
| 598 | end |
| 599 | q = add q 1 |
| 600 | end |
| 601 | if ne f 6 |
| 602 | badline mcols ln |
| 603 | end |
| 604 | end |
| 605 | v = num get fs 0 get fnn 0 |
| 606 | if or eq v 0 gt v get nlay 0 |
| 607 | badline mlayer ln |
| 608 | end |
| 609 | if lt v get prevl 0 |
| 610 | badline morder ln |
| 611 | end |
| 612 | put prevl 0 v |
| 613 | if not nam get fs 1 get fnn 1 |
| 614 | badline mrepo ln |
| 615 | end |
| 616 | k = needs get fs 2 get fnn 2 |
| 617 | if eq k 0 |
| 618 | badline mneeds ln |
| 619 | end |
| 620 | if true |
| 621 | cn = get fnn 3 |
| 622 | if or eq cn 0 gt cn 1024 |
| 623 | badline mcmd ln |
| 624 | end |
| 625 | for j ulong cn |
| 626 | c = get tb add get fs 3 j |
| 627 | if or lt c 32 gt c 126 |
| 628 | badline mcmd ln |
| 629 | end |
| 630 | end |
| 631 | if not rel get fs 4 get fnn 4 |
| 632 | badline mpath ln |
| 633 | end |
| 634 | if not rel get fs 5 get fnn 5 |
| 635 | badline mpath ln |
| 636 | end |
| 637 | if eqt get fs 4 get fnn 4 tdash |
| 638 | if not eqt get fs 5 get fnn 5 tdash |
| 639 | badline mcmp ln |
| 640 | end |
| 641 | end |
| 642 | end |
| 643 | r = get nrow 0 |
| 644 | if ge r 4096 |
| 645 | badline mmany ln |
| 646 | end |
| 647 | b = mul r 12 |
| 648 | put row b v |
| 649 | put row add b 1 get fs 1 |
| 650 | put row add b 2 get fnn 1 |
| 651 | put row add b 3 k |
| 652 | put row add b 4 get fs 3 |
| 653 | put row add b 5 get fnn 3 |
| 654 | put row add b 6 get fs 4 |
| 655 | put row add b 7 get fnn 4 |
| 656 | put row add b 8 get fs 5 |
| 657 | put row add b 9 get fnn 5 |
| 658 | put row add b 10 ln |
| 659 | put row add b 11 get fs 2 |
| 660 | put nrow 0 add r 1 |
| 661 | end |
| 662 | fn coverage to void |
| 663 | for i ulong get nlay 0 |
| 664 | found = false |
| 665 | for j ulong get nrow 0 |
| 666 | ly = get row mul j 12 |
| 667 | if eq ly add i 1 |
| 668 | found = true |
| 669 | end |
| 670 | end |
| 671 | if not found |
| 672 | say tpre |
| 673 | say mnorow1 |
| 674 | sayn add i 1 |
| 675 | say mnorow2 |
| 676 | say tnl |
| 677 | exit 1 |
| 678 | end |
| 679 | end |
| 680 | end |
| 681 | fn parse to void |
| 682 | n = get tbn 0 |
| 683 | p = ulong 0 |
| 684 | ln = ulong 0 |
| 685 | while lt p n bound 1048577 |
| 686 | s = p |
| 687 | while lt p n bound 1048577 |
| 688 | if eq get tb p 10 |
| 689 | break |
| 690 | end |
| 691 | p = add p 1 |
| 692 | end |
| 693 | e = p |
| 694 | p = add p 1 |
| 695 | ln = add ln 1 |
| 696 | if eq ln 1 |
| 697 | if lt sub e s 8 |
| 698 | die mfirst |
| 699 | end |
| 700 | if not eqt s 7 tlay |
| 701 | die mfirst |
| 702 | end |
| 703 | v = num add s 7 sub sub e s 7 |
| 704 | if lt v 2 |
| 705 | die mfirst |
| 706 | end |
| 707 | put nlay 0 v |
| 708 | else |
| 709 | if eq ln 2 |
| 710 | if not eqt s sub e s thdr |
| 711 | die mhdr |
| 712 | end |
| 713 | else |
| 714 | parserow s e ln |
| 715 | end |
| 716 | end |
| 717 | end |
| 718 | if lt ln 2 |
| 719 | die mhdr |
| 720 | end |
| 721 | coverage |
| 722 | end |
| 723 | fn loadtab to void |
| 724 | fd = fopen pb 0 get pbn 0 524288 0 |
| 725 | if lt fd 0 |
| 726 | die topen |
| 727 | end |
| 728 | p = ulong 0 |
| 729 | while lt p 1048576 bound 1048577 |
| 730 | k = read int fd tb p sub 1048576 p |
| 731 | if lt k 0 |
| 732 | die topen |
| 733 | end |
| 734 | if eq k 0 |
| 735 | break |
| 736 | end |
| 737 | p = add p ulong k |
| 738 | end |
| 739 | c = fclose int fd |
| 740 | if ge p 1048576 |
| 741 | die tbig |
| 742 | end |
| 743 | put tbn 0 p |
| 744 | parse |
| 745 | end |
| 746 | fn loadrepos to void |
| 747 | fd = fopen pb 0 get pbn 0 524288 0 |
| 748 | if lt fd 0 |
| 749 | die topen |
| 750 | end |
| 751 | p = ulong 0 |
| 752 | while lt p 4194304 bound 4194305 |
| 753 | k = read int fd rp p sub 4194304 p |
| 754 | if lt k 0 |
| 755 | die topen |
| 756 | end |
| 757 | if eq k 0 |
| 758 | break |
| 759 | end |
| 760 | p = add p ulong k |
| 761 | end |
| 762 | c = fclose int fd |
| 763 | if ge p 4194304 |
| 764 | die tbig |
| 765 | end |
| 766 | put rpn 0 p |
| 767 | end |
| 768 | note locate the row's name and copy its manifest commit; false if absent or malformed. |
| 769 | fn commit b ulong to bool |
| 770 | put cmn 0 0 |
| 771 | p = ulong 0 |
| 772 | while lt p get rpn 0 bound 4194305 |
| 773 | s = p |
| 774 | while lt p get rpn 0 bound 4194305 |
| 775 | if or eq get rp p 9 eq get rp p 10 |
| 776 | break |
| 777 | end |
| 778 | p = add p 1 |
| 779 | end |
| 780 | same = eq sub p s get row add b 2 |
| 781 | if same |
| 782 | for i ulong sub p s |
| 783 | co = add get row add b 1 i |
| 784 | cv = get tb co |
| 785 | if ne get rp add s i cv |
| 786 | same = false |
| 787 | end |
| 788 | end |
| 789 | end |
| 790 | if same |
| 791 | p = add p 1 |
| 792 | while lt p get rpn 0 bound 4194305 |
| 793 | if eq get rp p 9 |
| 794 | break |
| 795 | end |
| 796 | p = add p 1 |
| 797 | end |
| 798 | p = add p 1 |
| 799 | s = p |
| 800 | while lt p get rpn 0 bound 4194305 |
| 801 | if or eq get rp p 9 eq get rp p 10 |
| 802 | break |
| 803 | end |
| 804 | p = add p 1 |
| 805 | end |
| 806 | if ne sub p s 40 |
| 807 | ret false |
| 808 | end |
| 809 | for i ulong 40 |
| 810 | v = get rp add s i |
| 811 | if not hexchar v |
| 812 | ret false |
| 813 | end |
| 814 | put cm i v |
| 815 | end |
| 816 | put cmn 0 40 |
| 817 | ret true |
| 818 | end |
| 819 | while lt p get rpn 0 bound 4194305 |
| 820 | if eq get rp p 10 |
| 821 | break |
| 822 | end |
| 823 | p = add p 1 |
| 824 | end |
| 825 | p = add p 1 |
| 826 | end |
| 827 | ret false |
| 828 | end |
| 829 | fn aa t view uchar * to void |
| 830 | n = len t |
| 831 | p = get avp 0 |
| 832 | if or gt add add p 2 n 4096 ge get avc 0 64 |
| 833 | put ovf 0 1 |
| 834 | ret |
| 835 | end |
| 836 | put av p uchar and n 255 |
| 837 | put av add p 1 uchar shr n 8 |
| 838 | for i ulong n |
| 839 | put av add add p 2 i get t i |
| 840 | end |
| 841 | put avp 0 add add p 2 n |
| 842 | put avc 0 add get avc 0 1 |
| 843 | end |
| 844 | fn ap to void |
| 845 | n = get pbn 0 |
| 846 | p = get avp 0 |
| 847 | if or gt add add p 2 n 4096 ge get avc 0 64 |
| 848 | put ovf 0 1 |
| 849 | ret |
| 850 | end |
| 851 | put av p uchar and n 255 |
| 852 | put av add p 1 uchar shr n 8 |
| 853 | for i ulong n |
| 854 | put av add add p 2 i get pb i |
| 855 | end |
| 856 | put avp 0 add add p 2 n |
| 857 | put avc 0 add get avc 0 1 |
| 858 | end |
| 859 | fn envkeep n ulong t view uchar * to bool |
| 860 | if lt n len t |
| 861 | ret false |
| 862 | end |
| 863 | for i ulong len t |
| 864 | if ne get gb i get t i |
| 865 | ret false |
| 866 | end |
| 867 | end |
| 868 | ret true |
| 869 | end |
| 870 | fn envinit to void |
| 871 | put evn 0 0 |
| 872 | put evc 0 0 |
| 873 | nenv = ulong envcnt |
| 874 | for i ulong nenv |
| 875 | k = envread i gb 0 4096 |
| 876 | if gt k 0 |
| 877 | n = ulong k |
| 878 | keep = envkeep n e1 |
| 879 | keep = or keep envkeep n e2 |
| 880 | keep = or keep envkeep n e3 |
| 881 | keep = or keep envkeep n e4 |
| 882 | keep = or keep envkeep n e5 |
| 883 | keep = or keep envkeep n e6 |
| 884 | keep = or keep envkeep n e7 |
| 885 | keep = or keep envkeep n e8 |
| 886 | keep = or keep envkeep n e9 |
| 887 | if keep |
| 888 | p = get evn 0 |
| 889 | if le add add p 2 n 4096 |
| 890 | put ev p uchar and n 255 |
| 891 | put ev add p 1 uchar shr n 8 |
| 892 | for j ulong n |
| 893 | put ev add add p 2 j get gb j |
| 894 | end |
| 895 | put evn 0 add add p 2 n |
| 896 | put evc 0 add get evc 0 1 |
| 897 | end |
| 898 | end |
| 899 | end |
| 900 | end |
| 901 | end |
| 902 | fn start to void |
| 903 | put avp 0 2 |
| 904 | put avc 0 0 |
| 905 | put ovf 0 0 |
| 906 | aa xenv |
| 907 | p = ulong 0 |
| 908 | for i ulong get evc 0 |
| 909 | n = add ulong get ev p shl ulong get ev add p 1 8 |
| 910 | p = add p 2 |
| 911 | put pbn 0 n |
| 912 | for j ulong n |
| 913 | put pb j get ev add p j |
| 914 | end |
| 915 | ap |
| 916 | p = add p n |
| 917 | end |
| 918 | end |
| 919 | fn wrapadd to void |
| 920 | p = ulong 0 |
| 921 | while lt p get wrn 0 bound 4097 |
| 922 | if eq get wr p 32 |
| 923 | p = add p 1 |
| 924 | else |
| 925 | s = p |
| 926 | while lt p get wrn 0 bound 4097 |
| 927 | if eq get wr p 32 |
| 928 | break |
| 929 | end |
| 930 | p = add p 1 |
| 931 | end |
| 932 | put pbn 0 sub p s |
| 933 | for i ulong sub p s |
| 934 | put pb i get wr add s i |
| 935 | end |
| 936 | ap |
| 937 | end |
| 938 | end |
| 939 | end |
| 940 | fn spawn fd int inclone bool to ulong |
| 941 | if eq get ovf 0 1 |
| 942 | c = fclose fd |
| 943 | ret 512 |
| 944 | end |
| 945 | put av 0 uchar get avc 0 |
| 946 | put av 1 uchar 0 |
| 947 | pid = fork |
| 948 | if lt pid 0 |
| 949 | c = fclose fd |
| 950 | ret 512 |
| 951 | end |
| 952 | if eq pid 0 |
| 953 | if inclone |
| 954 | v = chdir cd 0 get cdn 0 |
| 955 | if ne v 0 |
| 956 | exit 97 |
| 957 | end |
| 958 | end |
| 959 | v = dupfd fd 1 0 |
| 960 | v = dupfd fd 2 0 |
| 961 | v = fopen tnull 0 len tnull 0 0 |
| 962 | if ge v 0 |
| 963 | z = dupfd int v 0 0 |
| 964 | end |
| 965 | v = execprog av 0 get avp 0 |
| 966 | exit 98 |
| 967 | end |
| 968 | c = fclose fd |
| 969 | v = waitpid int pid st 0 4 0 |
| 970 | if ne v pid |
| 971 | ret 512 |
| 972 | end |
| 973 | if ne get st 0 0 |
| 974 | ret add 256 ulong get st 0 |
| 975 | end |
| 976 | ret ulong get st 1 |
| 977 | end |
| 978 | fn workpath to void |
| 979 | put pbn 0 get wkn 0 |
| 980 | for i ulong get wkn 0 |
| 981 | put pb i get wk i |
| 982 | end |
| 983 | end |
| 984 | fn logpath b ulong to void |
| 985 | workpath |
| 986 | pa tlogp |
| 987 | pn get row b |
| 988 | pa tdash |
| 989 | pn add div b 12 1 |
| 990 | pa tlog |
| 991 | end |
| 992 | fn clonepath b ulong to void |
| 993 | put pbn 0 get dirn 0 |
| 994 | for i ulong get dirn 0 |
| 995 | put pb i get dir i |
| 996 | end |
| 997 | pa tslash |
| 998 | pt get row add b 1 get row add b 2 |
| 999 | put cdn 0 get pbn 0 |
| 1000 | for i ulong get pbn 0 |
| 1001 | put cd i get pb i |
| 1002 | end |
| 1003 | end |
| 1004 | fn cpbase to void |
| 1005 | put pbn 0 get cdn 0 |
| 1006 | for i ulong get cdn 0 |
| 1007 | put pb i get cd i |
| 1008 | end |
| 1009 | pa tslash |
| 1010 | end |
| 1011 | fn smallread to long |
| 1012 | fd = fopen pb 0 get pbn 0 0 0 |
| 1013 | if lt fd 0 |
| 1014 | ret -1 |
| 1015 | end |
| 1016 | n = read int fd gb 0 4096 |
| 1017 | c = fclose int fd |
| 1018 | ret n |
| 1019 | end |
| 1020 | fn outputfd to int |
| 1021 | ret int fopen pb 0 get pbn 0 577 420 |
| 1022 | end |
| 1023 | fn headok to bool |
| 1024 | start |
| 1025 | aa xgit |
| 1026 | aa xrp |
| 1027 | aa xhead |
| 1028 | workpath |
| 1029 | pa tgit |
| 1030 | fd = outputfd |
| 1031 | if lt fd 0 |
| 1032 | ret false |
| 1033 | end |
| 1034 | rc = spawn fd true |
| 1035 | if ne rc 0 |
| 1036 | ret false |
| 1037 | end |
| 1038 | workpath |
| 1039 | pa tgit |
| 1040 | n = smallread |
| 1041 | if lt n 40 |
| 1042 | ret false |
| 1043 | end |
| 1044 | for i ulong 40 |
| 1045 | if ne get gb i get cm i |
| 1046 | ret false |
| 1047 | end |
| 1048 | end |
| 1049 | ret true |
| 1050 | end |
| 1051 | fn hexstate s view uint 8 to void |
| 1052 | for i ulong 8 |
| 1053 | for j ulong 4 |
| 1054 | v = get s i |
| 1055 | v = shr v uint sub 24 mul j 8 |
| 1056 | by = uchar and v 255 |
| 1057 | ix = add mul i 8 mul j 2 |
| 1058 | put hx ix get hexd shr by 4 |
| 1059 | put hx add ix 1 get hexd and by 15 |
| 1060 | end |
| 1061 | end |
| 1062 | end |
| 1063 | fn hashfile to bool |
| 1064 | s = new uint 8 0 |
| 1065 | w = new uint 64 0 |
| 1066 | kt = new uint 64 0 |
| 1067 | pad = new uchar 128 0 |
| 1068 | buf = new uchar 64 0 |
| 1069 | fd = fopen pb 0 get pbn 0 0 0 |
| 1070 | if lt fd 0 |
| 1071 | ret false |
| 1072 | end |
| 1073 | kinit kt |
| 1074 | iv s |
| 1075 | total = ulong 0 |
| 1076 | pending = ulong 0 |
| 1077 | while true bound 9223372036854775807 |
| 1078 | n = read int fd buf pending sub 64 pending |
| 1079 | if lt n 0 |
| 1080 | c = fclose int fd |
| 1081 | ret false |
| 1082 | end |
| 1083 | if eq n 0 |
| 1084 | break |
| 1085 | end |
| 1086 | total = add total ulong n |
| 1087 | pending = add pending ulong n |
| 1088 | if eq pending 64 |
| 1089 | compress s w kt view buf 0 |
| 1090 | pending = 0 |
| 1091 | end |
| 1092 | end |
| 1093 | c = fclose int fd |
| 1094 | for i ulong pending |
| 1095 | put pad i get buf i |
| 1096 | end |
| 1097 | finish s w kt pad pending total |
| 1098 | hexstate s |
| 1099 | ret true |
| 1100 | end |
| 1101 | fn aarch to void |
| 1102 | pc tself |
| 1103 | n = smallread |
| 1104 | if gt n 20 |
| 1105 | if and eq get gb 18 183 eq get gb 19 0 |
| 1106 | put a64 0 1 |
| 1107 | end |
| 1108 | end |
| 1109 | end |
| 1110 | fn chipentry b ulong p ulong rn ulong to bool |
| 1111 | if true |
| 1112 | q = add p 19 |
| 1113 | e = q |
| 1114 | while lt e add p rn bound 32769 |
| 1115 | if eq get db e 0 |
| 1116 | break |
| 1117 | end |
| 1118 | e = add e 1 |
| 1119 | end |
| 1120 | pc tpcid |
| 1121 | pa tslash |
| 1122 | for i ulong sub e q |
| 1123 | z = get pbn 0 |
| 1124 | put pb z get db add q i |
| 1125 | put pbn 0 add z 1 |
| 1126 | end |
| 1127 | end |
| 1128 | base = get pbn 0 |
| 1129 | pa tvend |
| 1130 | v = smallread |
| 1131 | okv = ge v 6 |
| 1132 | if okv |
| 1133 | for i ulong 4 |
| 1134 | co = add get row add b 11 add 4 i |
| 1135 | by = get tb co |
| 1136 | if ne get gb add i 2 by |
| 1137 | okv = false |
| 1138 | end |
| 1139 | end |
| 1140 | end |
| 1141 | put pbn 0 base |
| 1142 | pa tdev |
| 1143 | v = smallread |
| 1144 | okd = ge v 6 |
| 1145 | if okd |
| 1146 | for i ulong 4 |
| 1147 | co = add get row add b 11 add 9 i |
| 1148 | by = get tb co |
| 1149 | if ne get gb add i 2 by |
| 1150 | okd = false |
| 1151 | end |
| 1152 | end |
| 1153 | end |
| 1154 | ret and okv okd |
| 1155 | end |
| 1156 | fn chip b ulong to bool |
| 1157 | fd = fopen tpcid 0 len tpcid 65536 0 |
| 1158 | if lt fd 0 |
| 1159 | ret false |
| 1160 | end |
| 1161 | found = false |
| 1162 | while not found bound 9223372036854775807 |
| 1163 | n = getdnts int fd db 0 32768 |
| 1164 | if le n 0 |
| 1165 | break |
| 1166 | end |
| 1167 | p = ulong 0 |
| 1168 | while lt p ulong n bound 32769 |
| 1169 | rn = ulong get db add p 16 |
| 1170 | rn = add rn shl ulong get db add p 17 8 |
| 1171 | if lt rn 20 |
| 1172 | break |
| 1173 | end |
| 1174 | if chipentry b p rn |
| 1175 | found = true |
| 1176 | break |
| 1177 | end |
| 1178 | p = add p rn |
| 1179 | end |
| 1180 | end |
| 1181 | c = fclose int fd |
| 1182 | ret found |
| 1183 | end |
| 1184 | fn fields b ulong to void |
| 1185 | say bl |
| 1186 | sayn get row b |
| 1187 | say br |
| 1188 | w = write 1 tb get row add b 1 get row add b 2 |
| 1189 | say bc |
| 1190 | if eq get cmn 0 40 |
| 1191 | w = write 1 cm 0 40 |
| 1192 | else |
| 1193 | say tdash |
| 1194 | end |
| 1195 | say brc |
| 1196 | if eq get hrc 0 1 |
| 1197 | sayn get crc 0 |
| 1198 | else |
| 1199 | say tdash |
| 1200 | end |
| 1201 | say bsha |
| 1202 | if eq get hsa 0 1 |
| 1203 | w = write 1 hx 0 64 |
| 1204 | else |
| 1205 | say tdash |
| 1206 | end |
| 1207 | say blog |
| 1208 | logpath b |
| 1209 | w = write 1 pb 0 get pbn 0 |
| 1210 | say bcmd |
| 1211 | w = write 1 tb get row add b 4 get row add b 5 |
| 1212 | say tnl |
| 1213 | end |
| 1214 | fn result b ulong status ulong why view uchar * to void |
| 1215 | if eq status 0 |
| 1216 | say vpass |
| 1217 | else |
| 1218 | if eq status 1 |
| 1219 | say vfail |
| 1220 | else |
| 1221 | say vnrun |
| 1222 | end |
| 1223 | say why |
| 1224 | if le get row b 2 |
| 1225 | put l12 0 1 |
| 1226 | end |
| 1227 | end |
| 1228 | put tally status add get tally status 1 |
| 1229 | fields b |
| 1230 | end |
| 1231 | fn executerow b ulong to void |
| 1232 | put hsa 0 0 |
| 1233 | put hrc 0 0 |
| 1234 | put cmn 0 0 |
| 1235 | has = commit b |
| 1236 | k = get row add b 3 |
| 1237 | if eq k 3 |
| 1238 | result b 2 rmac |
| 1239 | ret |
| 1240 | end |
| 1241 | if not has |
| 1242 | result b 2 rlist |
| 1243 | ret |
| 1244 | end |
| 1245 | if eq k 2 |
| 1246 | if eq get a64 0 0 |
| 1247 | result b 2 ra64 |
| 1248 | ret |
| 1249 | end |
| 1250 | end |
| 1251 | if eq k 4 |
| 1252 | if not chip b |
| 1253 | result b 2 rchip |
| 1254 | ret |
| 1255 | end |
| 1256 | if eq get hw 0 0 |
| 1257 | result b 2 rhw |
| 1258 | ret |
| 1259 | end |
| 1260 | end |
| 1261 | if eqt get row add b 4 get row add b 5 tdash |
| 1262 | result b 2 rcmd |
| 1263 | ret |
| 1264 | end |
| 1265 | clonepath b |
| 1266 | if not headok |
| 1267 | result b 1 rhead |
| 1268 | ret |
| 1269 | end |
| 1270 | start |
| 1271 | wrapadd |
| 1272 | aa xsh |
| 1273 | aa xc |
| 1274 | put pbn 0 0 |
| 1275 | pt get row add b 4 get row add b 5 |
| 1276 | ap |
| 1277 | logpath b |
| 1278 | fd = outputfd |
| 1279 | if lt fd 0 |
| 1280 | result b 1 rio |
| 1281 | ret |
| 1282 | end |
| 1283 | rc = spawn fd true |
| 1284 | put crc 0 rc |
| 1285 | put hrc 0 1 |
| 1286 | if not eqt get row add b 6 get row add b 7 tdash |
| 1287 | cpbase |
| 1288 | pt get row add b 6 get row add b 7 |
| 1289 | if hashfile |
| 1290 | put hsa 0 1 |
| 1291 | end |
| 1292 | end |
| 1293 | if ne rc 0 |
| 1294 | result b 1 rexit |
| 1295 | ret |
| 1296 | end |
| 1297 | if not eqt get row add b 6 get row add b 7 tdash |
| 1298 | if eq get hsa 0 0 |
| 1299 | result b 1 rart |
| 1300 | ret |
| 1301 | end |
| 1302 | end |
| 1303 | if not eqt get row add b 8 get row add b 9 tdash |
| 1304 | for i ulong 64 |
| 1305 | put hc i get hx i |
| 1306 | end |
| 1307 | start |
| 1308 | aa xgit |
| 1309 | aa xcf |
| 1310 | aa xblob |
| 1311 | put pbn 0 40 |
| 1312 | for i ulong 40 |
| 1313 | put pb i get cm i |
| 1314 | end |
| 1315 | pa tcolon |
| 1316 | pt get row add b 8 get row add b 9 |
| 1317 | ap |
| 1318 | workpath |
| 1319 | pa tcom |
| 1320 | fd = outputfd |
| 1321 | if lt fd 0 |
| 1322 | result b 1 rio |
| 1323 | ret |
| 1324 | end |
| 1325 | rc = spawn fd true |
| 1326 | if ne rc 0 |
| 1327 | result b 1 rcom |
| 1328 | ret |
| 1329 | end |
| 1330 | workpath |
| 1331 | pa tcom |
| 1332 | if not hashfile |
| 1333 | result b 1 rcom |
| 1334 | ret |
| 1335 | end |
| 1336 | same = true |
| 1337 | for i ulong 64 |
| 1338 | if ne get hc i get hx i |
| 1339 | same = false |
| 1340 | end |
| 1341 | put hx i get hc i |
| 1342 | end |
| 1343 | if not same |
| 1344 | result b 1 rdiff |
| 1345 | ret |
| 1346 | end |
| 1347 | end |
| 1348 | result b 0 tempty |
| 1349 | end |
| 1350 | fn summary to void |
| 1351 | say sum1 |
| 1352 | sayn get tally 0 |
| 1353 | say sum2 |
| 1354 | sayn get tally 1 |
| 1355 | say sum3 |
| 1356 | sayn get tally 2 |
| 1357 | say sum4 |
| 1358 | sayn get nrow 0 |
| 1359 | say sum5 |
| 1360 | sayn get nlay 0 |
| 1361 | say tnl |
| 1362 | end |
| 1363 | fn main to int |
| 1364 | if lt argcnt 3 |
| 1365 | say tusage |
| 1366 | ret 2 |
| 1367 | end |
| 1368 | patharg 1 |
| 1369 | checking = false |
| 1370 | if eq get pbn 0 5 |
| 1371 | checking = true |
| 1372 | for i ulong 5 |
| 1373 | if ne get pb i get tcheck i |
| 1374 | checking = false |
| 1375 | end |
| 1376 | end |
| 1377 | end |
| 1378 | if not checking |
| 1379 | if lt argcnt 6 |
| 1380 | say tusage |
| 1381 | ret 2 |
| 1382 | end |
| 1383 | end |
| 1384 | patharg 2 |
| 1385 | loadtab |
| 1386 | if checking |
| 1387 | say tok1 |
| 1388 | sayn get nlay 0 |
| 1389 | say tok2 |
| 1390 | sayn get nrow 0 |
| 1391 | say tok3 |
| 1392 | ret 0 |
| 1393 | end |
| 1394 | patharg 3 |
| 1395 | loadrepos |
| 1396 | n = argread 4 dir 0 4096 |
| 1397 | if le n 0 |
| 1398 | die targ |
| 1399 | end |
| 1400 | put dirn 0 ulong n |
| 1401 | n = argread 5 wk 0 4096 |
| 1402 | if le n 0 |
| 1403 | die targ |
| 1404 | end |
| 1405 | put wkn 0 ulong n |
| 1406 | extra = sub ulong argcnt 6 |
| 1407 | for i ulong extra |
| 1408 | patharg add i 6 |
| 1409 | if eq get pbn 0 6 |
| 1410 | same = true |
| 1411 | for j ulong 6 |
| 1412 | if ne get pb j get thw j |
| 1413 | same = false |
| 1414 | end |
| 1415 | end |
| 1416 | if same |
| 1417 | put hw 0 1 |
| 1418 | end |
| 1419 | end |
| 1420 | if ge get pbn 0 5 |
| 1421 | same = true |
| 1422 | for j ulong 5 |
| 1423 | if ne get pb j get twrap j |
| 1424 | same = false |
| 1425 | end |
| 1426 | end |
| 1427 | if same |
| 1428 | put wrn 0 sub get pbn 0 5 |
| 1429 | for j ulong get wrn 0 |
| 1430 | put wr j get pb add j 5 |
| 1431 | end |
| 1432 | end |
| 1433 | end |
| 1434 | end |
| 1435 | envinit |
| 1436 | aarch |
| 1437 | for i ulong get nrow 0 |
| 1438 | executerow mul i 12 |
| 1439 | end |
| 1440 | summary |
| 1441 | if or gt get tally 1 0 eq get l12 0 1 |
| 1442 | ret 1 |
| 1443 | end |
| 1444 | ret 0 |
| 1445 | end |