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 / bridge / shlib / test.tsv
| 1 | # SPDX-License-Identifier: Apache-2.0 |
| 2 | # bridge/shlib/test.tsv: the gate's test library (bridge/shlib/shlib.om lib) and its probe (shlib.om call). |
| 3 | soname libomshlib.so.1 |
| 4 | export omega_shlib_seven 999 |
| 5 | export omega_shlib_add 999 |
| 6 | export omega_shlib_div 999 |
| 7 | export omega_shlib_put 999 |
| 8 | export omega_shlib_get 999 |
| 9 | export omega_shlib_hi 999 |
| 10 | export omega_shlib_sum 999 |
| 11 | export omega_shlib_deep 999 |
| 12 | export omega_shlib_ub 999 |
| 13 | export omega_shlib_uh 999 |
| 14 | export omega_shlib_sb 999 |
| 15 | export omega_shlib_sh 999 |
| 16 | export omega_shlib_pdiv 999 |
| 17 | export omega_shlib_edge 999 |
| 18 | # The probe compares the low 32 bits of each result. 4294967293 is the int -3 with a zero upper half and |
| 19 | # 16045690981097406469 the int 5 under 0xdeadbeef: omc needs both sign-extended. Its int add checks that the |
| 20 | # 64-bit sum is an int (CMP X0, W0, SXTW) and traps otherwise, so call 1 fails without the wrapper's sign |
| 21 | # extension (999 for 7), as does call 5 (-9 div 3, a 64-bit division); call 9 (0xdeadbeef00010000 shifted |
| 22 | # right 16 as a uint) fails without zero extension. |
| 23 | # div by 0 traps 2 inside omc code; the library returns the trap value 999. |
| 24 | call omega_shlib_seven 7 |
| 25 | call omega_shlib_add 7 4294967293 10 |
| 26 | call omega_shlib_add 7 16045690981097406469 2 |
| 27 | call omega_shlib_add 4294967295 18446744073709551615 0 |
| 28 | call omega_shlib_div 999 1 0 |
| 29 | call omega_shlib_div 4294967293 4294967287 3 |
| 30 | call omega_shlib_seven 7 |
| 31 | # buf is one shared 4096-byte buffer: put writes its second uint, a later get reads it back. |
| 32 | call omega_shlib_put 0 buf 4242 |
| 33 | call omega_shlib_get 4242 buf |
| 34 | call omega_shlib_hi 1 16045690981097472000 |
| 35 | # sum needs 8 KiB of stack and deep 16 KiB through a private call: the wrapper probes those pages first. |
| 36 | call omega_shlib_sum 4950 100 |
| 37 | call omega_shlib_deep 42 41 |
| 38 | # Calls 12..15 pass a uchar, ushort, byte and short under the dirty upper bits 0xdeadbeef00000000 (low parts |
| 39 | # 0x1ff, 0x1ffff, 0x180, 0x8000): the wrapper's UXTB, UXTH, SXTB and SXTH make them 255, 65535, -128, -32768. |
| 40 | call omega_shlib_ub 255 16045690981097406975 |
| 41 | call omega_shlib_uh 65535 16045690981097537535 |
| 42 | call omega_shlib_sb 4294967168 16045690981097406848 |
| 43 | call omega_shlib_sh 4294934528 16045690981097439232 |
| 44 | # Calls 16 and 17: a division inside a private callee, trapping on 0 (999) and then -9 div 3. |
| 45 | call omega_shlib_pdiv 999 1 0 |
| 46 | call omega_shlib_pdiv 4294967293 4294967287 3 |
| 47 | # Call 18: a body whose need is one call cost past a page (its probe covers 2 pages). |
| 48 | call omega_shlib_edge 6 5 |