Commit 05d0e3ed authored by Christopher Dykes's avatar Christopher Dykes Committed by Facebook Github Bot

Don't define MALLOCX_* if building with JEMalloc

Summary:
With the way it is currently, if `jemalloc.h` is included after `folly/Malloc.h`, `jemalloc.h` ends up redefining these.
This changes it to just include `jemalloc.h` if we know we're compiling with JEMalloc.

Reviewed By: yfeldblum

Differential Revision: D4660285

fbshipit-source-id: 814e36432676e89cf7ba2bc5247b7dde2bfdc14a
parent 162ba310
...@@ -19,16 +19,23 @@ ...@@ -19,16 +19,23 @@
#pragma once #pragma once
#include <folly/portability/Config.h>
/** /**
* Define various MALLOCX_* macros normally provided by jemalloc. We define * 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 * them so that we don't have to include jemalloc.h, in case the program is
* built without jemalloc support. * built without jemalloc support.
*/ */
#ifndef MALLOCX_LG_ALIGN #if defined(USE_JEMALLOC) || defined(FOLLY_USE_JEMALLOC)
#define MALLOCX_LG_ALIGN(la) (la) // We have JEMalloc, so use it.
#endif # include <jemalloc/jemalloc.h>
#ifndef MALLOCX_ZERO #else
#define MALLOCX_ZERO (static_cast<int>(0x40)) # ifndef MALLOCX_LG_ALIGN
# define MALLOCX_LG_ALIGN(la) (la)
# endif
# ifndef MALLOCX_ZERO
# define MALLOCX_ZERO (static_cast<int>(0x40))
# endif
#endif #endif
// If using fbstring from libstdc++ (see comment in FBString.h), then // If using fbstring from libstdc++ (see comment in FBString.h), then
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment