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 / seed / ng / bench / ngbench-sha.om

50 lines · 1532 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note seed/ng/bench/ngbench-sha.om: the last unit of ngbench (D1b). Build, in this order:
3note cat seed/ng/ngbench.om seed/ng/sha256.om seed/ng/bench/ngbench-sha.om | seed/out/omc > ngbench
4note ngbench.om comes first because its om2 line must be the unit's first line; this part comes after
5note seed/ng/sha256.om because it names sha256.om's globals (sh_dat, sh_dig), and a global must be
6note declared before use (functions may be called before their definition). Owner: ng-bench lane.
7note hashpb: SHA-256 (sha256.om sh_all over sh_dat) of the file named by gpb into gdg and ghx; returns
8note its size; 2^63 only when it is absent (open fails with ENOENT, errno 2); 2^63 + 1 when it is
9note present but cannot be used: open fails with any other errno (EACCES, ENOTDIR, ELOOP, ...), a read
10note fails (a directory: EISDIR), or it holds len sh_dat (16 MiB) bytes or more. Callers that only need
11note "no hash" test ge 2^63; callers that treat "absent" as allowed must refuse 2^63 + 1.
12fn hashpb to ulong
13fd = fopen gpb 0 get gpbn 0 0 0
14if lt fd 0
15if eq fd -2
16ret 9223372036854775808
17end
18ret 9223372036854775809
19end
20n = ulong 0
21bad = false
22going = true
23while going bound 16777217
24r = read int fd sh_dat n sub len sh_dat n
25if lt r 0
26bad = true
27going = false
28else
29if eq r 0
30going = false
31else
32n = add n ulong r
33if eq n len sh_dat
34bad = true
35going = false
36end
37end
38end
39end
40x = fclose int fd
41if bad
42ret 9223372036854775809
43end
44sh_all n
45for i ulong 32
46put gdg i get sh_dig i
47end
48tohex
49ret n
50end