diff --git a/port/jemalloc_helper.h b/port/jemalloc_helper.h index 0c216face13e7a8f959e4b23baac67b6410fbb91..26e5fb663360dc58f0562a9d3ce2b0870e7a3bfd 100644 --- a/port/jemalloc_helper.h +++ b/port/jemalloc_helper.h @@ -16,6 +16,14 @@ #define JEMALLOC_CXX_THROW #endif +#if defined(OS_WIN) && defined(_MSC_VER) + +// MSVC does not have weak symbol support. As long as ROCKSDB_JEMALLOC is defined, +// Jemalloc memory allocator is used. +static inline bool HasJemalloc() { return true; } + +#else + // Declare non-standard jemalloc APIs as weak symbols. We can null-check these // symbols to detect whether jemalloc is linked with the binary. extern "C" void* mallocx(size_t, int) __attribute__((__weak__)); @@ -50,4 +58,6 @@ static inline bool HasJemalloc() { malloc_stats_print != nullptr && malloc_usable_size != nullptr; } +#endif + #endif // ROCKSDB_JEMALLOC