nx_arena_types.nx
buildroot/runtime/nx_arena_types.nx
about
nx_arena_types.nx -- arena type + constants, zero-syscall.
FOUR-PILLAR FIX (2026-05-16): nx_arena.nx hard-imports nx_syscalls.nx
because nx_arena_new() calls sys_mmap internally. Any caller that
wanted to compose against nx_arena PLUS a different syscall layer
(e.g., nx_syscalls_x86_64.nx for native exec) hit linker symbol
redefinition -- the F-meta-4-class cross-target portability gap.
This file ADDS the inversion-of-control entry point. It carries:
- struct NxArena (the type)
- NX_ARENA_BYTES (sizeof constant)
- nx_arena_align_up (pure math)
- nx_arena_alloc / _alloc_zero / _reset / _used / _cap_bytes /
_alloc_count / _oom_count (operate on a caller-owned arena)
- nx_arena_init(a, base, cap) (init a caller-allocated NxArena
struct + caller-allocated backing buffer)
What it does NOT carry: nx_arena_new (which mmaps). That stays
in nx_arena.nx for backwards-compat + convenience. Callers that
want a different syscall ABI can:
1. allocate the NxArena struct + backing buffer themselves
2. call nx_arena_init(a, base, cap)
3. pass `a` to nx_arena_alloc + friends as before
Per cardinal user-owns-every-bit: this is the canonical shape.
The caller mmaps the bytes (using whichever syscall layer matches
the target ABI); substrate just uses them.
nx_capability_claims:
needs: [pointer_arithmetic, struct_field_assign]
provides: [arena_type, arena_init, arena_alloc, arena_reset]
safety: [no_unchecked_deref, no_floating_point, no_syscall,
bit_equal_reproducible, target_agnostic]
verdict: [no_silent_failure (oom returns null + n_oom++)]
license: ORIGINAL
kind: racing_crew_specialist
dependencies 0 imports · 8 importers
imports: none
imported by: nx_arena.nxnx_arena_scope.nxnx_arena_scope_test.nxnx_chacha20_poly1305_pure.nxnx_chacha20_pure.nxnx_poly1305_pure.nxnx_poly1305_pure_test.nxnx_xor_arena.nx
structs
| 44 | struct NxArena |
consts
| 52 | const NX_ARENA_BYTES: i64 = 40 |
functions
| 66 | func nx_arena_init(a: *NxArena, base: *u8, cap: i64) -> i64 |
| 81 | func nx_arena_align_up(x: i64, align: i64) -> i64 |
| 88 | func nx_arena_alloc(a: *NxArena, n: i64, align: i64) -> *u8 |
| 104 | func nx_arena_alloc_zero(a: *NxArena, n: i64, align: i64) -> *u8 |
| 114 | func nx_arena_reset(a: *NxArena) -> i64 called by 1: main |
| 119 | func nx_arena_used(a: *NxArena) -> i64 { return a.off } |
| 120 | func nx_arena_cap_bytes(a: *NxArena) -> i64 { return a.cap } |
| 121 | func nx_arena_alloc_count(a: *NxArena) -> i64 { return a.n_alloc } called by 1: main |
| 122 | func nx_arena_oom_count(a: *NxArena) -> i64 { return a.n_oom } called by 1: main |