Add the --disable-experimental option.

This commit is contained in:
Jason Evans 2012-03-02 17:47:37 -08:00
parent 7b398aca3b
commit 7e77eaffff
7 changed files with 63 additions and 14 deletions

View File

@ -116,6 +116,9 @@ any of the following arguments (not a definitive list) to 'configure':
Disable support for junk/zero filling of memory. See the "opt.junk"/ Disable support for junk/zero filling of memory. See the "opt.junk"/
"opt.zero" option documentation for usage details. "opt.zero" option documentation for usage details.
--disable-experimental
Disable support for the experimental API (*allocm()).
--enable-xmalloc --enable-xmalloc
Enable support for optional immediate termination due to out-of-memory Enable support for optional immediate termination due to out-of-memory
errors, as is commonly implemented by "xmalloc" wrapper function for malloc. errors, as is commonly implemented by "xmalloc" wrapper function for malloc.

View File

@ -63,10 +63,12 @@ DOCS_XML := @objroot@doc/jemalloc@install_suffix@.xml
DOCS_HTML := $(DOCS_XML:@objroot@%.xml=@srcroot@%.html) DOCS_HTML := $(DOCS_XML:@objroot@%.xml=@srcroot@%.html)
DOCS_MAN3 := $(DOCS_XML:@objroot@%.xml=@srcroot@%.3) DOCS_MAN3 := $(DOCS_XML:@objroot@%.xml=@srcroot@%.3)
DOCS := $(DOCS_HTML) $(DOCS_MAN3) DOCS := $(DOCS_HTML) $(DOCS_MAN3)
CTESTS := @srcroot@test/allocated.c @srcroot@test/allocm.c \ CTESTS := @srcroot@test/allocated.c @srcroot@test/bitmap.c \
@srcroot@test/bitmap.c @srcroot@test/mremap.c \ @srcroot@test/mremap.c @srcroot@test/posix_memalign.c \
@srcroot@test/posix_memalign.c @srcroot@test/rallocm.c \
@srcroot@test/thread_arena.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: all dist doc_html doc_man doc
.PHONY: install_bin install_include install_lib .PHONY: install_bin install_include install_lib

View File

