From d9645327b3b6d18b04ac1dd0bc4346a2af87bb9b Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Wed, 14 Jun 2023 20:03:39 -0700 Subject: [PATCH] fixed MEM_STATIC already defined in Linux Kernel mode --- contrib/linux-kernel/mem.h | 1 + lib/common/allocations.h | 2 +- lib/common/compiler.h | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/contrib/linux-kernel/mem.h b/contrib/linux-kernel/mem.h index a7231822b..2e91e7780 100644 --- a/contrib/linux-kernel/mem.h +++ b/contrib/linux-kernel/mem.h @@ -24,6 +24,7 @@ /*-**************************************** * Compiler specifics ******************************************/ +#undef MEM_STATIC /* may be already defined from common/compiler.h */ #define MEM_STATIC static inline /*-************************************************************** diff --git a/lib/common/allocations.h b/lib/common/allocations.h index a3153c4ba..5e8995501 100644 --- a/lib/common/allocations.h +++ b/lib/common/allocations.h @@ -14,7 +14,7 @@ #define ZSTD_DEPS_NEED_MALLOC #include "zstd_deps.h" /* ZSTD_malloc, ZSTD_calloc, ZSTD_free, ZSTD_memset */ -#include "mem.h" /* MEM_STATIC */ +#include "compiler.h" /* MEM_STATIC */ #define ZSTD_STATIC_LINKING_ONLY #include "../zstd.h" /* ZSTD_customMem */ diff --git a/lib/common/compiler.h b/lib/common/compiler.h index 35b9c1387..bcaa575dd 100644 --- a/lib/common/compiler.h +++ b/lib/common/compiler.h @@ -90,6 +90,7 @@ * Updating the prefix is probably preferable, but requires a fairly large codemod, * since this name is used everywhere. */ +#ifndef MEM_STATIC /* already defined in Linux Kernel mem.h */ #if defined(__GNUC__) # define MEM_STATIC static __inline UNUSED_ATTR #elif defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */) @@ -99,6 +100,7 @@ #else # define MEM_STATIC static /* this version may generate warnings for unused static functions; disable the relevant warning */ #endif +#endif /* force no inlining */ #ifdef _MSC_VER