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 / si / architecture / tools / capreg / capreg.om

1210 lines · 20316 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note capreg: check and render the org-wide CUDA capability register
3note (docs/capability-register/register.tsv). Seeded native Omega, built only by the compiler
4note pinned in tools/zero-legacy/omega.pin. Schema and rules: tools/capreg/README.md.
5note usage:
6note capreg check REGISTER.tsv exit 0 valid, 1 invalid (FAIL lines on stderr)
7note capreg render REGISTER.tsv markdown view on stdout; exit 1, nothing rendered, if invalid
8note capreg verify REGISTER.tsv VIEW.md exit 0 only when valid and VIEW.md equals the render
9note capreg evidence REGISTER.tsv ROOT for each aien-dev/<repo>@<sha>:<path> evidence run
10note /usr/bin/git -C ROOT/<repo> cat-file -e <sha>:<path>;
11note exit 0 all present, 1 any missing, 3 a clone is missing
12note Exit 64 usage, 65 register unreadable or over 500000 bytes. Traps exit 100 + code.
13note Capacities: 1024 records, a view of 999000 bytes, paths of 4095 bytes (loop bounds stay under 999999).
14
15note entries of tt, separated by newlines (index: meaning)
16note 0 header; 1-4 ref_state forms; 5-10 arch forms; 11-18 levels; 19-20 deploy forms;
17note 21-25 verdicts; 26 (post-audit); 27-29 evidence prefixes; 30 -; 31-34 modes;
18note 35-77 messages; 78-109 render pieces; 110-156 audit map area names for rows 1..47
19text tt "row\tarea\towner_repo\trev\tref_state\tarch\tlevel\tscope\tapi_contract\ttest_command\tevidence\trefusals\tdeploy_state\taudit_claim\taudit_verdict\tnote\nMERGED\nDRAFT_PR#\nOPEN_PR#\nBRANCH:\nhost-aarch64\nhost-x86_64\nGB10\nQEMU\nnone\ngpu:\nNONE_FOUND\nPROPOSED\nIMPLEMENTED\nEXERCISED_HOST\nEXERCISED_EMULATOR\nEXERCISED_GB10\nEXERCISED_OTHER_GPU\nQUALIFIED_GB10\nNOT_DEPLOYED\nDEPLOYED:\nCONFIRMED\nCORRECTED\nOUTDATED\nNEW\nUNVERIFIED\n(post-audit)\naien-dev/\nregister:\nregister:absence/\n-\ncheck\nrender\nverify\nevidence\nusage: capreg check REGISTER.tsv / capreg render REGISTER.tsv / capreg verify REGISTER.tsv VIEW.md / capreg evidence REGISTER.tsv CLONEROOT\nFAIL line \n: \ncapreg: cannot read the register, or it exceeds 500000 bytes\nheader does not match the 16-field schema\nexpected 16 TAB-separated fields\nempty field (write none or - instead)\ncontrol character or backtick in line\nrow must be NN.k with NN 1..47 and k >= 1, no leading zeros\nrows must ascend by (NN, k) with no duplicates\narea is not the audit map name for this row number\nowner_repo must be aien-dev/<name>\nrev must be 40 lowercase hex\nref_state must be MERGED, DRAFT_PR#N, OPEN_PR#N or BRANCH:<name>\narch must be host-aarch64, host-x86_64, GB10, QEMU, gpu:<name> or none\nlevel must be NONE_FOUND, PROPOSED, IMPLEMENTED, EXERCISED_HOST, EXERCISED_EMULATOR, EXERCISED_GB10, EXERCISED_OTHER_GPU or QUALIFIED_GB10\nlevel exceeds or contradicts arch (NONE_FOUND, PROPOSED, IMPLEMENTED: none; EXERCISED_HOST: host-*; EXERCISED_EMULATOR: QEMU; EXERCISED_GB10, QUALIFIED_GB10: GB10; EXERCISED_OTHER_GPU: gpu:*)\nan exercised or qualified level needs a test_command\nevidence must be aien-dev/<repo>@<40-hex sha>:<path> or register:<path> without ..\nNONE_FOUND needs register:absence/ evidence\nregister evidence file does not exist next to the register\ndeploy_state must be NOT_DEPLOYED or DEPLOYED:<system>\nDEPLOYED needs ref_state MERGED\naudit_verdict must be CONFIRMED, CORRECTED, OUTDATED, NEW or UNVERIFIED\nNEW and (post-audit) must go together\nCORRECTED, OUTDATED and UNVERIFIED need a note, not -\nmore than 1024 records\nFAIL: map row \n has no record\ncapreg: register invalid, nothing rendered\nFAIL: view differs from the rendered register; regenerate it with capreg render\nFAIL: view unreadable or over 999000 bytes\nOK records=\nFAIL evidence missing: \nNOT_RUN clone missing: \nOK evidence checked=\n/usr/bin/git\n-C\ncat-file\n-e\n/dev/null\nFAIL: \nfile does not end with a newline\n<!-- Generated by tools/capreg/capreg.om render from register.tsv. Do not edit by hand: edit register.tsv, then regenerate. -->\n# CUDA capability register\nSource of truth: [register.tsv](register.tsv), one record per owner component for each row of the 47-row map in the 2026-10-27 audit, plus work since. Schema, rules and the checker: [tools/capreg/README.md](../../tools/capreg/README.md). A level never exceeds what the cited evidence file shows. A host or emulator pass is not GPU evidence. NONE_FOUND means the recorded search found nothing; it is not proof of absence.\n## Levels\n| Level | Records |\n|---|---|\n## Audit verdicts\n| Verdict | Records |\n## Summary\n| Row | Area | Owner | Level | Arch | State | Audit |\n|---|---|---|---|---|---|---|\n## Records\n### \n#### \n- Level: \n (arch \n- Rev: `\n` (\n- Scope: \n- API: \n- Test: `\n- Evidence: `\n- Refusals: \n- Deploy: \n- Audit claim: \n- Audit verdict: \n. \n| \n | \n |\n)\n`\nCUDA C++\nHost build\nnvcc\nNVVM\nlibdevice\nPTX\nptxas\nDevice linking\nNVRTC\nnvJitLink\ncubin/fatbin\nCUDA Python/cuTile\nRuntime API\nUser-space driver\nMemory interop\nStreams/events\nGraphs\nAdvanced execution\nKernel driver\nFirmware\nCCCL\nCUTLASS-style\ncuBLAS\ncuDNN\ncuTENSOR\ncuSPARSE\ncuSPARSELt\ncuSOLVER\ncuFFT\ncuRAND\nMathDx\nNPP/codecs\nnvCOMP\nDistributed math\nNCCL\nNVSHMEM\nGPUDirect\nBinary utils\nCUDA-GDB\nSanitizer\nCUPTI\nNsight\nNVTX\nNVML/nvidia-smi\nMPS/MIG\nPackaging\nFrameworks\n"
20
21const AREA0 ulong 110
22const SRCCAP ulong 500000
23const VCAP ulong 999000
24const MAXREC ulong 1024
25
26global tso ulong 256
27global tsl ulong 256
28global src uchar 500001
29global srcn ulong 1
30global vbuf uchar 999001
31global vbn ulong 1
32global fo ulong 16384
33global fl ulong 16384
34global rnn ulong 1024
35global rkk ulong 1024
36global nrow ulong 1
37global pnn ulong 1
38global pkk ulong 1
39global seen uchar 48
40global lvc ulong 8
41global vdc ulong 5
42global failn ulong 1
43global obuf uchar 999001
44global obl ulong 1
45global ebuf uchar 65536
46global ebl ulong 1
47global nb uchar 24
48global mode uchar 64
49global path uchar 4096
50global pathl ulong 1
51global dirl ulong 1
52global p2 uchar 4096
53global p2l ulong 1
54global tmp uchar 8192
55global ab uchar 8192
56global abl ulong 1
57global pk uchar 4096
58global pkn ulong 1
59global pkc ulong 1
60global status uchar 4
61
62note ---- text table ----
63
64fn tinit to void
65s = ulong 0
66k = ulong 0
67put tso 0 0
68n = len tt
69while lt s n bound 65536
70if eq get tt s 10
71put tsl k sub s get tso k
72k = add k 1
73put tso k add s 1
74end
75s = add s 1
76end
77end
78
79note ---- stderr lines ----
80
81fn ec c uchar to void
82n = get ebl 0
83put ebuf n c
84put ebl 0 add n 1
85end
86
87fn eflush to void
88r = write 2 ebuf 0 get ebl 0
89put ebl 0 0
90end
91
92fn emit t ulong to void
93o = get tso t
94n = get tsl t
95b = get ebl 0
96for i ulong n
97put ebuf add b i get tt add o i
98end
99put ebl 0 add b n
100end
101
102note write the decimal digits of v at the end of nb; return how many
103fn digs v ulong to ulong
104x = v
105n = ulong 0
106if eq x 0
107put nb 23 48
108ret 1
109end
110while gt x 0 bound 20
111put nb sub 23 n uchar add 48 rem x 10
112x = div x 10
113n = add n 1
114end
115ret n
116end
117
118fn enum v ulong to void
119n = digs v
120for i ulong n
121ec get nb add sub 24 n i
122end
123end
124
125fn efield r ulong f ulong to void
126a = fof r f
127n = fln r f
128for i ulong n
129ec get src add a i
130end
131end
132
133fn fail ln ulong m ulong to void
134put failn 0 add get failn 0 1
135emit 36
136enum ln
137emit 37
138emit m
139ec 10
140eflush
141end
142
143fn failg m ulong to void
144put failn 0 add get failn 0 1
145emit 76
146emit m
147ec 10
148eflush
149end
150
151note ---- stdout view ----
152
153fn oc c uchar to void
154n = get obl 0
155put obuf n c
156put obl 0 add n 1
157end
158
159fn oemit t ulong to void
160o = get tso t
161n = get tsl t
162b = get obl 0
163for i ulong n
164put obuf add b i get tt add o i
165end
166put obl 0 add b n
167end
168
169fn onum v ulong to void
170n = digs v
171for i ulong n
172oc get nb add sub 24 n i
173end
174end
175
176fn ofield r ulong f ulong to void
177a = fof r f
178n = fln r f
179b = get obl 0
180for i ulong n
181put obuf add b i get src add a i
182end
183put obl 0 add b n
184end
185
186fn oflush to bool
187n = get obl 0
188o = ulong 0
189while lt o n bound 999999
190k = write 1 obuf o sub n o
191if le k 0
192ret false
193end
194o = add o ulong k
195end
196put obl 0 0
197ret true
198end
199
200note ---- fields ----
201
202fn fof r ulong f ulong to ulong
203ret get fo add mul r 16 f
204end
205
206fn fln r ulong f ulong to ulong
207ret get fl add mul r 16 f
208end
209
210note field f of record r equals entry t
211fn feq r ulong f ulong t ulong to bool
212n = fln r f
213if ne n get tsl t
214ret false
215end
216a = fof r f
217b = get tso t
218for i ulong n
219if ne get src add a i get tt add b i
220ret false
221end
222end
223ret true
224end
225
226note field f of record r starts with entry t
227fn fpre r ulong f ulong t ulong to bool
228n = get tsl t
229if lt fln r f n
230ret false
231end
232a = fof r f
233b = get tso t
234for i ulong n
235if ne get src add a i get tt add b i
236ret false
237end
238end
239ret true
240end
241
242fn isdig c uchar to bool
243ret and ge c 48 le c 57
244end
245
246fn ishex c uchar to bool
247if isdig c
248ret true
249end
250ret and ge c 97 le c 102
251end
252
253fn namech c uchar to bool
254if isdig c
255ret true
256end
257if and ge c 97 le c 122
258ret true
259end
260if and ge c 65 le c 90
261ret true
262end
263ret or or eq c 46 eq c 95 eq c 45
264end
265
266note n lowercase hex bytes at offset o inside field f
267fn hexrun r ulong f ulong o ulong n ulong to bool
268if lt fln r f add o n
269ret false
270end
271a = fof r f
272for i ulong n
273if not ishex get src add a add o i
274ret false
275end
276end
277ret true
278end
279
280note the bytes of field f from offset o to its end are one or more digits
281fn digtail r ulong f ulong o ulong to bool
282n = fln r f
283if le n o
284ret false
285end
286a = fof r f
287i = o
288while lt i n bound 999999
289if not isdig get src add a i
290ret false
291end
292i = add i 1
293end
294ret true
295end
296
297note value of m digits at src offset o, or 100000 when a byte is not a digit
298fn numat o ulong m ulong to ulong
299v = ulong 0
300for i ulong m
301c = get src add o i
302if not isdig c
303ret 100000
304end
305v = add mul v 10 ulong sub c 48
306end
307ret v
308end
309
310note ---- per-field rules ----
311
312note NN.k: NN 1..47 of one or two digits, k 1..9999, no leading zeros; sets rnn and rkk
313fn rowid r ulong to bool
314n = fln r 0
315a = fof r 0
316d = ulong 0
317while lt d n bound 999999
318if eq get src add a d 46
319break
320end
321d = add d 1
322end
323if or eq d 0 gt d 2
324ret false
325end
326if ge add d 1 n
327ret false
328end
329m = sub sub n d 1
330if gt m 4
331ret false
332end
333if or eq get src a 48 eq get src add a add d 1 48
334ret false
335end
336nn = numat a d
337kk = numat add a add d 1 m
338if or lt nn 1 gt nn 47
339ret false
340end
341if or lt kk 1 gt kk 9999
342ret false
343end
344put rnn r nn
345put rkk r kk
346ret true
347end
348
349fn ownerok r ulong to bool
350if not fpre r 2 27
351ret false
352end
353n = fln r 2
354if le n 9
355ret false
356end
357a = fof r 2
358i = ulong 9
359while lt i n bound 999999
360if not namech get src add a i
361ret false
362end
363i = add i 1
364end
365ret true
366end
367
368fn refok r ulong to bool
369if feq r 4 1
370ret true
371end
372if fpre r 4 2
373ret digtail r 4 9
374end
375if fpre r 4 3
376ret digtail r 4 8
377end
378if fpre r 4 4
379ret gt fln r 4 7
380end
381ret false
382end
383
384note arch class: 0 none, 1 host, 2 GB10, 3 QEMU, 4 other GPU, 9 malformed
385fn archcls r ulong to ulong
386if feq r 5 9
387ret 0
388end
389if or feq r 5 5 feq r 5 6
390ret 1
391end
392if feq r 5 7
393ret 2
394end
395if feq r 5 8
396ret 3
397end
398if fpre r 5 10
399if gt fln r 5 4
400ret 4
401end
402end
403ret 9
404end
405
406note level 0..7 in the order of entries 11..18, 9 malformed
407fn levidx r ulong to ulong
408for t ulong 8
409if feq r 6 add 11 t
410ret t
411end
412end
413ret 9
414end
415
416note the only arch class each level may claim
417fn needarc lv ulong to ulong
418if le lv 2
419ret 0
420end
421if eq lv 3
422ret 1
423end
424if eq lv 4
425ret 3
426end
427if eq lv 6
428ret 4
429end
430ret 2
431end
432
433fn vidx r ulong to ulong
434for t ulong 5
435if feq r 14 add 21 t
436ret t
437end
438end
439ret 9
440end
441
442note aien-dev/<repo>@<40 hex>:<path>
443fn evrepo r ulong to bool
444if not fpre r 10 27
445ret false
446end
447n = fln r 10
448a = fof r 10
449q = ulong 9
450while lt q n bound 999999
451if eq get src add a q 64
452break
453end
454if not namech get src add a q
455ret false
456end
457q = add q 1
458end
459if or eq q 9 ge q n
460ret false
461end
462if not hexrun r 10 add q 1 40
463ret false
464end
465p = add q 41
466if ge p n
467ret false
468end
469if ne get src add a p 58
470ret false
471end
472ret gt n add p 1
473end
474
475note register:<path>, nonempty, no .. anywhere
476fn evreg r ulong to bool
477if not fpre r 10 28
478ret false
479end
480n = fln r 10
481if le n 9
482ret false
483end
484a = fof r 10
485i = ulong 9
486while lt add i 1 n bound 999999
487c0 = get src add a i
488c1 = get src add a add i 1
489if and eq c0 46 eq c1 46
490ret false
491end
492i = add i 1
493end
494ret true
495end
496
497note the register: path exists relative to the register file's directory
498fn regfile r ulong to bool
499d = get dirl 0
500n = fln r 10
501m = sub n 9
502if gt add d m 4095
503ret false
504end
505for i ulong d
506put tmp i get path i
507end
508a = fof r 10
509for j ulong m
510put tmp add d j get src add a add 9 j
511end
512fd = fopen tmp 0 add d m 0 0
513if lt fd 0
514ret false
515end
516c = fclose int fd
517ret true
518end
519
520note ---- record checks ----
521
522fn chkid r ulong ln ulong to void
523if not rowid r
524fail ln 43
525ret
526end
527nn = get rnn r
528kk = get rkk r
529up = gt nn get pnn 0
530if and eq nn get pnn 0 gt kk get pkk 0
531up = true
532end
533if up
534put pnn 0 nn
535put pkk 0 kk
536else
537fail ln 44
538end
539put seen nn 1
540if not feq r 1 add AREA0 sub nn 1
541fail ln 45
542end
543end
544
545fn chkrow r ulong ln ulong to void
546chkid r ln
547if not ownerok r
548fail ln 46
549end
550if or ne fln r 3 40 not hexrun r 3 0 40
551fail ln 47
552end
553if not refok r
554fail ln 48
555end
556ac = archcls r
557if eq ac 9
558fail ln 49
559end
560lv = levidx r
561if eq lv 9
562fail ln 50
563else
564put lvc lv add get lvc lv 1
565if and ne ac 9 ne ac needarc lv
566fail ln 51
567end
568if and ge lv 3 feq r 9 9
569fail ln 52
570end
571end
572chkev r ln lv
573chkend r ln
574end
575
576fn chkev r ulong ln ulong lv ulong to void
577er = evrepo r
578eg = evreg r
579if not or er eg
580fail ln 53
581end
582if and eq lv 0 not fpre r 10 29
583fail ln 54
584end
585if eg
586if not regfile r
587fail ln 55
588end
589end
590end
591
592fn chkend r ulong ln ulong to void
593nd = feq r 12 19
594dp = fpre r 12 20
595if dp
596if le fln r 12 9
597dp = false
598end
599end
600if not or nd dp
601fail ln 56
602end
603if and dp not feq r 4 1
604fail ln 57
605end
606vd = vidx r
607if eq vd 9
608fail ln 58
609else
610put vdc vd add get vdc vd 1
611end
612isnew = eq vd 3
613post = feq r 13 26
614if ne isnew post
615fail ln 59
616end
617bad = or or eq vd 1 eq vd 2 eq vd 4
618if and bad feq r 15 30
619fail ln 60
620end
621end
622
623note ---- parsing ----
624
625fn header s ulong e ulong to bool
626n = sub e s
627if ne n get tsl 0
628ret false
629end
630b = get tso 0
631for i ulong n
632if ne get src add s i get tt add b i
633ret false
634end
635end
636ret true
637end
638
639note bytes s..e (e excluded) are one line: no control byte but TAB, no backtick; count the TABs
640fn tabs s ulong e ulong to ulong
641k = ulong 0
642i = s
643while lt i e bound 999999
644c = get src i
645if eq c 9
646k = add k 1
647else
648if or lt c 32 eq c 96
649ret 99999
650end
651end
652i = add i 1
653end
654ret k
655end
656
657fn store r ulong s ulong e ulong to void
658f = ulong 0
659b = s
660i = s
661base = mul r 16
662while lt i e bound 999999
663if eq get src i 9
664put fo add base f b
665put fl add base f sub i b
666f = add f 1
667b = add i 1
668end
669i = add i 1
670end
671put fo add base f b
672put fl add base f sub e b
673end
674
675fn doline s ulong e ulong ln ulong to void
676if eq ln 1
677if not header s e
678fail ln 39
679end
680ret
681end
682k = tabs s e
683if eq k 99999
684fail ln 42
685ret
686end
687if ne k 15
688fail ln 40
689ret
690end
691r = get nrow 0
692if ge r MAXREC
693fail ln 61
694ret
695end
696store r s e
697put nrow 0 add r 1
698for f ulong 16
699if eq fln r f 0
700fail ln 41
701ret
702end
703end
704chkrow r ln
705end
706
707fn parse to void
708n = get srcn 0
709if eq n 0
710fail 1 39
711ret
712end
713if ne get src sub n 1 10
714failg 77
715end
716s = ulong 0
717ln = ulong 1
718while lt s n bound 999999
719e = s
720while lt e n bound 999999
721if eq get src e 10
722break
723end
724e = add e 1
725end
726doline s e ln
727s = add e 1
728ln = add ln 1
729end
730for i ulong 47
731if eq get seen add i 1 0
732put failn 0 add get failn 0 1
733emit 62
734enum add i 1
735emit 63
736ec 10
737eflush
738end
739end
740end
741
742note ---- files ----
743
744fn loadreg to bool
745fd = fopen path 0 get pathl 0 0 0
746if lt fd 0
747ret false
748end
749n = ulong 0
750k = long 0
751while lt n 500001 bound 500002
752k = read int fd src n sub 500001 n
753if le k 0
754break
755end
756n = add n ulong k
757end
758c = fclose int fd
759if lt k 0
760ret false
761end
762if gt n SRCCAP
763ret false
764end
765put srcn 0 n
766ret true
767end
768
769fn loadview to bool
770fd = fopen p2 0 get p2l 0 0 0
771if lt fd 0
772ret false
773end
774n = ulong 0
775k = long 0
776while lt n 999001 bound 999002
777k = read int fd vbuf n sub 999001 n
778if le k 0
779break
780end
781n = add n ulong k
782end
783c = fclose int fd
784if lt k 0
785ret false
786end
787if gt n VCAP
788ret false
789end
790put vbn 0 n
791ret true
792end
793
794note ---- render ----
795
796fn nl to void
797oc 10
798end
799
800fn cnttab hd ulong t0 ulong m ulong which ulong to void
801oemit hd
802nl
803nl
804if eq which 0
805oemit 82
806else
807oemit 85
808end
809nl
810oemit 83
811nl
812for i ulong m
813oemit 105
814oemit add t0 i
815oemit 106
816if eq which 0
817onum get lvc i
818else
819onum get vdc i
820end
821oemit 107
822nl
823end
824nl
825end
826
827fn sumrow r ulong to void
828oemit 105
829ofield r 0
830oemit 106
831ofield r 1
832oemit 106
833ofield r 2
834oemit 106
835ofield r 6
836oemit 106
837ofield r 5
838oemit 106
839ofield r 4
840oemit 106
841ofield r 14
842oemit 107
843nl
844end
845
846fn line t ulong r ulong f ulong to void
847oemit t
848ofield r f
849nl
850end
851
852fn record r ulong to void
853nl
854oemit 91
855ofield r 0
856oc 32
857ofield r 2
858nl
859nl
860oemit 92
861ofield r 6
862oemit 93
863ofield r 5
864oemit 108
865nl
866oemit 94
867ofield r 3
868oemit 95
869ofield r 4
870oemit 108
871nl
872line 96 r 7
873line 97 r 8
874oemit 98
875ofield r 9
876oemit 109
877nl
878oemit 99
879ofield r 10
880oemit 109
881nl
882line 100 r 11
883line 101 r 12
884line 102 r 13
885oemit 103
886ofield r 14
887if not feq r 15 30
888oemit 104
889ofield r 15
890end
891nl
892end
893
894fn render to void
895oemit 78
896nl
897nl
898oemit 79
899nl
900nl
901oemit 80
902nl
903nl
904cnttab 81 11 8 0
905cnttab 84 21 5 1
906oemit 86
907nl
908nl
909oemit 87
910nl
911oemit 88
912nl
913for r ulong get nrow 0
914sumrow r
915end
916nl
917oemit 89
918nl
919pn = ulong 0
920for r ulong get nrow 0
921nn = get rnn r
922if ne nn pn
923nl
924oemit 90
925onum nn
926oc 46
927oc 32
928oemit add AREA0 sub nn 1
929nl
930pn = nn
931end
932record r
933end
934end
935
936fn same to bool
937n = get obl 0
938if ne n get vbn 0
939ret false
940end
941for i ulong n
942if ne get obuf i get vbuf i
943ret false
944end
945end
946ret true
947end
948
949note ---- evidence mode ----
950
951fn pk0 to void
952put pkn 0 2
953put pkc 0 0
954end
955
956note append ab as one record of the execprog packet
957fn pka to void
958n = get pkn 0
959m = get abl 0
960put pk n uchar rem m 256
961put pk add n 1 uchar div m 256
962for i ulong m
963put pk add n add 2 i get ab i
964end
965put pkn 0 add n add 2 m
966c = add get pkc 0 1
967put pkc 0 c
968put pk 0 uchar rem c 256
969put pk 1 uchar div c 256
970end
971
972fn abt t ulong to void
973o = get tso t
974n = get tsl t
975for i ulong n
976put ab i get tt add o i
977end
978put abl 0 n
979end
980
981note ab gets field 10 of r from offset o for n bytes, appended after k existing bytes
982fn abf r ulong o ulong n ulong k ulong to void
983a = fof r 10
984for i ulong n
985put ab add k i get src add a add o i
986end
987put abl 0 add k n
988end
989
990fn child to void
991fd = fopen tt get tso 75 get tsl 75 1 0
992if ge fd 0
993r = dupfd int fd 1 0
994r = dupfd int fd 2 0
995end
996r = execprog pk 0 get pkn 0
997exit 127
998end
999
1000fn run to long
1001pid = fork
1002if lt pid 0
1003ret -1
1004end
1005if eq pid 0
1006child
1007end
1008r = waitpid int pid status 0 4 0
1009if ne r pid
1010ret -1
1011end
1012if ne get status 0 0
1013ret -1
1014end
1015ret long get status 1
1016end
1017
1018note 0 present, 1 missing, 3 clone directory missing or git not runnable
1019fn evone r ulong to ulong
1020n = fln r 10
1021a = fof r 10
1022q = ulong 9
1023while ne get src add a q 64 bound 999999
1024q = add q 1
1025end
1026pk0
1027abt 71
1028pka
1029abt 72
1030pka
1031k = get p2l 0
1032for i ulong k
1033put ab i get p2 i
1034end
1035put ab k 47
1036abf r 9 sub q 9 add k 1
1037fd = fopen ab 0 get abl 0 0 0
1038if lt fd 0
1039emit 69
1040for j ulong get abl 0
1041ec get ab j
1042end
1043ec 10
1044eflush
1045ret 3
1046end
1047c = fclose int fd
1048pka
1049abt 73
1050pka
1051abt 74
1052pka
1053abf r add q 1 sub sub n q 1 0
1054pka
1055x = run
1056if eq x 0
1057ret 0
1058end
1059if or lt x 0 eq x 127
1060ret 3
1061end
1062emit 68
1063efield r 10
1064ec 10
1065eflush
1066ret 1
1067end
1068
1069fn evcheck to int
1070miss = ulong 0
1071nocl = ulong 0
1072done = ulong 0
1073for r ulong get nrow 0
1074if evrepo r
1075x = evone r
1076if eq x 0
1077done = add done 1
1078end
1079if eq x 1
1080miss = add miss 1
1081end
1082if eq x 3
1083nocl = add nocl 1
1084end
1085end
1086end
1087if gt miss 0
1088ret 1
1089end
1090if gt nocl 0
1091ret 3
1092end
1093emit 70
1094enum done
1095ec 10
1096r = write 1 ebuf 0 get ebl 0
1097put ebl 0 0
1098ret 0
1099end
1100
1101note ---- main ----
1102
1103fn usage to int
1104emit 35
1105ec 10
1106eflush
1107ret 64
1108end
1109
1110fn modeis t ulong m ulong to bool
1111if ne m get tsl t
1112ret false
1113end
1114o = get tso t
1115for i ulong m
1116if ne get mode i get tt add o i
1117ret false
1118end
1119end
1120ret true
1121end
1122
1123fn main to int
1124tinit
1125ac = argcnt
1126if or lt ac 3 gt ac 4
1127ret usage
1128end
1129m = argread 1 mode 0 64
1130if lt m 1
1131ret usage
1132end
1133md = ulong 9
1134for t ulong 4
1135if modeis add 31 t ulong m
1136md = t
1137end
1138end
1139if eq md 9
1140ret usage
1141end
1142if ne ge md 2 eq ac 4
1143ret usage
1144end
1145n = argread 2 path 0 4095
1146if lt n 1
1147ret usage
1148end
1149put pathl 0 ulong n
1150d = ulong 0
1151for i ulong ulong n
1152if eq get path i 47
1153d = add i 1
1154end
1155end
1156put dirl 0 d
1157if eq ac 4
1158k = argread 3 p2 0 4095
1159if lt k 1
1160ret usage
1161end
1162put p2l 0 ulong k
1163end
1164if not loadreg
1165emit 38
1166ec 10
1167eflush
1168ret 65
1169end
1170parse
1171if gt get failn 0 0
1172if eq md 1
1173emit 64
1174ec 10
1175eflush
1176end
1177ret 1
1178end
1179if eq md 0
1180emit 67
1181enum get nrow 0
1182ec 10
1183r = write 1 ebuf 0 get ebl 0
1184put ebl 0 0
1185ret 0
1186end
1187if eq md 3
1188ret evcheck
1189end
1190render
1191if eq md 1
1192if not oflush
1193ret 1
1194end
1195ret 0
1196end
1197if not loadview
1198emit 66
1199ec 10
1200eflush
1201ret 1
1202end
1203if not same
1204emit 65
1205ec 10
1206eflush
1207ret 1
1208end
1209ret 0
1210end