@ -303,6 +303,34 @@ AC_PATH_PROG([AR], [ar], , [$PATH])
AC_PATH_PROG([LD], [ld], , [$PATH]) AC_PATH_PROG([LD], [ld], , [$PATH])
AC_PATH_PROG([AUTOCONF], [autoconf], , [$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. dnl Perform no name mangling by default.
AC_ARG_WITH([mangling], AC_ARG_WITH([mangling],
[AS_HELP_STRING([--with-mangling=<map>], [Mangle symbols in <map>])], [AS_HELP_STRING([--with-mangling=<map>], [Mangle symbols in <map>])],
@ -331,7 +359,7 @@ fi
dnl Generate macros to rename public symbols. All public symbols are prefixed 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 je_ in the source code, so these macro definitions are needed even if
dnl --with-jemalloc-prefix wasn't specified. 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}" n="je_${stem}"
m="${JEMALLOC_PREFIX}${stem}" m="${JEMALLOC_PREFIX}${stem}"
AC_DEFINE_UNQUOTED([${n}], [${m}]) AC_DEFINE_UNQUOTED([${n}], [${m}])
@ -795,14 +823,6 @@ if test "x${osspin}" = "xyes" ; then
AC_DEFINE([JEMALLOC_OSSPIN]) AC_DEFINE([JEMALLOC_OSSPIN])
fi 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 ============================================================================
dnl Darwin-related configuration. dnl Darwin-related configuration.
@ -903,6 +923,7 @@ AC_MSG_RESULT([JEMALLOC_PRIVATE_NAMESPACE])
AC_MSG_RESULT([ : ${JEMALLOC_PRIVATE_NAMESPACE}]) AC_MSG_RESULT([ : ${JEMALLOC_PRIVATE_NAMESPACE}])
AC_MSG_RESULT([install_suffix : ${install_suffix}]) AC_MSG_RESULT([install_suffix : ${install_suffix}])
AC_MSG_RESULT([autogen : ${enable_autogen}]) AC_MSG_RESULT([autogen : ${enable_autogen}])
AC_MSG_RESULT([experimental : ${enable_experimental}])
AC_MSG_RESULT([cc-silence : ${enable_cc_silence}]) AC_MSG_RESULT([cc-silence : ${enable_cc_silence}])
AC_MSG_RESULT([debug : ${enable_debug}]) AC_MSG_RESULT([debug : ${enable_debug}])
AC_MSG_RESULT([stats : ${enable_stats}]) AC_MSG_RESULT([stats : ${enable_stats}])

View File

@ -304,7 +304,9 @@ for (i = 0; i < nbins; i++) {
<refsect2> <refsect2>
<title>Experimental API</title> <title>Experimental API</title>
<para>The experimental API is subject to change or removal without regard <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>, <para>The <function>allocm<parameter/></function>,
<function>rallocm<parameter/></function>, <function>rallocm<parameter/></function>,

View File

@ -16,6 +16,7 @@ extern "C" {
#include "jemalloc_defs@install_suffix@.h" #include "jemalloc_defs@install_suffix@.h"
#ifdef JEMALLOC_EXPERIMENTAL
#define ALLOCM_LG_ALIGN(la) (la) #define ALLOCM_LG_ALIGN(la) (la)
#if LG_SIZEOF_PTR == 2 #if LG_SIZEOF_PTR == 2
#define ALLOCM_ALIGN(a) (ffs(a)-1) #define ALLOCM_ALIGN(a) (ffs(a)-1)
@ -28,6 +29,7 @@ extern "C" {
#define ALLOCM_SUCCESS 0 #define ALLOCM_SUCCESS 0
#define ALLOCM_ERR_OOM 1 #define ALLOCM_ERR_OOM 1
#define ALLOCM_ERR_NOT_MOVED 2 #define ALLOCM_ERR_NOT_MOVED 2
#endif
/* /*
* The je_ prefix on the following public symbol declarations is an artifact of * The je_ prefix on the following public symbol declarations is an artifact of
@ -53,6 +55,7 @@ int je_mallctlnametomib(const char *name, size_t *mibp, size_t *miblenp);
int je_mallctlbymib(const size_t *mib, size_t miblen, void *oldp, int je_mallctlbymib(const size_t *mib, size_t miblen, void *oldp,
size_t *oldlenp, void *newp, size_t newlen); size_t *oldlenp, void *newp, size_t newlen);
#ifdef JEMALLOC_EXPERIMENTAL
int je_allocm(void **ptr, size_t *rsize, size_t size, int flags) int je_allocm(void **ptr, size_t *rsize, size_t size, int flags)
JEMALLOC_ATTR(nonnull(1)); JEMALLOC_ATTR(nonnull(1));
int je_rallocm(void **ptr, size_t *rsize, size_t size, size_t extra, int je_rallocm(void **ptr, size_t *rsize, size_t size, size_t extra,
@ -61,6 +64,7 @@ int je_sallocm(const void *ptr, size_t *rsize, int flags)
JEMALLOC_ATTR(nonnull(1)); JEMALLOC_ATTR(nonnull(1));
int je_dallocm(void *ptr, int flags) 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); int je_nallocm(size_t *rsize, size_t size, int flags);
#endif
/* /*
* By default application code must explicitly refer to mangled symbol names, * By default application code must explicitly refer to mangled symbol names,
@ -87,12 +91,14 @@ int je_nallocm(size_t *rsize, size_t size, int flags);
#define mallctlbymib je_mallctlbymib #define mallctlbymib je_mallctlbymib
#define memalign je_memalign #define memalign je_memalign
#define valloc je_valloc #define valloc je_valloc
#ifdef JEMALLOC_EXPERIMENTAL
#define allocm je_allocm #define allocm je_allocm
#define rallocm je_rallocm #define rallocm je_rallocm
#define sallocm je_sallocm #define sallocm je_sallocm
#define dallocm je_dallocm #define dallocm je_dallocm
#define nallocm je_nallocm #define nallocm je_nallocm
#endif #endif
#endif
/* /*
* The je_* macros can be used as stable alternative names for the public * The je_* macros can be used as stable alternative names for the public
@ -116,12 +122,14 @@ int je_nallocm(size_t *rsize, size_t size, int flags);
#undef je_mallctlbymib #undef je_mallctlbymib
#undef je_memalign #undef je_memalign
#undef je_valloc #undef je_valloc
#ifdef JEMALLOC_EXPERIMENTAL
#undef je_allocm #undef je_allocm
#undef je_rallocm #undef je_rallocm
#undef je_sallocm #undef je_sallocm
#undef je_dallocm #undef je_dallocm
#undef je_nallocm #undef je_nallocm
#endif #endif
#endif
#ifdef __cplusplus #ifdef __cplusplus
}; };

View File

@ -108,6 +108,9 @@
/* Support memory filling (junk/zero). */ /* Support memory filling (junk/zero). */
#undef JEMALLOC_FILL #undef JEMALLOC_FILL
/* Support the experimental API. */
#undef JEMALLOC_EXPERIMENTAL
/* Support optional abort() on OOM. */ /* Support optional abort() on OOM. */
#undef JEMALLOC_XMALLOC #undef JEMALLOC_XMALLOC

View File

@ -1361,6 +1361,15 @@ je_mallctlbymib(const size_t *mib, size_t miblen, void *oldp, size_t *oldlenp,
return (ctl_bymib(mib, miblen, oldp, oldlenp, newp, newlen)); return (ctl_bymib(mib, miblen, oldp, oldlenp, newp, newlen));
} }
/*
* End non-standard functions.
*/
/******************************************************************************/
/*
* Begin experimental functions.
*/
#ifdef JEMALLOC_EXPERIMENTAL
JEMALLOC_INLINE void * JEMALLOC_INLINE void *
iallocm(size_t usize, size_t alignment, bool zero) iallocm(size_t usize, size_t alignment, bool zero)
{ {
@ -1601,8 +1610,9 @@ je_nallocm(size_t *rsize, size_t size, int flags)
return (ALLOCM_SUCCESS); return (ALLOCM_SUCCESS);
} }
#endif
/* /*
* End non-standard functions. * End experimental functions.
*/ */
/******************************************************************************/ /******************************************************************************/