Skip to content

Commit

Permalink
fix compilation error on MSVC (facebook#5458)
Browse files Browse the repository at this point in the history
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: facebook#5458

Differential Revision: D15827285

fbshipit-source-id: 8c5f7ad31de1ac677bd96f16c4450767de834beb
  • Loading branch information
hliu18 authored and facebook-github-bot committed Jun 14, 2019
1 parent 58c7835 commit b47cfec
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions port/jemalloc_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -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__));
Expand Down Expand Up @@ -50,4 +58,6 @@ static inline bool HasJemalloc() {
malloc_stats_print != nullptr && malloc_usable_size != nullptr;
}

#endif

#endif // ROCKSDB_JEMALLOC

0 comments on commit b47cfec

Please sign in to comment.