code wiki / _hdl_build / nx_mmap_probe.nx
nx_mmap_probe.nx source
↩ module page · 28 lines · 1327 B
1// nx_mmap_probe.nx -- pins the sovereign large-immediate/mmap bug: sovereign-built nxasm bails
2// pre-pass0 on 2.36MB inputs while the gcc-built one reads fine. Probes sys_mmap at small/2.4MB/16MiB
3// (the NXASM_BUF constant). Run VIA nx_sov_build_run; trust its run-exit= line ONLY (bash $? lies).
4// exit 0 = all mmaps good (bug elsewhere: read loop) ; 1/2/3 = which size failed. license_tier: ORIGINAL
5import "nx_sovjson_lib.nx"
6import "nx_syscalls.nx"
7const K_MAGIC_4096: i64 = 4096
8const K_MAGIC_4095: i64 = 4095
9const K_MAGIC_2400000: i64 = 2400000
10const K_MAGIC_2399999: i64 = 2399999
11const K_MAGIC_16777216: i64 = 16777216
12const K_MAGIC_16777215: i64 = 16777215
13
14func mp_w(s: *u8) -> i64 { return sj_puts(s) }
15
16func main() -> i64 {
17 let a: *u8 = sys_mmap(K_MAGIC_4096)
18 if (a as i64) <= 0 { mp_w("FAIL small\n" as *u8); sys_exit(1); return 1 }
19 a[0] = 7 as u8; a[K_MAGIC_4095] = 7 as u8
20 let b: *u8 = sys_mmap(K_MAGIC_2400000)
21 if (b as i64) <= 0 { mp_w("FAIL 2.4MB\n" as *u8); sys_exit(2); return 2 }
22 b[0] = 7 as u8; b[K_MAGIC_2399999] = 7 as u8
23 let c: *u8 = sys_mmap(K_MAGIC_16777216)
24 if (c as i64) <= 0 { mp_w("FAIL 16MiB\n" as *u8); sys_exit(3); return 3 }
25 c[0] = 7 as u8; c[K_MAGIC_16777215] = 7 as u8
26 mp_w("ALL MMAPS OK small/2.4MB/16MiB\n" as *u8)
27 sys_exit(0); return 0
28}