code wiki / _hdl_build / nx_atomic_swap.nx
nx_atomic_swap.nx
buildroot/runtime/_hdl_build/nx_atomic_swap.nx
about
nx_atomic_swap.nx -- DEP-001 (CALLOUT-012 deploy-exceed). Prove + register the ATOMIC content
swap: write the new version to a temp file, then sys_renameat(temp, live) -> live is replaced
in ONE atomic FS operation (a concurrent reader sees whole-old or whole-new, NEVER torn). This
is the no-torn-deploy primitive the deploy-check named as a GAP (had via renameat, unregistered).
Composes the PROVEN sys_renameat (nx_syscalls). Self-validating gate (ATOMICSWAPGATE):
pre=old, swap rc=0, post=new (old GONE), temp consumed. license_tier: ORIGINAL
dependencies 1 imports · 0 importers
imports: nx_syscalls.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 8 | const AW_MAGIC_4096: i64 = 4096 |
| 10 | const AW_LIVE: *u8 = "/tmp/nx_asw_live" |
| 11 | const AW_TMP: *u8 = "/tmp/nx_asw_tmp" |
| 12 | const AW_V1: *u8 = "VERSION-1-OLD-content" |
| 13 | const AW_V2: *u8 = "VERSION-2-NEW-content-atomic" |
functions
| 15 | func aw_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } |
| 16 | func aw_putn(v: i64) -> i64 { let bb: *u8 = sys_mmap(28); var m: i64=v; if m<0 {m=0-m}; let t: *u8 = sys_mmap(28); var k: i64=0; if m==0 {t[0]=48;k=1}; while m>0 {t[k]=48+(m%10); m=m/10; k=k+1}; var i: i64=0; while i<k {bb[i]=t[k-1-i]; i=i+1}; sys_write(1, bb, k); return 0 } |
| 17 | func aw_strlen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } called by 1: aw_write |
| 19 | func aw_write(path: *u8, content: *u8) -> i64 |
| 26 | func aw_read(path: *u8, buf: *u8, cap: i64) -> i64 |
| 35 | func aw_has(buf: *u8, n: i64, needle: *u8) -> i64 called by 1: main |
| 43 | func main() -> i64 |