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 / pio.om
| 1 | text p "pio.tmp" |
| 2 | text body "abcdefgh" |
| 3 | fn main to int |
| 4 | fd = int fopen p 0 len p 578 420 |
| 5 | if lt fd 0 |
| 6 | ret 1 |
| 7 | end |
| 8 | w = write fd body 0 len body |
| 9 | if ne w long len body |
| 10 | ret 2 |
| 11 | end |
| 12 | src = new uchar 2 0 |
| 13 | put src 0 88 |
| 14 | put src 1 89 |
| 15 | r = pwrite fd src 0 2 4 |
| 16 | if ne r 2 |
| 17 | ret 3 |
| 18 | end |
| 19 | buf = new uchar 8 0 |
| 20 | n = pread fd buf 0 8 0 |
| 21 | if ne n 8 |
| 22 | ret 4 |
| 23 | end |
| 24 | if ne get buf 4 88 |
| 25 | ret 5 |
| 26 | end |
| 27 | if ne get buf 5 89 |
| 28 | ret 6 |
| 29 | end |
| 30 | r = fclose fd |
| 31 | r = pwrite fd src 0 2 0 |
| 32 | if ge r 0 |
| 33 | ret 7 |
| 34 | end |
| 35 | r = unlink p 0 len p |
| 36 | if ne r 0 |
| 37 | ret 8 |
| 38 | end |
| 39 | ret 0 |
| 40 | end |