interplane.Get Omega
Read in your language

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

branch main Branches Tags History

omega-mv / gpu / nvidia / checks / gate.om

1855 lines · 37009 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note gpu/nvidia/checks/gate.om: OMEGA-GPU-CHECKS, the gate of the Omega checks in gpu/nvidia/checks (README.md
3note there), one slice of the port of CUDApp tests/ and tools/, in seeded Omega (Linux AArch64). Build from the
4note repository root (OM-2 program mode; seed/ng/sha256.om supplies sh_dat, sh_init, sh_blk, sh_out, sh_dig):
5note { printf 'om2\n'; cat seed/ng/sha256.om gpu/nvidia/checks/gate.om; } | seed/out/omc > checks-gate
6note Run from the repository root: checks-gate OMC SCRATCH
7note OMC the compiler under test; its sha256 must equal the first word of seed/out/omc.sha256, or nothing
8note runs (exit 69, nothing written)
9note SCRATCH a new directory (created 0700); SCRATCH/ and a file name of Linux NAME_MAX bytes must fit Linux
10note PATH_MAX, and an existing directory is refused (both exit 2)
11note Checks. gpu/nvidia/checks/checks.tsv lists every check, one per line: NAME, TABLE, then the paths of its parts,
12note single spaces; # starts a comment line and an empty line is skipped. NAME is of A-Z a-z 0-9 _ , at least one
13note byte and short enough that NAME and the longest suffix the gate gives it in SCRATCH fit Linux NAME_MAX, and
14note appears once. The parts are concatenated in order, each followed by a newline, into SCRATCH/NAME.om; a line
15note that starts with "export fn " is composed as "fn " (an exported function of a function-mode unit becomes an
16note ordinary function of the check program; nothing else of the unit changes). OMC compiles it twice: each
17note compile exits 0 with empty stderr and both outputs hold the same bytes. The check then runs as
18note SCRATCH/NAME.1 TABLE > SCRATCH/NAME.out 2> SCRATCH/NAME.run.err and must exit 0 with empty stderr.
19note Controls, each must be caught:
20note per check: TABLE with one byte changed (the last byte of its first case line: 0..8 and a..e step up by one,
21note 9 and f become 0, anything else becomes 0) must make the check exit 1;
22note per row of gpu/nvidia/checks/mutants.tsv (NAME, PART, FROM, TO split by tabs; # starts a comment line, an
23note empty line is skipped): the parts of check NAME composed again with the one line of PART that equals FROM
24note (as composed, so "export fn " already reads "fn ") replaced by TO must compile (exit 0) and the check built
25note from it must exit 1 on TABLE, a source mutant the check has to notice; FROM matching no line, or more than
26note one line, of PART is a failure;
27note a mutants.tsv row of six fields (NAME, PART, FROM, TO, EXIT, KTABLE) records a known difference that ends the
28note check (a trap): the check as composed must exit EXIT (decimal, 1..255) on KTABLE, and the mutant (TO is the
29note repair) must exit 0 on KTABLE, so KTABLE holds the pending C's answers and the repaired unit gives every one;
30note either side moving fails the row;
31note once: a compiler one byte longer fails the digest check.
32note Inventory: every row of gpu/nvidia/checks/ports.tsv (PATH, STATUS, DETAIL split by tabs) must be the status
33note and detail of PATH's row in gpu/nvidia/checks/INVENTORY.tsv, every other INVENTORY row must be open, the
34note INVENTORY footer counts (files, ported, retired, blocked, open) must be its rows, and every om_ref and
35note same_stem cell that is not - must name a .om file under gpu/ of this tree; a failure means INVENTORY.tsv was
36note not regenerated with inventory.om after ports.tsv or the tree changed.
37note Output: one line per check, control and the inventory, then
38note OMEGA-GPU-CHECKS PASS|FAIL checks=N controls=C caught=K hardware=NOT_RUN, where C = 1 + the rows of checks.tsv
39note + the rows of mutants.tsv.
40note Exit 0 PASS, 1 FAIL, 2 bad usage or setup, 69 compiler digest refused. Every input is length-checked; a trap
41note exit (101..114) would be a defect of this gate, never a pass. Host only: no check opens a device.
42text t_pin "seed/out/omc.sha256"
43text t_tab "gpu/nvidia/checks/checks.tsv"
44text t_om ".om"
45text t_b1 ".1"
46text t_b2 ".2"
47text t_e1 ".1.err"
48text t_e2 ".2.err"
49text t_out ".out"
50text t_rerr ".run.err"
51text t_bad ".bad.tsv"
52text t_badname "checks.tsv: name outside A-Z a-z 0-9 _"
53text t_dup "checks.tsv: name repeated, or the host refused the memory"
54text t_empty "checks.tsv names no check"
55text t_plus "omc-plus-one"
56text t_usage "usage: checks-gate OMC SCRATCH (run from the omega-mv repository root)\n"
57text t_refd "OMEGA-GPU-CHECKS REFUSED: compiler digest differs from seed/out/omc.sha256 (exit 69)\n"
58text t_nopin "OMEGA-GPU-CHECKS INVALID: cannot read a 64-hex digest from seed/out/omc.sha256\n"
59text t_noscr "OMEGA-GPU-CHECKS INVALID: SCRATCH exists or cannot be made\n"
60text t_notab "OMEGA-GPU-CHECKS INVALID: cannot read gpu/nvidia/checks/checks.tsv\n"
61text t_long "OMEGA-GPU-CHECKS INVALID: SCRATCH is too long: SCRATCH/ and a file name of Linux NAME_MAX bytes would not fit Linux PATH_MAX\n"
62text t_ok "ok "
63text t_fail "FAIL "
64text t_unit "check "
65text t_ctl "control "
66text t_bytes " bytes="
67text t_sha " sha256="
68text t_exit " exit="
69text t_src "source unreadable: "
70text t_big "output unreadable or the host refused the memory"
71text t_cmp "compile"
72text t_stderr " stderr not empty"
73text t_twice " two builds differ"
74text t_write "cannot write the composed check in SCRATCH"
75text t_row "checks.tsv: malformed row (a name that fits Linux NAME_MAX with its longest scratch suffix, a table, at least one part)"
76text t_plong "checks.tsv: a path does not fit Linux PATH_MAX"
77text t_run "run"
78text t_rstderr "run stderr not empty"
79text t_says " says: "
80text t_tabbad "table unreadable, or without a case line"
81text t_mut "-table-mutated"
82text t_caught " caught"
83text t_esc " ESCAPED"
84text t_kheld " known exit held, repair gives the recorded answers"
85text t_kfix " repair does not give the recorded answers on KTABLE"
86text t_kmoved "the check no longer exits EXIT on KTABLE (the known difference moved)"
87text t_sum "OMEGA-GPU-CHECKS "
88text t_pass "PASS"
89text t_fl "FAIL"
90text t_su " checks="
91text t_sc " controls="
92text t_sk " caught="
93text t_hw " hardware=NOT_RUN\n"
94text t_mutf "gpu/nvidia/checks/mutants.tsv"
95text t_nomut "OMEGA-GPU-CHECKS INVALID: cannot read gpu/nvidia/checks/mutants.tsv\n"
96text t_mo ".m"
97text t_me ".m.err"
98text t_msrc "-source-mutant-line-"
99text t_mrow "mutants.tsv: malformed row (NAME, PART, FROM, TO, and optionally EXIT 1..255 and KTABLE, split by tabs)"
100text t_mnot "FROM is not a line of PART"
101text t_muniq "FROM is more than one line of PART"
102text t_mcmp "the mutant does not compile"
103text t_ports "gpu/nvidia/checks/ports.tsv"
104text t_invf "gpu/nvidia/checks/INVENTORY.tsv"
105text t_invk "inventory "
106text t_line " line "
107text t_colon ": "
108text t_invnop "cannot read gpu/nvidia/checks/ports.tsv"
109text t_invnoi "cannot read gpu/nvidia/checks/INVENTORY.tsv"
110text t_invrow "not PATH, STATUS, DETAIL split by tabs"
111text t_invmiss "INVENTORY.tsv has no row for this path (regenerate it with inventory.om)"
112text t_invdiff "INVENTORY.tsv status or detail differs from this row (regenerate it with inventory.om)"
113text t_invcnt "INVENTORY.tsv: its ported, retired and blocked rows are not exactly the rows of ports.tsv, or a status is unknown"
114text t_invfoot "INVENTORY.tsv: the footer counts (files, ported, retired, blocked, open) differ from its rows"
115text t_invref "INVENTORY.tsv: an om_ref or same_stem cell names no .om file under gpu/ of this tree (regenerate it with inventory.om): "
116text t_gpu "gpu/"
117text t_sported "ported"
118text t_sretired "retired"
119text t_sblocked "blocked"
120text t_sopen "open"
121text t_hpath "path"
122text t_ffiles " files="
123text t_fported " ported="
124text t_fretired " retired="
125text t_fblocked " blocked="
126text t_fopen " open="
127text t_invok "ok inventory gpu/nvidia/checks/INVENTORY.tsv says what ports.tsv says"
128global g_pa uchar 4096
129global g_scr uchar 4096
130global g_omc uchar 4096
131global g_nm uchar 256
132note g_av: the argument list for execprog, a 2-byte count, then each argument as a 2-byte length and its bytes;
133note the gate passes at most two arguments, each a path of at most len g_pa - 1 bytes (shorter than Linux
134note PATH_MAX), so it holds 2 + 2 * (len g_pa + 1) bytes
135global g_av uchar 8196
136global g_b uchar *
137global g_u uchar *
138global g_o uchar 8192
139global g_hx uchar 64
140global g_pin uchar 64
141global g_d1 uchar 32
142global g_stb uchar 4
143global g_n ulong 40
144global g_seen uchar *
145global g_tb uchar 4096
146global g_m uchar *
147global g_p uchar *
148global g_ic ulong 16
149global g_tl uchar *
150note g_n: 0 path length, 1 omc length, 2 scratch length (with '/'), 3 argv bytes, 4 argc, 5 output length,
151note 6 buffer length, 7 table length, 8 checks passed, 11 failures, 12 controls, 13 caught, 14 name length,
152note 15 g_seen length, 16 check rows, 17 table path length (g_tb), 19 mutants.tsv length (g_m), 20 a mutant is
153note being composed, 21 it was applied (1), the host refused the memory (2) or FROM is more than one line (3), 22/23 the parts of the current check in g_u,
154note 24/25 PART, 26/27 FROM, 28/29 TO of the mutant in g_m, 30 its line in mutants.tsv, 31 ports.tsv length,
155note 33 the mutant row has six fields (1), 34 its EXIT, 35/36 its KTABLE in g_m
156note ---- output
157note one output byte; g_o is written out whenever it fills, so a line of any length is printed whole
158fn oc c ulong to void
159n = get g_n 5
160if ge n len g_o
161oflush
162n = 0
163end
164put g_o n uchar c
165put g_n 5 add n 1
166end
167fn ot t view uchar * to void
168for i ulong len t bound 4096
169oc ulong get t i
170end
171end
172fn onm to void
173for i ulong get g_n 14 bound 256
174oc ulong get g_nm i
175end
176end
177fn onum v ulong to void
178if ge v 10
179onum div v 10
180end
181oc add 48 rem v 10
182end
183fn ohex to void
184for j ulong 32
185b = get sh_dig j
186oc ulong sh_hexd uint shr b 4
187oc ulong sh_hexd uint and b 15
188end
189end
190fn ohx to void
191for j ulong 64
192oc ulong get g_hx j
193end
194end
195fn oflush to void
196r = write 1 g_o 0 get g_n 5
197put g_n 5 0
198end
199fn onl to void
200oc 10
201oflush
202end
203note a failed check: FAIL KIND NAME then the reason; counts a failure
204fn ofail kind view uchar * why view uchar * to void
205ot t_fail
206ot kind
207onm
208oc 32
209ot why
210onl
211put g_n 11 add get g_n 11 1
212end
213note ---- paths: g_pa[0, g_n 0)
214fn pclr to void
215put g_n 0 0
216end
217fn pc c ulong to void
218n = get g_n 0
219put g_pa n uchar c
220put g_n 0 add n 1
221end
222fn pt t view uchar * to void
223for i ulong len t bound 4096
224pc ulong get t i
225end
226end
227fn pscr to void
228for j ulong get g_n 2 bound 4096
229pc ulong get g_scr j
230end
231end
232fn pnm to void
233for j ulong get g_n 14 bound 256
234pc ulong get g_nm j
235end
236end
237note scratch file NAME then suffix
238fn psn suf view uchar * to void
239pclr
240pscr
241pnm
242pt suf
243end
244note scratch file named by a text
245fn pst t view uchar * suf view uchar * to void
246pclr
247pscr
248pt t
249pt suf
250end
251note scratch file named by a text alone
252fn psc t view uchar * to void
253pclr
254pscr
255pt t
256end
257fn nmset t view uchar * to void
258for i ulong len t bound 256
259put g_nm i get t i
260end
261put g_n 14 len t
262end
263note ---- files
264fn fopn fl ulong mode ulong to int
265r = fopen g_pa 0 get g_n 0 int fl int mode
266if lt r 0
267ret -1
268end
269ret int r
270end
271fn frd to int
272ret fopn 524288 0
273end
274fn fwr to int
275ret fopn 524865 420
276end
277fn fexe to int
278r = unlink g_pa 0 get g_n 0
279ret fopn 524865 448
280end
281fn fclo fd int to void
282if ge fd 0
283r = fclose fd
284end
285end
286note append the file at g_pa to g_b, growing g_b to fit; false when unreadable or the host refuses the memory
287fn bload to bool
288fd = frd
289if lt fd 0
290ret false
291end
292n = get g_n 6
293ok = true
294while true bound 9223372036854775807
295if ge add n 1 len g_b
296r = enlarge g_b add add n n 65536
297if lt r 0
298ok = false
299break
300end
301end
302x = read fd g_b n sub len g_b n
303if lt x 0
304ok = false
305break
306end
307if eq x 0
308break
309end
310n = add n ulong x
311end
312fclo fd
313put g_n 6 n
314ret ok
315end
316note write g_b[0, g_n 6) to the file at g_pa (0644, or 0700 when exe)
317fn bsave exe bool to bool
318fd = int -1
319if exe
320fd = fexe
321else
322fd = fwr
323end
324if lt fd 0
325ret false
326end
327n = get g_n 6
328o = ulong 0
329ok = true
330while lt o n bound 9223372036854775807
331x = write fd g_b o sub n o
332if le x 0
333ok = false
334break
335end
336o = add o ulong x
337end
338fclo fd
339ret ok
340end
341note sha256 of the file at g_pa into sh_dig, read in pieces through sh_dat so a file of any size is hashed;
342note false when unreadable
343fn fhash to bool
344fd = frd
345if lt fd 0
346ret false
347end
348sh_init
349for j ulong 8
350put sh_h j get sh_k add j 64
351end
352k = ulong 0
353tot = ulong 0
354ok = true
355while true bound 9223372036854775807
356x = read fd sh_dat k sub len sh_dat k
357if lt x 0
358ok = false
359break
360end
361if eq x 0
362break
363end
364k = add k ulong x
365tot = add tot ulong x
366nb = div k 64
367for b ulong nb bound 262144
368sh_blk 0 mul b 64
369end
370o = mul nb 64
371r = rem k 64
372for j ulong r bound 64
373put sh_dat j get sh_dat add o j
374end
375k = r
376end
377fclo fd
378if not ok
379ret false
380end
381hfin k tot
382ret true
383end
384note finish the digest of a message of tot bytes whose last k (under 64) bytes are at the front of sh_dat:
385note FIPS 180-4 padding, as sh_all of seed/ng/sha256.om does it
386fn hfin k ulong tot ulong to void
387for j ulong 128
388put sh_pad j 0
389end
390for j ulong k bound 64
391put sh_pad j get sh_dat j
392end
393put sh_pad k 128
394e = ulong 64
395if ge k 56
396e = 128
397end
398bits = mul tot 8
399for j ulong 8
400put sh_pad sub sub e 1 j uchar and shr bits mul j 8 255
401end
402sh_blk 1 0
403if eq e 128
404sh_blk 1 64
405end
406sh_out
407end
408note the size of the file at g_pa, or 2^63 when unreadable
409fn fsize to ulong
410put g_n 6 0
411if not bload
412ret shl ulong 1 63
413end
414ret get g_n 6
415end
416note sh_dig equals the hex in g_hx
417fn digeq to bool
418for j ulong 32
419b = get sh_dig j
420if ne get g_hx mul j 2 sh_hexd uint shr b 4
421ret false
422end
423if ne get g_hx add mul j 2 1 sh_hexd uint and b 15
424ret false
425end
426end
427ret true
428end
429fn dsave to void
430for j ulong 32
431put g_d1 j get sh_dig j
432end
433end
434fn dsame to bool
435for j ulong 32
436if ne get g_d1 j get sh_dig j
437ret false
438end
439end
440ret true
441end
442note ---- processes
443fn aclr to void
444put g_n 3 2
445put g_n 4 0
446put g_av 0 0
447put g_av 1 0
448end
449note append g_pa as one argument; the argument list must fit g_av, else exit 2 (see the note on g_av)
450fn apa to void
451p = get g_n 3
452n = get g_n 0
453if gt add add p 2 n len g_av
454exit 2
455end
456for j ulong n bound 4096
457put g_av add add p 2 j get g_pa j
458end
459put g_av p uchar and n 255
460put g_av add p 1 uchar shr n 8
461put g_n 3 add p add n 2
462c = add get g_n 4 1
463put g_n 4 c
464put g_av 0 uchar and c 255
465put g_av 1 uchar shr c 8
466end
467fn atx t view uchar * to void
468pclr
469pt t
470apa
471end
472fn redir s int d int to void
473if ne dupfd s d 0 long d
474exit 127
475end
476end
477note run the argument list with stdin, stdout, stderr fds (closed here): the exit code, 256 + the signal, 512
478note when a file could not be opened, 1000 when the child passed the 600 s deadline (killed)
479fn spawn fi int fo int fe int to ulong
480if or lt fi 0 or lt fo 0 lt fe 0
481fclo fi
482fclo fo
483fclo fe
484ret 512
485end
486pid = fork
487if lt pid 0
488exit 2
489end
490if eq pid 0
491redir fi 0
492redir fo 1
493redir fe 2
494r = execprog g_av 0 get g_n 3
495exit 127
496end
497fclo fi
498fclo fo
499fclo fe
500t0 = monons
501while true bound 1000000000
502r = waitpid int pid g_stb 0 len g_stb 1
503if eq r pid
504x = ulong get g_stb 0
505if ne x 0
506ret add 256 x
507end
508ret ulong get g_stb 1
509end
510if lt r 0
511exit 2
512end
513if gt sub monons t0 600000000000
514r = killpid int pid 9
515r = waitpid int pid g_stb 0 len g_stb 0
516ret 1000
517end
518q = sleepns 200000
519end
520exit 2
521end
522note OMC < SCRATCH/NAME.om > SCRATCH/NAME.SUF 2> SCRATCH/NAME.ERR
523fn omc suf view uchar * err view uchar * to ulong
524psn t_om
525fi = frd
526aclr
527pclr
528for j ulong get g_n 1 bound 4096
529pc ulong get g_omc j
530end
531apa
532psn suf
533fo = fexe
534psn err
535fe = fwr
536ret spawn fi fo fe
537end
538note ---- the compiler digest
539note the first 64 characters of seed/out/omc.sha256 into g_pin; false unless lowercase hex
540fn pinread to bool
541pclr
542pt t_pin
543put g_n 6 0
544if not bload
545ret false
546end
547if lt get g_n 6 64
548ret false
549end
550for j ulong 64
551c = get g_b j
552ok = or and ge c 48 le c 57 and ge c 97 le c 102
553if not ok
554ret false
555end
556put g_pin j c
557end
558ret true
559end
560note the file at g_pa hashes to g_pin
561fn pinok to bool
562if not fhash
563ret false
564end
565for j ulong 64
566put g_hx j get g_pin j
567end
568ret digeq
569end
570note ---- units
571note g_u[i] is c, for i below e (never reads at or past e)
572fn uis i ulong e ulong c ulong to bool
573if ge i e
574ret false
575end
576ret eq ulong get g_u i c
577end
578fn uisnt i ulong e ulong c ulong to bool
579if ge i e
580ret false
581end
582ret ne ulong get g_u i c
583end
584note append one newline to g_b (units.sh writes one after every part)
585fn nl to bool
586n = get g_n 6
587r = enlarge g_b add n 1
588if lt r 0
589ret false
590end
591put g_b n 10
592put g_n 6 add n 1
593ret true
594end
595note a missing or unreadable part: FAIL unit NAME source unreadable: PATH (the path is in g_pa)
596fn psrcfail to void
597ot t_fail
598ot t_unit
599onm
600oc 32
601ot t_src
602for q ulong get g_n 0 bound 4096
603oc ulong get g_pa q
604end
605onl
606put g_n 11 add get g_n 11 1
607end
608text t_export "export fn "
609note g_b[o, g_n 6) holds one part: drop the "export " of every line that starts "export fn ", in place
610fn unexport o ulong to void
611n = get g_n 6
612w = o
613i = o
614start = true
615while lt i n bound 9223372036854775807
616if start
617if isexp i n
618i = add i 7
619end
620end
621c = get g_b i
622put g_b w c
623w = add w 1
624i = add i 1
625start = eq c 10
626end
627put g_n 6 w
628end
629fn isexp i ulong n ulong to bool
630if gt add i len t_export n
631ret false
632end
633for j ulong len t_export
634if ne get g_b add i j get t_export j
635ret false
636end
637end
638ret true
639end
640note compose the parts g_u[s, e) into g_b: each part's bytes (a line starting "export fn " kept as "fn "), then
641note one newline; false (reported) when a part is unreadable or its path does not fit Linux PATH_MAX
642fn compose s ulong e ulong to bool
643put g_n 6 0
644i = s
645while lt i e bound 9223372036854775807
646while uis i e 32 bound 9223372036854775807
647i = add i 1
648end
649if ge i e
650break
651end
652j = i
653while uisnt j e 32 bound 9223372036854775807
654j = add j 1
655end
656if ge sub j i len g_pa
657ofail t_unit t_plong
658ret false
659end
660pclr
661for q ulong sub j i bound 4096
662pc ulong get g_u add i q
663end
664o0 = get g_n 6
665if not bload
666psrcfail
667ret false
668end
669unexport o0
670if ne get g_n 20 0
671if mpart
672mapply o0
673end
674end
675if not nl
676ofail t_unit t_big
677ret false
678end
679i = j
680end
681ret true
682end
683note compile the composed unit twice; true when both exit 0 with empty stderr and equal bytes
684fn build to bool
685psn t_om
686if not bsave false
687ofail t_unit t_write
688ret false
689end
690r1 = omc t_b1 t_e1
691r2 = omc t_b2 t_e2
692if or ne r1 0 ne r2 0
693ot t_fail
694ot t_unit
695onm
696oc 32
697ot t_cmp
698ot t_exit
699onum r1
700oc 47
701onum r2
702onl
703put g_n 11 add get g_n 11 1
704ret false
705end
706psn t_e1
707s1 = fsize
708psn t_e2
709s2 = fsize
710if or ne s1 0 ne s2 0
711ofail t_unit t_stderr
712ret false
713end
714psn t_b1
715if not fhash
716ofail t_unit t_big
717ret false
718end
719dsave
720psn t_b2
721if not fhash
722ofail t_unit t_big
723ret false
724end
725if not dsame
726ofail t_unit t_twice
727ret false
728end
729psn t_b1
730sz = fsize
731psn t_b1
732if not fhash
733ofail t_unit t_big
734ret false
735end
736ot t_ok
737ot t_unit
738onm
739ot t_bytes
740onum sz
741ot t_sha
742ohex
743onl
744ret true
745end
746note Linux NAME_MAX, the longest file name a directory entry takes (getconf NAME_MAX / gives 255)
747fn namemax to ulong
748ret 255
749end
750note the larger of m and the length of t
751fn lmax m ulong t view uchar * to ulong
752if gt len t m
753ret len t
754end
755ret m
756end
757note the longest suffix the gate puts after NAME in SCRATCH
758fn sufmax to ulong
759m = lmax 0 t_om
760m = lmax m t_b1
761m = lmax m t_b2
762m = lmax m t_e1
763m = lmax m t_e2
764m = lmax m t_out
765m = lmax m t_rerr
766m = lmax m t_bad
767m = lmax m t_mo
768ret lmax m t_me
769end
770note one table row [s, e): NAME TABLE then parts; # starts a comment line; an empty line is skipped
771fn urow s ulong e ulong to void
772if or eq s e eq get g_u s 35
773ret
774end
775put g_n 14 0
776k = s
777while uisnt k e 32 bound 9223372036854775807
778k = add k 1
779end
780if or ge k e or eq k s gt sub k s sub namemax sufmax
781ofail t_unit t_row
782ret
783end
784for q ulong sub k s bound 256
785put g_nm q get g_u add s q
786end
787put g_n 14 sub k s
788put g_n 16 add get g_n 16 1
789if not nameok
790ofail t_unit t_badname
791ret
792end
793if not nameadd
794ofail t_unit t_dup
795ret
796end
797t0 = k
798while uis t0 e 32 bound 9223372036854775807
799t0 = add t0 1
800end
801t1 = t0
802while uisnt t1 e 32 bound 9223372036854775807
803t1 = add t1 1
804end
805if or ge t1 e or eq t1 t0 ge sub t1 t0 len g_pa
806ofail t_unit t_row
807ret
808end
809for q ulong sub t1 t0 bound 4096
810put g_tb q get g_u add t0 q
811end
812put g_n 17 sub t1 t0
813put g_n 22 t1
814put g_n 23 e
815if not compose t1 e
816ret
817end
818if build
819runchk
820end
821end
822note the table path into g_pa
823fn ptab to void
824pclr
825for j ulong get g_n 17 bound 4096
826pc ulong get g_tb j
827end
828end
829note run SCRATCH/NAME.1 with the table file at g_pa (also its stdin); the exit as spawn gives it
830fn runon to ulong
831aclr
832psn t_b1
833apa
834ptab
835apa
836fi = frd
837psn t_out
838fo = fwr
839psn t_rerr
840fe = fwr
841ret spawn fi fo fe
842end
843note print the last line of SCRATCH/NAME.out
844fn olast to void
845psn t_out
846put g_n 6 0
847if not bload
848ret
849end
850n = get g_n 6
851note two ifs, not one and: Omega's and reads both sides, so get g_b sub n 1 would trap on an empty output
852if gt n 0
853if eq get g_b sub n 1 10
854n = sub n 1
855end
856end
857b = n
858while gt b 0 bound 9223372036854775807
859if eq get g_b sub b 1 10
860break
861end
862b = sub b 1
863end
864for j ulong sub n b bound 9223372036854775807
865oc ulong get g_b add b j
866end
867end
868note run the check on its table: exit 0 and empty stderr pass; then the mutated-table control
869fn runchk to void
870put g_n 18 0
871r = runon
872psn t_rerr
873s = fsize
874if ne r 0
875ot t_fail
876ot t_unit
877onm
878oc 32
879ot t_run
880ot t_exit
881onum r
882ot t_says
883olast
884onl
885put g_n 11 add get g_n 11 1
886ret
887end
888if ne s 0
889ofail t_unit t_rstderr
890ret
891end
892ot t_ok
893ot t_unit
894onm
895oc 32
896ot t_run
897ot t_says
898olast
899onl
900put g_n 8 add get g_n 8 1
901ctltab
902mutants
903end
904note the last byte of the first case line of g_b[0, n) (not empty, not #); n when there is none
905fn firstcase n ulong to ulong
906s = ulong 0
907while lt s n bound 9223372036854775807
908e = s
909while and lt e n ne get g_b e 10 bound 9223372036854775807
910e = add e 1
911end
912if gt e s
913if ne get g_b s 35
914ret sub e 1
915end
916end
917s = add e 1
918end
919ret n
920end
921fn mutb c ulong to ulong
922if and ge c 48 le c 56
923ret add c 1
924end
925if and ge c 97 le c 101
926ret add c 1
927end
928ret 48
929end
930note control: the table with the last byte of its first case changed must make the check exit 1
931fn ctltab to void
932put g_n 12 add get g_n 12 1
933ptab
934put g_n 6 0
935ok = bload
936n = get g_n 6
937p = firstcase n
938if or not ok ge p n
939ofail t_ctl t_tabbad
940ret
941end
942put g_b p uchar mutb ulong get g_b p
943psn t_bad
944if not bsave false
945ofail t_ctl t_write
946ret
947end
948aclr
949psn t_b1
950apa
951psn t_bad
952apa
953fi = frd
954psn t_out
955fo = fwr
956psn t_rerr
957fe = fwr
958r = spawn fi fo fe
959if eq r 1
960ot t_ok
961else
962ot t_fail
963end
964ot t_ctl
965onm
966ot t_mut
967if eq r 1
968ot t_caught
969put g_n 13 add get g_n 13 1
970else
971ot t_esc
972ot t_exit
973onum r
974put g_n 11 add get g_n 11 1
975end
976onl
977end
978note ---- source mutants: gpu/nvidia/checks/mutants.tsv in g_m[0, g_n 19)
979note read gpu/nvidia/checks/mutants.tsv into g_m, sized from the file
980fn mload to bool
981pclr
982pt t_mutf
983put g_n 6 0
984if not bload
985ret false
986end
987n = get g_n 6
988r = enlarge g_m add n 1
989if lt r 0
990ret false
991end
992for q ulong n bound 9223372036854775807
993put g_m q get g_b q
994end
995put g_n 19 n
996ret true
997end
998note g_m[i] is not c, for i below e (never reads at or past e)
999fn mnot i ulong e ulong c ulong to bool
1000if ge i e
1001ret false
1002end
1003ret ne ulong get g_m i c
1004end
1005note g_b[i] is not c, for i below e
1006fn bnot i ulong e ulong c ulong to bool
1007if ge i e
1008ret false
1009end
1010ret ne ulong get g_b i c
1011end
1012note the end of the field of g_m that starts at p: the next tab, or e
1013fn mtab p ulong e ulong to ulong
1014q = p
1015while mnot q e 9 bound 9223372036854775807
1016q = add q 1
1017end
1018ret q
1019end
1020note g_m[s, a) is the current check's name
1021fn mname s ulong a ulong to bool
1022if ne sub a s get g_n 14
1023ret false
1024end
1025for j ulong sub a s bound 256
1026if ne get g_m add s j get g_nm j
1027ret false
1028end
1029end
1030ret true
1031end
1032note the part being composed (g_pa) is PART of the current mutant
1033fn mpart to bool
1034s = get g_n 24
1035if ne sub get g_n 25 s get g_n 0
1036ret false
1037end
1038for j ulong get g_n 0 bound 4096
1039if ne get g_pa j get g_m add s j
1040ret false
1041end
1042end
1043ret true
1044end
1045note g_b[s, e) equals FROM of the current mutant
1046fn mline s ulong e ulong to bool
1047f = get g_n 26
1048if ne sub e s sub get g_n 27 f
1049ret false
1050end
1051for j ulong sub e s bound 9223372036854775807
1052if ne get g_b add s j get g_m add f j
1053ret false
1054end
1055end
1056ret true
1057end
1058note replace the line of g_b[o, g_n 6) that equals FROM by TO when exactly one does; g_n 21 says what happened
1059fn mapply o ulong to void
1060n = get g_n 6
1061s = o
1062while lt s n bound 9223372036854775807
1063e = s
1064while bnot e n 10 bound 9223372036854775807
1065e = add e 1
1066end
1067if mline s e
1068if muniq add e 1 n
1069mrepl s e n
1070else
1071put g_n 21 3
1072end
1073ret
1074end
1075s = add e 1
1076end
1077end
1078note no line of g_b[s, n) equals FROM
1079fn muniq s ulong n ulong to bool
1080while lt s n bound 9223372036854775807
1081e = s
1082while bnot e n 10 bound 9223372036854775807
1083e = add e 1
1084end
1085if mline s e
1086ret false
1087end
1088s = add e 1
1089end
1090ret true
1091end
1092note g_b[s, e) becomes TO; the bytes from e to n move after it (copied through g_tl, sized from them)
1093fn mrepl s ulong e ulong n ulong to void
1094ts = get g_n 28
1095tl = sub get g_n 29 ts
1096k = sub n e
1097m = add add s tl k
1098r = enlarge g_b add m 1
1099if lt r 0
1100put g_n 21 2
1101ret
1102end
1103r = enlarge g_tl add k 1
1104if lt r 0
1105put g_n 21 2
1106ret
1107end
1108mmove s e k
1109put g_n 6 m
1110put g_n 21 1
1111end
1112note g_b[e, e+k) moves through g_tl to follow TO, which is written at s
1113fn mmove s ulong e ulong k ulong to void
1114for a ulong k bound 9223372036854775807
1115put g_tl a get g_b add e a
1116end
1117ts = get g_n 28
1118tl = sub get g_n 29 ts
1119for b ulong tl bound 9223372036854775807
1120put g_b add s b get g_m add ts b
1121end
1122d = add s tl
1123for c ulong k bound 9223372036854775807
1124put g_b add d c get g_tl c
1125end
1126end
1127note FAIL control NAME-source-mutant-line-L WHY; counts a failure
1128fn mfail why view uchar * to void
1129ot t_fail
1130ot t_ctl
1131onm
1132ot t_msrc
1133onum get g_n 30
1134oc 32
1135ot why
1136onl
1137put g_n 11 add get g_n 11 1
1138end
1139note every row of mutants.tsv that names the current check
1140fn mutants to void
1141n = get g_n 19
1142s = ulong 0
1143line = ulong 1
1144while lt s n bound 9223372036854775807
1145e = s
1146while mnot e n 10 bound 9223372036854775807
1147e = add e 1
1148end
1149put g_n 30 line
1150mrow s e
1151s = add e 1
1152line = add line 1
1153end
1154end
1155fn mrow s ulong e ulong to void
1156if eq s e
1157ret
1158end
1159if eq get g_m s 35
1160ret
1161end
1162a = mtab s e
1163if not mname s a
1164ret
1165end
1166put g_n 12 add get g_n 12 1
1167b = mtab add a 1 e
1168c = mtab add b 1 e
1169d = mtab add c 1 e
1170if or or ge a e ge b e ge c e
1171mfail t_mrow
1172ret
1173end
1174put g_n 33 0
1175if lt d e
1176if not mknown d e
1177mfail t_mrow
1178ret
1179end
1180end
1181put g_n 24 add a 1
1182put g_n 25 b
1183put g_n 26 add b 1
1184put g_n 27 c
1185put g_n 28 add c 1
1186put g_n 29 d
1187mrun
1188end
1189note the EXIT and KTABLE fields after TO, which ends at d: EXIT 1..255 in decimal, KTABLE a path that fits g_pa
1190fn mknown d ulong e ulong to bool
1191f = mtab add d 1 e
1192if ge f e
1193ret false
1194end
1195if ne mtab add f 1 e e
1196ret false
1197end
1198x = ulong 0
1199p = add d 1
1200if or eq p f gt sub f p 3
1201ret false
1202end
1203while lt p f bound 9223372036854775807
1204c = ulong get g_m p
1205if or lt c 48 gt c 57
1206ret false
1207end
1208x = add mul x 10 sub c 48
1209p = add p 1
1210end
1211if or eq x 0 gt x 255
1212ret false
1213end
1214k = add f 1
1215if or eq k e ge sub e k len g_pa
1216ret false
1217end
1218put g_n 33 1
1219put g_n 34 x
1220put g_n 35 k
1221put g_n 36 e
1222ret true
1223end
1224note the KTABLE of the current mutant row into g_pa
1225fn pktab to void
1226pclr
1227s = get g_n 35
1228for j ulong sub get g_n 36 s bound 4096
1229pc ulong get g_m add s j
1230end
1231end
1232note run SCRATCH/NAME then suffix on KTABLE (also its stdin); the exit as spawn gives it
1233fn runk suf view uchar * to ulong
1234aclr
1235psn suf
1236apa
1237pktab
1238apa
1239fi = frd
1240psn t_out
1241fo = fwr
1242psn t_rerr
1243fe = fwr
1244ret spawn fi fo fe
1245end
1246note FAIL control NAME-source-mutant-line-L WHY exit=X; counts a failure
1247fn mfailx why view uchar * x ulong to void
1248ot t_fail
1249ot t_ctl
1250onm
1251ot t_msrc
1252onum get g_n 30
1253oc 32
1254ot why
1255ot t_exit
1256onum x
1257onl
1258put g_n 11 add get g_n 11 1
1259end
1260note compose the mutant, compile it to SCRATCH/NAME.m, run it on TABLE: exit 1 is caught; a six-field row first
1261note runs the check on KTABLE (it must exit EXIT), then the mutant on KTABLE (it must exit 0)
1262fn mrun to void
1263kn = eq get g_n 33 1
1264if kn
1265k = runk t_b1
1266if ne k get g_n 34
1267mfailx t_kmoved k
1268ret
1269end
1270end
1271put g_n 20 1
1272put g_n 21 0
1273ok = compose get g_n 22 get g_n 23
1274put g_n 20 0
1275if not ok
1276ret
1277end
1278if eq get g_n 21 0
1279mfail t_mnot
1280ret
1281end
1282if eq get g_n 21 3
1283mfail t_muniq
1284ret
1285end
1286if ne get g_n 21 1
1287mfail t_big
1288ret
1289end
1290psn t_om
1291if not bsave false
1292mfail t_write
1293ret
1294end
1295r = omc t_mo t_me
1296if ne r 0
1297mfail t_mcmp
1298ret
1299end
1300x = ulong 0
1301want = ulong 1
1302if kn
1303want = 0
1304x = runk t_mo
1305else
1306aclr
1307psn t_mo
1308apa
1309ptab
1310apa
1311fi = frd
1312psn t_out
1313fo = fwr
1314psn t_rerr
1315fe = fwr
1316x = spawn fi fo fe
1317end
1318if eq x want
1319ot t_ok
1320else
1321ot t_fail
1322end
1323ot t_ctl
1324onm
1325ot t_msrc
1326onum get g_n 30
1327if eq x want
1328if kn
1329ot t_kheld
1330else
1331ot t_caught
1332end
1333put g_n 13 add get g_n 13 1
1334else
1335if kn
1336ot t_kfix
1337else
1338ot t_esc
1339end
1340ot t_exit
1341onum x
1342put g_n 11 add get g_n 11 1
1343end
1344onl
1345end
1346note a unit name uses only A-Z a-z 0-9 _ (the alphabet om/units.sh gives its names), so it names a file in SCRATCH
1347fn nameok to bool
1348for q ulong get g_n 14 bound 256
1349c = get g_nm q
1350d = and ge c 48 le c 57
1351u = and ge c 65 le c 90
1352l = and ge c 97 le c 122
1353ok = or or d u or l eq c 95
1354if not ok
1355ret false
1356end
1357end
1358ret true
1359end
1360note record the name in g_seen (names joined by newlines, g_seen grown to fit); false when it is already there or the host refuses the memory
1361fn nameadd to bool
1362n = get g_n 15
1363m = get g_n 14
1364p = ulong 0
1365while lt p n bound 9223372036854775807
1366q = p
1367while and lt q n ne get g_seen q 10 bound 9223372036854775807
1368q = add q 1
1369end
1370if nameat p q
1371ret false
1372end
1373p = add q 1
1374end
1375r = enlarge g_seen add add n m 1
1376if lt r 0
1377ret false
1378end
1379for j ulong m bound 256
1380put g_seen add n j get g_nm j
1381end
1382put g_seen add n m 10
1383put g_n 15 add add n m 1
1384ret true
1385end
1386note g_seen[p, q) equals the current name
1387fn nameat p ulong q ulong to bool
1388if ne sub q p get g_n 14
1389ret false
1390end
1391for j ulong sub q p bound 256
1392if ne get g_seen add p j get g_nm j
1393ret false
1394end
1395end
1396ret true
1397end
1398fn table to bool
1399pclr
1400pt t_tab
1401put g_n 6 0
1402if not bload
1403ret false
1404end
1405n = get g_n 6
1406r = enlarge g_u add n 1
1407if lt r 0
1408ret false
1409end
1410for q ulong n bound 9223372036854775807
1411put g_u q get g_b q
1412end
1413put g_n 7 n
1414s = ulong 0
1415while lt s n bound 9223372036854775807
1416e = s
1417while uisnt e n 10 bound 9223372036854775807
1418e = add e 1
1419end
1420urow s e
1421s = add e 1
1422end
1423if eq get g_n 16 0
1424nmset t_tab
1425ofail t_unit t_empty
1426end
1427ret true
1428end
1429note ---- controls
1430fn caught c bool what view uchar * to void
1431put g_n 12 add get g_n 12 1
1432nmset what
1433if c
1434ot t_ok
1435ot t_ctl
1436onm
1437ot t_caught
1438onl
1439put g_n 13 add get g_n 13 1
1440else
1441ofail t_ctl t_esc
1442end
1443end
1444note ---- INVENTORY.tsv against ports.tsv: ports.tsv in g_p[0, g_n 31), INVENTORY.tsv in g_b[0, g_n 6).
1445note g_ic: 0..4 INVENTORY rows that are ported, retired, blocked, open, other; 5..9 the same for the INVENTORY rows
1446note that ports.tsv rows name; 15 INVENTORY rows
1447fn pnot i ulong e ulong c ulong to bool
1448if ge i e
1449ret false
1450end
1451ret ne ulong get g_p i c
1452end
1453note g_p[a, b) holds the same bytes as g_b[c, d)
1454fn peqb a ulong b ulong c ulong d ulong to bool
1455if ne sub b a sub d c
1456ret false
1457end
1458for j ulong sub b a bound 9223372036854775807
1459if ne get g_p add a j get g_b add c j
1460ret false
1461end
1462end
1463ret true
1464end
1465note g_b[c, d) holds the bytes of t
1466fn beqt c ulong d ulong t view uchar * to bool
1467if ne sub d c len t
1468ret false
1469end
1470for j ulong len t bound 4096
1471if ne get g_b add c j get t j
1472ret false
1473end
1474end
1475ret true
1476end
1477note the end of the g_b field that starts at q: the next tab, or e
1478fn bend q ulong e ulong to ulong
1479p = q
1480while bnot p e 9 bound 9223372036854775807
1481p = add p 1
1482end
1483ret p
1484end
1485note the start of field f (0-based) of the g_b line [s, e), or e when it has fewer fields
1486fn bfld s ulong e ulong f ulong to ulong
1487q = s
1488for k ulong f bound 64
1489q = bend q e
1490if ge q e
1491ret e
1492end
1493q = add q 1
1494end
1495ret q
1496end
1497note 0 ported, 1 retired, 2 blocked, 3 open, 4 anything else
1498fn bstat c ulong d ulong to ulong
1499if beqt c d t_sported
1500ret 0
1501end
1502if beqt c d t_sretired
1503ret 1
1504end
1505if beqt c d t_sblocked
1506ret 2
1507end
1508if beqt c d t_sopen
1509ret 3
1510end
1511ret 4
1512end
1513note the om_ref or same_stem cell g_b[c, d) is -, or names a gpu/ file of this tree ending in .om that opens
1514note for reading (a path the host takes: shorter than Linux PATH_MAX)
1515fn invcell c ulong d ulong to bool
1516if eq sub d c 1
1517if eq ulong get g_b c 45
1518ret true
1519end
1520end
1521if or lt sub d c add len t_gpu len t_om ge sub d c len g_pa
1522ret false
1523end
1524if not beqt c add c len t_gpu t_gpu
1525ret false
1526end
1527if not beqt sub d len t_om d t_om
1528ret false
1529end
1530pclr
1531for q ulong sub d c bound 4096
1532pc ulong get g_b add c q
1533end
1534fd = frd
1535if lt fd 0
1536ret false
1537end
1538fclo fd
1539ret true
1540end
1541note FAIL inventory, the reason, then the INVENTORY path g_b[s, e)
1542fn invref s ulong e ulong to void
1543ot t_fail
1544ot t_invk
1545ot t_invref
1546for q ulong sub e s bound 9223372036854775807
1547oc ulong get g_b add s q
1548end
1549onl
1550put g_n 11 add get g_n 11 1
1551end
1552fn invmsg why view uchar * to void
1553ot t_fail
1554ot t_invk
1555ot why
1556onl
1557put g_n 11 add get g_n 11 1
1558end
1559fn invfail line ulong why view uchar * to void
1560ot t_fail
1561ot t_invk
1562ot t_ports
1563ot t_line
1564onum line
1565ot t_colon
1566ot why
1567onl
1568put g_n 11 add get g_n 11 1
1569end
1570note count the statuses of the INVENTORY rows (not empty, not #, not the header line)
1571fn invrows to void
1572n = get g_n 6
1573s = ulong 0
1574while lt s n bound 9223372036854775807
1575e = s
1576while bnot e n 10 bound 9223372036854775807
1577e = add e 1
1578end
1579if lt s e
1580if ne ulong get g_b s 35
1581if not beqt s bend s e t_hpath
1582c = bfld s e 8
1583k = bstat c bend c e
1584put g_ic k add get g_ic k 1
1585for f ulong 2
1586o = bfld s e add 6 f
1587if not invcell o bend o e
1588invref s bend s e
1589end
1590end
1591put g_ic 15 add get g_ic 15 1
1592end
1593end
1594end
1595s = add e 1
1596end
1597end
1598note the start of the INVENTORY line whose first field equals g_p[a, b); g_n 6 when there is none
1599fn invfind a ulong b ulong to ulong
1600n = get g_n 6
1601s = ulong 0
1602while lt s n bound 9223372036854775807
1603e = s
1604while bnot e n 10 bound 9223372036854775807
1605e = add e 1
1606end
1607if peqb a b s bend s e
1608ret s
1609end
1610s = add e 1
1611end
1612ret n
1613end
1614note one ports.tsv row g_p[s, e): STATUS<tab>DETAIL must equal fields 9 and 10 of the INVENTORY row of PATH
1615fn invport s ulong e ulong line ulong to void
1616t1 = s
1617while pnot t1 e 9 bound 9223372036854775807
1618t1 = add t1 1
1619end
1620if ge t1 e
1621invfail line t_invrow
1622ret
1623end
1624n = get g_n 6
1625m = invfind s t1
1626if ge m n
1627invfail line t_invmiss
1628ret
1629end
1630me = m
1631while bnot me n 10 bound 9223372036854775807
1632me = add me 1
1633end
1634c = bfld m me 8
1635x = bend bfld m me 9 me
1636if not peqb add t1 1 e c x
1637invfail line t_invdiff
1638ret
1639end
1640k = add bstat c bend c me 5
1641put g_ic k add get g_ic k 1
1642end
1643fn invports to void
1644n = get g_n 31
1645s = ulong 0
1646line = ulong 1
1647while lt s n bound 9223372036854775807
1648e = s
1649while pnot e n 10 bound 9223372036854775807
1650e = add e 1
1651end
1652if lt s e
1653if ne ulong get g_p s 35
1654invport s e line
1655end
1656end
1657s = add e 1
1658line = add line 1
1659end
1660end
1661note the footer g_b[s, e) holds t followed by the decimal want
1662fn footnum s ulong e ulong t view uchar * want ulong to bool
1663p = s
1664while lt p e bound 9223372036854775807
1665q = add p len t
1666if le q e
1667if beqt p q t
1668v = ulong 0
1669dg = ulong 0
1670while lt q e bound 9223372036854775807
1671c = ulong get g_b q
1672if or lt c 48 gt c 57
1673break
1674end
1675if ge dg 19
1676ret false
1677end
1678v = add mul v 10 sub c 48
1679q = add q 1
1680dg = add dg 1
1681end
1682ret and gt dg 0 eq v want
1683end
1684end
1685p = add p 1
1686end
1687ret false
1688end
1689fn invfoot to void
1690ok = true
1691for k ulong 3
1692if ne get g_ic k get g_ic add k 5
1693ok = false
1694end
1695end
1696if or or ne get g_ic 4 0 ne get g_ic 8 0 ne get g_ic 9 0
1697ok = false
1698end
1699if not ok
1700invmsg t_invcnt
1701end
1702n = get g_n 6
1703e = n
1704if gt e 0
1705if eq get g_b sub e 1 10
1706e = sub e 1
1707end
1708end
1709s = e
1710while gt s 0 bound 9223372036854775807
1711if eq get g_b sub s 1 10
1712break
1713end
1714s = sub s 1
1715end
1716f = footnum s e t_ffiles get g_ic 15
1717f = and f footnum s e t_fported get g_ic 0
1718f = and f footnum s e t_fretired get g_ic 1
1719f = and f footnum s e t_fblocked get g_ic 2
1720f = and f footnum s e t_fopen get g_ic 3
1721if not f
1722invmsg t_invfoot
1723end
1724end
1725note INVENTORY.tsv must say what ports.tsv says: every ports.tsv row is the status and detail of its path, the
1726note other rows are open, and the footer counts are its rows
1727fn invchk to void
1728pclr
1729pt t_ports
1730put g_n 6 0
1731if not bload
1732invmsg t_invnop
1733ret
1734end
1735n = get g_n 6
1736r = enlarge g_p add n 1
1737if lt r 0
1738invmsg t_big
1739ret
1740end
1741for q ulong n bound 9223372036854775807
1742put g_p q get g_b q
1743end
1744put g_n 31 n
1745pclr
1746pt t_invf
1747put g_n 6 0
1748if not bload
1749invmsg t_invnoi
1750ret
1751end
1752for k ulong 16
1753put g_ic k 0
1754end
1755f = get g_n 11
1756invrows
1757invports
1758invfoot
1759if eq get g_n 11 f
1760ot t_invok
1761onl
1762end
1763end
1764note a compiler one byte longer must fail the digest check
1765fn cwrong to void
1766pclr
1767for j ulong get g_n 1 bound 4096
1768pc ulong get g_omc j
1769end
1770put g_n 6 0
1771ok = bload
1772n = get g_n 6
1773put g_b n 0
1774put g_n 6 add n 1
1775psc t_plus
1776ok = and ok bsave true
1777psc t_plus
1778c = and ok not pinok
1779caught c t_plus
1780end
1781note ---- main
1782fn ausage to int
1783r = write 2 t_usage 0 len t_usage
1784ret 2
1785end
1786fn main to int
1787if ne argcnt 3
1788ret ausage
1789end
1790r = argread 1 g_omc 0 4095
1791if lt r 1
1792ret ausage
1793end
1794put g_n 1 ulong r
1795if not pinread
1796r = write 2 t_nopin 0 len t_nopin
1797ret 2
1798end
1799pclr
1800for j ulong get g_n 1 bound 4096
1801pc ulong get g_omc j
1802end
1803if not pinok
1804r = write 2 t_refd 0 len t_refd
1805ret 69
1806end
1807r = argread 2 g_scr 0 4094
1808if lt r 1
1809ret ausage
1810end
1811if gt add add ulong r 1 namemax sub len g_pa 1
1812r = write 2 t_long 0 len t_long
1813ret 2
1814end
1815n = ulong r
1816x = makedir g_scr 0 n 448
1817if ne x 0
1818r = write 2 t_noscr 0 len t_noscr
1819ret 2
1820end
1821put g_scr n 47
1822put g_n 2 add n 1
1823if not mload
1824r = write 2 t_nomut 0 len t_nomut
1825ret 2
1826end
1827if not table
1828r = write 2 t_notab 0 len t_notab
1829ret 2
1830end
1831invchk
1832cwrong
1833f = get g_n 11
1834ot t_sum
1835if eq f 0
1836ot t_pass
1837else
1838ot t_fl
1839end
1840ot t_su
1841onum get g_n 8
1842ot t_sc
1843onum get g_n 12
1844ot t_sk
1845onum get g_n 13
1846ot t_hw
1847oflush
1848if ne f 0
1849ret 1
1850end
1851if ne get g_n 12 get g_n 13
1852ret 1
1853end
1854ret 0
1855end