From a835672d9b56b7431aa595ed09a0fa6e3753e12c Mon Sep 17 00:00:00 2001 From: wuggy Date: Thu, 16 Apr 2026 19:58:56 -0400 Subject: [PATCH] HOLY SHIT IT LAUNCHES --- modules/zlib/src/crc32_stub.c | 30 ++++++++++++------------------ modules/zlib/src/x86.c | 10 ++++++++++ 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/modules/zlib/src/crc32_stub.c b/modules/zlib/src/crc32_stub.c index d8d867642d..763d8b620b 100644 --- a/modules/zlib/src/crc32_stub.c +++ b/modules/zlib/src/crc32_stub.c @@ -1,29 +1,23 @@ -// Minimal CRC folding stubs for builds without CRC SIMD support. +// Scalar CRC fallback for builds that disable CRC SIMD folding. -#include "zutil.h" -#include "crc32.h" +#include "deflate.h" +#include -// 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) +void ZLIB_INTERNAL crc_fold_init(deflate_state *const s) { - // Initialize to standard CRC-32 initial value. - crc->crc = 0xffffffffu; + s->strm->adler = crc32(0L, Z_NULL, 0); } -void crc_fold_copy(crc32_fold *crc, - unsigned char *dst, - const unsigned char *src, - long len) +void ZLIB_INTERNAL crc_fold_copy(deflate_state *const s, + 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); + s->strm->adler = crc32(s->strm->adler, dst, (uInt)len); } -uint32_t crc_fold_512to32(crc32_fold *crc) +unsigned ZLIB_INTERNAL crc_fold_512to32(deflate_state *const s) { - // Finalize CRC (invert bits as usual). - return crc->crc ^ 0xffffffffu; + return (unsigned)s->strm->adler; } diff --git a/modules/zlib/src/x86.c b/modules/zlib/src/x86.c index b3e248333f..38fe0fe30a 100644 --- a/modules/zlib/src/x86.c +++ b/modules/zlib/src/x86.c @@ -59,6 +59,11 @@ static void _x86_check_features(void) x86_cpu_enable_simd = x86_cpu_has_sse2 && x86_cpu_has_sse42 && x86_cpu_has_pclmulqdq; +#if !defined(INFLATE_CHUNK_SIMD_SSE2) || !(INFLATE_CHUNK_SIMD_SSE2) || \ + !defined(CRC32_SIMD_SSE42_PCLMUL) || !(CRC32_SIMD_SSE42_PCLMUL) + /* Runtime SIMD must stay off if required SIMD objects were not built. */ + x86_cpu_enable_simd = 0; +#endif #ifdef __APPLE__ /* SIMD implementations not built on Darwin; disable even if CPU supports them */ x86_cpu_enable_simd = 0; @@ -122,5 +127,10 @@ static void _x86_check_features(void) x86_cpu_enable_simd = x86_cpu_has_sse2 && x86_cpu_has_sse42 && x86_cpu_has_pclmulqdq; +#if !defined(INFLATE_CHUNK_SIMD_SSE2) || !(INFLATE_CHUNK_SIMD_SSE2) || \ + !defined(CRC32_SIMD_SSE42_PCLMUL) || !(CRC32_SIMD_SSE42_PCLMUL) + /* Runtime SIMD must stay off if required SIMD objects were not built. */ + x86_cpu_enable_simd = 0; +#endif } #endif /* _MSC_VER */