From 7e77eaffffe5c73d44ee64b14ba4b3d7693179d6 Mon Sep 17 00:00:00 2001 From: Jason Evans Date: Fri, 2 Mar 2012 17:47:37 -0800 Subject: [PATCH] Add the --disable-experimental option. --- INSTALL | 3 +++ Makefile.in | 8 +++--- configure.ac | 39 ++++++++++++++++++++++------- doc/jemalloc.xml.in | 4 ++- include/jemalloc/jemalloc.h.in | 8 ++++++ include/jemalloc/jemalloc_defs.h.in | 3 +++ src/jemalloc.c | 12 ++++++++- 7 files changed, 63 insertions(+), 14 deletions(-) diff --git a/INSTALL b/INSTALL index 92cd0851..c0ae106a 100644 --- a/INSTALL +++ b/INSTALL @@ -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"/ "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 0accf102..1f1ffd33 100644 --- a/Makefile.in +++ b/Makefile.in @@ -63,10 +63,12 @@ DOCS_XML := @objroot@doc/jemalloc@install_suffix@.xml 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 81ab233a..c61a665b 100644 --- a/configure.ac +++ b/configure.ac @@ -303,6 +303,34 @@ AC_PATH_PROG([AR], [ar], , [$PATH]) 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=], [Mangle symbols in ])], @@ -331,7 +359,7 @@ fi 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}]) @@ -795,14 +823,6 @@ if test "x${osspin}" = "xyes" ; then AC_DEFINE([JEMALLOC_OSSPIN]) 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. @@ -903,6 +923,7 @@ AC_MSG_RESULT([JEMALLOC_PRIVATE_NAMESPACE]) 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 6aa412a1..ca13493a 100644 --- a/doc/jemalloc.xml.in +++ b/doc/jemalloc.xml.in @@ -304,7 +304,9 @@ for (i = 0; i < nbins; i++) { Experimental API The experimental API is subject to change or removal without regard - for backward compatibility. + for backward compatibility. If + is specified during configuration, the experimental API is + omitted. The allocm, rallocm, diff --git a/include/jemalloc/jemalloc.h.in b/include/jemalloc/jemalloc.h.in index f567ee57..742daddd 100644 --- a/include/jemalloc/jemalloc.h.in +++ b/include/jemalloc/jemalloc.h.in @@ -16,6 +16,7 @@ extern "C" { #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 @@ extern "C" { #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_mallctlnametomib(const char *name, size_t *mibp, size_t *miblenp); 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 @@ int je_sallocm(const void *ptr, size_t *rsize, 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); +#endif /* * 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 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 @@ int je_nallocm(size_t *rsize, size_t size, int flags); #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 444950c8..049cf01a 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 6e34706d..3c39c857 100644 --- a/src/jemalloc.c +++ b/src/jemalloc.c @@ -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)); } +/* + * 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 @@ je_nallocm(size_t *rsize, size_t size, int flags) return (ALLOCM_SUCCESS); } +#endif /* - * End non-standard functions. + * End experimental functions. */ /******************************************************************************/