Update MallctlHelperTest with jemalloc 5 APIs.
[folly.git] / folly / Malloc.h
index 4ed53ddda1c08499e7821d60ce9453872c50d703..ca9e7ae15705da3b5698b2a9e30df85cfd64fea3 100644 (file)
 
 #pragma once
 
+#include <folly/portability/Config.h>
+
 /**
  * Define various MALLOCX_* macros normally provided by jemalloc.  We define
  * them so that we don't have to include jemalloc.h, in case the program is
  * built without jemalloc support.
  */
-#ifndef MALLOCX_LG_ALIGN
-#define MALLOCX_LG_ALIGN(la) (la)
-#endif
-#ifndef MALLOCX_ZERO
-#define MALLOCX_ZERO (static_cast<int>(0x40))
+#if defined(USE_JEMALLOC) || defined(FOLLY_USE_JEMALLOC)
+// We have JEMalloc, so use it.
+# include <jemalloc/jemalloc.h>
+#else
+# ifndef MALLOCX_LG_ALIGN
+#  define MALLOCX_LG_ALIGN(la) (la)
+# endif
+# ifndef MALLOCX_ZERO
+#  define MALLOCX_ZERO (static_cast<int>(0x40))
+# endif
 #endif
 
 // If using fbstring from libstdc++ (see comment in FBString.h), then
@@ -38,7 +45,7 @@
 // includes and uses fbstring.
 #if defined(_GLIBCXX_USE_FB) && !defined(_LIBSTDCXX_FBSTRING)
 
-#include <folly/detail/Malloc.h>
+#include <folly/detail/MallocImpl.h>
 #include <folly/portability/BitsFunctexcept.h>
 
 #include <string>
@@ -91,7 +98,7 @@ __attribute__((__weak__));
 
 #else // !defined(_LIBSTDCXX_FBSTRING)
 
-#include <folly/detail/Malloc.h> /* nolint */
+#include <folly/detail/MallocImpl.h> /* nolint */
 #include <folly/portability/BitsFunctexcept.h> /* nolint */
 
 #endif