diff options
author | Florian Walch <florian@fwalch.com> | 2015-04-20 00:49:39 +0300 |
---|---|---|
committer | Florian Walch <florian@fwalch.com> | 2015-04-29 22:26:55 +0300 |
commit | 8130eb1191aece52d8b2790302abf1bd09aaf90f (patch) | |
tree | 734a0759fe9f1561a86f074396ec90d6f8011562 /src | |
parent | 5b5d3531518ec5d3e900d3e197174990162ca3ff (diff) | |
download | rneovim-8130eb1191aece52d8b2790302abf1bd09aaf90f.tar.gz rneovim-8130eb1191aece52d8b2790302abf1bd09aaf90f.tar.bz2 rneovim-8130eb1191aece52d8b2790302abf1bd09aaf90f.zip |
jemalloc: Force use of prefixed functions.
* Set JEMALLOC_NO_DEMANGLE to be able to use `je_*` functions,
regardless of how jemalloc was compiled (--with-jemalloc-prefix)
* Show jemalloc information in Neovim's version output.
Resolve #2449.
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/CMakeLists.txt | 4 | ||||
-rw-r--r-- | src/nvim/memory.c | 18 | ||||
-rw-r--r-- | src/nvim/version.c | 20 |
3 files changed, 24 insertions, 18 deletions
diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt index fa1f81cdd1..810809ea17 100644 --- a/src/nvim/CMakeLists.txt +++ b/src/nvim/CMakeLists.txt @@ -171,8 +171,8 @@ list(APPEND NVIM_LINK_LIBRARIES set(NVIM_EXEC_LINK_LIBRARIES ${NVIM_LINK_LIBRARIES}) -if(USE_JEMALLOC) - # dont use jemalloc in the unit test library +# Don't use jemalloc in the unit test library. +if(JEMALLOC_FOUND) list(APPEND NVIM_EXEC_LINK_LIBRARIES ${JEMALLOC_LIBRARIES}) endif() diff --git a/src/nvim/memory.c b/src/nvim/memory.c index 2d4259a238..8628661a98 100644 --- a/src/nvim/memory.c +++ b/src/nvim/memory.c @@ -14,16 +14,18 @@ #include "nvim/misc1.h" #include "nvim/ui.h" -#ifdef INCLUDE_GENERATED_DECLARATIONS -# include "memory.c.generated.h" +#ifdef HAVE_JEMALLOC +// Force je_ prefix on jemalloc functions. +# define JEMALLOC_NO_DEMANGLE +# include <jemalloc/jemalloc.h> +# define malloc(size) je_malloc(size) +# define calloc(count, size) je_calloc(count, size) +# define realloc(ptr, size) je_realloc(ptr, size) +# define free(ptr) je_free(ptr) #endif -#if defined(USE_JEMALLOC) && !defined(UNIT_TESTING) -#include "jemalloc/jemalloc.h" -#define malloc(size) je_malloc(size) -#define calloc(count, size) je_calloc(count, size) -#define realloc(ptr, size) je_realloc(ptr, size) -#define free(ptr) je_free(ptr) +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "memory.c.generated.h" #endif /// Try to free memory. Used when trying to recover from out of memory errors. diff --git a/src/nvim/version.c b/src/nvim/version.c index 3ca0b254f4..4b4d28dcc2 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -47,21 +47,25 @@ char *version_cflags = "Compilation: " NVIM_VERSION_CFLAGS; static char *features[] = { #ifdef HAVE_ACL "+acl", -#else // ifdef HAVE_ACL +#else "-acl", -#endif // ifdef HAVE_ACL +#endif #if (defined(HAVE_ICONV_H) && defined(USE_ICONV)) || defined(DYNAMIC_ICONV) # ifdef DYNAMIC_ICONV "+iconv/dyn", -# else // ifdef DYNAMIC_ICONV +# else "+iconv", -# endif // ifdef DYNAMIC_ICONV -#else // if (defined(HAVE_ICONV_H) && defined(USE_ICONV)) - // ||defined(DYNAMIC_ICONV) +# endif +#else "-iconv", -#endif // if (defined(HAVE_ICONV_H) && defined(USE_ICONV)) - // || defined(DYNAMIC_ICONV) +#endif + +#ifdef HAVE_JEMALLOC + "+jemalloc", +#else + "-jemalloc", +#endif NULL }; |