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 / om / gpu / dsv41 / decoder / io.om
| 1 | note SPDX-License-Identifier: AGPL-3.0-only |
| 2 | fn diRead fd int buf edit uchar * pos ulong count ulong to bool |
| 3 | used = ulong 0 |
| 4 | while lt used count |
| 5 | n = pread fd buf used sub count used long add pos used |
| 6 | if eq n -4 |
| 7 | continue |
| 8 | end |
| 9 | if le n 0 |
| 10 | ret false |
| 11 | end |
| 12 | used = add used ulong n |
| 13 | end |
| 14 | ret true |
| 15 | end |
| 16 | |
| 17 | fn diPut record edit uchar * off ulong width ulong v ulong to void |
| 18 | for i ulong width |
| 19 | put record add off i uchar and shr v mul i 8 255 |
| 20 | end |
| 21 | end |
| 22 | |
| 23 | fn diGet record view uchar * off ulong width ulong to ulong |
| 24 | value = ulong 0 |
| 25 | for i ulong width |
| 26 | value = or value shl ulong get record add off i mul i 8 |
| 27 | end |
| 28 | ret value |
| 29 | end |