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 / seed / host / tests / eventfd.om
| 1 | note Safe host behavior only: no VFIO or GPU paths. Helpers precede creation to exercise lifecycle codegen. |
| 2 | global buf uchar 8 |
| 3 | global arg uchar 8 |
| 4 | fn ck b bool to void |
| 5 | if not b |
| 6 | exit int 80 |
| 7 | end |
| 8 | end |
| 9 | fn shut fd int to void |
| 10 | ck eq fclose fd 0 |
| 11 | end |
| 12 | fn main to int |
| 13 | fd = int eventfd uint 0 |
| 14 | ck ge fd 0 |
| 15 | ck eq waitio fd 1 0 0 |
| 16 | ck eq read fd buf 0 8 neg long 11 |
| 17 | put buf 0 uchar 7 |
| 18 | ck eq write fd buf 0 8 8 |
| 19 | ck eq waitio fd 1 0 1 |
| 20 | ck eq read fd buf 0 8 8 |
| 21 | ck eq get buf 0 uchar 7 |
| 22 | for i ulong 7 |
| 23 | ck eq get buf add i 1 uchar 0 |
| 24 | end |
| 25 | ck eq waitio fd 1 0 0 |
| 26 | ck eq read fd buf 0 8 neg long 11 |
| 27 | if gt argcnt 1 |
| 28 | n = argread 1 arg 0 8 |
| 29 | ck eq n 1 |
| 30 | if eq get arg 0 uchar 49 |
| 31 | r = vfioirq fd uint 15213 buf 0 8 |
| 32 | ret int r |
| 33 | end |
| 34 | if eq get arg 0 uchar 50 |
| 35 | for i ulong 127 |
| 36 | more = eventfd uint 0 |
| 37 | ck ge more 0 |
| 38 | end |
| 39 | ck eq eventfd uint 0 neg long 24 |
| 40 | end |
| 41 | end |
| 42 | shut fd |
| 43 | ck eq read fd buf 0 8 neg long 9 |
| 44 | initial = int eventfd uint 7 |
| 45 | ck ge initial 0 |
| 46 | ck eq read initial buf 0 8 8 |
| 47 | ck eq get buf 0 uchar 7 |
| 48 | shut initial |
| 49 | ret 0 |
| 50 | end |