_self_host_mem_test.nx source
↩ module page · 14 lines · 435 B
1// Test that mmap+store+read works in self-host.
2// expect_exit: 4
3import "nx_syscalls.nx"
4
5func main() -> i64 {
6 let buf: *u8 = sys_mmap(64)
7 let p: *i64 = buf as *i64
8 p[0] = 0x0001000100010001
9 p[1] = 0x0001000100010001
10 p[2] = 0x0001000100010001
11 p[3] = 0x0001000100010001
12 // Read back and verify: low 16 of p[0] should be 1.
13 return (p[0] & 0xFFFF) + (p[1] & 0xFFFF) + (p[2] & 0xFFFF) + (p[3] & 0xFFFF)
14}