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
omega-mv / gpu / nvidia / om / platform-linux / fake_devctl.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note Fake-device fixture. Opens a pipe, never /dev/nvidia. FIONREAD is 21531. |
| 3 | note A wrong expected count is the negative control: this program exits 4. |
| 4 | global ends uchar 8 |
| 5 | global count uchar 12 |
| 6 | text msg "Omega device boundary" |
| 7 | fn word32 off ulong to int |
| 8 | v = uint 0 |
| 9 | for i ulong 4 |
| 10 | v = or v shl uint get ends add off i mul i 8 |
| 11 | end |
| 12 | ret int v |
| 13 | end |
| 14 | fn main to int |
| 15 | if ne pipefds ends 0 8 0 0 |
| 16 | ret 1 |
| 17 | end |
| 18 | rd = word32 0 |
| 19 | wr = word32 4 |
| 20 | if ne write wr msg 0 len msg long len msg |
| 21 | ret 2 |
| 22 | end |
| 23 | for i ulong 12 |
| 24 | put count i 171 |
| 25 | end |
| 26 | if ne devctl rd uint 21531 count 4 4 0 |
| 27 | ret 3 |
| 28 | end |
| 29 | if ne get count 4 uchar len msg |
| 30 | ret 4 |
| 31 | end |
| 32 | if ne devctl neg int 1 uint 21531 count 4 4 neg long 9 |
| 33 | ret 5 |
| 34 | end |
| 35 | if ne fclose rd 0 |
| 36 | ret 6 |
| 37 | end |
| 38 | if ne fclose wr 0 |
| 39 | ret 7 |
| 40 | end |
| 41 | ret 0 |
| 42 | end |