From 8931e992b06fd58726000286bbe50995bce600a4 Mon Sep 17 00:00:00 2001 From: Lasse Collin Date: Wed, 12 Jun 2024 12:29:57 +0300 Subject: [PATCH] liblzma: CRC64 CLMUL: Use __asm to work around a MSVC problem Thanks to Iouri Kharon for testing and the fix. --- src/liblzma/check/crc64_fast.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/liblzma/check/crc64_fast.c b/src/liblzma/check/crc64_fast.c index 9e43edc23..6c0951e1a 100644 --- a/src/liblzma/check/crc64_fast.c +++ b/src/liblzma/check/crc64_fast.c @@ -136,6 +136,14 @@ crc64_dispatch(const uint8_t *buf, size_t size, uint64_t crc) extern LZMA_API(uint64_t) lzma_crc64(const uint8_t *buf, size_t size, uint64_t crc) { +#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) && !defined(__clang__) \ + && defined(_M_IX86) + // VS2015-2022 might corrupt the ebx register on 32-bit x86. + // This hack forces MSVC to store and restore ebx. + // This is only needed here, not in lzma_crc32(). + __asm mov ebx, ebx +#endif + #if defined(CRC64_GENERIC) && defined(CRC64_ARCH_OPTIMIZED) return crc64_func(buf, size, crc);