code wiki / _hdl_build / nx_gzip.nx

nx_gzip.nx

buildroot/runtime/_hdl_build/nx_gzip.nx

13426 B304 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tooltopic gzip
docsdependenciesstructsconstsfunctions

about

nx_gzip.nx -- SOVEREIGN gzip/DEFLATE COMPRESSOR (the #1 remaining HOSTING SOTA gap). RFC 1951 DEFLATE (greedy LZ77 hash-chain + FIXED Huffman BTYPE=01) + RFC 1952 gzip (10B header + CRC32 + ISIZE). Correctness oracle = STANDARD gunzip byte-identical (PROVEN 2026-07-20: text 134->66=51%, 54KB src ->29% =71% cut, 25KB elf ->29%, empty+1byte OK). nx_gzip <in> <out> [mode 2 default|0 stored] | selftest. Envelope: in<=8MiB, window 32768, match 3..258, chain<=128, one final block. Rule 26 pure transform. license_tier: ORIGINAL

dependencies 2 imports · 0 importers

nx_syscalls.nx nx_itoa_lib.nx nx_gzip.nx

imports: nx_syscalls.nxnx_itoa_lib.nx

imported by: nobody (leaf or entry point)

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

main gz_w sys_write sys_exit sys_mmap gz_compress sys_mmap ↻ gz_deflate gz_putbits gz_flushbits sys_mmap ↻ gz_fill_len gz_fill_dist gz_hash3 gz_lencode gz_fixed gz_puthuff gz_putbits ↻ gz_rev gz_distcode gz_crc32 gz_write sys_openat_wr sys_write ↻ sys_close gz_wn nxi_out nxi_fd sys_mmap ↻ ccz_cat_num sys_write ↻ sys_munmap gz_filesize sys_openat_rd sys_lseek sys_close ↻ gz_read sys_openat_rd ↻ sys_read sys_mmap ↻

structs

none

consts

8const GZ_MAGIC_1025: i64 = 1025
9const GZ_MAGIC_1537: i64 = 1537
10const GZ_MAGIC_2049: i64 = 2049
11const GZ_MAGIC_3073: i64 = 3073
12const GZ_MAGIC_4097: i64 = 4097
13const GZ_MAGIC_6145: i64 = 6145
14const GZ_MAGIC_8193: i64 = 8193
15const GZ_MAGIC_12289: i64 = 12289
16const GZ_MAGIC_16385: i64 = 16385
17const GZ_MAGIC_24577: i64 = 24577
18const GZ_MAGIC_4096: i64 = 4096
20const GZ_INCAP: i64 = 8388608
21const GZ_MAXIN: i64 = 536870912 // 512MiB sanity ceiling: REFUSED loudly, never silently shrunk
22const GZ_HSIZE: i64 = 32768
23const GZ_HMASK: i64 = 32767
24const GZ_MAXCHAIN: i64 = 128
25const GZ_MINMATCH: i64 = 3
26const GZ_MAXMATCH: i64 = 258
27const GZ_WINDOW: i64 = 32768

functions

29func gz_w(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
called by 1: main calls 1: sys_write
34func gz_wn(v: i64) -> i64 { nxi_out(v); return 0 }
called by 1: main calls 1: nxi_out
35func gz_read(path: *u8, buf: *u8, cap: i64) -> i64
52func gz_filesize(path: *u8) -> i64
59func gz_write(path: *u8, buf: *u8, n: i64) -> i64
68func gz_crc32(bytes: *u8, n: i64) -> i64
called by 1: gz_compress
86func gz_rev(v: i64, n: i64) -> i64
called by 1: gz_puthuff
92func gz_fixed(sym: i64, out2: *i64) -> i64
called by 1: gz_deflate
99func gz_putbits(ob: *u8, bw: *i64, val: i64, nbits: i64) -> i64
107func gz_puthuff(ob: *u8, bw: *i64, code: i64, nbits: i64) -> i64 { return gz_putbits(ob, bw, gz_rev(code, nbits), nbits) }
called by 1: gz_deflate calls 2: gz_putbitsgz_rev
108func gz_flushbits(ob: *u8, bw: *i64) -> i64 { if bw[2] > 0 { ob[bw[0]] = (bw[1] & 0xff) as u8; bw[0] = bw[0] + 1; bw[1] = 0; bw[2] = 0 } return 0 }
called by 1: gz_deflate
110func gz_lencode(lb: *i64, le: *i64, length: i64, out3: *i64) -> i64
called by 1: gz_deflate
119func gz_distcode(db: *i64, de: *i64, dist: i64, out3: *i64) -> i64
called by 1: gz_deflate
128func gz_hash3(a: i64, b: i64, c: i64) -> i64 { return (((a & 0xff) << 10) ^ ((b & 0xff) << 5) ^ (c & 0xff)) & GZ_HMASK }
called by 1: gz_deflate
130func gz_fill_len(lb: *i64, le: *i64) -> i64
called by 1: gz_deflate
139func gz_fill_dist(db: *i64, de: *i64) -> i64
called by 1: gz_deflate
149func gz_deflate(src: *u8, n: i64, mode: i64, ob: *u8, bw: *i64) -> i64
230func gz_compress(src: *u8, n: i64, mode: i64, ob: *u8) -> i64
called by 1: main calls 3: sys_mmapgz_deflategz_crc32
257func main(argc: i64, argv: *i64) -> i64