From 26f7249898ec1819559173904c72dc45839d4b4e Mon Sep 17 00:00:00 2001 From: wuggy Date: Thu, 16 Apr 2026 19:42:31 -0400 Subject: [PATCH] i HATE ZLIB PART 2 --- modules/zlib/src/crc32_stub.c | 29 +++++++++++++++++++++++++++++ modules/zlib/src/moz.build | 1 + 2 files changed, 30 insertions(+) create mode 100644 modules/zlib/src/crc32_stub.c diff --git a/modules/zlib/src/crc32_stub.c b/modules/zlib/src/crc32_stub.c new file mode 100644 index 0000000000..d8d867642d --- /dev/null +++ b/modules/zlib/src/crc32_stub.c @@ -0,0 +1,29 @@ +// Minimal CRC folding stubs for builds without CRC SIMD support. + +#include "zutil.h" +#include "crc32.h" + +// The folded CRC state type is declared in crc32.h as crc32_fold (or similar). +// We don't use any SIMD here; we just fall back to scalar crc32. + +void crc_fold_init(crc32_fold *crc) +{ + // Initialize to standard CRC-32 initial value. + crc->crc = 0xffffffffu; +} + +void crc_fold_copy(crc32_fold *crc, + unsigned char *dst, + const unsigned char *src, + long len) +{ + // Simple scalar copy + CRC update. + memcpy(dst, src, (size_t)len); + crc->crc = crc32(crc->crc, src, (uInt)len); +} + +uint32_t crc_fold_512to32(crc32_fold *crc) +{ + // Finalize CRC (invert bits as usual). + return crc->crc ^ 0xffffffffu; +} diff --git a/modules/zlib/src/moz.build b/modules/zlib/src/moz.build index 72a2c6a783..2634a3bd9f 100644 --- a/modules/zlib/src/moz.build +++ b/modules/zlib/src/moz.build @@ -38,6 +38,7 @@ if CONFIG['INTEL_ARCHITECTURE']: DEFINES['INFLATE_CHUNK_SIMD_SSE2'] = False DEFINES['CRC32_SIMD_SSE42_PCLMUL'] = False SOURCES += [ + 'crc32_stub.c', 'simd_stub.c', ] else: