From: Kefu Chai Date: Thu, 21 Jul 2022 16:09:33 +0000 (+0800) Subject: include/compat: define aligned_free() as a function not a macro X-Git-Tag: v18.0.0~448^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F47212%2Fhead;p=ceph.git include/compat: define aligned_free() as a function not a macro so it does not get substituted by the preprocessor unconditionally. this change helps to address the compiling failure when using boost 1.79 using MinGW, like: ../build.deps/mingw/boost/include/boost/align/aligned_allocator.hpp: In member function 'void boost::alignment::aligned_allocator::deallocate(boost::alignment::aligned_allocator::pointer, boost::alignment::aligned_allocator::size_type)': ../src/include/compat.h:352:27: error: '_aligned_free' is not a member of 'boost::alignment'; did you mean 'aligned_free'? 352 | #define aligned_free(ptr) _aligned_free(ptr) | ^~~~~~~~~~~~~ Signed-off-by: Kefu Chai --- diff --git a/src/include/compat.h b/src/include/compat.h index 4881e01ff98f7..517e9d4fcd5f0 100644 --- a/src/include/compat.h +++ b/src/include/compat.h @@ -15,6 +15,7 @@ #include "acconfig.h" #include #include +#include #include #if defined(__linux__) @@ -349,7 +350,9 @@ extern _CRTIMP errno_t __cdecl _putenv_s(const char *_Name,const char *_Value); #define compat_closesocket closesocket // Use "aligned_free" when freeing memory allocated using posix_memalign or // _aligned_malloc. Using "free" will crash. -#define aligned_free(ptr) _aligned_free(ptr) +static inline void aligned_free(void* ptr) { + _aligned_free(ptr); +} // O_CLOEXEC is not defined on Windows. Since handles aren't inherited // with subprocesses unless explicitly requested, we'll define this @@ -363,7 +366,9 @@ extern _CRTIMP errno_t __cdecl _putenv_s(const char *_Name,const char *_Value); #define SOCKOPT_VAL_TYPE void* -#define aligned_free(ptr) free(ptr) +static inline void aligned_free(void* ptr) { + free(ptr); +} static inline int compat_closesocket(int fildes) { return close(fildes); }