interplane.Get Omega
Read in your language

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

branch main Branches Tags History

omega-mv / bridge / shlib / test.tsv

48 lines · 2421 bytes Raw Blame History
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).
3soname libomshlib.so.1
4export omega_shlib_seven 999
5export omega_shlib_add 999
6export omega_shlib_div 999
7export omega_shlib_put 999
8export omega_shlib_get 999
9export omega_shlib_hi 999
10export omega_shlib_sum 999
11export omega_shlib_deep 999
12export omega_shlib_ub 999
13export omega_shlib_uh 999
14export omega_shlib_sb 999
15export omega_shlib_sh 999
16export omega_shlib_pdiv 999
17export 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.
24call omega_shlib_seven 7
25call omega_shlib_add 7 4294967293 10
26call omega_shlib_add 7 16045690981097406469 2
27call omega_shlib_add 4294967295 18446744073709551615 0
28call omega_shlib_div 999 1 0
29call omega_shlib_div 4294967293 4294967287 3
30call omega_shlib_seven 7
31# buf is one shared 4096-byte buffer: put writes its second uint, a later get reads it back.
32call omega_shlib_put 0 buf 4242
33call omega_shlib_get 4242 buf
34call 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.
36call omega_shlib_sum 4950 100
37call 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.
40call omega_shlib_ub 255 16045690981097406975
41call omega_shlib_uh 65535 16045690981097537535
42call omega_shlib_sb 4294967168 16045690981097406848
43call 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.
45call omega_shlib_pdiv 999 1 0
46call 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).
48call omega_shlib_edge 6 5