summaryrefslogtreecommitdiffstats
path: root/lib/xxhash.c
diff options
context:
space:
mode:
authorAlex Deymo <deymo@google.com>2017-07-28 14:33:43 (GMT)
committerAlex Deymo <deymo@google.com>2017-08-07 08:34:33 (GMT)
commit76ef6d0ab0ea0937e8bb92c3a11a6445504d720f (patch)
treebce8cddddfe691fb961c86185a662e76ab317c2f /lib/xxhash.c
parent9a967030d7f049042a64cd095bd54ebd34f53780 (diff)
downloadlz4-76ef6d0ab0ea0937e8bb92c3a11a6445504d720f.zip
lz4-76ef6d0ab0ea0937e8bb92c3a11a6445504d720f.tar.gz
lz4-76ef6d0ab0ea0937e8bb92c3a11a6445504d720f.tar.bz2
Allow to predefine FORCE_INLINE macro.
FORCE_INLINE macro is defined based on the compiler used. When using gcc, it will include "__attribute__((always_inline))" forcing gcc to always inline all the functions marked as FORCE_INLINE. However, this can cause a performance degradation of about 15%. This patch allows to set the FORCE_INLINE macro from the compiler command line to either "static" or "static inline" giving allowing it to inline functions as needed when performing optimizations.
Diffstat (limited to 'lib/xxhash.c')
-rw-r--r--lib/xxhash.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/lib/xxhash.c b/lib/xxhash.c
index e9ff2d4..a532358 100644
--- a/lib/xxhash.c
+++ b/lib/xxhash.c
@@ -113,19 +113,24 @@ static void* XXH_memcpy(void* dest, const void* src, size_t size) { return memcp
***************************************/
#ifdef _MSC_VER /* Visual Studio */
# pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */
-# define FORCE_INLINE static __forceinline
-#else
-# if defined (__cplusplus) || defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 */
-# ifdef __GNUC__
-# define FORCE_INLINE static inline __attribute__((always_inline))
-# else
-# define FORCE_INLINE static inline
-# endif
-# else
-# define FORCE_INLINE static
-# endif /* __STDC_VERSION__ */
#endif
+#ifndef FORCE_INLINE
+# ifdef _MSC_VER /* Visual Studio */
+# define FORCE_INLINE static __forceinline
+# else
+# if defined (__cplusplus) || defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 */
+# ifdef __GNUC__
+# define FORCE_INLINE static inline __attribute__((always_inline))
+# else
+# define FORCE_INLINE static inline
+# endif
+# else
+# define FORCE_INLINE static
+# endif /* __STDC_VERSION__ */
+# endif /* _MSC_VER */
+#endif /* FORCE_INLINE */
+
/* *************************************
* Basic Types