Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/bench/omc_efficiency/run.om # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / bench / omc_efficiency / run.om` 2120 lines ยท 33926 bytes Raw Blame History 1 note OMC-EFF coordinator (PROTOCOL.md, corrected by PROTOCOL-2.md, profile option from PROTOCOL-3.md), the 2 note Omega port of the former run.sh (OMC-EFF-4). It builds the arms, records provenance and starts the 3 note Omega conductor; the conductor (conductor.om) does the timing, the output and runtime-line checks and 4 note the counter reading. It computes no statistics. 5 note 6 note run [--profile P] HERE OMC OUTDIR [CPU] baseline: omc, cO2, cO0, neg 7 note run [--profile P] --ab HERE BASE CAND SEED OUTDIR [CPU] A/B: omcB, omcC, cO2, neg 8 note 9 note P om1 (default): kernels/CASE.om, cases named CASE. om2: the committed kernels/om2/CASE.om, 10 note cases named om2/CASE on every row (PROTOCOL-3); the same C twins and want/ bytes 11 note HERE bench/omc_efficiency (PROTOCOL*.md, conductor.om, kernels/, want/) 12 note OMC/BASE the omc under test / the baseline omc (also builds the conductor and the neg mutants) 13 note CAND the candidate omc (A/B only) 14 note SEED the run seed of the A/B, declared in the candidate's evidence before the run (nonzero) 15 note OUTDIR a new directory for the work tree and the raw evidence (missing parents are created) 16 note CPU the core to pin to (default 19) 17 note Relative HERE, OMC, BASE, CAND and OUTDIR are made absolute against the working directory; symbolic 18 note links are not resolved. Host tools run by absolute path with an empty environment: /usr/bin/gcc 19 note -B/usr/bin/, objdump, size, sha256sum, git, date, uname, lscpu, perf. Pinning uses cpuset/setprio. 20 note Exit: 0 when every conductor invocation exits 0; 1 when any exits otherwise (the run still goes on, 21 note and its status is in provenance.txt as build_rc, build_B_rc, build_C_rc, run_rc); 64 bad usage; 22 note 70 a setup step failed (named on stderr). 23 om2 24 text tcases "arith branch fib leafcall sieve isort matmul" 25 text tcsort "arith branch fib isort leafcall matmul sieve" 26 text tmf "h = add mul h 31 i|k = add k 1|if lt n 2|shr x 5|m = mul p p|put a i rem x 100000|rem add mul i 3 j 11" 27 text tmt "h = add mul h 37 i|k = add k 2|if lt n 3|shr x 6|m = add mul p p p|put a i rem x 100001|rem add mul i 3 j 12" 28 text toarm "omc" 29 text toarmb "omcB omcC" 30 text tcarm "O2 O0" 31 text tcarmb "O2" 32 text tsarm "cO0 cO2 neg omc" 33 text tsarmb "cO2 neg omcB omcC" 34 text tprof "--profile" 35 text tab "--ab" 36 text to1 "om1" 37 text to2 "om2" 38 text tom2s "om2/" 39 text tslash "/" 40 text tsp " " 41 text tnl "\n" 42 text tdash "-" 43 text twork "/work" 44 text tkern "/kernels/" 45 text twantd "/want/" 46 text tom ".om" 47 text tc ".c" 48 text tout ".out" 49 text tdoto ".o" 50 text tdots ".s" 51 text tsrc "/src/" 52 text twant "/want/" 53 text tbin "/bin/" 54 text tneg "neg" 55 text tobj "/obj/" 56 text tmut "/mut/" 57 text tdis "/disasm-c" 58 text tdis2 "/disasm-c/" 59 text tcO "c" 60 text esha "sha256sum failed: " 61 text terr ".err" 62 text tcond "/conductor" 63 text tcondom "/conductor.om" 64 text tcap "/cap.out" 65 text tcaperr "/cap.err" 66 text tren "/om1-renamed.om" 67 text tidB "/om1-B" 68 text tidC "/om1-C" 69 text tnull "/dev/null" 70 text tload "/proc/loadavg" 71 text tprov "/provenance.txt" 72 text tinsha "/inputs.sha256" 73 text tarsha "/arms.sha256" 74 text tident "/om1-identity.txt" 75 text tsizes "/sizes.txt" 76 text tbraw "/build.raw" 77 text tberr "/build.err" 78 text tbbraw "/build-B.raw" 79 text tbberr "/build-B.err" 80 text tbcraw "/build-C.raw" 81 text tbcerr "/build-C.err" 82 text trraw "/run.raw" 83 text trerr "/run.err" 84 text tgcc "/usr/bin/gcc" 85 text tgccb "-B/usr/bin/" 86 text tstatic "-static" 87 text tdo "-o" 88 text tobjd "/usr/bin/objdump" 89 text tdc "-c" 90 text tdr "-dr" 91 text tsize "/usr/bin/size" 92 text tsA "-A" 93 text tsha "/usr/bin/sha256sum" 94 text tgit "/usr/bin/git" 95 text tgC "-C" 96 text trevp "rev-parse" 97 text thead "HEAD" 98 text tgst "status" 99 text tporc "--porcelain" 100 text tdd "--" 101 text tdot "." 102 text tdate "/usr/bin/date -u +%FT%TZ" 103 text tgccv "/usr/bin/gcc --version" 104 text tperfv "/usr/bin/perf --version" 105 text tuname "/usr/bin/uname -srm" 106 text tlscpu "/usr/bin/lscpu -e=CPU,MAXMHZ" 107 text t19 "19" 108 text tcondx "./conductor" 109 text tbuild "build" 110 text trun "run" 111 text t10 "10" 112 text t1 "1" 113 text t21 "21" 114 text t3 "3" 115 text t4 "4" 116 text tomcB "omcB" 117 text tomcC "omcC" 118 text tomc "omc" 119 text tcO2 "cO2" 120 text tcO0 "cO0" 121 text tprot1 "PROTOCOL.md" 122 text tprot2 "PROTOCOL-2.md" 123 text tprot3 "PROTOCOL-3.md" 124 text tprot4 "PROTOCOL-4.md" 125 text tcondn "conductor.om" 126 text trunom "run.om" 127 text tselfom "selftest.om" 128 text tkdir "kernels/" 129 text tkdir2 "kernels/om2/" 130 text twdir "want/" 131 text tcondw "conductor" 132 text tbinw "bin/" 133 text tmutw "mut/" 134 text tptext ".text" 135 text tnote "note" 136 text tseedb "`20261026`" 137 text tseedbb "`20261027`" 138 text tobjw "obj/" 139 text tsrcw "src/" 140 text pdate "date_utc " 141 text pmode "mode " 142 text pab "ab" 143 text pbase "baseline" 144 text pprof "profile " 145 text psrc "source " 146 text pdirty "source_dirty " 147 text pomc "omc " 148 text pomcs "omc_sha256 " 149 text pcand "cand " 150 text pcands "cand_sha256 " 151 text pp1 "protocol_sha256 " 152 text pp2 "protocol2_sha256 " 153 text pp3 "protocol3_sha256 " 154 text pp4 "protocol4_sha256 " 155 text pgcc "gcc " 156 text pperf "perf " 157 text pkern "kernel " 158 text ppin "cpu_pin " 159 text pmodel "cpu_model " 160 text pmhz " MHz max" 161 text pld0 "loadavg_start " 162 text pld1 "loadavg_end " 163 text prnd "rounds 21 warm 3 seed " 164 text pbrnd " build_rounds 10 build_warm 1 build_seed " 165 text pbrc "build_rc " 166 text pbbrc "build_B_rc " 167 text pbcrc "build_C_rc " 168 text prrc "run_rc " 169 text tsame "same" 170 text tdiff "differs" 171 text tbrc " base_rc=" 172 text tcrc " cand_rc=" 173 text tszh "case arm file_bytes text_bytes" 174 text ttl1 "==> " 175 text ttl2 " <==" 176 text eusage "usage: run [--profile om1|om2] HERE OMC OUTDIR [CPU]\n run [--profile om1|om2] --ab HERE BASE CAND SEED OUTDIR [CPU]\n" 177 text eprof "run: --profile must be om1 or om2\n" 178 text eseed "run: SEED must be a nonzero decimal number\n" 179 text ecpu "run: CPU must be a decimal number\n" 180 text eexist "run: OUTDIR exists; one declared run per directory: " 181 text emkdir "run: cannot create " 182 text erun "run: " 183 text eo2cnt ": om2 line count" 184 text eo2fst ": om2 is not the first non-note line" 185 text eo2dif ": differs from its om1 kernel beyond PROTOCOL-3" 186 text emutn ": mutant pattern not found exactly once" 187 text emutu ": mutant unchanged" 188 text econd "conductor refused" 189 text erefus " refused " 190 text egcc "gcc failed: " 191 text eobjd "objdump failed: " 192 text ecopy "cannot copy " 193 text ewrite "cannot write " 194 text ecwd "cannot read the working directory" 195 text eprov "cannot write provenance.txt" 196 note gpb: the path being built; gsl: argument slots (0 HERE, 1 OMC/BASE, 2 CAND, 3 R = OUTDIR, 4 W = 197 note OUTDIR/work, 5 SEED, 6 CPU, 7 build SEED); gpk: the exec packet; glb: the output line; gfb, gf2, gf3: 198 note whole files 199 global gpb uchar 4096 200 global gpbn ulong 1 201 global gsl uchar 32768 202 global gsln ulong 8 203 global gin uchar 4096 204 global ginn ulong 1 205 global gou uchar 4096 206 global goun ulong 1 207 global ger uchar 4096 208 global gern ulong 1 209 global gcd uchar 4096 210 global gcdn ulong 1 211 global gpk uchar 16384 212 global gpkn ulong 1 213 global gpkc ulong 1 214 global glb uchar 8192 215 global glbn ulong 1 216 global gfb uchar `4194304` 217 global gf2 uchar `4194304` 218 global gf3 uchar `4194304` 219 global gst uchar 4 220 global gv ulong 16 221 note gv: 0 profile om2 (1) or om1 (0), 1 A/B (1), 2 provenance fd, 3 conductor failures, 8/9 the field 222 note fldset found (start, length), 10/11 mutant from (start, length), 12/13 mutant to (start, length) 223 224 note ---- path builder 225 fn pbclr to void 226 put gpbn 0 0 227 end 228 fn pbtext t view uchar * to void 229 n = get gpbn 0 230 if gt add n len t 4096 231 trap 9 232 end 233 for i ulong len t 234 put gpb add n i get t i 235 end 236 put gpbn 0 add n len t 237 end 238 fn pbset t view uchar * to void 239 pbclr 240 pbtext t 241 end 242 fn pbslot k ulong to void 243 n = get gpbn 0 244 m = get gsln k 245 if gt add n m 4096 246 trap 9 247 end 248 for i ulong m 249 put gpb add n i get gsl add shl k 12 i 250 end 251 put gpbn 0 add n m 252 end 253 fn setslot k ulong to void 254 n = get gpbn 0 255 for i ulong n 256 put gsl add shl k 12 i get gpb i 257 end 258 put gsln k n 259 end 260 fn pbnum v ulong to void 261 d = new uchar 24 0 262 p = ulong 24 263 x = v 264 while gt x 9 265 p = sub p 1 266 put d p uchar add rem x 10 48 267 x = div x 10 268 end 269 p = sub p 1 270 put d p uchar add x 48 271 n = get gpbn 0 272 for i ulong sub 24 p 273 put gpb add n i get d add p i 274 end 275 put gpbn 0 add n sub 24 p 276 end 277 note fldset: field i of t split at byte sep, into gv 8 (start) and gv 9 (length) 278 fn fldset t view uchar * sep ulong i ulong to void 279 k = ulong 0 280 s = ulong 0 281 for j ulong len t 282 if eq ulong get t j sep 283 if eq k i 284 put gv 8 s 285 put gv 9 sub j s 286 ret 287 end 288 k = add k 1 289 s = add j 1 290 end 291 end 292 if ne k i 293 trap 9 294 end 295 put gv 8 s 296 put gv 9 sub len t s 297 end 298 fn pbfld t view uchar * to void 299 s = get gv 8 300 m = get gv 9 301 n = get gpbn 0 302 if gt add n m 4096 303 trap 9 304 end 305 for i ulong m 306 put gpb add n i get t add s i 307 end 308 put gpbn 0 add n m 309 end 310 fn pbcase i ulong to void 311 fldset tcases 32 i 312 pbfld tcases 313 end 314 note P (om2/ under --profile om2) then the case name: the key of every row and file name 315 fn pbkey i ulong to void 316 if eq get gv 0 1 317 pbtext tom2s 318 end 319 pbcase i 320 end 321 note HERE/kernels/[om2/]CASE.om 322 fn pbkd i ulong to void 323 pbclr 324 pbslot 0 325 pbtext tkern 326 if eq get gv 0 1 327 pbtext tom2s 328 end 329 pbcase i 330 pbtext tom 331 end 332 fn pbw t view uchar * to void 333 pbclr 334 pbslot 4 335 pbtext t 336 end 337 fn pbr t view uchar * to void 338 pbclr 339 pbslot 3 340 pbtext t 341 end 342 343 note ---- the child's redirections: from gpb, or none (inherit) by clearing 344 fn setin to void 345 n = get gpbn 0 346 for i ulong n 347 put gin i get gpb i 348 end 349 put ginn 0 n 350 end 351 fn setout to void 352 n = get gpbn 0 353 for i ulong n 354 put gou i get gpb i 355 end 356 put goun 0 n 357 end 358 fn seterr to void 359 n = get gpbn 0 360 for i ulong n 361 put ger i get gpb i 362 end 363 put gern 0 n 364 end 365 fn setcd to void 366 n = get gpbn 0 367 for i ulong n 368 put gcd i get gpb i 369 end 370 put gcdn 0 n 371 end 372 fn nored to void 373 put ginn 0 0 374 put goun 0 0 375 put gern 0 0 376 put gcdn 0 0 377 end 378 379 note ---- exec packet: u16 count, then records (u16 length, bytes) 380 global gpinned ulong 1 381 fn pkreset to void 382 put gpinned 0 0 383 put gpk 0 0 384 put gpk 1 0 385 put gpkn 0 2 386 put gpkc 0 0 387 end 388 fn pkpush to void 389 n = get gpkn 0 390 m = get gpbn 0 391 if gt add add n m 2 16384 392 trap 9 393 end 394 put gpk n uchar and m 255 395 put gpk add n 1 uchar shr m 8 396 for i ulong m 397 put gpk add add n 2 i get gpb i 398 end 399 put gpkn 0 add add n m 2 400 c = add get gpkc 0 1 401 put gpkc 0 c 402 put gpk 0 uchar and c 255 403 put gpk 1 uchar shr c 8 404 end 405 fn pkt t view uchar * to void 406 pbset t 407 pkpush 408 end 409 fn pks k ulong to void 410 pbclr 411 pbslot k 412 pkpush 413 end 414 note pkline: a new packet, one record per space-separated word of t 415 fn pkline t view uchar * to void 416 pkreset 417 pbclr 418 for i ulong len t 419 c = get t i 420 if eq c 32 421 if gt get gpbn 0 0 422 pkpush 423 end 424 pbclr 425 else 426 put gpb get gpbn 0 c 427 put gpbn 0 add get gpbn 0 1 428 end 429 end 430 if gt get gpbn 0 0 431 pkpush 432 end 433 end 434 435 note ---- one child: optional cwd, stdin, stdout, stderr; exec gpk; returns the exit status (1000+signal) 436 note Pin only the conductor child, never provenance/build subprocesses or the coordinator. 437 fn selfpin to void 438 mask = new uchar 128 0 439 c = ulong 0 440 for i ulong get gsln 6 441 c = add mul c 10 ulong sub get gsl add shl ulong 6 12 i 48 442 end 443 if ge c 1024 444 exit 118 445 end 446 put mask div c 8 shl uchar 1 uchar rem c 8 447 r = cpuset 0 mask 0 128 448 if ne r 0 449 exit 118 450 end 451 note Preserve nice -n 19: raw getpriority is 20 minus nice, so the unclamped target is 39 minus raw. 452 old = getprio 0 0 453 if lt old 0 454 exit 118 455 end 456 want = sub long 39 old 457 if gt want 19 458 want = 19 459 end 460 r = setprio 0 0 int want 461 if ne r 0 462 exit 118 463 end 464 end 465 fn child to void 466 if gt get gcdn 0 0 467 r = chdir gcd 0 get gcdn 0 468 if ne r 0 469 exit 119 470 end 471 end 472 if gt get ginn 0 0 473 fi = fopen gin 0 get ginn 0 0 0 474 if lt fi 0 475 exit 120 476 end 477 r1 = dupfd int fi 0 0 478 if ne r1 0 479 exit 121 480 end 481 end 482 chout 483 if ne get gpinned 0 0 484 selfpin 485 end 486 r3 = execprog gpk 0 get gpkn 0 487 exit 126 488 end 489 fn chout to void 490 if gt get goun 0 0 491 fo = fopen gou 0 get goun 0 577 420 492 if lt fo 0 493 exit 122 494 end 495 r = dupfd int fo 1 0 496 if ne r 1 497 exit 123 498 end 499 end 500 if gt get gern 0 0 501 fe = fopen ger 0 get gern 0 577 420 502 if lt fe 0 503 exit 124 504 end 505 r2 = dupfd int fe 2 0 506 if ne r2 2 507 exit 125 508 end 509 end 510 end 511 fn runpk to ulong 512 pid = fork 513 if lt pid 0 514 trap 9 515 end 516 if eq pid 0 517 child 518 exit 127 519 end 520 r = waitpid int pid gst 0 4 0 521 if ne r pid 522 trap 9 523 end 524 s0 = ulong get gst 0 525 if ne and s0 127 0 526 ret add 1000 and s0 127 527 end 528 ret ulong get gst 1 529 end 530 note capture: stdin /dev/null, stdout W/cap.out, stderr W/cap.err; the output is read into gfb 531 fn capture to ulong 532 nored 533 pbset tnull 534 setin 535 pbw tcap 536 setout 537 pbw tcaperr 538 seterr 539 r = runpk 540 pbw tcap 541 n = rdin 0 542 if gt n `4194304` 543 ret 0 544 end 545 ret n 546 end 547 548 note ---- files: rdin reads the file named by gpb into gfb, gf2 or gf3 (which 0, 1, 2); returns its size, 549 note `4194305` when it does not fit, `4194306` when it cannot be opened 550 fn rdin which ulong to ulong 551 fd = fopen gpb 0 get gpbn 0 0 0 552 if lt fd 0 553 ret `4194306` 554 end 555 n = ulong 0 556 going = true 557 while going bound `999999999` 558 r = rdpart fd n which 559 if le r 0 560 going = false 561 else 562 n = add n ulong r 563 if eq n `4194304` 564 going = false 565 end 566 end 567 end 568 c = fclose int fd 569 if eq n `4194304` 570 ret `4194305` 571 end 572 ret n 573 end 574 fn rdpart fd long n ulong which ulong to long 575 if eq which 1 576 ret read int fd gf2 n sub `4194304` n 577 end 578 if eq which 2 579 ret read int fd gf3 n sub `4194304` n 580 end 581 ret read int fd gfb n sub `4194304` n 582 end 583 note write gfb or gf3 (which 0, 2) [0 .. n) to the file named by gpb with mode; false on failure 584 fn wrbuf which ulong n ulong mode int to bool 585 fd = fopen gpb 0 get gpbn 0 577 mode 586 if lt fd 0 587 ret false 588 end 589 w = wrpart fd n which 590 c = fclose int fd 591 if ne w long n 592 ret false 593 end 594 m = chmod gpb 0 get gpbn 0 mode 595 ret true 596 end 597 fn wrpart fd long n ulong which ulong to long 598 if eq which 2 599 ret write int fd gf3 0 n 600 end 601 ret write int fd gfb 0 n 602 end 603 fn die t view uchar * to void 604 w = write 2 erun 0 len erun 605 w2 = write 2 t 0 len t 606 w3 = write 2 gpb 0 get gpbn 0 607 w4 = write 2 tnl 0 1 608 exit 70 609 end 610 note die naming the path in gpb first (run: PATH: message) 611 fn diep t view uchar * to void 612 w = write 2 erun 0 len erun 613 w2 = write 2 gpb 0 get gpbn 0 614 w3 = write 2 t 0 len t 615 w4 = write 2 tnl 0 1 616 exit 70 617 end 618 note copy the file at gpb into gfb; cpto writes it to the path in gpb (mode 420) 619 fn cpfrom to ulong 620 n = rdin 0 621 if gt n `4194304` 622 die ecopy 623 end 624 ret n 625 end 626 fn cpto n ulong to void 627 if not wrbuf 0 n 420 628 die ewrite 629 end 630 end 631 fn mkd to void 632 r = makedir gpb 0 get gpbn 0 493 633 if and lt r 0 ne r -17 634 die emkdir 635 end 636 end 637 638 note ---- the line buffer and provenance.txt (gv 2) 639 fn lbtext t view uchar * to void 640 n = get glbn 0 641 if gt add n len t 8192 642 trap 9 643 end 644 for i ulong len t 645 put glb add n i get t i 646 end 647 put glbn 0 add n len t 648 end 649 fn lbpb to void 650 n = get glbn 0 651 m = get gpbn 0 652 if gt add n m 8192 653 trap 9 654 end 655 for i ulong m 656 put glb add n i get gpb i 657 end 658 put glbn 0 add n m 659 end 660 fn lbslot k ulong to void 661 pbclr 662 pbslot k 663 lbpb 664 end 665 fn lbnum v ulong to void 666 pbclr 667 pbnum v 668 lbpb 669 end 670 note the first line of gfb[0 .. n) (without its LF); at most the first 64 bytes when hex64 is true 671 fn lbfirst n ulong hex64 bool to void 672 m = n 673 if and hex64 gt m 64 674 m = 64 675 end 676 k = get glbn 0 677 for i ulong m bound `4194304` 678 c = get gfb i 679 if eq c 10 680 ret 681 end 682 if lt k 8000 683 put glb k c 684 k = add k 1 685 put glbn 0 k 686 end 687 end 688 end 689 fn lbto fd ulong to void 690 lbtext tnl 691 w = write int fd glb 0 get glbn 0 692 put glbn 0 0 693 end 694 fn lbpv to void 695 lbto get gv 2 696 end 697 fn lbout to void 698 lbto 1 699 end 700 701 note ---- arguments 702 fn argis idx ulong t view uchar * to bool 703 b = new uchar 4096 0 704 r = argread idx b 0 4096 705 if ne r long len t 706 ret false 707 end 708 for i ulong len t 709 if ne get b i get t i 710 ret false 711 end 712 end 713 ret true 714 end 715 fn usage to void 716 w = write 2 eusage 0 len eusage 717 exit 64 718 end 719 note slot k := argument idx, made absolute against the working directory when it does not start with / 720 fn absarg idx ulong k ulong to void 721 b = new uchar 4096 0 722 r = argread idx b 0 4096 723 if lt r 1 724 usage 725 end 726 pbclr 727 if ne get b 0 47 728 c = cwd gpb 0 4096 729 if lt c 2 730 die ecwd 731 end 732 put gpbn 0 sub ulong c 1 733 pbtext tslash 734 end 735 m = ulong r 736 n = get gpbn 0 737 if gt add n m 4096 738 usage 739 end 740 for i ulong m 741 put gpb add n i get b i 742 end 743 put gpbn 0 add n m 744 setslot k 745 end 746 note slot k := argument idx, which must be 1 .. 18 decimal digits (nonzero when nz is true) 747 fn numarg idx ulong k ulong nz bool to bool 748 b = new uchar 4096 0 749 r = argread idx b 0 4096 750 if or lt r 1 gt r 18 751 ret false 752 end 753 m = ulong r 754 z = true 755 for i ulong m 756 c = get b i 757 if or lt c 48 gt c 57 758 ret false 759 end 760 if ne c 48 761 z = false 762 end 763 end 764 if and nz z 765 ret false 766 end 767 pbclr 768 for j ulong m 769 put gpb j get b j 770 end 771 put gpbn 0 m 772 setslot k 773 ret true 774 end 775 fn txtslot t view uchar * k ulong to void 776 pbset t 777 setslot k 778 end 779 fn parse to void 780 ac = ulong argcnt 781 i = ulong 1 782 if lt ac 2 783 usage 784 end 785 if argis 1 tprof 786 if lt ac 3 787 usage 788 end 789 if argis 2 to2 790 put gv 0 1 791 else 792 if not argis 2 to1 793 w = write 2 eprof 0 len eprof 794 exit 64 795 end 796 end 797 i = 3 798 end 799 if lt i ac 800 if argis i tab 801 put gv 1 1 802 pab6 add i 1 ac 803 ret 804 end 805 end 806 pbase3 i ac 807 end 808 note --ab HERE BASE CAND SEED OUTDIR [CPU] from argument i 809 fn pab6 i ulong ac ulong to void 810 if or lt ac add i 5 gt ac add i 6 811 usage 812 end 813 absarg i 0 814 absarg add i 1 1 815 absarg add i 2 2 816 if not numarg add i 3 5 true 817 w = write 2 eseed 0 len eseed 818 exit 64 819 end 820 absarg add i 4 3 821 cpuarg add i 5 ac 822 pbclr 823 pbslot 5 824 setslot 7 825 end 826 note HERE OMC OUTDIR [CPU] from argument i 827 fn pbase3 i ulong ac ulong to void 828 if or lt ac add i 3 gt ac add i 4 829 usage 830 end 831 absarg i 0 832 absarg add i 1 1 833 absarg add i 2 3 834 cpuarg add i 3 ac 835 txtslot tseedb 5 836 txtslot tseedbb 7 837 end 838 fn cpuarg idx ulong ac ulong to void 839 if lt idx ac 840 if not numarg idx 6 false 841 w = write 2 ecpu 0 len ecpu 842 exit 64 843 end 844 else 845 txtslot t19 6 846 end 847 end 848 849 note ---- directories 850 note mkdir -p of the path in gpb: every proper prefix ending before a / is created when missing 851 fn mkp to void 852 n = get gpbn 0 853 for i ulong n 854 if and gt i 0 eq get gpb i 47 855 r = makedir gpb 0 i 493 856 end 857 end 858 mkd 859 end 860 fn mkdirs to void 861 pbclr 862 pbslot 3 863 n = get gpbn 0 864 for i ulong n 865 if and gt i 0 eq get gpb i 47 866 r = makedir gpb 0 i 493 867 end 868 end 869 r2 = makedir gpb 0 n 493 870 if eq r2 -17 871 w = write 2 eexist 0 len eexist 872 w2 = write 2 gpb 0 n 873 w3 = write 2 tnl 0 1 874 exit 64 875 end 876 if lt r2 0 877 die emkdir 878 end 879 pbtext twork 880 setslot 4 881 mkd 882 mkw tsrc 883 mkw twant 884 pbw tbin 885 mkd 886 pbw tbin 887 pbtext tneg 888 mkd 889 mkw2 890 pbw tobj 891 mkd 892 mkw tmut 893 pbr tdis 894 mkd 895 mkarms 896 end 897 note W/X and, under --profile om2, W/X/om2 898 fn mkw t view uchar * to void 899 pbw t 900 mkd 901 if eq get gv 0 1 902 pbtext tom2s 903 mkd 904 end 905 end 906 fn mkw2 to void 907 if eq get gv 0 1 908 pbw tbin 909 pbtext tneg 910 pbtext tslash 911 pbtext tom2s 912 mkd 913 end 914 end 915 fn mkarms to void 916 for a ulong narm 0 917 pbw tbin 918 pbarm 0 a 919 mkarm2 920 end 921 for o ulong narm 1 922 pbw tbin 923 pbtext tcO 924 pbarm 1 o 925 mkarm2 926 end 927 end 928 fn mkarm2 to void 929 mkd 930 if eq get gv 0 1 931 pbtext tslash 932 pbtext tom2s 933 mkd 934 end 935 end 936 note arm lists: kind 0 the omc arms (omc | omcB omcC), 1 the C optimisation levels (O2 O0 | O2) 937 fn narm kind ulong to ulong 938 if eq kind 0 939 if eq get gv 1 1 940 ret 2 941 end 942 ret 1 943 end 944 if eq get gv 1 1 945 ret 1 946 end 947 ret 2 948 end 949 fn pbarm kind ulong a ulong to void 950 if eq kind 0 951 if eq get gv 1 1 952 fldset toarmb 32 a 953 pbfld toarmb 954 else 955 fldset toarm 32 a 956 pbfld toarm 957 end 958 ret 959 end 960 if eq get gv 1 1 961 fldset tcarmb 32 a 962 pbfld tcarmb 963 else 964 fldset tcarm 32 a 965 pbfld tcarm 966 end 967 end 968 969 note ---- provenance 970 fn prov to void 971 pbr tprov 972 fd = fopen gpb 0 get gpbn 0 577 420 973 if lt fd 0 974 die eprov 975 end 976 put gv 2 ulong fd 977 pkline tdate 978 n = capture 979 lbtext pdate 980 lbfirst n false 981 lbpv 982 lbtext pmode 983 if eq get gv 1 1 984 lbtext pab 985 else 986 lbtext pbase 987 end 988 lbpv 989 lbtext pprof 990 if eq get gv 0 1 991 lbtext to2 992 else 993 lbtext to1 994 end 995 lbpv 996 prov2 997 prov3 998 prov4 999 end 1000 fn prov2 to void 1001 pkreset 1002 pkt tgit 1003 pkt tgC 1004 pks 0 1005 pkt trevp 1006 pkt thead 1007 n = capture 1008 lbtext psrc 1009 lbfirst n false 1010 lbpv 1011 pkreset 1012 pkt tgit 1013 pkt tgC 1014 pks 0 1015 pkt tgst 1016 pkt tporc 1017 pkt tdd 1018 pkt tdot 1019 n2 = capture 1020 k = ulong 0 1021 for i ulong n2 bound `4194304` 1022 if eq get gfb i 10 1023 k = add k 1 1024 end 1025 end 1026 lbtext pdirty 1027 lbnum k 1028 lbpv 1029 lbtext pomc 1030 lbslot 1 1031 lbpv 1032 lbtext pomcs 1033 shaslot 1 1034 lbpv 1035 if eq get gv 1 1 1036 lbtext pcand 1037 lbslot 2 1038 lbpv 1039 lbtext pcands 1040 shaslot 2 1041 lbpv 1042 end 1043 end 1044 note the SHA-256 (64 hex digits) of the file named by slot k, or of HERE/NAME (shahere), onto glb 1045 fn shaslot k ulong to void 1046 pkreset 1047 pkt tsha 1048 pks k 1049 n = capture 1050 lbfirst n true 1051 end 1052 fn shahere t view uchar * to void 1053 pkreset 1054 pkt tsha 1055 pbclr 1056 pbslot 0 1057 pbtext tslash 1058 pbtext t 1059 pkpush 1060 n = capture 1061 lbfirst n true 1062 end 1063 fn prov3 to void 1064 lbtext pp1 1065 shahere tprot1 1066 lbpv 1067 lbtext pp2 1068 shahere tprot2 1069 lbpv 1070 lbtext pp3 1071 shahere tprot3 1072 lbpv 1073 lbtext pp4 1074 shahere tprot4 1075 lbpv 1076 pkline tgccv 1077 n = capture 1078 lbtext pgcc 1079 lbfirst n false 1080 lbpv 1081 pkline tperfv 1082 n2 = capture 1083 lbtext pperf 1084 lbfirst n2 false 1085 lbpv 1086 pkline tuname 1087 n3 = capture 1088 lbtext pkern 1089 lbfirst n3 false 1090 lbpv 1091 lbtext ppin 1092 lbslot 6 1093 lbpv 1094 end 1095 fn prov4 to void 1096 pkline tlscpu 1097 n = capture 1098 lbtext pmodel 1099 lscpu n 1100 lbtext pmhz 1101 lbpv 1102 lbtext pld0 1103 loadavg 1104 lbpv 1105 lbtext prnd 1106 lbslot 5 1107 lbtext pbrnd 1108 lbslot 7 1109 lbpv 1110 end 1111 note the MAXMHZ field of the lscpu -e=CPU,MAXMHZ line whose CPU field equals slot 6 1112 fn lscpu n ulong to void 1113 s = ulong 0 1114 while lt s n bound `4194304` 1115 e = lnend s n 1116 f0 = skipsp s e 1117 f1 = wordend f0 e 1118 if cpueq f0 f1 1119 lbfield skipsp f1 e e 1120 ret 1121 end 1122 s = add e 1 1123 end 1124 end 1125 note the word of gfb starting at s (up to a space or e) onto glb 1126 fn lbfield s ulong e ulong to void 1127 f = wordend s e 1128 for i ulong sub f s 1129 m = get glbn 0 1130 put glb m get gfb add s i 1131 put glbn 0 add m 1 1132 end 1133 end 1134 fn cpueq a ulong b ulong to bool 1135 m = get gsln 6 1136 if ne sub b a m 1137 ret false 1138 end 1139 for i ulong m 1140 if ne get gfb add a i get gsl add shl ulong 6 12 i 1141 ret false 1142 end 1143 end 1144 ret true 1145 end 1146 fn lnend s ulong n ulong to ulong 1147 i = s 1148 while lt i n bound `4194304` 1149 if eq get gfb i 10 1150 ret i 1151 end 1152 i = add i 1 1153 end 1154 ret n 1155 end 1156 fn skipsp s ulong e ulong to ulong 1157 i = s 1158 while and lt i e eq get gfb i 32 bound `4194304` 1159 i = add i 1 1160 end 1161 ret i 1162 end 1163 fn wordend s ulong e ulong to ulong 1164 i = s 1165 while and lt i e ne get gfb i 32 bound `4194304` 1166 i = add i 1 1167 end 1168 ret i 1169 end 1170 fn loadavg to void 1171 pbset tload 1172 n = rdin 0 1173 if gt n `4194304` 1174 ret 1175 end 1176 lbfirst n false 1177 end 1178 note inputs.sha256: sha256sum of the protocol files, the drivers and every kernel, C twin and want, run in HERE 1179 fn inputs to void 1180 pkreset 1181 pkt tsha 1182 pkt tprot1 1183 pkt tprot2 1184 pkt tprot3 1185 pkt tprot4 1186 pkt tcondn 1187 pkt trunom 1188 pkt tselfom 1189 for i ulong 7 1190 inkern i tkdir tom 1191 end 1192 for j ulong 7 1193 inkern j tkdir2 tom 1194 end 1195 for k ulong 7 1196 inkern k tkdir tc 1197 end 1198 for m ulong 7 1199 inkern m twdir tout 1200 end 1201 nored 1202 pbclr 1203 pbslot 0 1204 setcd 1205 pbset tnull 1206 setin 1207 pbr tinsha 1208 setout 1209 r = runpk 1210 if ne r 0 1211 die esha 1212 end 1213 end 1214 fn inkern i ulong d view uchar * x view uchar * to void 1215 pbset d 1216 fldset tcsort 32 i 1217 pbfld tcsort 1218 pbtext x 1219 pkpush 1220 end 1221 1222 note ---- PROTOCOL-3 section 2: kernels/om2/CASE.om is kernels/CASE.om with one line om2 before the first 1223 note line that is not a note and the global out spelled obuf; checked here, never generated here 1224 fn om2chk to void 1225 if eq get gv 0 0 1226 ret 1227 end 1228 for i ulong 7 1229 om2one i 1230 end 1231 end 1232 fn om2one i ulong to void 1233 pbkd i 1234 n = rdin 0 1235 if gt n `4194304` 1236 die ecopy 1237 end 1238 if ne om2cnt n 1 1239 diep eo2cnt 1240 end 1241 if not om2fst n 1242 diep eo2fst 1243 end 1244 a = om2filt n 1245 pbclr 1246 pbslot 0 1247 pbtext tkern 1248 pbcase i 1249 pbtext tom 1250 m = rdin 1 1251 if gt m `4194304` 1252 die ecopy 1253 end 1254 b = rename m 1255 pbkd i 1256 if ne a b 1257 diep eo2dif 1258 end 1259 for j ulong a bound `4194304` 1260 if ne get gf3 j get gfb j 1261 diep eo2dif 1262 end 1263 end 1264 end 1265 note lines of gfb[0 .. n) that are exactly om2 1266 fn om2cnt n ulong to ulong 1267 k = ulong 0 1268 s = ulong 0 1269 while lt s n bound `4194304` 1270 e = lnend s n 1271 if isom2 s e 1272 k = add k 1 1273 end 1274 s = add e 1 1275 end 1276 ret k 1277 end 1278 fn isom2 s ulong e ulong to bool 1279 if ne sub e s 3 1280 ret false 1281 end 1282 ret fbis s to2 1283 end 1284 note gfb[s ..] starts with t (the caller keeps s + len t inside the data) 1285 fn fbis s ulong t view uchar * to bool 1286 for i ulong len t 1287 if ne get gfb add s i get t i 1288 ret false 1289 end 1290 end 1291 ret true 1292 end 1293 note the first line not starting with note is exactly om2 1294 fn om2fst n ulong to bool 1295 s = ulong 0 1296 while lt s n bound `4194304` 1297 e = lnend s n 1298 if not isnote s e 1299 ret isom2 s e 1300 end 1301 s = add e 1 1302 end 1303 ret false 1304 end 1305 fn isnote s ulong e ulong to bool 1306 if lt sub e s 4 1307 ret false 1308 end 1309 ret fbis s tnote 1310 end 1311 note gfb without its om2 lines, each kept line ended by LF, into gf3; returns the length 1312 fn om2filt n ulong to ulong 1313 k = ulong 0 1314 s = ulong 0 1315 while lt s n bound `4194304` 1316 e = lnend s n 1317 if not isom2 s e 1318 for i ulong sub e s 1319 put gf3 add k i get gfb add s i 1320 end 1321 k = add k sub e s 1322 put gf3 k 10 1323 k = add k 1 1324 end 1325 s = add e 1 1326 end 1327 ret k 1328 end 1329 note gf2[0 .. m) with every word out (word bytes A-Z a-z 0-9 _) spelled obuf, into gfb; returns the length 1330 fn rename m ulong to ulong 1331 k = ulong 0 1332 i = ulong 0 1333 while lt i m bound `4194304` 1334 if isout i m 1335 put gfb k 111 1336 put gfb add k 1 98 1337 put gfb add k 2 117 1338 put gfb add k 3 102 1339 k = add k 4 1340 i = add i 3 1341 else 1342 put gfb k get gf2 i 1343 k = add k 1 1344 i = add i 1 1345 end 1346 end 1347 ret k 1348 end 1349 fn isout i ulong m ulong to bool 1350 if gt add i 3 m 1351 ret false 1352 end 1353 if ne get gf2 i 111 1354 ret false 1355 end 1356 if ne get gf2 add i 1 117 1357 ret false 1358 end 1359 if ne get gf2 add i 2 116 1360 ret false 1361 end 1362 if gt i 0 1363 if wordb get gf2 sub i 1 1364 ret false 1365 end 1366 end 1367 if lt add i 3 m 1368 if wordb get gf2 add i 3 1369 ret false 1370 end 1371 end 1372 ret true 1373 end 1374 fn wordb c uchar to bool 1375 if and ge c 48 le c 57 1376 ret true 1377 end 1378 if and ge c 65 le c 90 1379 ret true 1380 end 1381 if and ge c 97 le c 122 1382 ret true 1383 end 1384 ret eq c 95 1385 end 1386 1387 note ---- negative-control mutants: one output-changing edit per kernel; each must apply exactly once 1388 fn mutate i ulong to void 1389 fldset tmf 124 i 1390 put gv 10 get gv 8 1391 put gv 11 get gv 9 1392 fldset tmt 124 i 1393 put gv 12 get gv 8 1394 put gv 13 get gv 9 1395 pbkd i 1396 n = rdin 0 1397 if gt n `4194304` 1398 die ecopy 1399 end 1400 k = mutcnt n 1401 if ne k 1 1402 diep emutn 1403 end 1404 m = mutbld n 1405 pbw tmut 1406 pbkey i 1407 pbtext tom 1408 if not wrbuf 2 m 420 1409 die ewrite 1410 end 1411 if eq m n 1412 if mutsame n 1413 diep emutu 1414 end 1415 end 1416 end 1417 fn mutsame n ulong to bool 1418 for i ulong n bound `4194304` 1419 if ne get gfb i get gf3 i 1420 ret false 1421 end 1422 end 1423 ret true 1424 end 1425 note the first index in gfb[s .. e) where the mutant's from text starts, or e 1426 fn mfind s ulong e ulong to ulong 1427 f = get gv 10 1428 m = get gv 11 1429 if lt sub e s m 1430 ret e 1431 end 1432 for i ulong add sub sub e s m 1 bound `4194304` 1433 if mat add s i f m 1434 ret add s i 1435 end 1436 end 1437 ret e 1438 end 1439 fn mat p ulong f ulong m ulong to bool 1440 for j ulong m 1441 if ne get gfb add p j get tmf add f j 1442 ret false 1443 end 1444 end 1445 ret true 1446 end 1447 fn mutcnt n ulong to ulong 1448 k = ulong 0 1449 s = ulong 0 1450 while lt s n bound `4194304` 1451 e = lnend s n 1452 if lt mfind s e e 1453 k = add k 1 1454 end 1455 s = add e 1 1456 end 1457 ret k 1458 end 1459 note awk: every line printed with LF; in a line holding from, its first occurrence becomes to 1460 fn mutbld n ulong to ulong 1461 k = ulong 0 1462 s = ulong 0 1463 while lt s n bound `4194304` 1464 e = lnend s n 1465 p = mfind s e 1466 k = mutln s e p k 1467 s = add e 1 1468 end 1469 ret k 1470 end 1471 fn mutln s ulong e ulong p ulong k0 ulong to ulong 1472 k = g3cp k0 s p 1473 if lt p e 1474 k = g3to k 1475 k = g3cp k add p get gv 11 e 1476 end 1477 put gf3 k 10 1478 ret add k 1 1479 end 1480 note gfb[s .. e) appended to gf3 at k; returns the new end 1481 fn g3cp k ulong s ulong e ulong to ulong 1482 for i ulong sub e s bound `4194304` 1483 put gf3 add k i get gfb add s i 1484 end 1485 ret add k sub e s 1486 end 1487 note the mutant's to text appended to gf3 at k 1488 fn g3to k ulong to ulong 1489 t = get gv 12 1490 m = get gv 13 1491 for j ulong m 1492 put gf3 add k j get tmt add t j 1493 end 1494 ret add k m 1495 end 1496 1497 note ---- arms 1498 fn arms to void 1499 nored 1500 pbclr 1501 pbslot 0 1502 pbtext tcondom 1503 setin 1504 pbw tcond 1505 setout 1506 pbr tcond 1507 pbtext terr 1508 seterr 1509 pkreset 1510 pks 1 1511 if ne runpk 0 1512 die econd 1513 end 1514 pbw tcond 1515 m = chmod gpb 0 get gpbn 0 493 1516 for i ulong 7 1517 armcase i 1518 end 1519 end 1520 fn armcase i ulong to void 1521 pbkd i 1522 n = cpfrom 1523 pbw tsrc 1524 pbkey i 1525 pbtext tom 1526 cpto n 1527 pbclr 1528 pbslot 0 1529 pbtext tkern 1530 pbcase i 1531 pbtext tc 1532 n2 = cpfrom 1533 pbw tsrc 1534 pbkey i 1535 pbtext tc 1536 cpto n2 1537 pbclr 1538 pbslot 0 1539 pbtext twantd 1540 pbcase i 1541 pbtext tout 1542 n3 = cpfrom 1543 pbw twant 1544 pbkey i 1545 pbtext tout 1546 cpto n3 1547 for a ulong narm 0 1548 omcarm i a 1549 end 1550 negarm i 1551 for o ulong narm 1 1552 carm i o 1553 end 1554 end 1555 note omc arm a: its compiler (slot 2 for omcC, else slot 1) < W/src/KEY.om > W/bin/ARM/KEY 2> R/ARM-CASE.err 1556 fn omcarm i ulong a ulong to void 1557 nored 1558 pbw tsrc 1559 pbkey i 1560 pbtext tom 1561 setin 1562 pbw tbin 1563 pbarm 0 a 1564 pbtext tslash 1565 pbkey i 1566 setout 1567 pbclr 1568 pbslot 3 1569 pbtext tslash 1570 pbarm 0 a 1571 pbtext tdash 1572 pbcase i 1573 pbtext terr 1574 seterr 1575 pkreset 1576 if and eq get gv 1 1 eq a 1 1577 pks 2 1578 else 1579 pks 1 1580 end 1581 if ne runpk 0 1582 pbw tsrc 1583 pbkey i 1584 pbtext tom 1585 diep erefus 1586 end 1587 pbw tbin 1588 pbarm 0 a 1589 pbtext tslash 1590 pbkey i 1591 m = chmod gpb 0 get gpbn 0 493 1592 end 1593 fn negarm i ulong to void 1594 nored 1595 pbw tmut 1596 pbkey i 1597 pbtext tom 1598 setin 1599 pbw tbin 1600 pbtext tneg 1601 pbtext tslash 1602 pbkey i 1603 setout 1604 pbclr 1605 pbslot 3 1606 pbtext tslash 1607 pbtext tneg 1608 pbtext tdash 1609 pbcase i 1610 pbtext terr 1611 seterr 1612 pkreset 1613 pks 1 1614 if ne runpk 0 1615 pbw tmut 1616 pbkey i 1617 pbtext tom 1618 diep erefus 1619 end 1620 pbw tbin 1621 pbtext tneg 1622 pbtext tslash 1623 pbkey i 1624 m = chmod gpb 0 get gpbn 0 493 1625 end 1626 note gcc -Ox -static to bin/cOx/KEY and gcc -Ox -c to obj/CASE.Ox.o, in W; objdump -dr of the object 1627 note to R/disasm-c/CASE.Ox.s (PROTOCOL-2 section 3) 1628 fn carm i ulong o ulong to void 1629 gccpk i o false 1630 nored 1631 pbclr 1632 pbslot 4 1633 setcd 1634 if ne runpk 0 1635 pbw tsrc 1636 die egcc 1637 end 1638 gccpk i o true 1639 if ne runpk 0 1640 pbw tsrc 1641 die egcc 1642 end 1643 nored 1644 pkreset 1645 pkt tobjd 1646 pkt tdr 1647 pbw tobj 1648 pbobj i o 1649 pkpush 1650 pbr tdis2 1651 pbobj2 i o 1652 pbtext tdots 1653 setout 1654 if ne runpk 0 1655 die eobjd 1656 end 1657 end 1658 fn pbobj i ulong o ulong to void 1659 pbcase i 1660 pbtext tdot 1661 pbarm 1 o 1662 pbtext tdoto 1663 end 1664 fn pbobj2 i ulong o ulong to void 1665 pbcase i 1666 pbtext tdot 1667 pbarm 1 o 1668 end 1669 note /usr/bin/gcc -B/usr/bin/ -Ox -static -o bin/cOx/KEY src/KEY.c, or -Ox -c -o obj/CASE.Ox.o src/KEY.c 1670 fn gccpk i ulong o ulong obj bool to void 1671 pkreset 1672 pkt tgcc 1673 pkt tgccb 1674 pbset tdash 1675 pbarm 1 o 1676 pkpush 1677 if obj 1678 pkt tdc 1679 pkt tdo 1680 pbclr 1681 pbtext tobjw 1682 pbobj i o 1683 pkpush 1684 else 1685 pkt tstatic 1686 pkt tdo 1687 pbset tbinw 1688 pbtext tcO 1689 pbarm 1 o 1690 pbtext tslash 1691 pbkey i 1692 pkpush 1693 end 1694 pbset tsrcw 1695 pbkey i 1696 pbtext tc 1697 pkpush 1698 end 1699 1700 note ---- arms.sha256: the find conductor bin mut -type f | LC_ALL=C sort list, hashed in W 1701 fn armsha to void 1702 pkreset 1703 pkt tsha 1704 if eq get gv 1 1 1705 for a ulong 4 1706 armfil tsarmb a 1707 end 1708 else 1709 for b ulong 4 1710 armfil tsarm b 1711 end 1712 end 1713 pkt tcondw 1714 for i ulong 7 1715 pbset tmutw 1716 mkey i 1717 pbtext tom 1718 pkpush 1719 end 1720 nored 1721 pbclr 1722 pbslot 4 1723 setcd 1724 pbset tnull 1725 setin 1726 pbr tarsha 1727 setout 1728 r = runpk 1729 if ne r 0 1730 die esha 1731 end 1732 end 1733 fn armfil t view uchar * a ulong to void 1734 for i ulong 7 1735 pbset tbinw 1736 fldset t 32 a 1737 pbfld t 1738 pbtext tslash 1739 mkey i 1740 pkpush 1741 end 1742 end 1743 note P then the case name in sorted order 1744 fn mkey i ulong to void 1745 if eq get gv 0 1 1746 pbtext tom2s 1747 end 1748 fldset tcsort 32 i 1749 pbfld tcsort 1750 end 1751 1752 note ---- PROTOCOL-3 section 4: under --ab --profile om2, whether the candidate leaves every OM-1 kernel's 1753 note bytes unchanged (a report) 1754 fn identity to void 1755 if or eq get gv 1 0 eq get gv 0 0 1756 ret 1757 end 1758 pbr tident 1759 fd = fopen gpb 0 get gpbn 0 577 420 1760 if lt fd 0 1761 die ewrite 1762 end 1763 for i ulong 7 1764 idone i ulong fd 1765 end 1766 c = fclose int fd 1767 pbw tidB 1768 r = unlink gpb 0 get gpbn 0 1769 pbw tidC 1770 r2 = unlink gpb 0 get gpbn 0 1771 end 1772 fn idone i ulong fd ulong to void 1773 rb = idcomp i 1 tidB 1774 rc = idcomp i 2 tidC 1775 pbw tidB 1776 a = rdin 0 1777 pbw tidC 1778 b = rdin 1 1779 s = and and eq rb 0 eq rc 0 same2 a b 1780 pbclr 1781 pbcase i 1782 lbpb 1783 lbtext tsp 1784 if s 1785 lbtext tsame 1786 else 1787 lbtext tdiff 1788 end 1789 lbtext tbrc 1790 lbnum rb 1791 lbtext tcrc 1792 lbnum rc 1793 lbtext tsp 1794 shaw tidB 1795 lbtext tsp 1796 shaw tidC 1797 lbto fd 1798 end 1799 fn same2 a ulong b ulong to bool 1800 if or ne a b gt a `4194304` 1801 ret false 1802 end 1803 for i ulong a bound `4194304` 1804 if ne get gfb i get gf2 i 1805 ret false 1806 end 1807 end 1808 ret true 1809 end 1810 fn idcomp i ulong k ulong t view uchar * to ulong 1811 nored 1812 pbclr 1813 pbslot 0 1814 pbtext tkern 1815 pbcase i 1816 pbtext tom 1817 setin 1818 pbw t 1819 setout 1820 pbset tnull 1821 seterr 1822 pkreset 1823 pks k 1824 ret runpk 1825 end 1826 note the SHA-256 of W/NAME onto glb 1827 fn shaw t view uchar * to void 1828 pkreset 1829 pkt tsha 1830 pbw t 1831 pkpush 1832 n = capture 1833 lbfirst n true 1834 end 1835 1836 note ---- sizes.txt: file bytes of every arm binary; text bytes = file bytes for the omc arms (no section 1837 note table), the summed .text sections of size -A for the C objects 1838 fn sizes to void 1839 pbr tsizes 1840 fd = fopen gpb 0 get gpbn 0 577 420 1841 if lt fd 0 1842 die ewrite 1843 end 1844 lbtext tszh 1845 lbto ulong fd 1846 for i ulong 7 1847 sizcase i ulong fd 1848 end 1849 c = fclose int fd 1850 end 1851 fn sizcase i ulong fd ulong to void 1852 for a ulong narm 0 1853 pbw tbin 1854 pbarm 0 a 1855 pbtext tslash 1856 pbkey i 1857 n = fsize 1858 pbclr 1859 pbkey i 1860 lbpb 1861 lbtext tsp 1862 pbclr 1863 pbarm 0 a 1864 lbpb 1865 lbtext tsp 1866 lbnum n 1867 lbtext tsp 1868 lbnum n 1869 lbto fd 1870 end 1871 for o ulong narm 1 1872 sizc i o fd 1873 end 1874 end 1875 fn sizc i ulong o ulong fd ulong to void 1876 pbw tbin 1877 pbtext tcO 1878 pbarm 1 o 1879 pbtext tslash 1880 pbkey i 1881 n = fsize 1882 pbclr 1883 pbkey i 1884 lbpb 1885 lbtext tsp 1886 pbset tcO 1887 pbarm 1 o 1888 lbpb 1889 lbtext tsp 1890 lbnum n 1891 lbtext tsp 1892 pkreset 1893 pkt tsize 1894 pkt tsA 1895 pbw tobj 1896 pbobj i o 1897 pkpush 1898 m = capture 1899 lbnum textsz m 1900 lbto fd 1901 end 1902 fn fsize to ulong 1903 n = rdin 0 1904 if gt n `4194304` 1905 die ecopy 1906 end 1907 ret n 1908 end 1909 note the sum of the size column of the lines whose first field starts with .text 1910 fn textsz n ulong to ulong 1911 v = ulong 0 1912 s = ulong 0 1913 while lt s n bound `4194304` 1914 e = lnend s n 1915 f0 = skipsp s e 1916 if istext f0 e 1917 f1 = wordend f0 e 1918 f2 = skipsp f1 e 1919 v = add v decat f2 e 1920 end 1921 s = add e 1 1922 end 1923 ret v 1924 end 1925 fn istext s ulong e ulong to bool 1926 m = len tptext 1927 if lt sub e s m 1928 ret false 1929 end 1930 for i ulong m 1931 if ne get gfb add s i get tptext i 1932 ret false 1933 end 1934 end 1935 ret true 1936 end 1937 fn decat s ulong e ulong to ulong 1938 v = ulong 0 1939 i = s 1940 while lt i e bound 32 1941 c = get gfb i 1942 if or lt c 48 gt c 57 1943 ret v 1944 end 1945 v = add mul v 10 ulong sub c 48 1946 i = add i 1 1947 end 1948 ret v 1949 end 1950 1951 note ---- the declared runs: compile time first, then the emitted programs; each status is recorded and 1952 note any nonzero one makes the exit status 1 1953 fn cpk1 to void 1954 pkreset 1955 put gpinned 0 1 1956 pkt tcondx 1957 end 1958 fn crun ro view uchar * re view uchar * to ulong 1959 nored 1960 pbclr 1961 pbslot 4 1962 setcd 1963 pbset tnull 1964 setin 1965 pbr ro 1966 setout 1967 pbr re 1968 seterr 1969 r = runpk 1970 if ne r 0 1971 put gv 3 add get gv 3 1 1972 end 1973 ret r 1974 end 1975 fn cargs to void 1976 for i ulong 7 1977 pbclr 1978 pbkey i 1979 pkpush 1980 end 1981 end 1982 fn bpre k ulong to void 1983 cpk1 1984 pkt tbuild 1985 pkt t10 1986 pkt t1 1987 pks 7 1988 pks k 1989 end 1990 fn runs to void 1991 if eq get gv 1 1 1992 runsab 1993 ret 1994 end 1995 bpre 1 1996 pkt t3 1997 pkt tomc 1998 pkt tcO2 1999 pkt tcO0 2000 cargs 2001 r = crun tbraw tberr 2002 lbtext pbrc 2003 lbnum r 2004 lbpv 2005 rpre 2006 pkt tomc 2007 pkt tcO2 2008 pkt tcO0 2009 pkt tneg 2010 cargs 2011 r2 = crun trraw trerr 2012 lbtext prrc 2013 lbnum r2 2014 lbpv 2015 end 2016 fn rpre to void 2017 cpk1 2018 pkt trun 2019 pkt t21 2020 pkt t3 2021 pks 5 2022 pkt t1 2023 pkt t4 2024 end 2025 fn runsab to void 2026 bpre 1 2027 pkt t1 2028 pkt tomcB 2029 cargs 2030 r = crun tbbraw tbberr 2031 lbtext pbbrc 2032 lbnum r 2033 lbpv 2034 bpre 2 2035 pkt t1 2036 pkt tomcC 2037 cargs 2038 r2 = crun tbcraw tbcerr 2039 lbtext pbcrc 2040 lbnum r2 2041 lbpv 2042 rpre 2043 pkt tomcB 2044 pkt tomcC 2045 pkt tcO2 2046 pkt tneg 2047 cargs 2048 r3 = crun trraw trerr 2049 lbtext prrc 2050 lbnum r3 2051 lbpv 2052 end 2053 2054 note ---- the end: provenance.txt and the last row of every raw file on stdout 2055 fn finish to int 2056 lbtext pld1 2057 loadavg 2058 lbpv 2059 c = fclose int get gv 2 2060 pbr tprov 2061 n = rdin 0 2062 if le n `4194304` 2063 w = write 1 gfb 0 n 2064 end 2065 if eq get gv 1 1 2066 tailf tbbraw 2067 tailf tbcraw 2068 else 2069 tailf tbraw 2070 end 2071 tailf trraw 2072 if eq get gv 3 0 2073 ret 0 2074 end 2075 ret 1 2076 end 2077 fn tailf t view uchar * to void 2078 pbr t 2079 lbtext ttl1 2080 lbpb 2081 lbtext ttl2 2082 lbout 2083 n = rdin 0 2084 if gt n `4194304` 2085 ret 2086 end 2087 e = n 2088 if and gt e 0 eq get gfb sub e 1 10 2089 e = sub e 1 2090 end 2091 s = e 2092 while and gt s 0 ne get gfb sub s 1 10 bound `4194304` 2093 s = sub s 1 2094 end 2095 for i ulong sub e s bound `4194304` 2096 m = get glbn 0 2097 if lt m 8000 2098 put glb m get gfb add s i 2099 put glbn 0 add m 1 2100 end 2101 end 2102 lbout 2103 end 2104 2105 fn main to int 2106 parse 2107 mkdirs 2108 prov 2109 inputs 2110 om2chk 2111 for i ulong 7 2112 mutate i 2113 end 2114 arms 2115 armsha 2116 identity 2117 sizes 2118 runs 2119 ret finish 2120 end