fix compilation error on MSVC (#5458)

Summary:
"__attribute__((__weak__))" was introduced in port\jemalloc_helper.h. It's not supported by Microsoft VS 2015, resulting in compile error. This fix adds a #if branch to work around the compile issue.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/5458

Differential Revision: D15827285

fbshipit-source-id: 8c5f7ad31de1ac677bd96f16c4450767de834beb
main
Huisheng Liu 6 years ago committed by Facebook Github Bot
parent 58c78358ef
commit b47cfec5d0
  1. 10
      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

Loading…
Cancel
Save