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/gpu/runtime/gate.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 / gpu / runtime / gate.om` 1348 lines ยท 25261 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 2 note gpu/runtime/gate.om: OMEGA-GPU-RUNTIME, the gate of gpu/runtime/ (the inventory of CUDApp src/, the C runtime, and 3 note the Omega rewrites of its files done so far), in 4 note seeded Omega (OM-2 program mode, Linux AArch64). Build from the repository root: 5 note { printf 'om2\n'; cat seed/ng/sha256.om gpu/runtime/zsha.om gpu/runtime/gate.om; } | seed/out/omc > gate 6 note Run from the repository root: gate OMC SCRATCH 7 note OMC the compiler under test; its sha256 must equal the first word of seed/out/omc.sha256, or nothing 8 note runs (exit 69, nothing written) 9 note SCRATCH a new directory (created 0700); an existing one is refused (exit 2) 10 note Checks. gpu/runtime/checks.tsv, one per line, tab separated: NAME PARTS EXPECT MPART FIND REPLACE. 11 note NAME one or more of A-Z a-z 0-9 _ -, once. PARTS: paths joined by commas, composed in order, each followed by a 12 note newline into SCRATCH/uK.om (K the number of the name, counted from 1 in the order names are read, so a name 13 note never becomes a file name); the part om2 is the literal line om2. The unit is compiled by OMC and run from 14 note the repository root with no argument: exit 0, and its stdout holds exactly the bytes of the file EXPECT. 15 note Mutant control: the same composition with the first FIND in part number MPART (from 1) replaced by 16 note REPLACE must compile, and its run must exit nonzero or print other bytes. FIND absent is a FAIL. 17 note Inventory controls. gpu/runtime/controls.tsv, tab separated: NAME FILE TOKEN EXIT. The check named 18 note inventory is run as SCRATCH/uI.bin DIR (I its number), DIR a copy of its inputs in SCRATCH: first unchanged (the 19 note output must be gpu/runtime/INVENTORY.tsv, exit 0), then once per row with FILE's byte after the first 20 note TOKEN changed (0 becomes 1, anything else 0; an empty TOKEN is the first byte). Caught: EXIT - when the 21 note run exits nonzero or prints other bytes, a number when it exits with exactly that code. 22 note Rewrites. Every row of gpu/runtime/rewrites.tsv (CUDAPP-PATH TAB OMEGA-PATH) must have its OMEGA-PATH as one 23 note whole part of the PARTS of some check row, or it is a FAIL line. Control: the first row's OMEGA-PATH less its 24 note last byte must be in no check's PARTS (a matcher that took a prefix or substring would pass it). 25 note Control: a compiler one byte longer fails the digest check. 26 note Output: one line per check and control, then 27 note OMEGA-GPU-RUNTIME PASS|FAIL checks=N controls=C caught=K hardware=NOT_RUN; PASS needs N above 0, no FAIL line 28 note and K equal to C. N and C follow the tables (each check row adds a check and a control, each control row a 29 note control, plus the compiler control and the rewrites control), so no other file restates them. 30 note Exit 0 PASS, 1 FAIL, 2 bad usage or setup, 4 the host refused memory, 69 compiler digest refused. 31 note Memory grows with the input (run-time pools), names included. The one fixed limit is the Linux path limit: 32 note PATH_MAX is 4096 bytes with the terminating zero, so every path the gate builds (OMC, or SCRATCH/ plus a 33 note file name of its own) must be under 4096 bytes, and a longer one is refused (exit 2) before any system call takes it. 34 note A child that runs past 600 s is killed and is a FAIL line. 35 text t_pin "seed/out/omc.sha256" 36 text t_tab "gpu/runtime/checks.tsv" 37 text t_ctab "gpu/runtime/controls.tsv" 38 text t_inv "inventory" 39 text t_invx "gpu/runtime/INVENTORY.tsv" 40 text t_rt "gpu/runtime/" 41 text t_null "/dev/null" 42 text t_base "base" 43 text t_in1 "cudapp-src.sha256.txt" 44 text t_in2 "omega-base.sha256.txt" 45 text t_in3 "cudapp-ident.txt" 46 text t_in4 "pathmap.tsv" 47 text t_in5 "rewrites.tsv" 48 text t_om ".om" 49 text t_bin ".bin" 50 text t_err ".err" 51 text t_out ".out" 52 text t_mom ".m.om" 53 text t_mbin ".m.bin" 54 text t_merr ".m.err" 55 text t_mout ".m.out" 56 text t_l2 "om2" 57 text t_plus "omc-plus-one" 58 text t_usage "usage: gate OMC SCRATCH (run from the omega-mv repository root)\n" 59 text t_refd "OMEGA-GPU-RUNTIME REFUSED: compiler digest differs from seed/out/omc.sha256 (exit 69)\n" 60 text t_nopin "OMEGA-GPU-RUNTIME INVALID: cannot read a 64-hex digest from seed/out/omc.sha256\n" 61 text t_noscr "OMEGA-GPU-RUNTIME INVALID: SCRATCH exists or cannot be made\n" 62 text t_notab "OMEGA-GPU-RUNTIME INVALID: cannot read gpu/runtime/checks.tsv or controls.tsv\n" 63 text t_plong "OMEGA-GPU-RUNTIME INVALID: a path longer than 4095 bytes\n" 64 text t_mem "OMEGA-GPU-RUNTIME: the host refused memory\n" 65 text t_ok "ok " 66 text t_fail "FAIL " 67 text t_chk "check " 68 text t_ctl "control " 69 text t_bytes " bytes=" 70 text t_sha " sha256=" 71 text t_exit " exit=" 72 text t_mut " mutant" 73 text t_row "malformed row" 74 text t_src "source unreadable" 75 text t_cmp "compile failed" 76 text t_mcmp "mutant compile failed" 77 text t_find "FIND not in part MPART" 78 text t_wr "cannot write in SCRATCH" 79 text t_run "run exit not 0" 80 text t_diff "output differs from EXPECT" 81 text t_mto "child passed the 600 s deadline and was killed: a timeout is not a catch" 82 text t_noexp "EXPECT unreadable" 83 text t_nobin "no inventory check" 84 text t_none "no check passed" 85 text t_ntok "TOKEN not in FILE" 86 text t_caught " caught" 87 text t_esc " ESCAPED" 88 text t_sum "OMEGA-GPU-RUNTIME " 89 text t_pass "PASS" 90 text t_fl "FAIL" 91 text t_sk " checks=" 92 text t_sc " controls=" 93 text t_sg " caught=" 94 text t_hw " hardware=NOT_RUN\n" 95 text t_rwk "rewrite " 96 text t_nochk " is in no check's PARTS" 97 text t_rwc "rewrite-unchecked" 98 text t_pre " prefix of a rewrite path" 99 global g_pa uchar 4096 100 global g_scr uchar 4096 101 global g_omc uchar 4096 102 global g_nm uchar * 103 global g_pin uchar 64 104 global g_stb uchar 4 105 global g_n ulong 32 106 global g_b uchar * 107 global g_c uchar * 108 global g_t uchar * 109 global g_o uchar * 110 note execprog takes a fixed array: at most two path arguments of under 4096 bytes each (pc refuses longer) 111 global g_av uchar 8196 112 note g_n: 0 path length, 1 omc length, 2 scratch length (with '/'), 3 argv bytes, 4 argc, 5 output length, 113 note 6 g_b length, 7 g_c length, 8 checks passed, 9 name number K, 10 the inventory check's K, 11 failures, 114 note 12 controls, 13 caught, 14 name length, 115 note 15 g_t length, 16 inventory check passed, 17 a field start, 18 a field end 116 note ---- memory 117 fn die4 to void 118 r = write 2 t_mem 0 len t_mem 119 exit 4 120 end 121 fn growb n ulong to void 122 if gt n len g_b 123 r = enlarge g_b add mul len g_b 2 n 124 if ne r 0 125 die4 126 end 127 end 128 end 129 note g_nm holds at least n bytes 130 fn nmgrow n ulong to void 131 if gt n len g_nm 132 r = enlarge g_nm add mul len g_nm 2 n 133 if ne r 0 134 die4 135 end 136 end 137 end 138 fn growc n ulong to void 139 if gt n len g_c 140 r = enlarge g_c add mul len g_c 2 n 141 if ne r 0 142 die4 143 end 144 end 145 end 146 note ---- output 147 fn oc c ulong to void 148 n = get g_n 5 149 if ge n len g_o 150 r = enlarge g_o add mul n 2 4096 151 if ne r 0 152 die4 153 end 154 end 155 put g_o n uchar c 156 put g_n 5 add n 1 157 end 158 fn ot t view uchar * to void 159 for i ulong len t bound 4096 160 oc ulong get t i 161 end 162 end 163 fn onm to void 164 for i ulong get g_n 14 bound `9223372036854775807` 165 oc ulong get g_nm i 166 end 167 end 168 fn onum v ulong to void 169 if ge v 10 170 onum div v 10 171 end 172 oc add 48 rem v 10 173 end 174 fn ohex to void 175 for j ulong 32 176 b = get sh_dig j 177 oc ulong sh_hexd uint shr b 4 178 oc ulong sh_hexd uint and b 15 179 end 180 end 181 fn oflush to void 182 n = get g_n 5 183 o = ulong 0 184 while lt o n bound `9223372036854775807` 185 x = write 1 g_o o sub n o 186 if le x 0 187 exit 2 188 end 189 o = add o ulong x 190 end 191 put g_n 5 0 192 end 193 fn onl to void 194 oc 10 195 oflush 196 end 197 note a failed check: FAIL KIND NAME then the reason; counts a failure 198 fn ofail kind view uchar * why view uchar * to void 199 ot t_fail 200 ot kind 201 onm 202 oc 32 203 ot why 204 onl 205 put g_n 11 add get g_n 11 1 206 end 207 note ---- paths: g_pa[0, g_n 0) 208 fn pclr to void 209 put g_n 0 0 210 end 211 fn pc c ulong to void 212 n = get g_n 0 213 if ge n 4095 214 r = write 2 t_plong 0 len t_plong 215 exit 2 216 end 217 put g_pa n uchar c 218 put g_n 0 add n 1 219 end 220 fn pt t view uchar * to void 221 for i ulong len t bound 4096 222 pc ulong get t i 223 end 224 end 225 fn pscr to void 226 for j ulong get g_n 2 bound 4096 227 pc ulong get g_scr j 228 end 229 end 230 note the scratch file stem uK: u, then K in decimal 231 fn pstem k ulong to void 232 pc 117 233 pdec k 234 end 235 fn pdec v ulong to void 236 if ge v 10 237 pdec div v 10 238 end 239 pc add 48 rem v 10 240 end 241 note g_t[a, b) as path bytes 242 fn ptr a ulong b ulong to void 243 for i ulong sub b a bound `9223372036854775807` 244 pc ulong get g_t add a i 245 end 246 end 247 note scratch file uK then suffix, K the number of the current name (g_n 9) 248 fn psn suf view uchar * to void 249 pclr 250 pscr 251 pstem get g_n 9 252 pt suf 253 end 254 fn nmset t view uchar * to void 255 put g_n 9 add get g_n 9 1 256 nmgrow len t 257 for i ulong len t bound 4096 258 put g_nm i get t i 259 end 260 put g_n 14 len t 261 end 262 note ---- files 263 fn fopn fl ulong mode ulong to int 264 r = fopen g_pa 0 get g_n 0 int fl int mode 265 if lt r 0 266 ret -1 267 end 268 ret int r 269 end 270 fn frd to int 271 ret fopn 524288 0 272 end 273 fn fwr to int 274 ret fopn 524865 420 275 end 276 fn fexe to int 277 r = unlink g_pa 0 get g_n 0 278 ret fopn 524865 448 279 end 280 fn fclo fd int to void 281 if ge fd 0 282 r = fclose fd 283 end 284 end 285 fn rdb fd int n ulong to long 286 growb add n 65536 287 ret read fd g_b n sub len g_b n 288 end 289 fn rdc fd int n ulong to long 290 growc add n 65536 291 ret read fd g_c n sub len g_c n 292 end 293 note append the file at g_pa to g_b (w 0) or g_c (w 1); false when unreadable 294 fn fload w ulong to bool 295 fd = frd 296 if lt fd 0 297 ret false 298 end 299 ok = true 300 while true bound `9223372036854775807` 301 n = get g_n add 6 w 302 x = long 0 303 if eq w 0 304 x = rdb fd n 305 else 306 x = rdc fd n 307 end 308 if lt x 0 309 ok = false 310 break 311 end 312 if eq x 0 313 break 314 end 315 put g_n add 6 w add n ulong x 316 end 317 fclo fd 318 ret ok 319 end 320 note write g_b[0, g_n 6) to the file at g_pa (0644, or 0700 when exe) 321 fn bsave exe bool to bool 322 fd = int -1 323 if exe 324 fd = fexe 325 else 326 fd = fwr 327 end 328 if lt fd 0 329 ret false 330 end 331 n = get g_n 6 332 o = ulong 0 333 ok = true 334 while lt o n bound `9223372036854775807` 335 x = write fd g_b o sub n o 336 if le x 0 337 ok = false 338 break 339 end 340 o = add o ulong x 341 end 342 fclo fd 343 ret ok 344 end 345 note sha256 of the file at g_pa into sh_dig; false when unreadable 346 fn fhash to bool 347 fd = frd 348 if lt fd 0 349 ret false 350 end 351 zbeg 352 ok = zfd fd 353 fclo fd 354 zend 355 ret ok 356 end 357 note sha256 of g_b[0, g_n 6) into sh_dig 358 fn bhash to void 359 zbeg 360 for i ulong get g_n 6 bound `9223372036854775807` 361 zbyte ulong get g_b i 362 end 363 zend 364 end 365 note g_b[0, g_n 6) equals g_c[0, g_n 7) 366 fn bceq to bool 367 n = get g_n 6 368 if ne n get g_n 7 369 ret false 370 end 371 for i ulong n bound `9223372036854775807` 372 if ne get g_b i get g_c i 373 ret false 374 end 375 end 376 ret true 377 end 378 note ---- processes 379 fn aclr to void 380 put g_n 3 2 381 put g_n 4 0 382 put g_av 0 0 383 put g_av 1 0 384 end 385 note append g_pa as one argument 386 fn apa to void 387 p = get g_n 3 388 n = get g_n 0 389 for j ulong n bound 4096 390 put g_av add add p 2 j get g_pa j 391 end 392 put g_av p uchar and n 255 393 put g_av add p 1 uchar shr n 8 394 put g_n 3 add p add n 2 395 c = add get g_n 4 1 396 put g_n 4 c 397 put g_av 0 uchar and c 255 398 put g_av 1 uchar shr c 8 399 end 400 fn redir s int d int to void 401 if ne dupfd s d 0 long d 402 exit 127 403 end 404 end 405 note run the argument list with stdin, stdout, stderr fds (closed here): the exit code, 256 + the signal, 512 406 note when a file could not be opened, 1000 when the child passed the 600 s deadline (killed) 407 fn spawn fi int fo int fe int to ulong 408 if or lt fi 0 or lt fo 0 lt fe 0 409 fclo fi 410 fclo fo 411 fclo fe 412 ret 512 413 end 414 pid = fork 415 if lt pid 0 416 exit 2 417 end 418 if eq pid 0 419 redir fi 0 420 redir fo 1 421 redir fe 2 422 r = execprog g_av 0 get g_n 3 423 exit 127 424 end 425 fclo fi 426 fclo fo 427 fclo fe 428 t0 = monons 429 while true bound `9223372036854775807` 430 r = waitpid int pid g_stb 0 len g_stb 1 431 if eq r pid 432 x = ulong get g_stb 0 433 if ne x 0 434 ret add 256 x 435 end 436 ret ulong get g_stb 1 437 end 438 if lt r 0 439 exit 2 440 end 441 if gt sub monons t0 `600000000000` 442 r = killpid int pid 9 443 r = waitpid int pid g_stb 0 len g_stb 0 444 ret 1000 445 end 446 q = sleepns 200000 447 end 448 exit 2 449 end 450 fn pomc to void 451 pclr 452 for j ulong get g_n 1 bound 4096 453 pc ulong get g_omc j 454 end 455 end 456 note OMC < SCRATCH/uK.SRC > SCRATCH/uK.BIN 2> SCRATCH/uK.ERR 457 fn omc src view uchar * bin view uchar * err view uchar * to ulong 458 psn src 459 fi = frd 460 aclr 461 pomc 462 apa 463 psn bin 464 fo = fexe 465 psn err 466 fe = fwr 467 ret spawn fi fo fe 468 end 469 note SCRATCH/uK.BIN < /dev/null > SCRATCH/uK.OUT 2> SCRATCH/uK.ERR 470 fn runb bin view uchar * outf view uchar * err view uchar * to ulong 471 pclr 472 pt t_null 473 fi = frd 474 aclr 475 psn bin 476 apa 477 psn outf 478 fo = fwr 479 psn err 480 fe = fwr 481 ret spawn fi fo fe 482 end 483 note ---- the compiler digest 484 fn pinread to bool 485 pclr 486 pt t_pin 487 put g_n 6 0 488 if not fload 0 489 ret false 490 end 491 if lt get g_n 6 64 492 ret false 493 end 494 for j ulong 64 495 c = get g_b j 496 ok = or and ge c 48 le c 57 and ge c 97 le c 102 497 if not ok 498 ret false 499 end 500 put g_pin j c 501 end 502 ret true 503 end 504 note the file at g_pa hashes to g_pin 505 fn pinok to bool 506 if not fhash 507 ret false 508 end 509 for j ulong 32 510 b = get sh_dig j 511 if ne get g_pin mul j 2 sh_hexd uint shr b 4 512 ret false 513 end 514 if ne get g_pin add mul j 2 1 sh_hexd uint and b 15 515 ret false 516 end 517 end 518 ret true 519 end 520 note ---- the table g_t 521 fn tis i ulong e ulong c ulong to bool 522 if ge i e 523 ret false 524 end 525 ret eq ulong get g_t i c 526 end 527 fn eol p ulong to ulong 528 e = get g_n 15 529 q = p 530 while lt q e bound `9223372036854775807` 531 if eq get g_t q 10 532 ret q 533 end 534 q = add q 1 535 end 536 ret e 537 end 538 note field k (from 0) of the tab-separated line [s, z) into g_n 17, 18; false when the line has fewer fields 539 fn fld s ulong z ulong k ulong to bool 540 a = s 541 for f ulong k bound `9223372036854775807` 542 while and lt a z not tis a z 9 bound `9223372036854775807` 543 a = add a 1 544 end 545 if ge a z 546 ret false 547 end 548 a = add a 1 549 end 550 b = a 551 while and lt b z not tis b z 9 bound `9223372036854775807` 552 b = add b 1 553 end 554 put g_n 17 a 555 put g_n 18 b 556 ret true 557 end 558 fn nameok c ulong to bool 559 if and ge c 48 le c 57 560 ret true 561 end 562 if and ge c 65 le c 90 563 ret true 564 end 565 if and ge c 97 le c 122 566 ret true 567 end 568 ret or eq c 95 eq c 45 569 end 570 note field 0 of [s, z) to g_nm; false unless one or more name bytes 571 fn nmfld s ulong z ulong to bool 572 put g_n 9 add get g_n 9 1 573 if not fld s z 0 574 ret false 575 end 576 a = get g_n 17 577 b = get g_n 18 578 if eq a b 579 ret false 580 end 581 nmgrow sub b a 582 for i ulong sub b a bound `9223372036854775807` 583 c = ulong get g_t add a i 584 if not nameok c 585 ret false 586 end 587 put g_nm i uchar c 588 end 589 put g_n 14 sub b a 590 ret true 591 end 592 note ---- compose: parts field [a, b), part number mp (from 1) mutated by FIND [fa, fb) to REPLACE [ra, rb) 593 note when mp is not 0; false (a FAIL line written) when a part is unreadable or FIND is absent 594 fn cat i ulong fa ulong k ulong to bool 595 for j ulong k bound `9223372036854775807` 596 c = get g_c add i j 597 if ne c get g_t add fa j 598 ret false 599 end 600 end 601 ret true 602 end 603 note the first FIND [fa, fb) in g_c[0, g_n 7), or g_n 7 when absent or empty 604 fn cfind fa ulong fb ulong to ulong 605 n = get g_n 7 606 k = sub fb fa 607 if or eq k 0 gt k n 608 ret n 609 end 610 for i ulong add sub n k 1 bound `9223372036854775807` 611 if cat i fa k 612 ret i 613 end 614 end 615 ret n 616 end 617 fn bput c ulong to void 618 n = get g_n 6 619 growb add n 1 620 put g_b n uchar c 621 put g_n 6 add n 1 622 end 623 note g_c to g_b, the first FIND replaced; false when FIND is absent 624 fn cmut fa ulong fb ulong ra ulong rb ulong to bool 625 n = get g_n 7 626 p = cfind fa fb 627 if ge p n 628 ret false 629 end 630 for i ulong p bound `9223372036854775807` 631 bput ulong get g_c i 632 end 633 for i ulong sub rb ra bound `9223372036854775807` 634 bput ulong get g_t add ra i 635 end 636 q = add p sub fb fa 637 for i ulong sub n q bound `9223372036854775807` 638 bput ulong get g_c add q i 639 end 640 ret true 641 end 642 fn ctx t view uchar * to void 643 for i ulong len t bound 4096 644 bput ulong get t i 645 end 646 end 647 fn isom2 a ulong b ulong to bool 648 if ne sub b a 3 649 ret false 650 end 651 for i ulong 3 652 if ne get g_t add a i get t_l2 i 653 ret false 654 end 655 end 656 ret true 657 end 658 fn compose a ulong b ulong mp ulong to bool 659 put g_n 6 0 660 i = a 661 k = ulong 1 662 while lt i b bound `9223372036854775807` 663 j = i 664 while and lt j b not tis j b 44 bound `9223372036854775807` 665 j = add j 1 666 end 667 if isom2 i j 668 ctx t_l2 669 else 670 pclr 671 ptr i j 672 put g_n 7 0 673 if not fload 1 674 ofail t_chk t_src 675 ret false 676 end 677 if eq k mp 678 if not cmut get g_n 19 get g_n 20 get g_n 21 get g_n 22 679 ofail t_chk t_find 680 ret false 681 end 682 else 683 for q ulong get g_n 7 bound `9223372036854775807` 684 bput ulong get g_c q 685 end 686 end 687 end 688 bput 10 689 k = add k 1 690 i = add j 1 691 end 692 ret true 693 end 694 note ---- one check row [s, z) 695 note load EXPECT [ea, eb) into g_c, SCRATCH/uK.OUTF into g_b; true when equal (the output sha256 in sh_dig) 696 fn cmpout ea ulong eb ulong outf view uchar * to ulong 697 pclr 698 ptr ea eb 699 put g_n 7 0 700 if not fload 1 701 ret 2 702 end 703 psn outf 704 put g_n 6 0 705 if not fload 0 706 ret 1 707 end 708 bhash 709 if bceq 710 ret 0 711 end 712 ret 1 713 end 714 fn cfail why view uchar * r ulong to void 715 ot t_fail 716 ot t_chk 717 onm 718 oc 32 719 ot why 720 ot t_exit 721 onum r 722 onl 723 put g_n 11 add get g_n 11 1 724 end 725 fn crow s ulong z ulong to void 726 if not nmset2 s z 727 ret 728 end 729 if not fld s z 1 730 ofail t_chk t_row 731 ret 732 end 733 pa = get g_n 17 734 pb = get g_n 18 735 if not fld s z 2 736 ofail t_chk t_row 737 ret 738 end 739 ea = get g_n 17 740 eb = get g_n 18 741 if not crowm s z 742 ofail t_chk t_row 743 ret 744 end 745 if not compose pa pb 0 746 ret 747 end 748 psn t_om 749 if not bsave false 750 ofail t_chk t_wr 751 ret 752 end 753 r = omc t_om t_bin t_err 754 if ne r 0 755 cfail t_cmp r 756 ret 757 end 758 r = runb t_bin t_out t_err 759 if ne r 0 760 cfail t_run r 761 ret 762 end 763 c = cmpout ea eb t_out 764 if eq c 2 765 ofail t_chk t_noexp 766 ret 767 end 768 if ne c 0 769 ofail t_chk t_diff 770 ret 771 end 772 ot t_ok 773 ot t_chk 774 onm 775 ot t_bytes 776 onum get g_n 6 777 ot t_sha 778 ohex 779 onl 780 put g_n 8 add get g_n 8 1 781 if istx t_inv 782 put g_n 16 1 783 put g_n 10 get g_n 9 784 end 785 cmutant pa pb ea eb 786 end 787 note name field to g_nm, or a FAIL line 788 fn nmset2 s ulong z ulong to bool 789 if nmfld s z 790 ret true 791 end 792 put g_n 14 0 793 ofail t_chk t_row 794 ret false 795 end 796 note MPART, FIND, REPLACE of row [s, z) into g_n 23, 19..22 797 fn crowm s ulong z ulong to bool 798 if not fld s z 3 799 ret false 800 end 801 a = get g_n 17 802 b = get g_n 18 803 if or eq a b gt sub b a 18 804 ret false 805 end 806 m = ulong 0 807 for i ulong sub b a bound 32 808 c = ulong get g_t add a i 809 if or lt c 48 gt c 57 810 ret false 811 end 812 m = add mul m 10 sub c 48 813 end 814 if eq m 0 815 ret false 816 end 817 put g_n 23 m 818 if not fld s z 4 819 ret false 820 end 821 if eq get g_n 17 get g_n 18 822 ret false 823 end 824 put g_n 19 get g_n 17 825 put g_n 20 get g_n 18 826 if not fld s z 5 827 ret false 828 end 829 put g_n 21 get g_n 17 830 put g_n 22 get g_n 18 831 ret true 832 end 833 fn istx t view uchar * to bool 834 if ne get g_n 14 len t 835 ret false 836 end 837 for i ulong len t bound 4096 838 if ne get g_nm i get t i 839 ret false 840 end 841 end 842 ret true 843 end 844 note the mutant of the current check: compiles, then exits nonzero or prints other bytes 845 fn cmutant pa ulong pb ulong ea ulong eb ulong to void 846 put g_n 12 add get g_n 12 1 847 if not compose pa pb get g_n 23 848 ret 849 end 850 psn t_mom 851 if not bsave false 852 ofail t_chk t_wr 853 ret 854 end 855 r = omc t_mom t_mbin t_merr 856 if ne r 0 857 cfail t_mcmp r 858 ret 859 end 860 r = runb t_mbin t_mout t_merr 861 if eq r 1000 862 cfail t_mto r 863 ret 864 end 865 c = cmpout ea eb t_mout 866 if eq c 2 867 ofail t_chk t_noexp 868 ret 869 end 870 caught or ne r 0 ne c 0 t_mut 871 end 872 fn caught c bool what view uchar * to void 873 if c 874 ot t_ok 875 ot t_ctl 876 onm 877 ot what 878 ot t_caught 879 onl 880 put g_n 13 add get g_n 13 1 881 else 882 ot t_fail 883 ot t_ctl 884 onm 885 ot what 886 ot t_esc 887 onl 888 put g_n 11 add get g_n 11 1 889 end 890 end 891 fn tload tb view uchar * to bool 892 pclr 893 pt tb 894 put g_n 6 0 895 if not fload 0 896 ret false 897 end 898 n = get g_n 6 899 r = enlarge g_t n 900 if ne r 0 901 die4 902 end 903 for i ulong n bound `9223372036854775807` 904 put g_t i get g_b i 905 end 906 put g_n 15 n 907 ret true 908 end 909 fn rowskip s ulong z ulong to bool 910 if eq s z 911 ret true 912 end 913 ret eq get g_t s 35 914 end 915 fn checks to void 916 e = get g_n 15 917 s = ulong 0 918 while lt s e bound `9223372036854775807` 919 z = eol s 920 if not rowskip s z 921 crow s z 922 end 923 s = add z 1 924 end 925 end 926 note ---- rewrites.tsv against the PARTS of checks.tsv (in g_t) 927 note g_b[a, b) equals g_t[i, j) 928 fn bteq a ulong b ulong i ulong j ulong to bool 929 if ne sub b a sub j i 930 ret false 931 end 932 for k ulong sub b a bound `9223372036854775807` 933 if ne get g_b add a k get g_t add i k 934 ret false 935 end 936 end 937 ret true 938 end 939 note one comma-separated part of the PARTS of the check row [s, z) is g_b[a, b) 940 fn rowhas a ulong b ulong s ulong z ulong to bool 941 if not fld s z 1 942 ret false 943 end 944 i = get g_n 17 945 e = get g_n 18 946 while le i e bound `9223372036854775807` 947 j = i 948 while and lt j e not tis j e 44 bound `9223372036854775807` 949 j = add j 1 950 end 951 if bteq a b i j 952 ret true 953 end 954 i = add j 1 955 end 956 ret false 957 end 958 fn tabhas a ulong b ulong to bool 959 e = get g_n 15 960 s = ulong 0 961 while lt s e bound `9223372036854775807` 962 z = eol s 963 if not rowskip s z 964 if rowhas a b s z 965 ret true 966 end 967 end 968 s = add z 1 969 end 970 ret false 971 end 972 note the first byte c (or q) in g_b[p, q) 973 fn bto p ulong q ulong c ulong to ulong 974 i = p 975 while lt i q bound `9223372036854775807` 976 if eq ulong get g_b i c 977 ret i 978 end 979 i = add i 1 980 end 981 ret q 982 end 983 fn rwnot a ulong b ulong to void 984 ot t_fail 985 ot t_rwk 986 for i ulong sub b a bound `9223372036854775807` 987 oc ulong get g_b add a i 988 end 989 ot t_nochk 990 onl 991 put g_n 11 add get g_n 11 1 992 end 993 fn rwchk to void 994 pclr 995 pt t_rt 996 pt t_in5 997 put g_n 6 0 998 if not fload 0 999 nmset t_in5 1000 ofail t_chk t_src 1001 ret 1002 end 1003 e = get g_n 6 1004 s = ulong 0 1005 first = true 1006 while lt s e bound `9223372036854775807` 1007 z = bto s e 10 1008 if and lt s z ne get g_b s 35 1009 t = bto s z 9 1010 if ge add t 1 z 1011 nmset t_in5 1012 ofail t_chk t_row 1013 ret 1014 end 1015 a = add t 1 1016 b = bto a z 9 1017 if not tabhas a b 1018 rwnot a b 1019 end 1020 if first 1021 first = false 1022 put g_n 12 add get g_n 12 1 1023 nmset t_rwc 1024 caught not tabhas a sub b 1 t_pre 1025 end 1026 end 1027 s = add z 1 1028 end 1029 end 1030 note ---- inventory controls 1031 note copy gpu/runtime/FILE to SCRATCH/uKd/FILE (K the number of the current name); with flip, change the byte 1032 note after the first TOKEN [ta, tb) of g_n 19, 20 when FILE is FL [fa, fb) of g_t; false on a failure 1033 fn cpin f view uchar * flip bool fa ulong fb ulong to bool 1034 pclr 1035 pt t_rt 1036 pt f 1037 put g_n 7 0 1038 if not fload 1 1039 ret false 1040 end 1041 put g_n 6 0 1042 mine = flip 1043 if mine 1044 mine = tfeq fa fb f 1045 end 1046 if mine 1047 p = cfind get g_n 19 get g_n 20 1048 if eq get g_n 19 get g_n 20 1049 p = ulong 0 1050 else 1051 p = add p sub get g_n 20 get g_n 19 1052 end 1053 if ge p get g_n 7 1054 put g_n 24 1 1055 ret true 1056 end 1057 c = get g_c p 1058 if eq c 48 1059 put g_c p 49 1060 else 1061 put g_c p 48 1062 end 1063 end 1064 for q ulong get g_n 7 bound `9223372036854775807` 1065 bput ulong get g_c q 1066 end 1067 pdir 1068 pt f 1069 ret bsave false 1070 end 1071 fn tfeq a ulong b ulong t view uchar * to bool 1072 if ne sub b a len t 1073 ret false 1074 end 1075 for i ulong len t bound 4096 1076 if ne get g_t add a i get t i 1077 ret false 1078 end 1079 end 1080 ret true 1081 end 1082 fn pdir to void 1083 pclr 1084 pscr 1085 pstem get g_n 9 1086 pc 100 1087 pc 47 1088 end 1089 note make SCRATCH/uKd with the inventory inputs, FILE [fa, fb) flipped when flip 1090 fn mkin flip bool fa ulong fb ulong to bool 1091 pdir 1092 x = makedir g_pa 0 sub get g_n 0 1 448 1093 if ne x 0 1094 ret false 1095 end 1096 put g_n 24 0 1097 ok = cpin t_in1 flip fa fb 1098 ok = and ok cpin t_in2 flip fa fb 1099 ok = and ok cpin t_in3 flip fa fb 1100 ok = and ok cpin t_in4 flip fa fb 1101 ok = and ok cpin t_in5 flip fa fb 1102 ret ok 1103 end 1104 note run SCRATCH/uI.bin SCRATCH/uKd (I the inventory check's number, g_n 10); out and err as uK.out / uK.err 1105 fn invrun to ulong 1106 aclr 1107 pclr 1108 pscr 1109 pstem get g_n 10 1110 pt t_bin 1111 apa 1112 pdir 1113 put g_n 0 sub get g_n 0 1 1114 apa 1115 pclr 1116 pt t_null 1117 fi = frd 1118 psn t_out 1119 fo = fwr 1120 psn t_err 1121 fe = fwr 1122 ret spawn fi fo fe 1123 end 1124 note the unchanged copy SCRATCH/uKd: exit 0 and exactly INVENTORY.tsv (proves the copied input set is complete) 1125 fn ctlbase to bool 1126 nmset t_base 1127 if not mkin false 0 0 1128 ofail t_ctl t_wr 1129 ret false 1130 end 1131 r = invrun 1132 pclr 1133 pt t_invx 1134 put g_n 7 0 1135 if not fload 1 1136 ofail t_ctl t_noexp 1137 ret false 1138 end 1139 c = invout 1140 if or ne r 0 not c 1141 cfail t_diff r 1142 ret false 1143 end 1144 ot t_ok 1145 ot t_ctl 1146 onm 1147 ot t_bytes 1148 onum get g_n 6 1149 onl 1150 ret true 1151 end 1152 note SCRATCH/uK.out of the last invrun (K the row name's number) into g_b; equal to g_c 1153 fn invout to bool 1154 psn t_out 1155 put g_n 6 0 1156 if not fload 0 1157 ret false 1158 end 1159 ret bceq 1160 end 1161 fn ctlrow s ulong z ulong to void 1162 put g_n 12 add get g_n 12 1 1163 if not nmfld s z 1164 put g_n 14 0 1165 ofail t_ctl t_row 1166 ret 1167 end 1168 if not fld s z 1 1169 ofail t_ctl t_row 1170 ret 1171 end 1172 fa = get g_n 17 1173 fb = get g_n 18 1174 if not fld s z 2 1175 ofail t_ctl t_row 1176 ret 1177 end 1178 put g_n 19 get g_n 17 1179 put g_n 20 get g_n 18 1180 if not fld s z 3 1181 ofail t_ctl t_row 1182 ret 1183 end 1184 ea = get g_n 17 1185 eb = get g_n 18 1186 if not mkin true fa fb 1187 ofail t_ctl t_wr 1188 ret 1189 end 1190 if ne get g_n 24 0 1191 ofail t_ctl t_ntok 1192 ret 1193 end 1194 r = invrun 1195 if eq r 1000 1196 ofail t_ctl t_mto 1197 ret 1198 end 1199 pclr 1200 pt t_invx 1201 put g_n 7 0 1202 if not fload 1 1203 ofail t_ctl t_noexp 1204 ret 1205 end 1206 c = invout 1207 ex = ctlexp ea eb 1208 if eq ex `1000000` 1209 caught or ne r 0 not c t_mut 1210 else 1211 caught eq r ex t_mut 1212 end 1213 end 1214 note EXIT field [a, b): - is `1000000`, else the number 1215 fn ctlexp a ulong b ulong to ulong 1216 if and eq sub b a 1 eq get g_t a 45 1217 ret `1000000` 1218 end 1219 m = ulong 0 1220 for i ulong sub b a bound 32 1221 c = ulong get g_t add a i 1222 m = add mul m 10 sub c 48 1223 end 1224 ret m 1225 end 1226 fn controls to void 1227 if eq get g_n 16 0 1228 nmset t_inv 1229 ofail t_ctl t_nobin 1230 ret 1231 end 1232 pclr 1233 pt t_invx 1234 put g_n 7 0 1235 if not fload 1 1236 nmset t_inv 1237 ofail t_ctl t_noexp 1238 ret 1239 end 1240 if not ctlbase 1241 ret 1242 end 1243 e = get g_n 15 1244 s = ulong 0 1245 while lt s e bound `9223372036854775807` 1246 z = eol s 1247 if not rowskip s z 1248 ctlrow s z 1249 end 1250 s = add z 1 1251 end 1252 end 1253 note ---- the wrong-compiler control: OMC one byte longer must fail the digest check 1254 fn cwrong to void 1255 put g_n 12 add get g_n 12 1 1256 pomc 1257 put g_n 6 0 1258 ok = fload 0 1259 bput 0 1260 nmset t_plus 1261 psn t_bin 1262 ok = and ok bsave true 1263 psn t_bin 1264 c = and ok not pinok 1265 caught c t_mut 1266 end 1267 note ---- main 1268 fn ausage to int 1269 r = write 2 t_usage 0 len t_usage 1270 ret 2 1271 end 1272 fn main to int 1273 if ne argcnt 3 1274 ret ausage 1275 end 1276 r = argread 1 g_omc 0 4095 1277 if lt r 0 1278 r = write 2 t_plong 0 len t_plong 1279 ret 2 1280 end 1281 if eq r 0 1282 ret ausage 1283 end 1284 put g_n 1 ulong r 1285 if not pinread 1286 r = write 2 t_nopin 0 len t_nopin 1287 ret 2 1288 end 1289 pomc 1290 if not pinok 1291 r = write 2 t_refd 0 len t_refd 1292 ret 69 1293 end 1294 r = argread 2 g_scr 0 4094 1295 if lt r 0 1296 r = write 2 t_plong 0 len t_plong 1297 ret 2 1298 end 1299 if eq r 0 1300 ret ausage 1301 end 1302 n = ulong r 1303 x = makedir g_scr 0 n 448 1304 if ne x 0 1305 r = write 2 t_noscr 0 len t_noscr 1306 ret 2 1307 end 1308 put g_scr n 47 1309 put g_n 2 add n 1 1310 if not tload t_tab 1311 r = write 2 t_notab 0 len t_notab 1312 ret 2 1313 end 1314 checks 1315 rwchk 1316 if not tload t_ctab 1317 r = write 2 t_notab 0 len t_notab 1318 ret 2 1319 end 1320 controls 1321 cwrong 1322 if eq get g_n 8 0 1323 nmset t_tab 1324 ofail t_chk t_none 1325 end 1326 f = get g_n 11 1327 ot t_sum 1328 if eq f 0 1329 ot t_pass 1330 else 1331 ot t_fl 1332 end 1333 ot t_sk 1334 onum get g_n 8 1335 ot t_sc 1336 onum get g_n 12 1337 ot t_sg 1338 onum get g_n 13 1339 ot t_hw 1340 oflush 1341 if ne f 0 1342 ret 1 1343 end 1344 if ne get g_n 12 get g_n 13 1345 ret 1 1346 end 1347 ret 0 1348 end