code wiki / (root) / nx_le.nx

nx_le.nx

buildroot/runtime/nx_le.nx

7576 B246 linesdepth 2pulls 2 transitivereach 329 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_le.nx -- canonical little-endian / big-endian fixed-width binary read + write primitives. DRY consolidation per the shared-libraries cardinal. Three existing callers inlined their own LE-read helpers: nx_bmp_header.bmp_read_u32 (BMP image parsing) nx_cbor_decode (byte count reads) (CBOR length parsing) nx_wav.nx (WAV audio parsing) Plus the queued GGUF (model weight) + safetensors + ELF / PE header readers. Per the "rule of three" + no-reinventing cardinals: this is the canonical primitive. ===== LE byte order ============================================= Little-endian: least-significant byte at lowest address. Used by x86, AArch64 (default), RISC-V, ppc64LE, MIPS-LE, GGUF, ELF on LE platforms, BMP, WAV, safetensors, most binary AI formats. ===== BE byte order ============================================= Big-endian: most-significant byte at lowest address. Used by network protocols (TCP/IP headers, DNS, HTTP/2 frames), s390x (big-endian platform), Java class files, PNG, MP3 ID3, MIDI. ===== API ======================================================= All readers take (buf: *u8, off: i64) and return the value as i64 (sign-extended for signed forms). Caller is responsible for bounds-checking off + width <= buf_len. All writers take (buf: *u8, off: i64, val: i64). Per the bounded-loop cardinal: no loops needed (fixed-width extracts are unrolled). genealogy_id: ietf_rfc_8949_cbor + ieee_754_byte_order + wikipedia_endianness lineage_id: substrate_le_be_v1

dependencies 2 imports · 161 importers

nx_syscalls.nx nx_tier.nx nx_le.nx nx_actor_role_llm_v2_real_test.nx nx_bam.nx nx_batched_gate.nx nx_batched_tput.nx nx_bgzf.nx nx_bigread_test.nx nx_coder_swap_gate.nx nx_dequant_bench.nx nx_dequant_bench_test.nx nx_dequant_iter.nx

diagram shows first 10 each side; +0 more imports, +151 more importers in the complete lists below.

imports: nx_syscalls.nxnx_tier.nx

imported by: nx_actor_role_llm_v2_real_test.nxnx_bam.nxnx_batched_gate.nxnx_batched_tput.nxnx_bgzf.nxnx_bigread_test.nxnx_coder_swap_gate.nxnx_dequant_bench.nxnx_dequant_bench_test.nxnx_dequant_iter.nxnx_dequant_iter_bench_test.nxnx_dequant_iter_test.nxnx_f32_bpe_load.nxnx_f32_bpe_load_test.nxnx_f32_dit_block_simd.nxnx_f32_image_to_bmp.nxnx_f32_lazy_weight.nxnx_f32_lazy_weight_test.nxnx_f32_linear_simd.nxnx_f32_llama_layer_lazy_load.nxnx_f32_llm_bench_test.nxnx_f32_llm_diag_test.nxnx_f32_llm_dim_dump_test.nxnx_f32_llm_read_dims_test.nxnx_f32_llm_special_tokens_test.nxnx_f32_q14_encode_test.nxnx_f32_q4k_matmul.nxnx_f32_q4k_matmul_test.nxnx_f32x8_dot_bench.nxnx_f32x8_probe.nxnx_flashattn_scale.nxnx_gguf.nxnx_gguf_dequant_kat_gate.nxnx_gguf_fixture_tiny.nxnx_gguf_load.nxnx_gguf_load_block_test.nxnx_gguf_load_f32.nxnx_gguf_load_f32_test.nxnx_gguf_load_lazy_test.nxnx_gguf_load_model_test.nxnx_gguf_load_q4k_test.nxnx_gguf_load_test.nxnx_gguf_meta.nxnx_gguf_meta_test.nxnx_gguf_type_census_gate.nxnx_gguf_write_gate.nxnx_gpu_export.nxnx_gpu_serve_gate.nxnx_live_fire_gguf.nxnx_live_fire_gguf_test.nxnx_llm_batch_serve.nxnx_llm_capcheck.nxnx_llm_loopb_gate.nxnx_llm_ppl_bench_gate.nxnx_llm_run_v2_test.nxnx_llm_sched_gate.nxnx_nofloat_arch.nxnx_nofloat_arch_config_gate.nxnx_nofloat_arch_moe_gate.nxnx_nofloat_llm.nxnx_nofloat_moe_real_gate.nxnx_nofloat_olmoe_forward_gate.nxnx_nofloat_olmoe_gate.nxnx_nofloat_q6k_gate.nxnx_nofloat_qwen_bias_probe.nxnx_nofloat_qwen_config_gate.nxnx_nofloat_qwen_decode_gate.nxnx_nofloat_qwen_diag_gate.nxnx_nofloat_qwen_dqprobe_gate.nxnx_nofloat_qwen_encode_gate.nxnx_nofloat_qwen_encode_prep_gate.nxnx_nofloat_qwen_fastgen_gate.nxnx_nofloat_qwen_fastgen_i32_gate.nxnx_nofloat_qwen_fastgen_i8_gate.nxnx_nofloat_qwen_fidelity_gate.nxnx_nofloat_qwen_forward_gate.nxnx_nofloat_qwen_gen_gate.nxnx_nofloat_qwen_kvgen_gate.nxnx_nofloat_qwen_rope_h2h_gate.nxnx_nofloat_qwen_stack_gate.nxnx_nofloat_qwen_text_gate.nxnx_nofloat_qwen_tok_gate.nxnx_nofloat_qwen_wload_gate.nxnx_nofloat_serve_core.nxnx_nofloat_tok.nxnx_olmoe_recon2_gate.nxnx_olmoe_recon_gate.nxnx_paged_fwd_gate.nxnx_placement_test.nxnx_q4k_dot_simd.nxnx_q4k_fused_fidelity_gate.nxnx_q4k_gemm_mt.nxnx_q4k_ggml_kat.nxnx_q4k_linear.nxnx_q4k_linear_hp.nxnx_q4k_matmul.nxnx_q4k_matmul_bench_test.nxnx_q4k_matmul_test.nxnx_q4k_q24_gate.nxnx_q4k_real_gemm.nx +61 more (shown cap 100 declared)

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

