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 / bench / omc_efficiency / run.om

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