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/aienux/units-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 / aienux / units-gate.om` 1013 lines ยท 18422 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 2 note aienux/units-gate.om: OMEGA-AIENUX-UNITS, the gate of the pure-Omega Aienux units moved from Aienux, in 3 note seeded Omega (Linux AArch64). Build from the repository root (OM-2 program mode; seed/ng/sha256.om supplies 4 note sh_dat, sh_all, sh_dig): 5 note { printf 'om2\n'; cat seed/ng/sha256.om aienux/units-gate.om; } | seed/out/omc > aienux-units-gate 6 note Run from the repository root: aienux-units-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), at most 1024 bytes of path; an existing one is refused (exit 2) 10 note Units. aienux/units.tsv lists every unit, one per line: NAME [@run|@qemu] then the paths of its parts, single 11 note spaces; a line starting with # is a comment and an empty line is skipped. NAME is 1 to 240 of A-Z a-z 0-9 _ and 12 note appears once (240 leaves room for scratch suffixes such as ".run.out" inside a 255-byte file name). 13 note The parts are concatenated in order, each followed by a newline (the composition of aienux/units.tsv), into 14 note SCRATCH/NAME.om and compiled twice by OMC: each compile exits 0 with empty stderr, and both outputs hold the same 15 note bytes. Units tagged @run are then executed directly and must exit 0 (run=PASS / run=FAIL). Units tagged @qemu are 16 note booted under /usr/bin/qemu-system-aarch64 when present (qemu=PASS / qemu=FAIL), or reported qemu=NOT_RUN when QEMU 17 note is absent so host-only runs stay honest. A malformed or repeated row, a missing part, a failed compile, two 18 note different outputs, a failed behavioral run, or a table with no unit is a FAIL line. 19 note Control, must be caught: a compiler one byte longer fails the digest check. 20 note Output: one line per unit, then 21 note OMEGA-AIENUX-UNITS PASS|FAIL units=U behavior_passed=BP/BT qemu_passed=QP/QT qemu_not_run=QN controls=C caught=K hardware=NOT_RUN. 22 note Exit 0 PASS, 1 FAIL, 2 bad usage or setup, 69 compiler digest refused. Every input is length-checked; a trap 23 note exit (101..114) would be a defect of this gate, never a pass. 24 text t_pin "seed/out/omc.sha256" 25 text t_tab "aienux/units.tsv" 26 text t_om ".om" 27 text t_b1 ".1" 28 text t_b2 ".2" 29 text t_e1 ".1.err" 30 text t_e2 ".2.err" 31 text t_rout ".run.out" 32 text t_rerr ".run.err" 33 text t_qout ".q.out" 34 text t_qerr ".q.err" 35 text t_qlog ".qlog" 36 text t_null "/dev/null" 37 text t_mrun "@run" 38 text t_mqemu "@qemu" 39 text t_badmode "units.tsv: unknown mode tag (expected @run or @qemu)" 40 text t_qemu "/usr/bin/qemu-system-aarch64" 41 text t_qM "-M" 42 text t_qvirt "virt" 43 text t_qcpu "-cpu" 44 text t_qmax "max" 45 text t_qm "-m" 46 text t_q256 "256" 47 text t_qdisp "-display" 48 text t_qnone "none" 49 text t_qnet "-net" 50 text t_qmon "-monitor" 51 text t_qnorb "-no-reboot" 52 text t_qser "-serial" 53 text t_qfile "file:" 54 text t_qkern "-kernel" 55 text t_rpass " run=PASS" 56 text t_rfail " run=FAIL" 57 text t_qpass " qemu=PASS" 58 text t_qfail " qemu=FAIL" 59 text t_qnr " qemu=NOT_RUN" 60 text t_sbp " behavior_passed=" 61 text t_sqp " qemu_passed=" 62 text t_sqn " qemu_not_run=" 63 text t_badname "units.tsv: name outside A-Z a-z 0-9 _" 64 text t_dup "units.tsv: name repeated, or more than 64 KiB of names" 65 text t_empty "units.tsv names no unit" 66 text t_plus "omc-plus-one" 67 text t_usage "usage: aienux-units-gate OMC SCRATCH (run from the omega-mv repository root)\n" 68 text t_refd "OMEGA-AIENUX-UNITS REFUSED: compiler digest differs from seed/out/omc.sha256 (exit 69)\n" 69 text t_nopin "OMEGA-AIENUX-UNITS INVALID: cannot read a 64-hex digest from seed/out/omc.sha256\n" 70 text t_noscr "OMEGA-AIENUX-UNITS INVALID: SCRATCH exists or cannot be made\n" 71 text t_notab "OMEGA-AIENUX-UNITS INVALID: cannot read aienux/units.tsv\n" 72 text t_long "OMEGA-AIENUX-UNITS INVALID: SCRATCH path longer than 1024 bytes\n" 73 text t_ok "ok " 74 text t_fail "FAIL " 75 text t_unit "unit " 76 text t_ctl "control " 77 text t_bytes " bytes=" 78 text t_sha " sha256=" 79 text t_exit " exit=" 80 text t_src "source unreadable: " 81 text t_big "output unreadable or over 16 MiB" 82 text t_cmp "compile" 83 text t_stderr " stderr not empty" 84 text t_twice " two builds differ" 85 text t_write "cannot write the composed unit in SCRATCH" 86 text t_row "units.tsv: malformed row (name 1..249 bytes, at least one part)" 87 text t_plong "units.tsv: a part path is longer than 4000 bytes" 88 text t_caught " caught" 89 text t_esc " ESCAPED" 90 text t_sum "OMEGA-AIENUX-UNITS " 91 text t_pass "PASS" 92 text t_fl "FAIL" 93 text t_su " units=" 94 text t_sc " controls=" 95 text t_sk " caught=" 96 text t_hw " hardware=NOT_RUN\n" 97 global g_pa uchar 4096 98 global g_scr uchar 4096 99 global g_omc uchar 4096 100 global g_nm uchar 256 101 global g_av uchar 8192 102 global g_b uchar `16777216` 103 global g_u uchar `1048576` 104 global g_o uchar 8192 105 global g_hx uchar 64 106 global g_pin uchar 64 107 global g_d1 uchar 32 108 global g_stb uchar 4 109 global g_n ulong 32 110 global g_seen uchar 65536 111 note g_n: 0 path length, 1 omc length, 2 scratch length (with '/'), 3 argv bytes, 4 argc, 5 output length, 112 note 6 buffer length, 7 table length, 8 units, 11 failures, 12 controls, 13 caught, 14 name length, 15 g_seen length, 113 note 16 unit rows, 17 behavior total, 18 behavior passed, 19 qemu total, 20 qemu passed, 21 qemu not_run, 22 row mode 114 note ---- output 115 fn oc c ulong to void 116 n = get g_n 5 117 put g_o n uchar c 118 put g_n 5 add n 1 119 end 120 fn ot t view uchar * to void 121 for i ulong len t bound 4096 122 oc ulong get t i 123 end 124 end 125 fn onm to void 126 for i ulong get g_n 14 bound 256 127 oc ulong get g_nm i 128 end 129 end 130 fn onum v ulong to void 131 if ge v 10 132 onum div v 10 133 end 134 oc add 48 rem v 10 135 end 136 fn ohex to void 137 for j ulong 32 138 b = get sh_dig j 139 oc ulong sh_hexd uint shr b 4 140 oc ulong sh_hexd uint and b 15 141 end 142 end 143 fn ohx to void 144 for j ulong 64 145 oc ulong get g_hx j 146 end 147 end 148 fn oflush to void 149 r = write 1 g_o 0 get g_n 5 150 put g_n 5 0 151 end 152 fn onl to void 153 oc 10 154 oflush 155 end 156 note a failed check: FAIL KIND NAME then the reason; counts a failure 157 fn ofail kind view uchar * why view uchar * to void 158 ot t_fail 159 ot kind 160 onm 161 oc 32 162 ot why 163 onl 164 put g_n 11 add get g_n 11 1 165 end 166 note ---- paths: g_pa[0, g_n 0) 167 fn pclr to void 168 put g_n 0 0 169 end 170 fn pc c ulong to void 171 n = get g_n 0 172 put g_pa n uchar c 173 put g_n 0 add n 1 174 end 175 fn pt t view uchar * to void 176 for i ulong len t bound 4096 177 pc ulong get t i 178 end 179 end 180 fn pscr to void 181 for j ulong get g_n 2 bound 4096 182 pc ulong get g_scr j 183 end 184 end 185 fn pnm to void 186 for j ulong get g_n 14 bound 256 187 pc ulong get g_nm j 188 end 189 end 190 note scratch file NAME then suffix 191 fn psn suf view uchar * to void 192 pclr 193 pscr 194 pnm 195 pt suf 196 end 197 note scratch file named by a text 198 fn pst t view uchar * suf view uchar * to void 199 pclr 200 pscr 201 pt t 202 pt suf 203 end 204 note scratch file named by a text alone 205 fn psc t view uchar * to void 206 pclr 207 pscr 208 pt t 209 end 210 fn nmset t view uchar * to void 211 for i ulong len t bound 256 212 put g_nm i get t i 213 end 214 put g_n 14 len t 215 end 216 note ---- files 217 fn fopn fl ulong mode ulong to int 218 r = fopen g_pa 0 get g_n 0 int fl int mode 219 if lt r 0 220 ret -1 221 end 222 ret int r 223 end 224 fn frd to int 225 ret fopn 524288 0 226 end 227 fn fwr to int 228 ret fopn 524865 420 229 end 230 fn fexe to int 231 r = unlink g_pa 0 get g_n 0 232 ret fopn 524865 448 233 end 234 fn fclo fd int to void 235 if ge fd 0 236 r = fclose fd 237 end 238 end 239 note append the file at g_pa to g_b; false when unreadable or past the buffer 240 fn bload to bool 241 fd = frd 242 if lt fd 0 243 ret false 244 end 245 n = get g_n 6 246 ok = true 247 while true bound `16777218` 248 x = read fd g_b n sub len g_b n 249 if lt x 0 250 ok = false 251 break 252 end 253 if eq x 0 254 break 255 end 256 n = add n ulong x 257 if ge n len g_b 258 ok = false 259 break 260 end 261 end 262 fclo fd 263 put g_n 6 n 264 ret ok 265 end 266 note write g_b[0, g_n 6) to the file at g_pa (0644, or 0700 when exe) 267 fn bsave exe bool to bool 268 fd = int -1 269 if exe 270 fd = fexe 271 else 272 fd = fwr 273 end 274 if lt fd 0 275 ret false 276 end 277 n = get g_n 6 278 o = ulong 0 279 ok = true 280 while lt o n bound `16777217` 281 x = write fd g_b o sub n o 282 if le x 0 283 ok = false 284 break 285 end 286 o = add o ulong x 287 end 288 fclo fd 289 ret ok 290 end 291 note sha256 of the file at g_pa into sh_dig; false when unreadable or past 16 MiB 292 fn fhash to bool 293 fd = frd 294 if lt fd 0 295 ret false 296 end 297 n = ulong 0 298 ok = true 299 while true bound `16777218` 300 x = read fd sh_dat n sub len sh_dat n 301 if lt x 0 302 ok = false 303 break 304 end 305 if eq x 0 306 break 307 end 308 n = add n ulong x 309 if ge n len sh_dat 310 ok = false 311 break 312 end 313 end 314 fclo fd 315 if not ok 316 ret false 317 end 318 sh_all n 319 ret true 320 end 321 note the size of the file at g_pa, or 2^63 when unreadable 322 fn fsize to ulong 323 put g_n 6 0 324 if not bload 325 ret shl ulong 1 63 326 end 327 ret get g_n 6 328 end 329 note sh_dig equals the hex in g_hx 330 fn digeq to bool 331 for j ulong 32 332 b = get sh_dig j 333 if ne get g_hx mul j 2 sh_hexd uint shr b 4 334 ret false 335 end 336 if ne get g_hx add mul j 2 1 sh_hexd uint and b 15 337 ret false 338 end 339 end 340 ret true 341 end 342 fn dsave to void 343 for j ulong 32 344 put g_d1 j get sh_dig j 345 end 346 end 347 fn dsame to bool 348 for j ulong 32 349 if ne get g_d1 j get sh_dig j 350 ret false 351 end 352 end 353 ret true 354 end 355 note ---- processes 356 fn aclr to void 357 put g_n 3 2 358 put g_n 4 0 359 put g_av 0 0 360 put g_av 1 0 361 end 362 note append g_pa as one argument 363 fn apa to void 364 p = get g_n 3 365 n = get g_n 0 366 for j ulong n bound 4096 367 put g_av add add p 2 j get g_pa j 368 end 369 put g_av p uchar and n 255 370 put g_av add p 1 uchar shr n 8 371 put g_n 3 add p add n 2 372 c = add get g_n 4 1 373 put g_n 4 c 374 put g_av 0 uchar and c 255 375 put g_av 1 uchar shr c 8 376 end 377 fn atx t view uchar * to void 378 pclr 379 pt t 380 apa 381 end 382 fn redir s int d int to void 383 if ne dupfd s d 0 long d 384 exit 127 385 end 386 end 387 note run the argument list with stdin, stdout, stderr fds (closed here) and deadline lim ns: the exit code, 388 note 256 + the signal, 512 when a file could not be opened, 1000 when the child passed lim (killed) 389 fn spawn_lim fi int fo int fe int lim long to ulong 390 if or lt fi 0 or lt fo 0 lt fe 0 391 fclo fi 392 fclo fo 393 fclo fe 394 ret 512 395 end 396 pid = fork 397 if lt pid 0 398 exit 2 399 end 400 if eq pid 0 401 redir fi 0 402 redir fo 1 403 redir fe 2 404 r = execprog g_av 0 get g_n 3 405 exit 127 406 end 407 fclo fi 408 fclo fo 409 fclo fe 410 t0 = monons 411 while true bound `1000000000` 412 r = waitpid int pid g_stb 0 len g_stb 1 413 if eq r pid 414 x = ulong get g_stb 0 415 if ne x 0 416 ret add 256 x 417 end 418 ret ulong get g_stb 1 419 end 420 if lt r 0 421 exit 2 422 end 423 if gt sub monons t0 lim 424 r = killpid int pid 9 425 r = waitpid int pid g_stb 0 len g_stb 0 426 ret 1000 427 end 428 q = sleepns 200000 429 end 430 exit 2 431 end 432 fn spawn fi int fo int fe int to ulong 433 ret spawn_lim fi fo fe `600000000000` 434 end 435 note execute SCRATCH/NAME.1 directly with /dev/null stdin (60 s deadline) 436 fn runbin to ulong 437 psn t_b1 438 r = chmod g_pa 0 get g_n 0 448 439 pclr 440 pt t_null 441 fi = frd 442 aclr 443 psn t_b1 444 apa 445 psn t_rout 446 fo = fwr 447 psn t_rerr 448 fe = fwr 449 ret spawn_lim fi fo fe `60000000000` 450 end 451 note boot SCRATCH/NAME.1 under qemu-system-aarch64 -M virt (15 s deadline) 452 fn runqemu to ulong 453 pclr 454 pt t_null 455 fi = frd 456 aclr 457 atx t_qemu 458 atx t_qM 459 atx t_qvirt 460 atx t_qcpu 461 atx t_qmax 462 atx t_qm 463 atx t_q256 464 atx t_qdisp 465 atx t_qnone 466 atx t_qnet 467 atx t_qnone 468 atx t_qmon 469 atx t_qnone 470 atx t_qnorb 471 atx t_qser 472 pclr 473 pt t_qfile 474 pscr 475 pnm 476 pt t_qlog 477 apa 478 atx t_qkern 479 psn t_b1 480 apa 481 psn t_qout 482 fo = fwr 483 psn t_qerr 484 fe = fwr 485 ret spawn_lim fi fo fe `15000000000` 486 end 487 note OMC < SCRATCH/NAME.om > SCRATCH/NAME.SUF 2> SCRATCH/NAME.ERR 488 fn omc suf view uchar * err view uchar * to ulong 489 psn t_om 490 fi = frd 491 aclr 492 pclr 493 for j ulong get g_n 1 bound 4096 494 pc ulong get g_omc j 495 end 496 apa 497 psn suf 498 fo = fexe 499 psn err 500 fe = fwr 501 ret spawn fi fo fe 502 end 503 note ---- the compiler digest 504 note the first 64 characters of seed/out/omc.sha256 into g_pin; false unless lowercase hex 505 fn pinread to bool 506 pclr 507 pt t_pin 508 put g_n 6 0 509 if not bload 510 ret false 511 end 512 if lt get g_n 6 64 513 ret false 514 end 515 for j ulong 64 516 c = get g_b j 517 ok = or and ge c 48 le c 57 and ge c 97 le c 102 518 if not ok 519 ret false 520 end 521 put g_pin j c 522 end 523 ret true 524 end 525 note the file at g_pa hashes to g_pin 526 fn pinok to bool 527 if not fhash 528 ret false 529 end 530 for j ulong 64 531 put g_hx j get g_pin j 532 end 533 ret digeq 534 end 535 note ---- units 536 note g_u[i] is c, for i below e (never reads at or past e) 537 fn uis i ulong e ulong c ulong to bool 538 if ge i e 539 ret false 540 end 541 ret eq ulong get g_u i c 542 end 543 fn uisnt i ulong e ulong c ulong to bool 544 if ge i e 545 ret false 546 end 547 ret ne ulong get g_u i c 548 end 549 note append one newline to g_b (units.sh writes one after every part) 550 fn nl to bool 551 n = get g_n 6 552 if ge add n 1 len g_b 553 ret false 554 end 555 put g_b n 10 556 put g_n 6 add n 1 557 ret true 558 end 559 note a missing or unreadable part: FAIL unit NAME source unreadable: PATH (the path is in g_pa, at most 4000 bytes) 560 fn psrcfail to void 561 ot t_fail 562 ot t_unit 563 onm 564 oc 32 565 ot t_src 566 for q ulong get g_n 0 bound 4096 567 oc ulong get g_pa q 568 end 569 onl 570 put g_n 11 add get g_n 11 1 571 end 572 note compose the parts g_u[s, e) into g_b as aienux/units.tsv does: each part's bytes, then one newline; false 573 note (reported) when a part is unreadable or its path is longer than 4000 bytes 574 fn compose s ulong e ulong to bool 575 put g_n 6 0 576 i = s 577 while lt i e bound `1048576` 578 while uis i e 32 bound `1048576` 579 i = add i 1 580 end 581 if ge i e 582 break 583 end 584 j = i 585 while uisnt j e 32 bound `1048576` 586 j = add j 1 587 end 588 if gt sub j i 4000 589 ofail t_unit t_plong 590 ret false 591 end 592 pclr 593 for q ulong sub j i bound 4096 594 pc ulong get g_u add i q 595 end 596 if not bload 597 psrcfail 598 ret false 599 end 600 if not nl 601 ofail t_unit t_big 602 ret false 603 end 604 i = j 605 end 606 ret true 607 end 608 note compile the composed unit twice; true when both exit 0 with empty stderr and equal bytes 609 fn build to bool 610 psn t_om 611 if not bsave false 612 ofail t_unit t_write 613 ret false 614 end 615 r1 = omc t_b1 t_e1 616 r2 = omc t_b2 t_e2 617 if or ne r1 0 ne r2 0 618 ot t_fail 619 ot t_unit 620 onm 621 oc 32 622 ot t_cmp 623 ot t_exit 624 onum r1 625 oc 47 626 onum r2 627 onl 628 put g_n 11 add get g_n 11 1 629 ret false 630 end 631 psn t_e1 632 s1 = fsize 633 psn t_e2 634 s2 = fsize 635 if or ne s1 0 ne s2 0 636 ofail t_unit t_stderr 637 ret false 638 end 639 psn t_b1 640 if not fhash 641 ofail t_unit t_big 642 ret false 643 end 644 dsave 645 psn t_b2 646 if not fhash 647 ofail t_unit t_big 648 ret false 649 end 650 if not dsame 651 ofail t_unit t_twice 652 ret false 653 end 654 psn t_b1 655 sz = fsize 656 psn t_b1 657 if not fhash 658 ofail t_unit t_big 659 ret false 660 end 661 md = get g_n 22 662 if eq md 1 663 put g_n 17 add get g_n 17 1 664 rc = runbin 665 if ne rc 0 666 ot t_fail 667 ot t_unit 668 onm 669 ot t_rfail 670 ot t_exit 671 onum rc 672 onl 673 put g_n 11 add get g_n 11 1 674 ret false 675 end 676 put g_n 18 add get g_n 18 1 677 ot t_ok 678 ot t_unit 679 onm 680 ot t_bytes 681 onum sz 682 ot t_sha 683 ohex 684 ot t_rpass 685 onl 686 put g_n 8 add get g_n 8 1 687 ret true 688 end 689 if eq md 2 690 put g_n 19 add get g_n 19 1 691 if ne faccess t_qemu 0 len t_qemu 1 0 692 put g_n 21 add get g_n 21 1 693 ot t_ok 694 ot t_unit 695 onm 696 ot t_bytes 697 onum sz 698 ot t_sha 699 ohex 700 ot t_qnr 701 onl 702 put g_n 8 add get g_n 8 1 703 ret true 704 end 705 rc = runqemu 706 if ne rc 0 707 ot t_fail 708 ot t_unit 709 onm 710 ot t_qfail 711 ot t_exit 712 onum rc 713 onl 714 put g_n 11 add get g_n 11 1 715 ret false 716 end 717 put g_n 20 add get g_n 20 1 718 ot t_ok 719 ot t_unit 720 onm 721 ot t_bytes 722 onum sz 723 ot t_sha 724 ohex 725 ot t_qpass 726 onl 727 put g_n 8 add get g_n 8 1 728 ret true 729 end 730 ot t_ok 731 ot t_unit 732 onm 733 ot t_bytes 734 onum sz 735 ot t_sha 736 ohex 737 onl 738 put g_n 8 add get g_n 8 1 739 ret true 740 end 741 note g_u[s, e) equals text t 742 fn ueq s ulong e ulong t view uchar * to bool 743 if ne sub e s len t 744 ret false 745 end 746 for j ulong len t bound 64 747 if ne get g_u add s j get t j 748 ret false 749 end 750 end 751 ret true 752 end 753 fn parsemode s ulong e ulong to ulong 754 if ueq s e t_mrun 755 ret 1 756 end 757 if ueq s e t_mqemu 758 ret 2 759 end 760 ret 99 761 end 762 note one table row [s, e): NAME [@run|@qemu] then parts; # starts a comment line; an empty line is skipped 763 fn urow s ulong e ulong to void 764 if or eq s e eq get g_u s 35 765 ret 766 end 767 put g_n 14 0 768 put g_n 22 0 769 k = s 770 while uisnt k e 32 bound `1048576` 771 k = add k 1 772 end 773 if or ge k e or eq k s gt sub k s 240 774 ofail t_unit t_row 775 ret 776 end 777 for q ulong sub k s bound 256 778 put g_nm q get g_u add s q 779 end 780 put g_n 14 sub k s 781 put g_n 16 add get g_n 16 1 782 if not nameok 783 ofail t_unit t_badname 784 ret 785 end 786 if not nameadd 787 ofail t_unit t_dup 788 ret 789 end 790 while uis k e 32 bound `1048576` 791 k = add k 1 792 end 793 if ge k e 794 ofail t_unit t_row 795 ret 796 end 797 if uis k e 64 798 m = k 799 while uisnt m e 32 bound `1048576` 800 m = add m 1 801 end 802 md = parsemode k m 803 if eq md 99 804 ofail t_unit t_badmode 805 ret 806 end 807 put g_n 22 md 808 k = m 809 while uis k e 32 bound `1048576` 810 k = add k 1 811 end 812 if ge k e 813 ofail t_unit t_row 814 ret 815 end 816 end 817 if compose k e 818 z = build 819 end 820 end 821 note a unit name uses only A-Z a-z 0-9 _, so it names a file in SCRATCH 822 fn nameok to bool 823 for q ulong get g_n 14 bound 256 824 c = get g_nm q 825 d = and ge c 48 le c 57 826 u = and ge c 65 le c 90 827 l = and ge c 97 le c 122 828 ok = or or d u or l eq c 95 829 if not ok 830 ret false 831 end 832 end 833 ret true 834 end 835 note record the name in g_seen (names joined by newlines); false when it is already there or g_seen is full 836 fn nameadd to bool 837 n = get g_n 15 838 m = get g_n 14 839 p = ulong 0 840 while lt p n bound 65536 841 q = p 842 while and lt q n ne get g_seen q 10 bound 65536 843 q = add q 1 844 end 845 if nameat p q 846 ret false 847 end 848 p = add q 1 849 end 850 if ge add add n m 1 len g_seen 851 ret false 852 end 853 for j ulong m bound 256 854 put g_seen add n j get g_nm j 855 end 856 put g_seen add n m 10 857 put g_n 15 add add n m 1 858 ret true 859 end 860 note g_seen[p, q) equals the current name 861 fn nameat p ulong q ulong to bool 862 if ne sub q p get g_n 14 863 ret false 864 end 865 for j ulong sub q p bound 256 866 if ne get g_seen add p j get g_nm j 867 ret false 868 end 869 end 870 ret true 871 end 872 fn table to bool 873 pclr 874 pt t_tab 875 put g_n 6 0 876 if not bload 877 ret false 878 end 879 n = get g_n 6 880 if ge n len g_u 881 ret false 882 end 883 for q ulong n bound `1048576` 884 put g_u q get g_b q 885 end 886 put g_n 7 n 887 s = ulong 0 888 while lt s n bound `1048576` 889 e = s 890 while uisnt e n 10 bound `1048576` 891 e = add e 1 892 end 893 urow s e 894 s = add e 1 895 end 896 if eq get g_n 16 0 897 nmset t_tab 898 ofail t_unit t_empty 899 end 900 ret true 901 end 902 note ---- controls 903 fn caught c bool what view uchar * to void 904 put g_n 12 add get g_n 12 1 905 nmset what 906 if c 907 ot t_ok 908 ot t_ctl 909 onm 910 ot t_caught 911 onl 912 put g_n 13 add get g_n 13 1 913 else 914 ofail t_ctl t_esc 915 end 916 end 917 note a compiler one byte longer must fail the digest check 918 fn cwrong to void 919 pclr 920 for j ulong get g_n 1 bound 4096 921 pc ulong get g_omc j 922 end 923 put g_n 6 0 924 ok = bload 925 n = get g_n 6 926 put g_b n 0 927 put g_n 6 add n 1 928 psc t_plus 929 ok = and ok bsave true 930 psc t_plus 931 c = and ok not pinok 932 caught c t_plus 933 end 934 note ---- main 935 fn ausage to int 936 r = write 2 t_usage 0 len t_usage 937 ret 2 938 end 939 fn main to int 940 if ne argcnt 3 941 ret ausage 942 end 943 r = argread 1 g_omc 0 4095 944 if lt r 1 945 ret ausage 946 end 947 put g_n 1 ulong r 948 if not pinread 949 r = write 2 t_nopin 0 len t_nopin 950 ret 2 951 end 952 pclr 953 for j ulong get g_n 1 bound 4096 954 pc ulong get g_omc j 955 end 956 if not pinok 957 r = write 2 t_refd 0 len t_refd 958 ret 69 959 end 960 r = argread 2 g_scr 0 4094 961 if lt r 1 962 ret ausage 963 end 964 if gt r 1024 965 r = write 2 t_long 0 len t_long 966 ret 2 967 end 968 n = ulong r 969 x = makedir g_scr 0 n 448 970 if ne x 0 971 r = write 2 t_noscr 0 len t_noscr 972 ret 2 973 end 974 put g_scr n 47 975 put g_n 2 add n 1 976 if not table 977 r = write 2 t_notab 0 len t_notab 978 ret 2 979 end 980 cwrong 981 f = get g_n 11 982 ot t_sum 983 if eq f 0 984 ot t_pass 985 else 986 ot t_fl 987 end 988 ot t_su 989 onum get g_n 8 990 ot t_sbp 991 onum get g_n 18 992 oc 47 993 onum get g_n 17 994 ot t_sqp 995 onum get g_n 20 996 oc 47 997 onum get g_n 19 998 ot t_sqn 999 onum get g_n 21 1000 ot t_sc 1001 onum get g_n 12 1002 ot t_sk 1003 onum get g_n 13 1004 ot t_hw 1005 oflush 1006 if ne f 0 1007 ret 1 1008 end 1009 if ne get g_n 12 get g_n 13 1010 ret 1 1011 end 1012 ret 0 1013 end