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 / tests / slab-arena / gate.om

185 lines · 3517 bytes Raw Blame History
1note Exercise serialized ownership in both orders, including wrong-owner teardown.
2fn leases h edit zonehdr to bool
3 if or slab_acquire_lease h 0 slab_acquire_lease h 3
4 ret false
5 end
6 if not slab_acquire_lease h 1
7 ret false
8 end
9 if or slab_acquire_lease h 2 slab_release_lease h 2
10 ret false
11 end
12 if not slab_release_lease h 1
13 ret false
14 end
15 if not slab_acquire_lease h 2
16 ret false
17 end
18 if or slab_acquire_lease h 1 slab_release_lease h 1
19 ret false
20 end
21 ret slab_release_lease h 2
22end
23
24fn offer h edit zonehdr slots edit uchar 256 id ushort to uchar
25 hint = new uchar 32 0
26 put_word hint 0 8 get h epoch
27 put_word hint 10 2 ulong id
28 put hint 12 2
29 put hint 13 3
30 result = slab_admit_hint h slots hint
31 if ne result get hint 16
32 ret 255
33 end
34 ret result
35end
36
37note Distinct nonzero patterns expose partial, high-byte and cross-slot overwrites.
38fn hash_ok slots view uchar 256 index ulong to bool
39 for j ulong 8
40 if ne get slots add add mul index 64 32 j uchar add 128 add mul index 8 j
41 ret false
42 end
43 end
44 ret true
45end
46
47fn fixture slots out uchar 256 to void
48 for i ulong 256
49 put slots i 0
50 end
51 for k ulong 4
52 pos = mul k 64
53 put slots add pos 2 uchar k
54 put slots add pos 4 1
55 if ge k 2
56 put slots add pos 4 2
57 end
58 put slots add pos 5 2
59 for j ulong 8
60 put slots add add pos 32 j uchar add 128 add mul k 8 j
61 end
62 end
63end
64
65fn all_hashes slots view uchar 256 to bool
66 for k ulong 4
67 if not hash_ok slots k
68 ret false
69 end
70 end
71 ret true
72end
73
74fn main to int
75 h = new uchar 128 255
76 slots = new uchar 256 0
77 slab_init h 7 2 2
78 fixture slots
79 if not leases h
80 ret 1
81 end
82 if or z2_check_promotion h 1 9 ne get_word h 0 8 0
83 ret 30
84 end
85 if ne offer h slots 3 3
86 ret 2
87 end
88 if not all_hashes slots
89 ret 3
90 end
91 if not slab_acquire_lease h 1
92 ret 4
93 end
94 if ne offer h slots 2 1
95 ret 5
96 end
97 if not all_hashes slots
98 ret 6
99 end
100 if ne offer h slots 384 3
101 ret 7
102 end
103 if not all_hashes slots
104 ret 8
105 end
106 put slots 133 3
107 if ne offer h slots 383 0
108 ret 9
109 end
110 if not all_hashes slots
111 ret 10
112 end
113 put slots 133 2
114 if z2_check_promotion h 1 9
115 ret 11
116 end
117 if ne offer h slots 383 2
118 ret 12
119 end
120 if or ne get_word slots 130 2 383 ne get slots 133 1
121 ret 13
122 end
123 if ne offer h slots 383 1
124 ret 14
125 end
126 if or ne get_word h 8 4 7 ne get_word h 40 8 0
127 ret 15
128 end
129 if z2_check_promotion h 2 7
130 ret 16
131 end
132 if ne get_word h 16 4 0
133 ret 17
134 end
135 if z2_check_promotion h 3 9
136 ret 18
137 end
138 if ne offer h slots 382 2
139 ret 19
140 end
141 if z2_check_promotion h 4 9
142 ret 20
143 end
144 if or ne get_word h 28 4 0 ne offer h slots 381 0
145 ret 21
146 end
147 if or ne get_word h 8 4 7 ne get_word h 40 8 0
148 ret 22
149 end
150 if or not hash_ok slots 0 not hash_ok slots 1
151 ret 23
152 end
153 if z2_check_promotion h 4 9
154 ret 24
155 end
156 if not z2_check_promotion h 5 9
157 ret 25
158 end
159 if or ne get_word h 8 4 9 ne get_word h 16 4 0
160 ret 26
161 end
162 if or ne get_word h 48 4 2 ne get_word h 52 4 2
163 ret 27
164 end
165 for i ulong 72
166 if ne get h add 56 i 0
167 ret 28
168 end
169 end
170 rep = new uchar 32 0
171 put_word rep 0 8 get_word h 0 8
172 put_word rep 10 2 ulong 383
173 put rep 12 2
174 put rep 13 3
175 if ne slab_admit_hint h slots rep 1
176 ret 31
177 end
178 if not slab_release_lease h 1
179 ret 32
180 end
181 if or ne slab_admit_hint h slots rep 1 ne get_word h 48 4 2
182 ret 33
183 end
184 ret 0
185end