code wiki / (root) / nx_archive.nx

nx_archive.nx

buildroot/runtime/nx_archive.nx

7814 B228 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tooltopic archive
docsdependenciesstructsconstsfunctions

about

nx_archive.nx -- BSD-format ar(1) static library builder. Replaces `ar rcs libfoo.a *.o`. Useful for shipping reusable NishiLang code as a single linkable artifact. AR format (System V variant; also BSD-compatible): "!<arch>\n" 8 bytes -- magic one or more entries: [name (16 bytes, space-padded, ends with '/')] [date (12 bytes ASCII decimal seconds-since-epoch)] [uid (6 bytes ASCII decimal)] [gid (6 bytes ASCII decimal)] [mode (8 bytes ASCII octal)] [size (10 bytes ASCII decimal)] [magic (2 bytes "`\n")] [data (size bytes)] [pad (1 byte if size is odd -- "\n")] Total per entry: 60-byte header + data + optional pad. Names longer than 15 chars use the "//" extended-name table (BSD/SysV convention), which we DEFER to v0.0.2 -- v0.0.1 names must be ≤ 15 chars + a single trailing '/'. Pairs with nx_elf_writer (produces objects), nx_elf_read + nx_objdump (inspect), nxld (linker that consumes archives).

dependencies 1 imports · 0 importers

syscalls.nx nx_archive.nx

imports: syscalls.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main nx_ar_new nx_ar_size nx_ar_count nx_ar_add nx_ar_pad_name nx_ar_pad_dec

structs

47struct NxAr

consts

35const NX_MAGIC_4096: i64 = 4096
39const NX_AR_HEADER_BYTES: i64 = 60
40const NX_AR_NAME_BYTES: i64 = 16
41const NX_AR_DATE_BYTES: i64 = 12
42const NX_AR_UID_BYTES: i64 = 6
43const NX_AR_GID_BYTES: i64 = 6
44const NX_AR_MODE_BYTES: i64 = 8
45const NX_AR_SIZE_BYTES: i64 = 10
54const NX_AR_BYTES: i64 = 32

functions

60func nx_ar_pad_dec(dst: *u8, off: i64, width: i64, v: i64) -> i64
called by 1: nx_ar_add
89func nx_ar_pad_name(dst: *u8, off: i64, name: *u8) -> i64
called by 1: nx_ar_add
116func nx_ar_new(cap: i64) -> *NxAr
called by 1: main
137func nx_ar_add(a: *NxAr, name: *u8, data: *u8, size: i64) -> i64
called by 1: main calls 2: nx_ar_pad_namenx_ar_pad_dec
173func nx_ar_size(a: *NxAr) -> i64 { return a.used }
called by 1: main
174func nx_ar_count(a: *NxAr) -> i64 { return a.n }
called by 1: main
175func nx_ar_bytes(a: *NxAr) -> *u8 { return a.buf }
179func main() -> i64