[PATCH] Allow to include memalign and valloc even when prefixing the API

Mike Hommey mh+jemalloc at glandium.org
Wed Feb 22 09:36:50 PST 2012


From: Mike Hommey <mh at glandium.org>

In some cases, like when using the "__wrap_" prefix for use with ld's
--wrap, one may want to still expose memalign and valloc.
---
 configure.ac                        |    6 ++++++
 include/jemalloc/jemalloc_defs.h.in |    6 ++++++
 src/jemalloc.c                      |    5 +++--
 3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index 5ce16eb..e3c0736 100644
--- a/configure.ac
+++ b/configure.ac
@@ -320,6 +320,12 @@ if test "x$JEMALLOC_PREFIX" != "x" ; then
   AC_DEFINE_UNQUOTED([JEMALLOC_P(string_that_no_one_should_want_to_use_as_a_jemalloc_API_prefix)], [${JEMALLOC_PREFIX}##string_that_no_one_should_want_to_use_as_a_jemalloc_API_prefix])
 fi
 
+AC_ARG_ENABLE([jemalloc_prefix_omit],
+  [AS_HELP_STRING([--disable-jemalloc-prefix-omit], [Do not omit APIs that are normally ommitted when --with-jemalloc-prefix is used])])
+if test "x$enable_jemalloc_prefix_omit" = "xno" ; then
+  AC_DEFINE([JEMALLOC_PREFIX_NO_OMIT])
+fi
+
 dnl Do not mangle library-private APIs by default.
 AC_ARG_WITH([private_namespace],
   [AS_HELP_STRING([--with-private-namespace=<prefix>], [Prefix to prepend to all library-private APIs])],
diff --git a/include/jemalloc/jemalloc_defs.h.in b/include/jemalloc/jemalloc_defs.h.in
index d1622fb..7bb171d 100644
--- a/include/jemalloc/jemalloc_defs.h.in
+++ b/include/jemalloc/jemalloc_defs.h.in
@@ -19,6 +19,12 @@
 #endif
 
 /*
+ * If JEMALLOC_PREFIX_NO_OMIT is defined, it will cause APIs that are normally
+ * ommitted when JEMALLOC_PREFIX is defined, to be included.
+ */
+#undef JEMALLOC_PREFIX_NO_OMIT
+
+/*
  * JEMALLOC_PRIVATE_NAMESPACE is used as a prefix for all library-private APIs.
  * For shared libraries, symbol visibility mechanisms prevent these symbols
  * from being exported, but for static libraries, naming collisions are a real
diff --git a/src/jemalloc.c b/src/jemalloc.c
index 64961c5..67035b7 100644
--- a/src/jemalloc.c
+++ b/src/jemalloc.c
@@ -1293,9 +1293,10 @@ JEMALLOC_P(free)(void *ptr)
  * Begin non-standard override functions.
  *
  * These overrides are omitted if the JEMALLOC_PREFIX is defined, since the
- * entire point is to avoid accidental mixed allocator usage.
+ * entire point is to avoid accidental mixed allocator usage. They may however
+ * be included with the JEMALLOC_PREFIX if JEMALLOC_PREFIX_NO_OMIT is defined.
  */
-#ifndef JEMALLOC_PREFIX
+#if !defined(JEMALLOC_PREFIX) || defined(JEMALLOC_PREFIX_NO_OMIT)
 
 #ifdef JEMALLOC_OVERRIDE_MEMALIGN
 JEMALLOC_ATTR(malloc)
-- 
1.7.9




More information about the jemalloc-discuss mailing list