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 / mapio.om

100 lines · 1771 bytes Raw Blame History
1note Exact word access through managed mappings. No GPU or device opens.
2global bytes uchar 16
3global status uchar 4
4text msg "PASS managed addresses and ordered mapped words\n"
5fn ck yes bool to void
6if not yes
7exit int 80
8end
9end
10fn bad k int to void
11h = mapnew neg int 1 0 4096 3 34
12ck gt h 0
13if eq k 0
14ck eq mapdrop h 0
15r = mapaddr h
16ret
17end
18if eq k 1
19ck eq mapdrop h 0
20r = mapget h 0 4
21ret
22end
23if eq k 2
24r = mapget h 4096 4
25ret
26end
27if eq k 3
28r = mapset h 4092 8 0
29ret
30end
31if eq k 4
32r = mapget h 1 4
33ret
34end
35if eq k 5
36r = mapset h 4 8 0
37ret
38end
39if eq k 6
40ro = mapnew neg int 1 0 4096 1 34
41r = mapset ro 0 4 0
42ret
43end
44if eq k 7
45r = mapset h 0 4 4294967296
46ret
47end
48r = mapget h 18446744073709551615 8
49end
50fn held h long a ulong b ulong c ulong d ulong e ulong to void
51ck gt mapaddr h 4096
52ck eq mapset h 0 8 18446744073709551615 0
53ck eq mapget h 0 8 18446744073709551615
54ck eq a 101
55ck eq b 202
56ck eq c 303
57ck eq d 404
58ck eq e 505
59end
60fn main to int
61h = mapnew neg int 1 0 4096 3 33
62ck gt h 0
63ck eq and mapaddr h 4095 0
64held h 101 202 303 404 505
65ck eq mapset h 8 4 4294967295 0
66ck eq mapget h 8 4 4294967295
67ck eq mapset h 12 4 305419896 0
68ck eq mapread h 0 bytes 0 16 16
69for i ulong 12
70ck eq get bytes i 255
71end
72ck eq get bytes 12 120
73ck eq get bytes 13 86
74ck eq get bytes 14 52
75ck eq get bytes 15 18
76ck eq mapset h 4088 8 81985529216486895 0
77ck eq mapget h 4088 8 81985529216486895
78p = fork
79ck ge p 0
80if eq p 0
81ck eq mapset h 0 8 42 0
82exit int 0
83end
84ck eq waitpid int p status 0 4 0 p
85ck and eq get status 0 0 eq get status 1 0
86ck eq mapget h 0 8 42
87ck eq mapdrop h 0
88for k int 9
89p = fork
90ck ge p 0
91if eq p 0
92bad k
93exit int 80
94end
95ck eq waitpid int p status 0 4 0 p
96ck and eq get status 0 0 eq get status 1 103
97end
98ck eq write 1 msg 0 len msg long len msg
99ret 0
100end