Add the --disable-experimental option.
diff --git a/INSTALL b/INSTALL
index 92cd085..c0ae106 100644
--- a/INSTALL
+++ b/INSTALL
@@ -116,6 +116,9 @@
Disable support for junk/zero filling of memory. See the "opt.junk"/
"opt.zero" option documentation for usage details.
+--disable-experimental
+ Disable support for the experimental API (*allocm()).
+
--enable-xmalloc
Enable support for optional immediate termination due to out-of-memory
errors, as is commonly implemented by "xmalloc" wrapper function for malloc.
diff --git a/Makefile.in b/Makefile.in
index 0accf10..1f1ffd3 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -63,10 +63,12 @@
DOCS_HTML := $(DOCS_XML:@objroot@%.xml=@srcroot@%.html)
DOCS_MAN3 := $(DOCS_XML:@objroot@%.xml=@srcroot@%.3)
DOCS := $(DOCS_HTML) $(DOCS_MAN3)
-CTESTS := @srcroot@test/allocated.c @srcroot@test/allocm.c \
- @srcroot@test/bitmap.c @srcroot@test/mremap.c \
- @srcroot@test/posix_memalign.c @srcroot@test/rallocm.c \
+CTESTS := @srcroot@test/allocated.c @srcroot@test/bitmap.c \
+ @srcroot@test/mremap.c @srcroot@test/posix_memalign.c \
@srcroot@test/thread_arena.c
+ifeq (@enable_experimental@, 1)
+CTESTS += @srcroot@test/allocm.c @srcroot@test/rallocm.c
+endif
.PHONY: all dist doc_html doc_man doc
.PHONY: install_bin install_include install_lib
diff --git a/configure.ac b/configure.ac
index 81ab233..c61a665 100644
--- a/configure.ac
+++ b/configure.ac
@@ -303,6 +303,34 @@
AC_PATH_PROG([LD], [ld], , [$PATH])
AC_PATH_PROG([AUTOCONF], [autoconf], , [$PATH])
+public_syms="malloc_conf malloc_message malloc calloc posix_memalign realloc free malloc_usable_size malloc_stats_print mallctl mallctlnametomib mallctlbymib"
+
+dnl Check for allocator-related functions that should be wrapped.
+AC_CHECK_FUNC([memalign],
+ [AC_DEFINE([JEMALLOC_OVERRIDE_MEMALIGN])
+ public_syms="${public_syms} memalign"])
+AC_CHECK_FUNC([valloc],
+ [AC_DEFINE([JEMALLOC_OVERRIDE_VALLOC])
+ public_syms="${public_syms} valloc"])
+
+dnl Support the experimental API by default.
+AC_ARG_ENABLE([experimental],
+ [AS_HELP_STRING([--disable-experimental],
+ [Disable support for the experimental API])],
+[if test "x$enable_experimental" = "xno" ; then
+ enable_experimental="0"
+else
+ enable_experimental="1"
+fi
+],
+[enable_experimental="1"]
+)
+if test "x$enable_experimental" = "x1" ; then
+ AC_DEFINE([JEMALLOC_EXPERIMENTAL], [ ])
+ public_syms="${public_syms} allocm dallocm nallocm rallocm sallocm"
+fi
+AC_SUBST([enable_experimental])
+
dnl Perform no name mangling by default.
AC_ARG_WITH([mangling],
[AS_HELP_STRING([--with-mangling=<map>], [Mangle symbols in <map>])],
@@ -331,7 +359,7 @@
dnl Generate macros to rename public symbols. All public symbols are prefixed
dnl with je_ in the source code, so these macro definitions are needed even if
dnl --with-jemalloc-prefix wasn't specified.
-for stem in malloc_conf malloc_message malloc calloc posix_memalign realloc free malloc_usable_size malloc_stats_print mallctl mallctlnametomib mallctlbymib memalign valloc allocm dallocm nallocm rallocm sallocm; do
+for stem in ${public_syms}; do
n="je_${stem}"
m="${JEMALLOC_PREFIX}${stem}"
AC_DEFINE_UNQUOTED([${n}], [${m}])
@@ -796,14 +824,6 @@
fi
dnl ============================================================================
-dnl Check for allocator-related functions that should be wrapped.
-
-AC_CHECK_FUNC([memalign],
- [AC_DEFINE([JEMALLOC_OVERRIDE_MEMALIGN])])
-AC_CHECK_FUNC([valloc],
- [AC_DEFINE([JEMALLOC_OVERRIDE_VALLOC])])
-
-dnl ============================================================================
dnl Darwin-related configuration.
if test "x${abi}" = "xmacho" ; then
@@ -903,6 +923,7 @@
AC_MSG_RESULT([ : ${JEMALLOC_PRIVATE_NAMESPACE}])
AC_MSG_RESULT([install_suffix : ${install_suffix}])
AC_MSG_RESULT([autogen : ${enable_autogen}])
+AC_MSG_RESULT([experimental : ${enable_experimental}])
AC_MSG_RESULT([cc-silence : ${enable_cc_silence}])
AC_MSG_RESULT([debug : ${enable_debug}])
AC_MSG_RESULT([stats : ${enable_stats}])
diff --git a/doc/jemalloc.xml.in b/doc/jemalloc.xml.in
index 6aa412a..ca13493 100644
--- a/doc/jemalloc.xml.in
+++ b/doc/jemalloc.xml.in
@@ -304,7 +304,9 @@
<refsect2>
<title>Experimental API</title>
<para>The experimental API is subject to change or removal without regard
- for backward compatibility.</para>
+ for backward compatibility. If <option>--disable-experimental</option>
+ is specified during configuration, the experimental API is
+ omitted.</para>
<para>The <function>allocm<parameter/></function>,
<function>rallocm<parameter/></function>,
diff --git a/include/jemalloc/jemalloc.h.in b/include/jemalloc/jemalloc.h.in
index f567ee5..742dadd 100644
--- a/include/jemalloc/jemalloc.h.in
+++ b/include/jemalloc/jemalloc.h.in
@@ -16,6 +16,7 @@
#include "jemalloc_defs@install_suffix@.h"
+#ifdef JEMALLOC_EXPERIMENTAL
#define ALLOCM_LG_ALIGN(la) (la)
#if LG_SIZEOF_PTR == 2
#define ALLOCM_ALIGN(a) (ffs(a)-1)
@@ -28,6 +29,7 @@
#define ALLOCM_SUCCESS 0
#define ALLOCM_ERR_OOM 1
#define ALLOCM_ERR_NOT_MOVED 2
+#endif
/*
* The je_ prefix on the following public symbol declarations is an artifact of
@@ -53,6 +55,7 @@
int je_mallctlbymib(const size_t *mib, size_t miblen, void *oldp,
size_t *oldlenp, void *newp, size_t newlen);
+#ifdef JEMALLOC_EXPERIMENTAL
int je_allocm(void **ptr, size_t *rsize, size_t size, int flags)
JEMALLOC_ATTR(nonnull(1));
int je_rallocm(void **ptr, size_t *rsize, size_t size, size_t extra,
@@ -61,6 +64,7 @@
JEMALLOC_ATTR(nonnull(1));
int je_dallocm(void *ptr, int flags) JEMALLOC_ATTR(nonnull(1));
int je_nallocm(size_t *rsize, size_t size, int flags);
+#endif
/*
* By default application code must explicitly refer to mangled symbol names,
@@ -87,12 +91,14 @@
#define mallctlbymib je_mallctlbymib
#define memalign je_memalign
#define valloc je_valloc
+#ifdef JEMALLOC_EXPERIMENTAL
#define allocm je_allocm
#define rallocm je_rallocm
#define sallocm je_sallocm
#define dallocm je_dallocm
#define nallocm je_nallocm
#endif
+#endif
/*
* The je_* macros can be used as stable alternative names for the public
@@ -116,12 +122,14 @@
#undef je_mallctlbymib
#undef je_memalign
#undef je_valloc
+#ifdef JEMALLOC_EXPERIMENTAL
#undef je_allocm
#undef je_rallocm
#undef je_sallocm
#undef je_dallocm
#undef je_nallocm
#endif
+#endif
#ifdef __cplusplus
};
diff --git a/include/jemalloc/jemalloc_defs.h.in b/include/jemalloc/jemalloc_defs.h.in
index 444950c..049cf01 100644
--- a/include/jemalloc/jemalloc_defs.h.in
+++ b/include/jemalloc/jemalloc_defs.h.in
@@ -108,6 +108,9 @@
/* Support memory filling (junk/zero). */
#undef JEMALLOC_FILL
+/* Support the experimental API. */
+#undef JEMALLOC_EXPERIMENTAL
+
/* Support optional abort() on OOM. */
#undef JEMALLOC_XMALLOC
diff --git a/src/jemalloc.c b/src/jemalloc.c
index 6e34706..3c39c85 100644
--- a/src/jemalloc.c
+++ b/src/jemalloc.c
@@ -1361,6 +1361,15 @@
return (ctl_bymib(mib, miblen, oldp, oldlenp, newp, newlen));
}
+/*
+ * End non-standard functions.
+ */
+/******************************************************************************/
+/*
+ * Begin experimental functions.
+ */
+#ifdef JEMALLOC_EXPERIMENTAL
+
JEMALLOC_INLINE void *
iallocm(size_t usize, size_t alignment, bool zero)
{
@@ -1601,8 +1610,9 @@
return (ALLOCM_SUCCESS);
}
+#endif
/*
- * End non-standard functions.
+ * End experimental functions.
*/
/******************************************************************************/