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

105 lines · 1869 bytes Raw Blame History
1note Owned low-address reservations and complete-span file binding. Host only.
2text path "reserve.bin"
3text mark "Z"
4text msg "PASS owned reservations, collision refusal and failed-bind retirement\n"
5global buf uchar 4
6global status uchar 4
7global fds int 2
8fn ck yes bool to void
9if not yes
10exit int 80
11end
12end
13fn bad k int to void
14if eq k 0
15r = maphold 4096 4096
16ret
17end
18if eq k 1
19r = maphold 1099511627776 4096
20ret
21end
22if eq k 2
23r = maphold 68719476737 4096
24ret
25end
26if eq k 3
27r = maphold 68719476736 4097
28ret
29end
30if eq k 4
31r = maphold 18446744073709551615 4096
32ret
33end
34h = maphold 68719542272 4096
35ck gt h 0
36if eq k 5
37r = mapread h 0 buf 0 1
38ret
39end
40if eq k 6
41r = mapwrite h 0 mark 0 1
42ret
43end
44if eq k 7
45r = mapget h 0 4
46ret
47end
48if eq k 8
49r = mapset h 0 4 0
50ret
51end
52if eq k 9
53ck eq mapbind h neg int 1 0 3 neg long 9
54r = mapaddr h
55ret
56end
57ck eq mapbind h get fds 0 0 3 0
58r = mapbind h get fds 0 0 3
59end
60fn main to int
61fd = fopen path 0 len path 524482 384
62ck ge fd 0
63put fds 0 int fd
64ck eq fseek int fd 4095 0 4095
65ck eq write int fd mark 0 1 1
66ro = fopen path 0 len path 524288 0
67ck ge ro 0
68put fds 1 int ro
69for i ulong 16
70h = maphold 68719476736 4096
71ck gt h 0
72ck eq mapaddr h 68719476736
73ck eq maphold 68719476736 4096 neg long 17
74ck eq mapbind h int fd 0 3 0
75ck eq mapread h 4095 buf 0 1 1
76ck eq get buf 0 90
77ck eq mapset h 0 4 add 123 i 0
78ck eq mapget h 0 4 add 123 i
79ck eq mapdrop h 0
80end
81h = maphold 68719476736 4096
82ck gt h 0
83ck eq mapbind h int ro 0 3 neg long 13
84j = maphold 68719476736 4096
85ck gt j 0
86ck ne j h
87ck eq mapbind j int ro 0 1 0
88ck eq mapget j 0 4 138
89ck eq mapdrop j 0
90for k int 11
91p = fork
92ck ge p 0
93if eq p 0
94bad k
95exit int 80
96end
97ck eq waitpid int p status 0 4 0 p
98ck and eq get status 0 0 eq get status 1 103
99end
100ck eq fclose int fd 0
101ck eq fclose int ro 0
102ck eq unlink path 0 len path 0
103ck eq write 1 msg 0 len msg long len msg
104ret 0
105end