code wiki / (root) / nx_crc32.nx

nx_crc32.nx

buildroot/runtime/nx_crc32.nx

4306 B129 linesdepth 3pulls 3 transitivereach 452 importersview sourcekind tooltopic crc32
docsdependenciesstructsconstsfunctions

about

nx_crc32.nx -- CRC-32 (IEEE 802.3, gzip / zlib / png polynomial). Used for: gzip integrity, png chunk checksums, ELF .gnu.hash table consistency, network protocol framing checks. We use the standard reflected polynomial (0xEDB88320), seed 0xFFFFFFFF, and final XOR 0xFFFFFFFF. Matches: - zlib crc32() - python binascii.crc32() - tar/gzip/png/ethernet checksums The 256-entry lookup table approach is the textbook method -- 8 bits of input per iteration, ~1 GB/s on a modern CPU. We build the table at runtime (no static initialisers in NishiLang yet) and cache it in BSS so subsequent calls are O(n). Slice-by-N (faster) is deferred until we benchmark a real bottleneck.

dependencies 1 imports · 16 importers

syscalls.nx nx_crc32.nx nx_bgzf.nx nx_bgzf_test.nx nx_crc32_gate.nx nx_gzip_wrap.nx nx_image_e2e_gate.nx nx_image_index_gate.nx nx_img_decode_gate.nx nx_img_to_rgb_gate.nx nx_imgquery_e2e_gate.nx nx_opc.nx

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

imports: syscalls.nx

imported by: nx_bgzf.nxnx_bgzf_test.nxnx_crc32_gate.nxnx_gzip_wrap.nxnx_image_e2e_gate.nxnx_image_index_gate.nxnx_img_decode_gate.nxnx_img_to_rgb_gate.nxnx_imgquery_e2e_gate.nxnx_opc.nxnx_png_adam7_gate.nxnx_png_decoder.nxnx_png_real_smoke.nxnx_revimg_crawl_gate.nxnx_roku_emit.nxnx_roku_grid_emit.nx

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

main nx_crc32 nx_crc32_update nx_crc32_init nx_crc32_table_at nx_crc32_update ↻

structs

none

consts

34const NX_CRC32_POLY: i64 = 0xEDB88320

functions

38func nx_crc32_init() -> i64
called by 2: nx_crc32_updatemain
66func nx_crc32_table_at(idx: i64) -> i64
called by 2: nx_crc32_updatemain
82func nx_crc32_update(crc_in: i64, data: *u8, n: i64) -> i64
96func nx_crc32(data: *u8, n: i64) -> i64
102func main() -> i64