diff --git a/src/jemalloc.c b/src/jemalloc.c index d958c8ca..3ef573b7 100644 --- a/src/jemalloc.c +++ b/src/jemalloc.c @@ -28,12 +28,31 @@ /******************************************************************************/ /* Data. */ +#ifdef _MSC_VER +#define STR(s) #s +#define XSTR(s) STR(s) +#endif + /* Runtime configuration options. */ +#ifndef _MSC_VER const char *je_malloc_conf #ifndef _WIN32 JEMALLOC_ATTR(weak) #endif ; +#else +extern const char *je_malloc_conf; +const char *malloc_conf_default = NULL; +#if defined (_M_IX86) +// NOTE: The JEMALLOC_PRIVATE_NAMESPACE does not get applied properly on 32-bit +// windows, presumably due to the leading underscore being automatically added +// to all symbols. +#pragma comment(linker, "/alternatename:_" XSTR(je_malloc_conf) "=_malloc_conf_default") +#else +#pragma comment(linker, "/alternatename:" XSTR(je_malloc_conf) "=" XSTR(JEMALLOC_PRIVATE_NAMESPACE) "malloc_conf_default") +#endif +#endif + /* * The usual rule is that the closer to runtime you are, the higher priority * your configuration settings are (so the jemalloc config options get lower @@ -51,11 +70,24 @@ const char *je_malloc_conf * We don't actually want this to be widespread, so we'll give it a silly name * and not mention it in headers or documentation. */ +#ifndef _MSC_VER const char *je_malloc_conf_2_conf_harder #ifndef _WIN32 JEMALLOC_ATTR(weak) #endif ; +#else +extern const char *je_malloc_conf_2_conf_harder; +const char *malloc_conf_2_conf_harder_default = NULL; +#if defined (_M_IX86) +// NOTE: The JEMALLOC_PRIVATE_NAMESPACE does not get applied properly on 32-bit +// windows, presumably due to the leading underscore being automatically added +// to all symbols. +#pragma comment(linker, "/alternatename:_" XSTR(je_malloc_conf_2_conf_harder) "=_malloc_conf_2_conf_harder_default") +#else +#pragma comment(linker, "/alternatename:" XSTR(je_malloc_conf_2_conf_harder) "=" XSTR(JEMALLOC_PRIVATE_NAMESPACE) "malloc_conf_2_conf_harder_default") +#endif +#endif const char *opt_malloc_conf_symlink = NULL; const char *opt_malloc_conf_env_var = NULL;