]> git.ipfire.org Git - thirdparty/xz.git/commitdiff
liblzma: Prevent warning for MSYS2 Windows build.
authorJia Tan <jiat0218@gmail.com>
Wed, 28 Jun 2023 12:22:38 +0000 (20:22 +0800)
committerLasse Collin <lasse.collin@tukaani.org>
Tue, 7 May 2024 12:28:35 +0000 (15:28 +0300)
In lzma_memcmplen(), the <intrin.h> header file is only included if
_MSC_VER and _M_X64 are both defined but _BitScanForward64() was
previously used if _M_X64 was defined. GCC for MSYS2 defines _M_X64 but
not _MSC_VER so _BitScanForward64() was used without including
<intrin.h>.

Now, lzma_memcmplen() will use __builtin_ctzll() for MSYS2 GCC builds as
expected.

(cherry picked from commit 64ee0caaea06654b28afaee850fb187a11bf9cb2)

src/liblzma/common/memcmplen.h

index da7c33585f0868c86fc3a2efb0542bf559c1a6e1..dea778c487f81588ed069ee4d09c614a6f51bf63 100644 (file)
@@ -73,11 +73,13 @@ lzma_memcmplen(const uint8_t *buf1, const uint8_t *buf2,
        while (len < limit) {
                const uint64_t x = read64ne(buf1 + len) - read64ne(buf2 + len);
                if (x != 0) {
-#      if defined(_M_X64) // MSVC or Intel C compiler on Windows
+       // MSVC or Intel C compiler on Windows
+#      if defined(_M_X64) && defined(_MSC_VER)
                        unsigned long tmp;
                        _BitScanForward64(&tmp, x);
                        len += (uint32_t)tmp >> 3;
-#      else // GCC, clang, or Intel C compiler
+       // GCC, clang, or Intel C compiler
+#      else
                        len += (uint32_t)__builtin_ctzll(x) >> 3;
 #      endif
                        return my_min(len, limit);