main sys_mmap nx_le_read_u32 nx_be_read_u32 nx_le_write_u64 nx_le_write_u32 nx_le_read_u64 nx_le_read_u32 ↻ nx_be_write_u64 nx_be_write_u32 nx_be_read_u64 nx_be_read_u32 ↻ nx_le_read_i32 nx_le_read_u32 ↻ nx_le_read_i16 nx_le_read_u16 nx_le_read_u16 ↻ nx_be_read_u16 nx_le_write_u8 nx_le_read_u8 nx_le_verdict_is_valid

structs

none

consts

50const NX_MAGIC_32768: i64 = 32768
51const NX_MAGIC_65536: i64 = 65536
52const NX_MAGIC_2147483648: i64 = 2147483648
53const NX_MAGIC_4294967296: i64 = 4294967296
57const NX_LE_OK: nx_int = 0
58const NX_LE_ERR_OOB: nx_int = 1
59const NX_LE_N_VERDICTS: nx_int = 2

functions

61func nx_le_verdict_is_valid(v: nx_int) -> nx_int
called by 1: main
69func nx_le_read_u8(buf: *u8, off: i64) -> i64
73func nx_le_read_u16(buf: *u8, off: i64) -> i64
79func nx_le_read_u32(buf: *u8, off: i64) -> i64
87func nx_le_read_u64(buf: *u8, off: i64) -> i64
96func nx_le_read_i16(buf: *u8, off: i64) -> i64
called by 1: main calls 1: nx_le_read_u16
102func nx_le_read_i32(buf: *u8, off: i64) -> i64
called by 1: main calls 1: nx_le_read_u32
110func nx_le_read_i64(buf: *u8, off: i64) -> i64
calls 1: nx_le_read_u64
116func nx_le_write_u8(buf: *u8, off: i64, val: i64) -> i64
called by 2: mainmain
121func nx_le_write_u16(buf: *u8, off: i64, val: i64) -> i64
127func nx_le_write_u32(buf: *u8, off: i64, val: i64) -> i64
135func nx_le_write_u64(buf: *u8, off: i64, val: i64) -> i64
143func nx_be_read_u16(buf: *u8, off: i64) -> i64
called by 1: main
149func nx_be_read_u32(buf: *u8, off: i64) -> i64
called by 2: nx_be_read_u64main
157func nx_be_read_u64(buf: *u8, off: i64) -> i64
called by 1: main calls 1: nx_be_read_u32
165func nx_be_write_u16(buf: *u8, off: i64, val: i64) -> i64
171func nx_be_write_u32(buf: *u8, off: i64, val: i64) -> i64
called by 1: nx_be_write_u64
179func nx_be_write_u64(buf: *u8, off: i64, val: i64) -> i64
called by 1: main calls 1: nx_be_write_u32
194func main() -> i64