]> git.ipfire.org Git - thirdparty/xz.git/commitdiff
liblzma: #define lzma_always_inline in common.h.
authorLasse Collin <lasse.collin@tukaani.org>
Mon, 30 Oct 2023 15:43:03 +0000 (17:43 +0200)
committerLasse Collin <lasse.collin@tukaani.org>
Mon, 30 Oct 2023 16:44:32 +0000 (18:44 +0200)
src/liblzma/common/common.h

index b09e8ddfc57c09766b73012b7b7f4e687bb3e20c..378923e4012b2bcaf7b2d085144a5bd4be6914d3 100644 (file)
 #      endif
 #endif
 
+// MSVC has __forceinline which shouldn't be combined with the inline keyword
+// (results in a warning).
+//
+// GCC 3.1 added always_inline attribute so we don't need to check
+// for __GNUC__ version. Similarly, all relevant Clang versions
+// support it (at least Clang 3.0.0 does already).
+// Other compilers might support too which also support __has_attribute
+// (Solaris Studio) so do that check too.
+#if defined(_MSC_VER)
+#      define lzma_always_inline __forceinline
+#elif defined(__GNUC__) || defined(__clang__) || defined(__INTEL_COMPILER) \
+               || lzma_has_attribute(__always_inline__)
+#      define lzma_always_inline inline __attribute__((__always_inline__))
+#else
+#      define lzma_always_inline inline
+#endif
+
 // These allow helping the compiler in some often-executed branches, whose
 // result is almost always the same.
 #ifdef __GNUC__