aboutsummaryrefslogtreecommitdiff
path: root/src/liblzma/common/memcmplen.h
diff options
context:
space:
mode:
authorJia Tan <jiat0218@gmail.com>2023-04-19 22:22:16 +0800
committerLasse Collin <lasse.collin@tukaani.org>2023-05-03 22:33:10 +0300
commitb02e74eb7387fe2bc91b3481d99e2755329efc05 (patch)
treea6296939defb7076b729a88a7d2329669aa05f9e /src/liblzma/common/memcmplen.h
parenttuklib_integer: Use __builtin_clz() with Clang. (diff)
downloadxz-b02e74eb7387fe2bc91b3481d99e2755329efc05.tar.xz
Windows: Include <intrin.h> when needed.
Legacy Windows did not need to #include <intrin.h> to use the MSVC intrinsics. Newer versions likely just issue a warning, but the MSVC documentation says to include the header file for the intrinsics we use. GCC and Clang can "pretend" to be MSVC on Windows, so extra checks are needed in tuklib_integer.h to only include <intrin.h> when it will is actually needed.
Diffstat (limited to '')
-rw-r--r--src/liblzma/common/memcmplen.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/liblzma/common/memcmplen.h b/src/liblzma/common/memcmplen.h
index b76a0b63..da7c3358 100644
--- a/src/liblzma/common/memcmplen.h
+++ b/src/liblzma/common/memcmplen.h
@@ -19,6 +19,16 @@
# include <immintrin.h>
#endif
+// Only include <intrin.h> if it is needed. The header is only needed
+// on Windows when using an MSVC compatible compiler. The Intel compiler
+// can use the intrinsics without the header file.
+#if defined(TUKLIB_FAST_UNALIGNED_ACCESS) \
+ && (defined(_MSC_VER) \
+ && defined(_M_X64) \
+ && !defined(__INTEL_COMPILER))
+# include <intrin.h>
+#endif
+
/// Find out how many equal bytes the two buffers have.
///