omega-bridge
Omega-first language interoperability: checked conversion backends and native language bindings
Brought by drakestapleton
omega-bridge / tests / native / v2 / om3 / fnmap.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note OM-3 function-mode mapping context run (omega-mv#1008 section 1). CPU memory only: |
| 3 | note anonymous maps, a PROT_NONE reservation and a memfd. No device, no GPU. |
| 4 | note Export names match the existing tests/native/v2/dev callers (context.c, cleanup.c). |
| 5 | om2 |
| 6 | export fn anon to long |
| 7 | ret mapnew neg int 1 0 4096 3 34 |
| 8 | end |
| 9 | export fn reserve addr ulong bytes ulong to long |
| 10 | ret maphold addr bytes |
| 11 | end |
| 12 | export fn attach h long fd long to long |
| 13 | ret mapbind h int fd 0 3 |
| 14 | end |
| 15 | export fn address h long to ulong |
| 16 | ret mapaddr h |
| 17 | end |
| 18 | export fn drop h long to long |
| 19 | ret mapdrop h |
| 20 | end |
| 21 | export fn publish h long v ulong to long |
| 22 | p = new uchar 16 7 |
| 23 | w = mapwrite h 16 p 0 16 |
| 24 | cpufence |
| 25 | w = mapset h 8 8 v |
| 26 | w = mapset h 0 4 1 |
| 27 | ret w |
| 28 | end |
| 29 | export fn fetch h long to long |
| 30 | p = new uchar 16 0 |
| 31 | n = mapread h 16 p 0 16 |
| 32 | v = mapget h 8 8 |
| 33 | ret add long v long get p 15 |
| 34 | end |
| 35 | export fn rd h long to ulong |
| 36 | ret mapget h 0 4 |
| 37 | end |
| 38 | export fn store h long to long |
| 39 | ret mapset h 0 4 1 |
| 40 | end |