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 / host / tests / device.om

102 lines · 1641 bytes Raw Blame History
1note Host/device composition. No GPU opened. FIONREAD observes real native pipes.
2global ends uchar 8
3global count uchar 12
4global status uchar 4
5text msg "Omega device boundary"
6text zero "/dev/zero"
7fn word32 off ulong to int
8v = uint 0
9for i ulong 4
10v = or v shl uint get ends add off i mul i 8
11end
12ret int v
13end
14fn fault kind int to int
15if eq kind 0
16r = devctl neg int 1 uint 21531 count 0 3
17ret int r
18end
19if eq kind 1
20r = devctl neg int 1 uint 21531 count 0 5
21ret int r
22end
23if eq kind 2
24r = devctl neg int 1 uint 21531 count 9 4
25ret int r
26end
27if eq kind 3
28r = devctl neg int 1 uint 21531 count 18446744073709551615 4
29ret int r
30end
31r = devctl neg int 1 uint 21531 count 0 18446744073709551615
32ret int r
33end
34fn main to int
35if ne pipefds ends 0 8 0 0
36ret 1
37end
38rd = word32 0
39wr = word32 4
40if ne write wr msg 0 len msg long len msg
41ret 2
42end
43for i ulong 12
44put count i 171
45end
46if ne devctl rd uint 21531 count 4 4 0
47ret 3
48end
49if ne get count 4 uchar len msg
50ret 4
51end
52for i ulong 12
53if or lt i 4 ge i 8
54if ne get count i 171
55ret 5
56end
57else
58if and gt i 4 ne get count i 0
59ret 6
60end
61end
62end
63if ne devctl neg int 1 uint 21531 count 4 4 neg long 9
64ret 7
65end
66note Normal file operations and nested native calls retain live values.
67fd = fopen zero 0 len zero 0 0
68if lt fd 0
69ret 8
70end
71if ne add devctl int fd uint 21531 count 4 4 25 0
72ret 9
73end
74if ne fclose int fd 0
75ret 10
76end
77if ne fclose rd 0
78ret 11
79end
80if ne fclose wr 0
81ret 12
82end
83for kind int 5
84pid = fork
85if lt pid 0
86ret 13
87end
88if eq pid 0
89exit fault kind
90end
91if ne waitpid int pid status 0 4 0 pid
92ret 14
93end
94if ne get status 0 0
95ret 15
96end
97if ne get status 1 103
98ret 16
99end
100end
101ret 0
102end