#pragma once
+#include <folly/CPortability.h>
#include <folly/portability/Config.h>
/**
* them so that we don't have to include jemalloc.h, in case the program is
* built without jemalloc support.
*/
-#if defined(USE_JEMALLOC) || defined(FOLLY_USE_JEMALLOC)
+#if (defined(USE_JEMALLOC) || defined(FOLLY_USE_JEMALLOC)) && !FOLLY_SANITIZE
// We have JEMalloc, so use it.
# include <jemalloc/jemalloc.h>
#else
#define FOLLY_MALLOC_CHECKED_MALLOC
#endif
+#include <folly/CPortability.h>
/**
* Determine if we are using jemalloc or not.
*/
+#if defined(USE_JEMALLOC) && !FOLLY_SANITIZE
+ inline bool usingJEMalloc() noexcept {
+ return true;
+ }
+#else
FOLLY_MALLOC_NOINLINE inline bool usingJEMalloc() noexcept {
// Checking for rallocx != nullptr is not sufficient; we may be in a
// dlopen()ed module that depends on libjemalloc, so rallocx is resolved, but
uint64_t origAllocated = *counter;
- const void* ptr = malloc(1);
+ static const void* volatile ptr = malloc(1);
if (!ptr) {
// wtf, failing to allocate 1 byte
return false;
}
- /* Avoid optimizing away the malloc. */
- asm volatile("" ::"m"(ptr) : "memory");
-
return (origAllocated != *counter);
}();
return result;
}
+#endif
inline size_t goodMallocSize(size_t minSize) noexcept {
if (minSize == 0) {