aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2023-10-30 17:43:03 +0200
committerJia Tan <jiat0218@gmail.com>2023-10-31 18:44:59 +0800
commit6cdf0a7b7974baf58c1fd20ec3278f3b84ae56e5 (patch)
treefc61f2ad758e7c2ce4ac5694027a1d858427a71a
parentliblzma: Use lzma_attr_visibility_hidden on private extern declarations. (diff)
downloadxz-6cdf0a7b7974baf58c1fd20ec3278f3b84ae56e5.tar.xz
liblzma: #define lzma_always_inline in common.h.
-rw-r--r--src/liblzma/common/common.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/liblzma/common/common.h b/src/liblzma/common/common.h
index b09e8ddf..378923e4 100644
--- a/src/liblzma/common/common.h
+++ b/src/liblzma/common/common.h
@@ -98,6 +98,23 @@
# 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__