code wiki / _hdl_build / nx_gzip_lib.nx

nx_gzip_lib.nx

buildroot/runtime/_hdl_build/nx_gzip_lib.nx

32361 B689 linesdepth 3pulls 3 transitivereach 11 importersview sourcekind librarytopic 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 · 4 importers

nx_syscalls.nx nx_itoa_lib.nx nx_gzip_lib.nx nx_gzip.nx nx_gzip_kat.nx nx_gzip_lib_probe.nx nx_host_router.nx

imports: nx_syscalls.nxnx_itoa_lib.nx

imported by: nx_gzip.nxnx_gzip_kat.nxnx_gzip_lib_probe.nxnx_host_router.nx

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 }
34func gz_wn(v: i64) -> i64 { nxi_out(v); return 0 }
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
157func gz_dh_pow2(k: i64) -> i64 { var r: i64 = 1; var j: i64 = 0; while j < k { r = r * 2; j = j + 1 } return r }
called by 2: maingz_dh_lens
160func gz_dh_fixlen(s: i64) -> i64
called by 1: gz_deflate
169func gz_dh_fill_clperm(p: *i64) -> i64
called by 1: gz_deflate
182func gz_dh_lens(freq: *i64, n: i64, maxbits: i64, lens: *i64) -> i64
called by 2: maingz_deflate calls 2: sys_mmapgz_dh_pow2
287func gz_dh_canon(lens: *i64, n: i64, maxbits: i64, codes: *i64) -> i64
called by 1: gz_deflate calls 1: sys_mmap
307func gz_dh_clrle(seq: *i64, total: i64, outsym: *i64, outext: *i64, clfreq: *i64, xbits: *i64) -> i64
called by 1: gz_deflate
358func gz_deflate(src: *u8, n: i64, mode: i64, ob: *u8, bw: *i64) -> i64
605func gz_compress(src: *u8, n: i64, mode: i64, ob: *u8) -> i64
642func gzlib_retired_cli_main(argc: i64, argv: *i64) -> i64