code wiki / _hdl_build / nx_gzip.nx
nx_gzip.nx
buildroot/runtime/_hdl_build/nx_gzip.nx
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
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
structs
| none |
consts
| 8 | const GZ_MAGIC_1025: i64 = 1025 |
| 9 | const GZ_MAGIC_1537: i64 = 1537 |
| 10 | const GZ_MAGIC_2049: i64 = 2049 |
| 11 | const GZ_MAGIC_3073: i64 = 3073 |
| 12 | const GZ_MAGIC_4097: i64 = 4097 |
| 13 | const GZ_MAGIC_6145: i64 = 6145 |
| 14 | const GZ_MAGIC_8193: i64 = 8193 |
| 15 | const GZ_MAGIC_12289: i64 = 12289 |
| 16 | const GZ_MAGIC_16385: i64 = 16385 |
| 17 | const GZ_MAGIC_24577: i64 = 24577 |
| 18 | const GZ_MAGIC_4096: i64 = 4096 |
| 20 | const GZ_INCAP: i64 = 8388608 |
| 21 | const GZ_MAXIN: i64 = 536870912 // 512MiB sanity ceiling: REFUSED loudly, never silently shrunk |
| 22 | const GZ_HSIZE: i64 = 32768 |
| 23 | const GZ_HMASK: i64 = 32767 |
| 24 | const GZ_MAXCHAIN: i64 = 128 |
| 25 | const GZ_MINMATCH: i64 = 3 |
| 26 | const GZ_MAXMATCH: i64 = 258 |
| 27 | const GZ_WINDOW: i64 = 32768 |
functions
| 29 | func 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 } |
| 34 | func gz_wn(v: i64) -> i64 { nxi_out(v); return 0 } |
| 35 | func gz_read(path: *u8, buf: *u8, cap: i64) -> i64 |
| 52 | func gz_filesize(path: *u8) -> i64 |
| 59 | func gz_write(path: *u8, buf: *u8, n: i64) -> i64 |
| 68 | func gz_crc32(bytes: *u8, n: i64) -> i64 called by 1: gz_compress |
| 86 | func gz_rev(v: i64, n: i64) -> i64 called by 1: gz_puthuff |
| 92 | func gz_fixed(sym: i64, out2: *i64) -> i64 called by 1: gz_deflate |
| 99 | func gz_putbits(ob: *u8, bw: *i64, val: i64, nbits: i64) -> i64 |
| 107 | func gz_puthuff(ob: *u8, bw: *i64, code: i64, nbits: i64) -> i64 { return gz_putbits(ob, bw, gz_rev(code, nbits), nbits) } |
| 108 | func 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 |
| 110 | func gz_lencode(lb: *i64, le: *i64, length: i64, out3: *i64) -> i64 called by 1: gz_deflate |
| 119 | func gz_distcode(db: *i64, de: *i64, dist: i64, out3: *i64) -> i64 called by 1: gz_deflate |
| 128 | func 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 |
| 130 | func gz_fill_len(lb: *i64, le: *i64) -> i64 called by 1: gz_deflate |
| 139 | func gz_fill_dist(db: *i64, de: *i64) -> i64 called by 1: gz_deflate |
| 149 | func gz_deflate(src: *u8, n: i64, mode: i64, ob: *u8, bw: *i64) -> i64 |
| 230 | func gz_compress(src: *u8, n: i64, mode: i64, ob: *u8) -> i64 |
| 257 | func main(argc: i64, argv: *i64) -> i64 |