Home | History | Annotate | Download | only in jemalloc
      1 dnl Process this file with autoconf to produce a configure script.
      2 AC_INIT([Makefile.in])
      3 
      4 dnl ============================================================================
      5 dnl Custom macro definitions.
      6 
      7 dnl JE_CFLAGS_APPEND(cflag)
      8 AC_DEFUN([JE_CFLAGS_APPEND],
      9 [
     10 AC_MSG_CHECKING([whether compiler supports $1])
     11 TCFLAGS="${CFLAGS}"
     12 if test "x${CFLAGS}" = "x" ; then
     13   CFLAGS="$1"
     14 else
     15   CFLAGS="${CFLAGS} $1"
     16 fi
     17 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
     18 [[
     19 ]], [[
     20     return 0;
     21 ]])],
     22               [je_cv_cflags_appended=$1]
     23               AC_MSG_RESULT([yes]),
     24               [je_cv_cflags_appended=]
     25               AC_MSG_RESULT([no])
     26               [CFLAGS="${TCFLAGS}"]
     27 )
     28 ])
     29 
     30 dnl JE_COMPILABLE(label, hcode, mcode, rvar)
     31 dnl 
     32 dnl Use AC_LINK_IFELSE() rather than AC_COMPILE_IFELSE() so that linker errors
     33 dnl cause failure.
     34 AC_DEFUN([JE_COMPILABLE],
     35 [
     36 AC_CACHE_CHECK([whether $1 is compilable],
     37                [$4],
     38                [AC_LINK_IFELSE([AC_LANG_PROGRAM([$2],
     39                                                 [$3])],
     40                                [$4=yes],
     41                                [$4=no])])
     42 ])
     43 
     44 dnl ============================================================================
     45 
     46 CONFIG=`echo ${ac_configure_args} | sed -e 's#'"'"'\([^ ]*\)'"'"'#\1#g'`
     47 AC_SUBST([CONFIG])
     48 
     49 dnl Library revision.
     50 rev=2
     51 AC_SUBST([rev])
     52 
     53 srcroot=$srcdir
     54 if test "x${srcroot}" = "x." ; then
     55   srcroot=""
     56 else
     57   srcroot="${srcroot}/"
     58 fi
     59 AC_SUBST([srcroot])
     60 abs_srcroot="`cd \"${srcdir}\"; pwd`/"
     61 AC_SUBST([abs_srcroot])
     62 
     63 objroot=""
     64 AC_SUBST([objroot])
     65 abs_objroot="`pwd`/"
     66 AC_SUBST([abs_objroot])
     67 
     68 dnl Munge install path variables.
     69 if test "x$prefix" = "xNONE" ; then
     70   prefix="/usr/local"
     71 fi
     72 if test "x$exec_prefix" = "xNONE" ; then
     73   exec_prefix=$prefix
     74 fi
     75 PREFIX=$prefix
     76 AC_SUBST([PREFIX])
     77 BINDIR=`eval echo $bindir`
     78 BINDIR=`eval echo $BINDIR`
     79 AC_SUBST([BINDIR])
     80 INCLUDEDIR=`eval echo $includedir`
     81 INCLUDEDIR=`eval echo $INCLUDEDIR`
     82 AC_SUBST([INCLUDEDIR])
     83 LIBDIR=`eval echo $libdir`
     84 LIBDIR=`eval echo $LIBDIR`
     85 AC_SUBST([LIBDIR])
     86 DATADIR=`eval echo $datadir`
     87 DATADIR=`eval echo $DATADIR`
     88 AC_SUBST([DATADIR])
     89 MANDIR=`eval echo $mandir`
     90 MANDIR=`eval echo $MANDIR`
     91 AC_SUBST([MANDIR])
     92 
     93 dnl Support for building documentation.
     94 AC_PATH_PROG([XSLTPROC], [xsltproc], [false], [$PATH])
     95 if test -d "/usr/share/xml/docbook/stylesheet/docbook-xsl" ; then
     96   DEFAULT_XSLROOT="/usr/share/xml/docbook/stylesheet/docbook-xsl"
     97 elif test -d "/usr/share/sgml/docbook/xsl-stylesheets" ; then
     98   DEFAULT_XSLROOT="/usr/share/sgml/docbook/xsl-stylesheets"
     99 else
    100   dnl Documentation building will fail if this default gets used.
    101   DEFAULT_XSLROOT=""
    102 fi
    103 AC_ARG_WITH([xslroot],
    104   [AS_HELP_STRING([--with-xslroot=<path>], [XSL stylesheet root path])], [
    105 if test "x$with_xslroot" = "xno" ; then
    106   XSLROOT="${DEFAULT_XSLROOT}"
    107 else
    108   XSLROOT="${with_xslroot}"
    109 fi
    110 ],
    111   XSLROOT="${DEFAULT_XSLROOT}"
    112 )
    113 AC_SUBST([XSLROOT])
    114 
    115 dnl If CFLAGS isn't defined, set CFLAGS to something reasonable.  Otherwise,
    116 dnl just prevent autoconf from molesting CFLAGS.
    117 CFLAGS=$CFLAGS
    118 AC_PROG_CC
    119 if test "x$GCC" != "xyes" ; then
    120   AC_CACHE_CHECK([whether compiler is MSVC],
    121                  [je_cv_msvc],
    122                  [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
    123                                                      [
    124 #ifndef _MSC_VER
    125   int fail[-1];
    126 #endif
    127 ])],
    128                                [je_cv_msvc=yes],
    129                                [je_cv_msvc=no])])
    130 fi
    131 
    132 if test "x$CFLAGS" = "x" ; then
    133   no_CFLAGS="yes"
    134   if test "x$GCC" = "xyes" ; then
    135     JE_CFLAGS_APPEND([-std=gnu99])
    136     if test "x$je_cv_cflags_appended" = "x-std=gnu99" ; then
    137       AC_DEFINE_UNQUOTED([JEMALLOC_HAS_RESTRICT])
    138     fi
    139     JE_CFLAGS_APPEND([-Wall])
    140     JE_CFLAGS_APPEND([-Werror=declaration-after-statement])
    141     JE_CFLAGS_APPEND([-pipe])
    142     JE_CFLAGS_APPEND([-g3])
    143   elif test "x$je_cv_msvc" = "xyes" ; then
    144     CC="$CC -nologo"
    145     JE_CFLAGS_APPEND([-Zi])
    146     JE_CFLAGS_APPEND([-MT])
    147     JE_CFLAGS_APPEND([-W3])
    148     JE_CFLAGS_APPEND([-FS])
    149     CPPFLAGS="$CPPFLAGS -I${srcdir}/include/msvc_compat"
    150   fi
    151 fi
    152 dnl Append EXTRA_CFLAGS to CFLAGS, if defined.
    153 if test "x$EXTRA_CFLAGS" != "x" ; then
    154   JE_CFLAGS_APPEND([$EXTRA_CFLAGS])
    155 fi
    156 AC_PROG_CPP
    157 
    158 AC_C_BIGENDIAN([ac_cv_big_endian=1], [ac_cv_big_endian=0])
    159 if test "x${ac_cv_big_endian}" = "x1" ; then
    160   AC_DEFINE_UNQUOTED([JEMALLOC_BIG_ENDIAN], [ ])
    161 fi
    162 
    163 if test "x${je_cv_msvc}" = "xyes" -a "x${ac_cv_header_inttypes_h}" = "xno"; then
    164   CPPFLAGS="$CPPFLAGS -I${srcdir}/include/msvc_compat/C99"
    165 fi
    166 
    167 AC_CHECK_SIZEOF([void *])
    168 if test "x${ac_cv_sizeof_void_p}" = "x8" ; then
    169   LG_SIZEOF_PTR=3
    170 elif test "x${ac_cv_sizeof_void_p}" = "x4" ; then
    171   LG_SIZEOF_PTR=2
    172 else
    173   AC_MSG_ERROR([Unsupported pointer size: ${ac_cv_sizeof_void_p}])
    174 fi
    175 AC_DEFINE_UNQUOTED([LG_SIZEOF_PTR], [$LG_SIZEOF_PTR])
    176 
    177 AC_CHECK_SIZEOF([int])
    178 if test "x${ac_cv_sizeof_int}" = "x8" ; then
    179   LG_SIZEOF_INT=3
    180 elif test "x${ac_cv_sizeof_int}" = "x4" ; then
    181   LG_SIZEOF_INT=2
    182 else
    183   AC_MSG_ERROR([Unsupported int size: ${ac_cv_sizeof_int}])
    184 fi
    185 AC_DEFINE_UNQUOTED([LG_SIZEOF_INT], [$LG_SIZEOF_INT])
    186 
    187 AC_CHECK_SIZEOF([long])
    188 if test "x${ac_cv_sizeof_long}" = "x8" ; then
    189   LG_SIZEOF_LONG=3
    190 elif test "x${ac_cv_sizeof_long}" = "x4" ; then
    191   LG_SIZEOF_LONG=2
    192 else
    193   AC_MSG_ERROR([Unsupported long size: ${ac_cv_sizeof_long}])
    194 fi
    195 AC_DEFINE_UNQUOTED([LG_SIZEOF_LONG], [$LG_SIZEOF_LONG])
    196 
    197 AC_CHECK_SIZEOF([intmax_t])
    198 if test "x${ac_cv_sizeof_intmax_t}" = "x16" ; then
    199   LG_SIZEOF_INTMAX_T=4
    200 elif test "x${ac_cv_sizeof_intmax_t}" = "x8" ; then
    201   LG_SIZEOF_INTMAX_T=3
    202 elif test "x${ac_cv_sizeof_intmax_t}" = "x4" ; then
    203   LG_SIZEOF_INTMAX_T=2
    204 else
    205   AC_MSG_ERROR([Unsupported intmax_t size: ${ac_cv_sizeof_intmax_t}])
    206 fi
    207 AC_DEFINE_UNQUOTED([LG_SIZEOF_INTMAX_T], [$LG_SIZEOF_INTMAX_T])
    208 
    209 AC_CANONICAL_HOST
    210 dnl CPU-specific settings.
    211 CPU_SPINWAIT=""
    212 case "${host_cpu}" in
    213   i686|x86_64)
    214 	AC_CACHE_VAL([je_cv_pause],
    215 	  [JE_COMPILABLE([pause instruction], [],
    216 	                [[__asm__ volatile("pause"); return 0;]],
    217 	                [je_cv_pause])])
    218 	if test "x${je_cv_pause}" = "xyes" ; then
    219 	    CPU_SPINWAIT='__asm__ volatile("pause")'
    220 	fi
    221 	;;
    222   powerpc)
    223 	AC_DEFINE_UNQUOTED([HAVE_ALTIVEC], [ ])
    224 	;;
    225   *)
    226 	;;
    227 esac
    228 AC_DEFINE_UNQUOTED([CPU_SPINWAIT], [$CPU_SPINWAIT])
    229 
    230 LD_PRELOAD_VAR="LD_PRELOAD"
    231 so="so"
    232 importlib="${so}"
    233 o="$ac_objext"
    234 a="a"
    235 exe="$ac_exeext"
    236 libprefix="lib"
    237 DSO_LDFLAGS='-shared -Wl,-soname,$(@F)'
    238 RPATH='-Wl,-rpath,$(1)'
    239 SOREV="${so}.${rev}"
    240 PIC_CFLAGS='-fPIC -DPIC'
    241 CTARGET='-o $@'
    242 LDTARGET='-o $@'
    243 EXTRA_LDFLAGS=
    244 ARFLAGS='crus'
    245 AROUT=' $@'
    246 CC_MM=1
    247 
    248 AN_MAKEVAR([AR], [AC_PROG_AR])
    249 AN_PROGRAM([ar], [AC_PROG_AR])
    250 AC_DEFUN([AC_PROG_AR], [AC_CHECK_TOOL(AR, ar, :)])
    251 AC_PROG_AR
    252 
    253 dnl Platform-specific settings.  abi and RPATH can probably be determined
    254 dnl programmatically, but doing so is error-prone, which makes it generally
    255 dnl not worth the trouble.
    256 dnl 
    257 dnl Define cpp macros in CPPFLAGS, rather than doing AC_DEFINE(macro), since the
    258 dnl definitions need to be seen before any headers are included, which is a pain
    259 dnl to make happen otherwise.
    260 default_munmap="1"
    261 case "${host}" in
    262   *-*-darwin* | *-*-ios*)
    263 	CFLAGS="$CFLAGS"
    264 	abi="macho"
    265 	AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ])
    266 	RPATH=""
    267 	LD_PRELOAD_VAR="DYLD_INSERT_LIBRARIES"
    268 	so="dylib"
    269 	importlib="${so}"
    270 	force_tls="0"
    271 	DSO_LDFLAGS='-shared -Wl,-install_name,$(LIBDIR)/$(@F)'
    272 	SOREV="${rev}.${so}"
    273 	sbrk_deprecated="1"
    274 	;;
    275   *-*-freebsd*)
    276 	CFLAGS="$CFLAGS"
    277 	abi="elf"
    278 	AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ])
    279 	force_lazy_lock="1"
    280 	;;
    281   *-*-dragonfly*)
    282 	CFLAGS="$CFLAGS"
    283 	abi="elf"
    284 	AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ])
    285 	;;
    286   *-*-openbsd*|*-*-bitrig*)
    287 	CFLAGS="$CFLAGS"
    288 	abi="elf"
    289 	AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ])
    290 	;;
    291   *-*-linux*)
    292 	CFLAGS="$CFLAGS"
    293 	CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
    294 	abi="elf"
    295 	AC_DEFINE([JEMALLOC_HAS_ALLOCA_H])
    296 	AC_DEFINE([JEMALLOC_PURGE_MADVISE_DONTNEED], [ ])
    297 	AC_DEFINE([JEMALLOC_THREADED_INIT], [ ])
    298 	default_munmap="0"
    299 	;;
    300   *-*-netbsd*)
    301 	AC_MSG_CHECKING([ABI])
    302         AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
    303 [[#ifdef __ELF__
    304 /* ELF */
    305 #else
    306 #error aout
    307 #endif
    308 ]])],
    309                           [CFLAGS="$CFLAGS"; abi="elf"],
    310                           [abi="aout"])
    311 	AC_MSG_RESULT([$abi])
    312 	AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ])
    313 	;;
    314   *-*-solaris2*)
    315 	CFLAGS="$CFLAGS"
    316 	abi="elf"
    317 	AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ])
    318 	RPATH='-Wl,-R,$(1)'
    319 	dnl Solaris needs this for sigwait().
    320 	CPPFLAGS="$CPPFLAGS -D_POSIX_PTHREAD_SEMANTICS"
    321 	LIBS="$LIBS -lposix4 -lsocket -lnsl"
    322 	;;
    323   *-ibm-aix*)
    324 	if "$LG_SIZEOF_PTR" = "8"; then
    325 	  dnl 64bit AIX
    326 	  LD_PRELOAD_VAR="LDR_PRELOAD64"
    327 	else
    328 	  dnl 32bit AIX
    329 	  LD_PRELOAD_VAR="LDR_PRELOAD"
    330 	fi
    331 	abi="xcoff"
    332 	;;
    333   *-*-mingw* | *-*-cygwin*)
    334 	abi="pecoff"
    335 	force_tls="0"
    336 	RPATH=""
    337 	so="dll"
    338 	if test "x$je_cv_msvc" = "xyes" ; then
    339 	  importlib="lib"
    340 	  DSO_LDFLAGS="-LD"
    341 	  EXTRA_LDFLAGS="-link -DEBUG"
    342 	  CTARGET='-Fo$@'
    343 	  LDTARGET='-Fe$@'
    344 	  AR='lib'
    345 	  ARFLAGS='-nologo -out:'
    346 	  AROUT='$@'
    347 	  CC_MM=
    348         else
    349 	  importlib="${so}"
    350 	  DSO_LDFLAGS="-shared"
    351 	fi
    352 	a="lib"
    353 	libprefix=""
    354 	SOREV="${so}"
    355 	PIC_CFLAGS=""
    356 	;;
    357   *)
    358 	AC_MSG_RESULT([Unsupported operating system: ${host}])
    359 	abi="elf"
    360 	;;
    361 esac
    362 
    363 JEMALLOC_USABLE_SIZE_CONST=const
    364 AC_CHECK_HEADERS([malloc.h], [
    365   AC_MSG_CHECKING([whether malloc_usable_size definition can use const argument])
    366   AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
    367     [#include <malloc.h>
    368      #include <stddef.h>
    369     size_t malloc_usable_size(const void *ptr);
    370     ],
    371     [])],[
    372                 AC_MSG_RESULT([yes])
    373          ],[
    374                 JEMALLOC_USABLE_SIZE_CONST=
    375                 AC_MSG_RESULT([no])
    376          ])
    377 ])
    378 AC_DEFINE_UNQUOTED([JEMALLOC_USABLE_SIZE_CONST], [$JEMALLOC_USABLE_SIZE_CONST])
    379 AC_SUBST([abi])
    380 AC_SUBST([RPATH])
    381 AC_SUBST([LD_PRELOAD_VAR])
    382 AC_SUBST([so])
    383 AC_SUBST([importlib])
    384 AC_SUBST([o])
    385 AC_SUBST([a])
    386 AC_SUBST([exe])
    387 AC_SUBST([libprefix])
    388 AC_SUBST([DSO_LDFLAGS])
    389 AC_SUBST([EXTRA_LDFLAGS])
    390 AC_SUBST([SOREV])
    391 AC_SUBST([PIC_CFLAGS])
    392 AC_SUBST([CTARGET])
    393 AC_SUBST([LDTARGET])
    394 AC_SUBST([MKLIB])
    395 AC_SUBST([ARFLAGS])
    396 AC_SUBST([AROUT])
    397 AC_SUBST([CC_MM])
    398 
    399 JE_COMPILABLE([__attribute__ syntax],
    400               [static __attribute__((unused)) void foo(void){}],
    401               [],
    402               [je_cv_attribute])
    403 if test "x${je_cv_attribute}" = "xyes" ; then
    404   AC_DEFINE([JEMALLOC_HAVE_ATTR], [ ])
    405   if test "x${GCC}" = "xyes" -a "x${abi}" = "xelf"; then
    406     JE_CFLAGS_APPEND([-fvisibility=hidden])
    407   fi
    408 fi
    409 dnl Check for tls_model attribute support (clang 3.0 still lacks support).
    410 SAVED_CFLAGS="${CFLAGS}"
    411 JE_CFLAGS_APPEND([-Werror])
    412 JE_COMPILABLE([tls_model attribute], [],
    413               [static __thread int
    414                __attribute__((tls_model("initial-exec"), unused)) foo;
    415                foo = 0;],
    416               [je_cv_tls_model])
    417 CFLAGS="${SAVED_CFLAGS}"
    418 if test "x${je_cv_tls_model}" = "xyes" ; then
    419   AC_DEFINE([JEMALLOC_TLS_MODEL],
    420             [__attribute__((tls_model("initial-exec")))])
    421 else
    422   AC_DEFINE([JEMALLOC_TLS_MODEL], [ ])
    423 fi
    424 
    425 dnl Support optional additions to rpath.
    426 AC_ARG_WITH([rpath],
    427   [AS_HELP_STRING([--with-rpath=<rpath>], [Colon-separated rpath (ELF systems only)])],
    428 if test "x$with_rpath" = "xno" ; then
    429   RPATH_EXTRA=
    430 else
    431   RPATH_EXTRA="`echo $with_rpath | tr \":\" \" \"`"
    432 fi,
    433   RPATH_EXTRA=
    434 )
    435 AC_SUBST([RPATH_EXTRA])
    436 
    437 dnl Disable rules that do automatic regeneration of configure output by default.
    438 AC_ARG_ENABLE([autogen],
    439   [AS_HELP_STRING([--enable-autogen], [Automatically regenerate configure output])],
    440 if test "x$enable_autogen" = "xno" ; then
    441   enable_autogen="0"
    442 else
    443   enable_autogen="1"
    444 fi
    445 ,
    446 enable_autogen="0"
    447 )
    448 AC_SUBST([enable_autogen])
    449 
    450 AC_PROG_INSTALL
    451 AC_PROG_RANLIB
    452 AC_PATH_PROG([LD], [ld], [false], [$PATH])
    453 AC_PATH_PROG([AUTOCONF], [autoconf], [false], [$PATH])
    454 
    455 public_syms="malloc_conf malloc_message malloc calloc posix_memalign aligned_alloc realloc free mallocx rallocx xallocx sallocx dallocx sdallocx nallocx mallctl mallctlnametomib mallctlbymib malloc_stats_print malloc_usable_size"
    456 
    457 dnl Check for allocator-related functions that should be wrapped.
    458 AC_CHECK_FUNC([memalign],
    459 	      [AC_DEFINE([JEMALLOC_OVERRIDE_MEMALIGN], [ ])
    460 	       public_syms="${public_syms} memalign"])
    461 AC_CHECK_FUNC([valloc],
    462 	      [AC_DEFINE([JEMALLOC_OVERRIDE_VALLOC], [ ])
    463 	       public_syms="${public_syms} valloc"])
    464 
    465 dnl Do not compute test code coverage by default.
    466 GCOV_FLAGS=
    467 AC_ARG_ENABLE([code-coverage],
    468   [AS_HELP_STRING([--enable-code-coverage],
    469    [Enable code coverage])],
    470 [if test "x$enable_code_coverage" = "xno" ; then
    471   enable_code_coverage="0"
    472 else
    473   enable_code_coverage="1"
    474 fi
    475 ],
    476 [enable_code_coverage="0"]
    477 )
    478 if test "x$enable_code_coverage" = "x1" ; then
    479   deoptimize="no"
    480   echo "$CFLAGS $EXTRA_CFLAGS" | grep '\-O' >/dev/null || deoptimize="yes"
    481   if test "x${deoptimize}" = "xyes" ; then
    482     JE_CFLAGS_APPEND([-O0])
    483   fi
    484   JE_CFLAGS_APPEND([-fprofile-arcs -ftest-coverage])
    485   EXTRA_LDFLAGS="$EXTRA_LDFLAGS -fprofile-arcs -ftest-coverage"
    486   AC_DEFINE([JEMALLOC_CODE_COVERAGE], [ ])
    487 fi
    488 AC_SUBST([enable_code_coverage])
    489 
    490 dnl Perform no name mangling by default.
    491 AC_ARG_WITH([mangling],
    492   [AS_HELP_STRING([--with-mangling=<map>], [Mangle symbols in <map>])],
    493   [mangling_map="$with_mangling"], [mangling_map=""])
    494 
    495 dnl Do not prefix public APIs by default.
    496 AC_ARG_WITH([jemalloc_prefix],
    497   [AS_HELP_STRING([--with-jemalloc-prefix=<prefix>], [Prefix to prepend to all public APIs])],
    498   [JEMALLOC_PREFIX="$with_jemalloc_prefix"],
    499   [if test "x$abi" != "xmacho" -a "x$abi" != "xpecoff"; then
    500   JEMALLOC_PREFIX=""
    501 else
    502   JEMALLOC_PREFIX="je_"
    503 fi]
    504 )
    505 if test "x$JEMALLOC_PREFIX" != "x" ; then
    506   JEMALLOC_CPREFIX=`echo ${JEMALLOC_PREFIX} | tr "a-z" "A-Z"`
    507   AC_DEFINE_UNQUOTED([JEMALLOC_PREFIX], ["$JEMALLOC_PREFIX"])
    508   AC_DEFINE_UNQUOTED([JEMALLOC_CPREFIX], ["$JEMALLOC_CPREFIX"])
    509 fi
    510 
    511 AC_ARG_WITH([export],
    512   [AS_HELP_STRING([--without-export], [disable exporting jemalloc public APIs])],
    513   [if test "x$with_export" = "xno"; then
    514   AC_DEFINE([JEMALLOC_EXPORT],[])
    515 fi]
    516 )
    517 
    518 dnl Mangle library-private APIs.
    519 AC_ARG_WITH([private_namespace],
    520   [AS_HELP_STRING([--with-private-namespace=<prefix>], [Prefix to prepend to all library-private APIs])],
    521   [JEMALLOC_PRIVATE_NAMESPACE="${with_private_namespace}je_"],
    522   [JEMALLOC_PRIVATE_NAMESPACE="je_"]
    523 )
    524 AC_DEFINE_UNQUOTED([JEMALLOC_PRIVATE_NAMESPACE], [$JEMALLOC_PRIVATE_NAMESPACE])
    525 private_namespace="$JEMALLOC_PRIVATE_NAMESPACE"
    526 AC_SUBST([private_namespace])
    527 
    528 dnl Do not add suffix to installed files by default.
    529 AC_ARG_WITH([install_suffix],
    530   [AS_HELP_STRING([--with-install-suffix=<suffix>], [Suffix to append to all installed files])],
    531   [INSTALL_SUFFIX="$with_install_suffix"],
    532   [INSTALL_SUFFIX=]
    533 )
    534 install_suffix="$INSTALL_SUFFIX"
    535 AC_SUBST([install_suffix])
    536 
    537 dnl Substitute @je_@ in jemalloc_protos.h.in, primarily to make generation of
    538 dnl jemalloc_protos_jet.h easy.
    539 je_="je_"
    540 AC_SUBST([je_])
    541 
    542 cfgoutputs_in="Makefile.in"
    543 cfgoutputs_in="${cfgoutputs_in} jemalloc.pc.in"
    544 cfgoutputs_in="${cfgoutputs_in} doc/html.xsl.in"
    545 cfgoutputs_in="${cfgoutputs_in} doc/manpages.xsl.in"
    546 cfgoutputs_in="${cfgoutputs_in} doc/jemalloc.xml.in"
    547 cfgoutputs_in="${cfgoutputs_in} include/jemalloc/jemalloc_macros.h.in"
    548 cfgoutputs_in="${cfgoutputs_in} include/jemalloc/jemalloc_protos.h.in"
    549 cfgoutputs_in="${cfgoutputs_in} include/jemalloc/jemalloc_typedefs.h.in"
    550 cfgoutputs_in="${cfgoutputs_in} include/jemalloc/internal/jemalloc_internal.h.in"
    551 cfgoutputs_in="${cfgoutputs_in} test/test.sh.in"
    552 cfgoutputs_in="${cfgoutputs_in} test/include/test/jemalloc_test.h.in"
    553 
    554 cfgoutputs_out="Makefile"
    555 cfgoutputs_out="${cfgoutputs_out} jemalloc.pc"
    556 cfgoutputs_out="${cfgoutputs_out} doc/html.xsl"
    557 cfgoutputs_out="${cfgoutputs_out} doc/manpages.xsl"
    558 cfgoutputs_out="${cfgoutputs_out} doc/jemalloc.xml"
    559 cfgoutputs_out="${cfgoutputs_out} include/jemalloc/jemalloc_macros.h"
    560 cfgoutputs_out="${cfgoutputs_out} include/jemalloc/jemalloc_protos.h"
    561 cfgoutputs_out="${cfgoutputs_out} include/jemalloc/jemalloc_typedefs.h"
    562 cfgoutputs_out="${cfgoutputs_out} include/jemalloc/internal/jemalloc_internal.h"
    563 cfgoutputs_out="${cfgoutputs_out} test/test.sh"
    564 cfgoutputs_out="${cfgoutputs_out} test/include/test/jemalloc_test.h"
    565 
    566 cfgoutputs_tup="Makefile"
    567 cfgoutputs_tup="${cfgoutputs_tup} jemalloc.pc:jemalloc.pc.in"
    568 cfgoutputs_tup="${cfgoutputs_tup} doc/html.xsl:doc/html.xsl.in"
    569 cfgoutputs_tup="${cfgoutputs_tup} doc/manpages.xsl:doc/manpages.xsl.in"
    570 cfgoutputs_tup="${cfgoutputs_tup} doc/jemalloc.xml:doc/jemalloc.xml.in"
    571 cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/jemalloc_macros.h:include/jemalloc/jemalloc_macros.h.in"
    572 cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/jemalloc_protos.h:include/jemalloc/jemalloc_protos.h.in"
    573 cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/jemalloc_typedefs.h:include/jemalloc/jemalloc_typedefs.h.in"
    574 cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/internal/jemalloc_internal.h"
    575 cfgoutputs_tup="${cfgoutputs_tup} test/test.sh:test/test.sh.in"
    576 cfgoutputs_tup="${cfgoutputs_tup} test/include/test/jemalloc_test.h:test/include/test/jemalloc_test.h.in"
    577 
    578 cfghdrs_in="include/jemalloc/jemalloc_defs.h.in"
    579 cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/jemalloc_internal_defs.h.in"
    580 cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/private_namespace.sh"
    581 cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/private_unnamespace.sh"
    582 cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/private_symbols.txt"
    583 cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/public_namespace.sh"
    584 cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/public_unnamespace.sh"
    585 cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/size_classes.sh"
    586 cfghdrs_in="${cfghdrs_in} include/jemalloc/jemalloc_rename.sh"
    587 cfghdrs_in="${cfghdrs_in} include/jemalloc/jemalloc_mangle.sh"
    588 cfghdrs_in="${cfghdrs_in} include/jemalloc/jemalloc.sh"
    589 cfghdrs_in="${cfghdrs_in} test/include/test/jemalloc_test_defs.h.in"
    590 
    591 cfghdrs_out="include/jemalloc/jemalloc_defs.h"
    592 cfghdrs_out="${cfghdrs_out} include/jemalloc/jemalloc${install_suffix}.h"
    593 cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/private_namespace.h"
    594 cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/private_unnamespace.h"
    595 cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/public_symbols.txt"
    596 cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/public_namespace.h"
    597 cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/public_unnamespace.h"
    598 cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/size_classes.h"
    599 cfghdrs_out="${cfghdrs_out} include/jemalloc/jemalloc_protos_jet.h"
    600 cfghdrs_out="${cfghdrs_out} include/jemalloc/jemalloc_rename.h"
    601 cfghdrs_out="${cfghdrs_out} include/jemalloc/jemalloc_mangle.h"
    602 cfghdrs_out="${cfghdrs_out} include/jemalloc/jemalloc_mangle_jet.h"
    603 cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/jemalloc_internal_defs.h"
    604 cfghdrs_out="${cfghdrs_out} test/include/test/jemalloc_test_defs.h"
    605 
    606 cfghdrs_tup="include/jemalloc/jemalloc_defs.h:include/jemalloc/jemalloc_defs.h.in"
    607 cfghdrs_tup="${cfghdrs_tup} include/jemalloc/internal/jemalloc_internal_defs.h:include/jemalloc/internal/jemalloc_internal_defs.h.in"
    608 cfghdrs_tup="${cfghdrs_tup} test/include/test/jemalloc_test_defs.h:test/include/test/jemalloc_test_defs.h.in"
    609 
    610 dnl Silence irrelevant compiler warnings by default.
    611 AC_ARG_ENABLE([cc-silence],
    612   [AS_HELP_STRING([--disable-cc-silence],
    613                   [Do not silence irrelevant compiler warnings])],
    614 [if test "x$enable_cc_silence" = "xno" ; then
    615   enable_cc_silence="0"
    616 else
    617   enable_cc_silence="1"
    618 fi
    619 ],
    620 [enable_cc_silence="1"]
    621 )
    622 if test "x$enable_cc_silence" = "x1" ; then
    623   AC_DEFINE([JEMALLOC_CC_SILENCE], [ ])
    624 fi
    625 
    626 dnl Do not compile with debugging by default.
    627 AC_ARG_ENABLE([debug],
    628   [AS_HELP_STRING([--enable-debug],
    629                   [Build debugging code (implies --enable-ivsalloc)])],
    630 [if test "x$enable_debug" = "xno" ; then
    631   enable_debug="0"
    632 else
    633   enable_debug="1"
    634 fi
    635 ],
    636 [enable_debug="0"]
    637 )
    638 if test "x$enable_debug" = "x1" ; then
    639   AC_DEFINE([JEMALLOC_DEBUG], [ ])
    640 fi
    641 if test "x$enable_debug" = "x1" ; then
    642   AC_DEFINE([JEMALLOC_DEBUG], [ ])
    643   enable_ivsalloc="1"
    644 fi
    645 AC_SUBST([enable_debug])
    646 
    647 dnl Do not validate pointers by default.
    648 AC_ARG_ENABLE([ivsalloc],
    649   [AS_HELP_STRING([--enable-ivsalloc],
    650                   [Validate pointers passed through the public API])],
    651 [if test "x$enable_ivsalloc" = "xno" ; then
    652   enable_ivsalloc="0"
    653 else
    654   enable_ivsalloc="1"
    655 fi
    656 ],
    657 [enable_ivsalloc="0"]
    658 )
    659 if test "x$enable_ivsalloc" = "x1" ; then
    660   AC_DEFINE([JEMALLOC_IVSALLOC], [ ])
    661 fi
    662 
    663 dnl Only optimize if not debugging.
    664 if test "x$enable_debug" = "x0" -a "x$no_CFLAGS" = "xyes" ; then
    665   dnl Make sure that an optimization flag was not specified in EXTRA_CFLAGS.
    666   optimize="no"
    667   echo "$CFLAGS $EXTRA_CFLAGS" | grep '\-O' >/dev/null || optimize="yes"
    668   if test "x${optimize}" = "xyes" ; then
    669     if test "x$GCC" = "xyes" ; then
    670       JE_CFLAGS_APPEND([-O3])
    671       JE_CFLAGS_APPEND([-funroll-loops])
    672     elif test "x$je_cv_msvc" = "xyes" ; then
    673       JE_CFLAGS_APPEND([-O2])
    674     else
    675       JE_CFLAGS_APPEND([-O])
    676     fi
    677   fi
    678 fi
    679 
    680 dnl Enable statistics calculation by default.
    681 AC_ARG_ENABLE([stats],
    682   [AS_HELP_STRING([--disable-stats],
    683                   [Disable statistics calculation/reporting])],
    684 [if test "x$enable_stats" = "xno" ; then
    685   enable_stats="0"
    686 else
    687   enable_stats="1"
    688 fi
    689 ],
    690 [enable_stats="1"]
    691 )
    692 if test "x$enable_stats" = "x1" ; then
    693   AC_DEFINE([JEMALLOC_STATS], [ ])
    694 fi
    695 AC_SUBST([enable_stats])
    696 
    697 dnl Do not enable profiling by default.
    698 AC_ARG_ENABLE([prof],
    699   [AS_HELP_STRING([--enable-prof], [Enable allocation profiling])],
    700 [if test "x$enable_prof" = "xno" ; then
    701   enable_prof="0"
    702 else
    703   enable_prof="1"
    704 fi
    705 ],
    706 [enable_prof="0"]
    707 )
    708 if test "x$enable_prof" = "x1" ; then
    709   backtrace_method=""
    710 else
    711   backtrace_method="N/A"
    712 fi
    713 
    714 AC_ARG_ENABLE([prof-libunwind],
    715   [AS_HELP_STRING([--enable-prof-libunwind], [Use libunwind for backtracing])],
    716 [if test "x$enable_prof_libunwind" = "xno" ; then
    717   enable_prof_libunwind="0"
    718 else
    719   enable_prof_libunwind="1"
    720 fi
    721 ],
    722 [enable_prof_libunwind="0"]
    723 )
    724 AC_ARG_WITH([static_libunwind],
    725   [AS_HELP_STRING([--with-static-libunwind=<libunwind.a>],
    726   [Path to static libunwind library; use rather than dynamically linking])],
    727 if test "x$with_static_libunwind" = "xno" ; then
    728   LUNWIND="-lunwind"
    729 else
    730   if test ! -f "$with_static_libunwind" ; then
    731     AC_MSG_ERROR([Static libunwind not found: $with_static_libunwind])
    732   fi
    733   LUNWIND="$with_static_libunwind"
    734 fi,
    735   LUNWIND="-lunwind"
    736 )
    737 if test "x$backtrace_method" = "x" -a "x$enable_prof_libunwind" = "x1" ; then
    738   AC_CHECK_HEADERS([libunwind.h], , [enable_prof_libunwind="0"])
    739   if test "x$LUNWIND" = "x-lunwind" ; then
    740     AC_CHECK_LIB([unwind], [unw_backtrace], [LIBS="$LIBS $LUNWIND"],
    741                  [enable_prof_libunwind="0"])
    742   else
    743     LIBS="$LIBS $LUNWIND"
    744   fi
    745   if test "x${enable_prof_libunwind}" = "x1" ; then
    746     backtrace_method="libunwind"
    747     AC_DEFINE([JEMALLOC_PROF_LIBUNWIND], [ ])
    748   fi
    749 fi
    750 
    751 AC_ARG_ENABLE([prof-libgcc],
    752   [AS_HELP_STRING([--disable-prof-libgcc],
    753   [Do not use libgcc for backtracing])],
    754 [if test "x$enable_prof_libgcc" = "xno" ; then
    755   enable_prof_libgcc="0"
    756 else
    757   enable_prof_libgcc="1"
    758 fi
    759 ],
    760 [enable_prof_libgcc="1"]
    761 )
    762 if test "x$backtrace_method" = "x" -a "x$enable_prof_libgcc" = "x1" \
    763      -a "x$GCC" = "xyes" ; then
    764   AC_CHECK_HEADERS([unwind.h], , [enable_prof_libgcc="0"])
    765   AC_CHECK_LIB([gcc], [_Unwind_Backtrace], [LIBS="$LIBS -lgcc"], [enable_prof_libgcc="0"])
    766   if test "x${enable_prof_libgcc}" = "x1" ; then
    767     backtrace_method="libgcc"
    768     AC_DEFINE([JEMALLOC_PROF_LIBGCC], [ ])
    769   fi
    770 else
    771   enable_prof_libgcc="0"
    772 fi
    773 
    774 AC_ARG_ENABLE([prof-gcc],
    775   [AS_HELP_STRING([--disable-prof-gcc],
    776   [Do not use gcc intrinsics for backtracing])],
    777 [if test "x$enable_prof_gcc" = "xno" ; then
    778   enable_prof_gcc="0"
    779 else
    780   enable_prof_gcc="1"
    781 fi
    782 ],
    783 [enable_prof_gcc="1"]
    784 )
    785 if test "x$backtrace_method" = "x" -a "x$enable_prof_gcc" = "x1" \
    786      -a "x$GCC" = "xyes" ; then
    787   JE_CFLAGS_APPEND([-fno-omit-frame-pointer])
    788   backtrace_method="gcc intrinsics"
    789   AC_DEFINE([JEMALLOC_PROF_GCC], [ ])
    790 else
    791   enable_prof_gcc="0"
    792 fi
    793 
    794 if test "x$backtrace_method" = "x" ; then
    795   backtrace_method="none (disabling profiling)"
    796   enable_prof="0"
    797 fi
    798 AC_MSG_CHECKING([configured backtracing method])
    799 AC_MSG_RESULT([$backtrace_method])
    800 if test "x$enable_prof" = "x1" ; then
    801   if test "x$abi" != "xpecoff"; then
    802     dnl Heap profiling uses the log(3) function.
    803     LIBS="$LIBS -lm"
    804   fi
    805 
    806   AC_DEFINE([JEMALLOC_PROF], [ ])
    807 fi
    808 AC_SUBST([enable_prof])
    809 
    810 dnl Enable thread-specific caching by default.
    811 AC_ARG_ENABLE([tcache],
    812   [AS_HELP_STRING([--disable-tcache], [Disable per thread caches])],
    813 [if test "x$enable_tcache" = "xno" ; then
    814   enable_tcache="0"
    815 else
    816   enable_tcache="1"
    817 fi
    818 ],
    819 [enable_tcache="1"]
    820 )
    821 if test "x$enable_tcache" = "x1" ; then
    822   AC_DEFINE([JEMALLOC_TCACHE], [ ])
    823 fi
    824 AC_SUBST([enable_tcache])
    825 
    826 dnl Enable VM deallocation via munmap() by default.
    827 AC_ARG_ENABLE([munmap],
    828   [AS_HELP_STRING([--disable-munmap], [Disable VM deallocation via munmap(2)])],
    829 [if test "x$enable_munmap" = "xno" ; then
    830   enable_munmap="0"
    831 else
    832   enable_munmap="1"
    833 fi
    834 ],
    835 [enable_munmap="${default_munmap}"]
    836 )
    837 if test "x$enable_munmap" = "x1" ; then
    838   AC_DEFINE([JEMALLOC_MUNMAP], [ ])
    839 fi
    840 AC_SUBST([enable_munmap])
    841 
    842 dnl Enable allocation from DSS if supported by the OS.
    843 have_dss="1"
    844 dnl Check whether the BSD/SUSv1 sbrk() exists.  If not, disable DSS support.
    845 AC_CHECK_FUNC([sbrk], [have_sbrk="1"], [have_sbrk="0"])
    846 if test "x$have_sbrk" = "x1" ; then
    847   if test "x$sbrk_deprecated" = "x1" ; then
    848     AC_MSG_RESULT([Disabling dss allocation because sbrk is deprecated])
    849     have_dss="0"
    850   fi
    851 else
    852   have_dss="0"
    853 fi
    854 
    855 if test "x$have_dss" = "x1" ; then
    856   AC_DEFINE([JEMALLOC_DSS], [ ])
    857 fi
    858 
    859 dnl Support the junk/zero filling option by default.
    860 AC_ARG_ENABLE([fill],
    861   [AS_HELP_STRING([--disable-fill],
    862                   [Disable support for junk/zero filling, quarantine, and redzones])],
    863 [if test "x$enable_fill" = "xno" ; then
    864   enable_fill="0"
    865 else
    866   enable_fill="1"
    867 fi
    868 ],
    869 [enable_fill="1"]
    870 )
    871 if test "x$enable_fill" = "x1" ; then
    872   AC_DEFINE([JEMALLOC_FILL], [ ])
    873 fi
    874 AC_SUBST([enable_fill])
    875 
    876 dnl Disable utrace(2)-based tracing by default.
    877 AC_ARG_ENABLE([utrace],
    878   [AS_HELP_STRING([--enable-utrace], [Enable utrace(2)-based tracing])],
    879 [if test "x$enable_utrace" = "xno" ; then
    880   enable_utrace="0"
    881 else
    882   enable_utrace="1"
    883 fi
    884 ],
    885 [enable_utrace="0"]
    886 )
    887 JE_COMPILABLE([utrace(2)], [
    888 #include <sys/types.h>
    889 #include <sys/param.h>
    890 #include <sys/time.h>
    891 #include <sys/uio.h>
    892 #include <sys/ktrace.h>
    893 ], [
    894 	utrace((void *)0, 0);
    895 ], [je_cv_utrace])
    896 if test "x${je_cv_utrace}" = "xno" ; then
    897   enable_utrace="0"
    898 fi
    899 if test "x$enable_utrace" = "x1" ; then
    900   AC_DEFINE([JEMALLOC_UTRACE], [ ])
    901 fi
    902 AC_SUBST([enable_utrace])
    903 
    904 dnl Support Valgrind by default.
    905 AC_ARG_ENABLE([valgrind],
    906   [AS_HELP_STRING([--disable-valgrind], [Disable support for Valgrind])],
    907 [if test "x$enable_valgrind" = "xno" ; then
    908   enable_valgrind="0"
    909 else
    910   enable_valgrind="1"
    911 fi
    912 ],
    913 [enable_valgrind="1"]
    914 )
    915 if test "x$enable_valgrind" = "x1" ; then
    916   JE_COMPILABLE([valgrind], [
    917 #include <valgrind/valgrind.h>
    918 #include <valgrind/memcheck.h>
    919 
    920 #if !defined(VALGRIND_RESIZEINPLACE_BLOCK)
    921 #  error "Incompatible Valgrind version"
    922 #endif
    923 ], [], [je_cv_valgrind])
    924   if test "x${je_cv_valgrind}" = "xno" ; then
    925     enable_valgrind="0"
    926   fi
    927   if test "x$enable_valgrind" = "x1" ; then
    928     AC_DEFINE([JEMALLOC_VALGRIND], [ ])
    929   fi
    930 fi
    931 AC_SUBST([enable_valgrind])
    932 
    933 dnl Do not support the xmalloc option by default.
    934 AC_ARG_ENABLE([xmalloc],
    935   [AS_HELP_STRING([--enable-xmalloc], [Support xmalloc option])],
    936 [if test "x$enable_xmalloc" = "xno" ; then
    937   enable_xmalloc="0"
    938 else
    939   enable_xmalloc="1"
    940 fi
    941 ],
    942 [enable_xmalloc="0"]
    943 )
    944 if test "x$enable_xmalloc" = "x1" ; then
    945   AC_DEFINE([JEMALLOC_XMALLOC], [ ])
    946 fi
    947 AC_SUBST([enable_xmalloc])
    948 
    949 dnl Support cache-oblivious allocation alignment by default.
    950 AC_ARG_ENABLE([cache-oblivious],
    951   [AS_HELP_STRING([--disable-cache-oblivious],
    952                   [Disable support for cache-oblivious allocation alignment])],
    953 [if test "x$enable_cache_oblivious" = "xno" ; then
    954   enable_cache_oblivious="0"
    955 else
    956   enable_cache_oblivious="1"
    957 fi
    958 ],
    959 [enable_cache_oblivious="1"]
    960 )
    961 if test "x$enable_cache_oblivious" = "x1" ; then
    962   AC_DEFINE([JEMALLOC_CACHE_OBLIVIOUS], [ ])
    963 fi
    964 AC_SUBST([enable_cache_oblivious])
    965 
    966 dnl ============================================================================
    967 dnl Check for  __builtin_ffsl(), then ffsl(3), and fail if neither are found.
    968 dnl One of those two functions should (theoretically) exist on all platforms
    969 dnl that jemalloc currently has a chance of functioning on without modification.
    970 dnl We additionally assume ffs() or __builtin_ffs() are defined if
    971 dnl ffsl() or __builtin_ffsl() are defined, respectively.
    972 JE_COMPILABLE([a program using __builtin_ffsl], [
    973 #include <stdio.h>
    974 #include <strings.h>
    975 #include <string.h>
    976 ], [
    977 	{
    978 		int rv = __builtin_ffsl(0x08);
    979 		printf("%d\n", rv);
    980 	}
    981 ], [je_cv_gcc_builtin_ffsl])
    982 if test "x${je_cv_gcc_builtin_ffsl}" = "xyes" ; then
    983   AC_DEFINE([JEMALLOC_INTERNAL_FFSL], [__builtin_ffsl])
    984   AC_DEFINE([JEMALLOC_INTERNAL_FFS], [__builtin_ffs])
    985 else
    986   JE_COMPILABLE([a program using ffsl], [
    987   #include <stdio.h>
    988   #include <strings.h>
    989   #include <string.h>
    990   ], [
    991 	{
    992 		int rv = ffsl(0x08);
    993 		printf("%d\n", rv);
    994 	}
    995   ], [je_cv_function_ffsl])
    996   if test "x${je_cv_function_ffsl}" = "xyes" ; then
    997     AC_DEFINE([JEMALLOC_INTERNAL_FFSL], [ffsl])
    998     AC_DEFINE([JEMALLOC_INTERNAL_FFS], [ffs])
    999   else
   1000     AC_MSG_ERROR([Cannot build without ffsl(3) or __builtin_ffsl()])
   1001   fi
   1002 fi
   1003 
   1004 AC_ARG_WITH([lg_tiny_min],
   1005   [AS_HELP_STRING([--with-lg-tiny-min=<lg-tiny-min>],
   1006    [Base 2 log of minimum tiny size class to support])],
   1007   [LG_TINY_MIN="$with_lg_tiny_min"],
   1008   [LG_TINY_MIN="3"])
   1009 AC_DEFINE_UNQUOTED([LG_TINY_MIN], [$LG_TINY_MIN])
   1010 
   1011 AC_ARG_WITH([lg_quantum],
   1012   [AS_HELP_STRING([--with-lg-quantum=<lg-quantum>],
   1013    [Base 2 log of minimum allocation alignment])],
   1014   [LG_QUANTA="$with_lg_quantum"],
   1015   [LG_QUANTA="3 4"])
   1016 if test "x$with_lg_quantum" != "x" ; then
   1017   AC_DEFINE_UNQUOTED([LG_QUANTUM], [$with_lg_quantum])
   1018 fi
   1019 
   1020 AC_ARG_WITH([lg_page],
   1021   [AS_HELP_STRING([--with-lg-page=<lg-page>], [Base 2 log of system page size])],
   1022   [LG_PAGE="$with_lg_page"], [LG_PAGE="detect"])
   1023 if test "x$LG_PAGE" = "xdetect"; then
   1024   AC_CACHE_CHECK([LG_PAGE],
   1025                [je_cv_lg_page],
   1026                AC_RUN_IFELSE([AC_LANG_PROGRAM(
   1027 [[
   1028 #include <strings.h>
   1029 #ifdef _WIN32
   1030 #include <windows.h>
   1031 #else
   1032 #include <unistd.h>
   1033 #endif
   1034 #include <stdio.h>
   1035 ]],
   1036 [[
   1037     int result;
   1038     FILE *f;
   1039 
   1040 #ifdef _WIN32
   1041     SYSTEM_INFO si;
   1042     GetSystemInfo(&si);
   1043     result = si.dwPageSize;
   1044 #else
   1045     result = sysconf(_SC_PAGESIZE);
   1046 #endif
   1047     if (result == -1) {
   1048 	return 1;
   1049     }
   1050     result = JEMALLOC_INTERNAL_FFSL(result) - 1;
   1051 
   1052     f = fopen("conftest.out", "w");
   1053     if (f == NULL) {
   1054 	return 1;
   1055     }
   1056     fprintf(f, "%d\n", result);
   1057     fclose(f);
   1058 
   1059     return 0;
   1060 ]])],
   1061                              [je_cv_lg_page=`cat conftest.out`],
   1062                              [je_cv_lg_page=undefined],
   1063                              [je_cv_lg_page=12]))
   1064 fi
   1065 if test "x${je_cv_lg_page}" != "x" ; then
   1066   LG_PAGE="${je_cv_lg_page}"
   1067 fi
   1068 if test "x${LG_PAGE}" != "xundefined" ; then
   1069    AC_DEFINE_UNQUOTED([LG_PAGE], [$LG_PAGE])
   1070 else
   1071    AC_MSG_ERROR([cannot determine value for LG_PAGE])
   1072 fi
   1073 
   1074 AC_ARG_WITH([lg_page_sizes],
   1075   [AS_HELP_STRING([--with-lg-page-sizes=<lg-page-sizes>],
   1076    [Base 2 logs of system page sizes to support])],
   1077   [LG_PAGE_SIZES="$with_lg_page_sizes"], [LG_PAGE_SIZES="$LG_PAGE"])
   1078 
   1079 AC_ARG_WITH([lg_size_class_group],
   1080   [AS_HELP_STRING([--with-lg-size-class-group=<lg-size-class-group>],
   1081    [Base 2 log of size classes per doubling])],
   1082   [LG_SIZE_CLASS_GROUP="$with_lg_size_class_group"],
   1083   [LG_SIZE_CLASS_GROUP="2"])
   1084 
   1085 dnl ============================================================================
   1086 dnl jemalloc configuration.
   1087 dnl 
   1088 
   1089 dnl Set VERSION if source directory is inside a git repository.
   1090 if test "x`test ! \"${srcroot}\" && cd \"${srcroot}\"; git rev-parse --is-inside-work-tree 2>/dev/null`" = "xtrue" ; then
   1091   dnl Pattern globs aren't powerful enough to match both single- and
   1092   dnl double-digit version numbers, so iterate over patterns to support up to
   1093   dnl version 99.99.99 without any accidental matches.
   1094   rm -f "${objroot}VERSION"
   1095   for pattern in ['[0-9].[0-9].[0-9]' '[0-9].[0-9].[0-9][0-9]' \
   1096                  '[0-9].[0-9][0-9].[0-9]' '[0-9].[0-9][0-9].[0-9][0-9]' \
   1097                  '[0-9][0-9].[0-9].[0-9]' '[0-9][0-9].[0-9].[0-9][0-9]' \
   1098                  '[0-9][0-9].[0-9][0-9].[0-9]' \
   1099                  '[0-9][0-9].[0-9][0-9].[0-9][0-9]']; do
   1100     if test ! -e "${objroot}VERSION" ; then
   1101       (test ! "${srcroot}" && cd "${srcroot}"; git describe --long --abbrev=40 --match="${pattern}") > "${objroot}VERSION.tmp" 2>/dev/null
   1102       if test $? -eq 0 ; then
   1103         mv "${objroot}VERSION.tmp" "${objroot}VERSION"
   1104         break
   1105       fi
   1106     fi
   1107   done
   1108 fi
   1109 rm -f "${objroot}VERSION.tmp"
   1110 if test ! -e "${objroot}VERSION" ; then
   1111   if test ! -e "${srcroot}VERSION" ; then
   1112     AC_MSG_RESULT(
   1113       [Missing VERSION file, and unable to generate it; creating bogus VERSION])
   1114     echo "0.0.0-0-g0000000000000000000000000000000000000000" > "${objroot}VERSION"
   1115   else
   1116     cp ${srcroot}VERSION ${objroot}VERSION
   1117   fi
   1118 fi
   1119 jemalloc_version=`cat "${objroot}VERSION"`
   1120 jemalloc_version_major=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]1}'`
   1121 jemalloc_version_minor=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]2}'`
   1122 jemalloc_version_bugfix=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]3}'`
   1123 jemalloc_version_nrev=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]4}'`
   1124 jemalloc_version_gid=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]5}'`
   1125 AC_SUBST([jemalloc_version])
   1126 AC_SUBST([jemalloc_version_major])
   1127 AC_SUBST([jemalloc_version_minor])
   1128 AC_SUBST([jemalloc_version_bugfix])
   1129 AC_SUBST([jemalloc_version_nrev])
   1130 AC_SUBST([jemalloc_version_gid])
   1131 
   1132 dnl ============================================================================
   1133 dnl Configure pthreads.
   1134 
   1135 if test "x$abi" != "xpecoff" ; then
   1136   AC_CHECK_HEADERS([pthread.h], , [AC_MSG_ERROR([pthread.h is missing])])
   1137   dnl Some systems may embed pthreads functionality in libc; check for libpthread
   1138   dnl first, but try libc too before failing.
   1139   AC_CHECK_LIB([pthread], [pthread_create], [LIBS="$LIBS -lpthread"],
   1140                [AC_SEARCH_LIBS([pthread_create], , ,
   1141                                AC_MSG_ERROR([libpthread is missing]))])
   1142 fi
   1143 
   1144 CPPFLAGS="$CPPFLAGS -D_REENTRANT"
   1145 
   1146 dnl Check if the GNU-specific secure_getenv function exists.
   1147 AC_CHECK_FUNC([secure_getenv],
   1148               [have_secure_getenv="1"],
   1149               [have_secure_getenv="0"]
   1150              )
   1151 if test "x$have_secure_getenv" = "x1" ; then
   1152   AC_DEFINE([JEMALLOC_HAVE_SECURE_GETENV], [ ])
   1153 fi
   1154 
   1155 dnl Check if the Solaris/BSD issetugid function exists.
   1156 AC_CHECK_FUNC([issetugid],
   1157               [have_issetugid="1"],
   1158               [have_issetugid="0"]
   1159              )
   1160 if test "x$have_issetugid" = "x1" ; then
   1161   AC_DEFINE([JEMALLOC_HAVE_ISSETUGID], [ ])
   1162 fi
   1163 
   1164 dnl Check whether the BSD-specific _malloc_thread_cleanup() exists.  If so, use
   1165 dnl it rather than pthreads TSD cleanup functions to support cleanup during
   1166 dnl thread exit, in order to avoid pthreads library recursion during
   1167 dnl bootstrapping.
   1168 AC_CHECK_FUNC([_malloc_thread_cleanup],
   1169               [have__malloc_thread_cleanup="1"],
   1170               [have__malloc_thread_cleanup="0"]
   1171              )
   1172 if test "x$have__malloc_thread_cleanup" = "x1" ; then
   1173   AC_DEFINE([JEMALLOC_MALLOC_THREAD_CLEANUP], [ ])
   1174   force_tls="1"
   1175 fi
   1176 
   1177 dnl Check whether the BSD-specific _pthread_mutex_init_calloc_cb() exists.  If
   1178 dnl so, mutex initialization causes allocation, and we need to implement this
   1179 dnl callback function in order to prevent recursive allocation.
   1180 AC_CHECK_FUNC([_pthread_mutex_init_calloc_cb],
   1181               [have__pthread_mutex_init_calloc_cb="1"],
   1182               [have__pthread_mutex_init_calloc_cb="0"]
   1183              )
   1184 if test "x$have__pthread_mutex_init_calloc_cb" = "x1" ; then
   1185   AC_DEFINE([JEMALLOC_MUTEX_INIT_CB])
   1186 fi
   1187 
   1188 dnl Disable lazy locking by default.
   1189 AC_ARG_ENABLE([lazy_lock],
   1190   [AS_HELP_STRING([--enable-lazy-lock],
   1191   [Enable lazy locking (only lock when multi-threaded)])],
   1192 [if test "x$enable_lazy_lock" = "xno" ; then
   1193   enable_lazy_lock="0"
   1194 else
   1195   enable_lazy_lock="1"
   1196 fi
   1197 ],
   1198 [enable_lazy_lock="0"]
   1199 )
   1200 if test "x$enable_lazy_lock" = "x0" -a "x${force_lazy_lock}" = "x1" ; then
   1201   AC_MSG_RESULT([Forcing lazy-lock to avoid allocator/threading bootstrap issues])
   1202   enable_lazy_lock="1"
   1203 fi
   1204 if test "x$enable_lazy_lock" = "x1" ; then
   1205   if test "x$abi" != "xpecoff" ; then
   1206     AC_CHECK_HEADERS([dlfcn.h], , [AC_MSG_ERROR([dlfcn.h is missing])])
   1207     AC_CHECK_FUNC([dlsym], [],
   1208       [AC_CHECK_LIB([dl], [dlsym], [LIBS="$LIBS -ldl"],
   1209                     [AC_MSG_ERROR([libdl is missing])])
   1210       ])
   1211   fi
   1212   AC_DEFINE([JEMALLOC_LAZY_LOCK], [ ])
   1213 fi
   1214 AC_SUBST([enable_lazy_lock])
   1215 
   1216 AC_ARG_ENABLE([tls],
   1217   [AS_HELP_STRING([--disable-tls], [Disable thread-local storage (__thread keyword)])],
   1218 if test "x$enable_tls" = "xno" ; then
   1219   enable_tls="0"
   1220 else
   1221   enable_tls="1"
   1222 fi
   1223 ,
   1224 enable_tls="1"
   1225 )
   1226 if test "x${enable_tls}" = "x0" -a "x${force_tls}" = "x1" ; then
   1227   AC_MSG_RESULT([Forcing TLS to avoid allocator/threading bootstrap issues])
   1228   enable_tls="1"
   1229 fi
   1230 if test "x${enable_tls}" = "x1" -a "x${force_tls}" = "x0" ; then
   1231   AC_MSG_RESULT([Forcing no TLS to avoid allocator/threading bootstrap issues])
   1232   enable_tls="0"
   1233 fi
   1234 if test "x${enable_tls}" = "x1" ; then
   1235 AC_MSG_CHECKING([for TLS])
   1236 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
   1237 [[
   1238     __thread int x;
   1239 ]], [[
   1240     x = 42;
   1241 
   1242     return 0;
   1243 ]])],
   1244               AC_MSG_RESULT([yes]),
   1245               AC_MSG_RESULT([no])
   1246               enable_tls="0")
   1247 fi
   1248 AC_SUBST([enable_tls])
   1249 if test "x${enable_tls}" = "x1" ; then
   1250   AC_DEFINE_UNQUOTED([JEMALLOC_TLS], [ ])
   1251 elif test "x${force_tls}" = "x1" ; then
   1252   AC_MSG_ERROR([Failed to configure TLS, which is mandatory for correct function])
   1253 fi
   1254 
   1255 dnl ============================================================================
   1256 dnl Check for C11 atomics.
   1257 
   1258 JE_COMPILABLE([C11 atomics], [
   1259 #include <stdint.h>
   1260 #if (__STDC_VERSION__ >= 201112L) && !defined(__STDC_NO_ATOMICS__)
   1261 #include <stdatomic.h>
   1262 #else
   1263 #error Atomics not available
   1264 #endif
   1265 ], [
   1266     uint64_t *p = (uint64_t *)0;
   1267     uint64_t x = 1;
   1268     volatile atomic_uint_least64_t *a = (volatile atomic_uint_least64_t *)p;
   1269     uint64_t r = atomic_fetch_add(a, x) + x;
   1270     return (r == 0);
   1271 ], [je_cv_c11atomics])
   1272 if test "x${je_cv_c11atomics}" = "xyes" ; then
   1273   AC_DEFINE([JEMALLOC_C11ATOMICS])
   1274 fi
   1275 
   1276 dnl ============================================================================
   1277 dnl Check for atomic(9) operations as provided on FreeBSD.
   1278 
   1279 JE_COMPILABLE([atomic(9)], [
   1280 #include <sys/types.h>
   1281 #include <machine/atomic.h>
   1282 #include <inttypes.h>
   1283 ], [
   1284 	{
   1285 		uint32_t x32 = 0;
   1286 		volatile uint32_t *x32p = &x32;
   1287 		atomic_fetchadd_32(x32p, 1);
   1288 	}
   1289 	{
   1290 		unsigned long xlong = 0;
   1291 		volatile unsigned long *xlongp = &xlong;
   1292 		atomic_fetchadd_long(xlongp, 1);
   1293 	}
   1294 ], [je_cv_atomic9])
   1295 if test "x${je_cv_atomic9}" = "xyes" ; then
   1296   AC_DEFINE([JEMALLOC_ATOMIC9])
   1297 fi
   1298 
   1299 dnl ============================================================================
   1300 dnl Check for atomic(3) operations as provided on Darwin.
   1301 
   1302 JE_COMPILABLE([Darwin OSAtomic*()], [
   1303 #include <libkern/OSAtomic.h>
   1304 #include <inttypes.h>
   1305 ], [
   1306 	{
   1307 		int32_t x32 = 0;
   1308 		volatile int32_t *x32p = &x32;
   1309 		OSAtomicAdd32(1, x32p);
   1310 	}
   1311 	{
   1312 		int64_t x64 = 0;
   1313 		volatile int64_t *x64p = &x64;
   1314 		OSAtomicAdd64(1, x64p);
   1315 	}
   1316 ], [je_cv_osatomic])
   1317 if test "x${je_cv_osatomic}" = "xyes" ; then
   1318   AC_DEFINE([JEMALLOC_OSATOMIC], [ ])
   1319 fi
   1320 
   1321 dnl ============================================================================
   1322 dnl Check for madvise(2).
   1323 
   1324 JE_COMPILABLE([madvise(2)], [
   1325 #include <sys/mman.h>
   1326 ], [
   1327 	{
   1328 		madvise((void *)0, 0, 0);
   1329 	}
   1330 ], [je_cv_madvise])
   1331 if test "x${je_cv_madvise}" = "xyes" ; then
   1332   AC_DEFINE([JEMALLOC_HAVE_MADVISE], [ ])
   1333 fi
   1334 
   1335 dnl ============================================================================
   1336 dnl Check whether __sync_{add,sub}_and_fetch() are available despite
   1337 dnl __GCC_HAVE_SYNC_COMPARE_AND_SWAP_n macros being undefined.
   1338 
   1339 AC_DEFUN([JE_SYNC_COMPARE_AND_SWAP_CHECK],[
   1340   AC_CACHE_CHECK([whether to force $1-bit __sync_{add,sub}_and_fetch()],
   1341                [je_cv_sync_compare_and_swap_$2],
   1342                [AC_LINK_IFELSE([AC_LANG_PROGRAM([
   1343                                                  #include <stdint.h>
   1344                                                 ],
   1345                                                 [
   1346                                                  #ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_$2
   1347                                                  {
   1348                                                     uint$1_t x$1 = 0;
   1349                                                     __sync_add_and_fetch(&x$1, 42);
   1350                                                     __sync_sub_and_fetch(&x$1, 1);
   1351                                                  }
   1352                                                  #else
   1353                                                  #error __GCC_HAVE_SYNC_COMPARE_AND_SWAP_$2 is defined, no need to force
   1354                                                  #endif
   1355                                                 ])],
   1356                                [je_cv_sync_compare_and_swap_$2=yes],
   1357                                [je_cv_sync_compare_and_swap_$2=no])])
   1358 
   1359   if test "x${je_cv_sync_compare_and_swap_$2}" = "xyes" ; then
   1360     AC_DEFINE([JE_FORCE_SYNC_COMPARE_AND_SWAP_$2], [ ])
   1361   fi
   1362 ])
   1363 
   1364 if test "x${je_cv_atomic9}" != "xyes" -a "x${je_cv_osatomic}" != "xyes" ; then
   1365   JE_SYNC_COMPARE_AND_SWAP_CHECK(32, 4)
   1366   JE_SYNC_COMPARE_AND_SWAP_CHECK(64, 8)
   1367 fi
   1368 
   1369 dnl ============================================================================
   1370 dnl Check for __builtin_clz() and __builtin_clzl().
   1371 
   1372 AC_CACHE_CHECK([for __builtin_clz],
   1373                [je_cv_builtin_clz],
   1374                [AC_LINK_IFELSE([AC_LANG_PROGRAM([],
   1375                                                 [
   1376                                                 {
   1377                                                         unsigned x = 0;
   1378                                                         int y = __builtin_clz(x);
   1379                                                 }
   1380                                                 {
   1381                                                         unsigned long x = 0;
   1382                                                         int y = __builtin_clzl(x);
   1383                                                 }
   1384                                                 ])],
   1385                                [je_cv_builtin_clz=yes],
   1386                                [je_cv_builtin_clz=no])])
   1387 
   1388 if test "x${je_cv_builtin_clz}" = "xyes" ; then
   1389   AC_DEFINE([JEMALLOC_HAVE_BUILTIN_CLZ], [ ])
   1390 fi
   1391 
   1392 dnl ============================================================================
   1393 dnl Check for spinlock(3) operations as provided on Darwin.
   1394 
   1395 JE_COMPILABLE([Darwin OSSpin*()], [
   1396 #include <libkern/OSAtomic.h>
   1397 #include <inttypes.h>
   1398 ], [
   1399 	OSSpinLock lock = 0;
   1400 	OSSpinLockLock(&lock);
   1401 	OSSpinLockUnlock(&lock);
   1402 ], [je_cv_osspin])
   1403 if test "x${je_cv_osspin}" = "xyes" ; then
   1404   AC_DEFINE([JEMALLOC_OSSPIN], [ ])
   1405 fi
   1406 
   1407 dnl ============================================================================
   1408 dnl Darwin-related configuration.
   1409 
   1410 AC_ARG_ENABLE([zone-allocator],
   1411   [AS_HELP_STRING([--disable-zone-allocator],
   1412                   [Disable zone allocator for Darwin])],
   1413 [if test "x$enable_zone_allocator" = "xno" ; then
   1414   enable_zone_allocator="0"
   1415 else
   1416   enable_zone_allocator="1"
   1417 fi
   1418 ],
   1419 [if test "x${abi}" = "xmacho"; then
   1420   enable_zone_allocator="1"
   1421 fi
   1422 ]
   1423 )
   1424 AC_SUBST([enable_zone_allocator])
   1425 
   1426 if test "x${enable_zone_allocator}" = "x1" ; then
   1427   if test "x${abi}" != "xmacho"; then
   1428     AC_MSG_ERROR([--enable-zone-allocator is only supported on Darwin])
   1429   fi
   1430   AC_DEFINE([JEMALLOC_ZONE], [ ])
   1431 
   1432   dnl The szone version jumped from 3 to 6 between the OS X 10.5.x and 10.6
   1433   dnl releases.  malloc_zone_t and malloc_introspection_t have new fields in
   1434   dnl 10.6, which is the only source-level indication of the change.
   1435   AC_MSG_CHECKING([malloc zone version])
   1436   AC_DEFUN([JE_ZONE_PROGRAM],
   1437     [AC_LANG_PROGRAM(
   1438       [#include <malloc/malloc.h>],
   1439       [static int foo[[sizeof($1) $2 sizeof(void *) * $3 ? 1 : -1]]]
   1440     )])
   1441 
   1442   AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,14)],[JEMALLOC_ZONE_VERSION=3],[
   1443   AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,15)],[JEMALLOC_ZONE_VERSION=5],[
   1444   AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,16)],[
   1445     AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_introspection_t,==,9)],[JEMALLOC_ZONE_VERSION=6],[
   1446     AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_introspection_t,==,13)],[JEMALLOC_ZONE_VERSION=7],[JEMALLOC_ZONE_VERSION=]
   1447   )])],[
   1448   AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,17)],[JEMALLOC_ZONE_VERSION=8],[
   1449   AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,>,17)],[JEMALLOC_ZONE_VERSION=9],[JEMALLOC_ZONE_VERSION=]
   1450   )])])])])
   1451   if test "x${JEMALLOC_ZONE_VERSION}" = "x"; then
   1452     AC_MSG_RESULT([unsupported])
   1453     AC_MSG_ERROR([Unsupported malloc zone version])
   1454   fi
   1455   if test "${JEMALLOC_ZONE_VERSION}" = 9; then
   1456     JEMALLOC_ZONE_VERSION=8
   1457     AC_MSG_RESULT([> 8])
   1458   else
   1459     AC_MSG_RESULT([$JEMALLOC_ZONE_VERSION])
   1460   fi
   1461   AC_DEFINE_UNQUOTED(JEMALLOC_ZONE_VERSION, [$JEMALLOC_ZONE_VERSION])
   1462 fi
   1463 
   1464 dnl ============================================================================
   1465 dnl Check for glibc malloc hooks
   1466 
   1467 JE_COMPILABLE([glibc malloc hook], [
   1468 #include <stddef.h>
   1469 
   1470 extern void (* __free_hook)(void *ptr);
   1471 extern void *(* __malloc_hook)(size_t size);
   1472 extern void *(* __realloc_hook)(void *ptr, size_t size);
   1473 ], [
   1474   void *ptr = 0L;
   1475   if (__malloc_hook) ptr = __malloc_hook(1);
   1476   if (__realloc_hook) ptr = __realloc_hook(ptr, 2);
   1477   if (__free_hook && ptr) __free_hook(ptr);
   1478 ], [je_cv_glibc_malloc_hook])
   1479 if test "x${je_cv_glibc_malloc_hook}" = "xyes" ; then
   1480   AC_DEFINE([JEMALLOC_GLIBC_MALLOC_HOOK], [ ])
   1481 fi
   1482 
   1483 JE_COMPILABLE([glibc memalign hook], [
   1484 #include <stddef.h>
   1485 
   1486 extern void *(* __memalign_hook)(size_t alignment, size_t size);
   1487 ], [
   1488   void *ptr = 0L;
   1489   if (__memalign_hook) ptr = __memalign_hook(16, 7);
   1490 ], [je_cv_glibc_memalign_hook])
   1491 if test "x${je_cv_glibc_memalign_hook}" = "xyes" ; then
   1492   AC_DEFINE([JEMALLOC_GLIBC_MEMALIGN_HOOK], [ ])
   1493 fi
   1494 
   1495 JE_COMPILABLE([pthreads adaptive mutexes], [
   1496 #include <pthread.h>
   1497 ], [
   1498   pthread_mutexattr_t attr;
   1499   pthread_mutexattr_init(&attr);
   1500   pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ADAPTIVE_NP);
   1501   pthread_mutexattr_destroy(&attr);
   1502 ], [je_cv_pthread_mutex_adaptive_np])
   1503 if test "x${je_cv_pthread_mutex_adaptive_np}" = "xyes" ; then
   1504   AC_DEFINE([JEMALLOC_HAVE_PTHREAD_MUTEX_ADAPTIVE_NP], [ ])
   1505 fi
   1506 
   1507 dnl ============================================================================
   1508 dnl Check for typedefs, structures, and compiler characteristics.
   1509 AC_HEADER_STDBOOL
   1510 
   1511 dnl ============================================================================
   1512 dnl Define commands that generate output files.
   1513 
   1514 AC_CONFIG_COMMANDS([include/jemalloc/internal/private_namespace.h], [
   1515   mkdir -p "${objroot}include/jemalloc/internal"
   1516   "${srcdir}/include/jemalloc/internal/private_namespace.sh" "${srcdir}/include/jemalloc/internal/private_symbols.txt" > "${objroot}include/jemalloc/internal/private_namespace.h"
   1517 ], [
   1518   srcdir="${srcdir}"
   1519   objroot="${objroot}"
   1520 ])
   1521 AC_CONFIG_COMMANDS([include/jemalloc/internal/private_unnamespace.h], [
   1522   mkdir -p "${objroot}include/jemalloc/internal"
   1523   "${srcdir}/include/jemalloc/internal/private_unnamespace.sh" "${srcdir}/include/jemalloc/internal/private_symbols.txt" > "${objroot}include/jemalloc/internal/private_unnamespace.h"
   1524 ], [
   1525   srcdir="${srcdir}"
   1526   objroot="${objroot}"
   1527 ])
   1528 AC_CONFIG_COMMANDS([include/jemalloc/internal/public_symbols.txt], [
   1529   f="${objroot}include/jemalloc/internal/public_symbols.txt"
   1530   mkdir -p "${objroot}include/jemalloc/internal"
   1531   cp /dev/null "${f}"
   1532   for nm in `echo ${mangling_map} |tr ',' ' '` ; do
   1533     n=`echo ${nm} |tr ':' ' ' |awk '{print $[]1}'`
   1534     m=`echo ${nm} |tr ':' ' ' |awk '{print $[]2}'`
   1535     echo "${n}:${m}" >> "${f}"
   1536     dnl Remove name from public_syms so that it isn't redefined later.
   1537     public_syms=`for sym in ${public_syms}; do echo "${sym}"; done |grep -v "^${n}\$" |tr '\n' ' '`
   1538   done
   1539   for sym in ${public_syms} ; do
   1540     n="${sym}"
   1541     m="${JEMALLOC_PREFIX}${sym}"
   1542     echo "${n}:${m}" >> "${f}"
   1543   done
   1544 ], [
   1545   srcdir="${srcdir}"
   1546   objroot="${objroot}"
   1547   mangling_map="${mangling_map}"
   1548   public_syms="${public_syms}"
   1549   JEMALLOC_PREFIX="${JEMALLOC_PREFIX}"
   1550 ])
   1551 AC_CONFIG_COMMANDS([include/jemalloc/internal/public_namespace.h], [
   1552   mkdir -p "${objroot}include/jemalloc/internal"
   1553   "${srcdir}/include/jemalloc/internal/public_namespace.sh" "${objroot}include/jemalloc/internal/public_symbols.txt" > "${objroot}include/jemalloc/internal/public_namespace.h"
   1554 ], [
   1555   srcdir="${srcdir}"
   1556   objroot="${objroot}"
   1557 ])
   1558 AC_CONFIG_COMMANDS([include/jemalloc/internal/public_unnamespace.h], [
   1559   mkdir -p "${objroot}include/jemalloc/internal"
   1560   "${srcdir}/include/jemalloc/internal/public_unnamespace.sh" "${objroot}include/jemalloc/internal/public_symbols.txt" > "${objroot}include/jemalloc/internal/public_unnamespace.h"
   1561 ], [
   1562   srcdir="${srcdir}"
   1563   objroot="${objroot}"
   1564 ])
   1565 AC_CONFIG_COMMANDS([include/jemalloc/internal/size_classes.h], [
   1566   mkdir -p "${objroot}include/jemalloc/internal"
   1567   "${srcdir}/include/jemalloc/internal/size_classes.sh" "${LG_QUANTA}" ${LG_TINY_MIN} "${LG_PAGE_SIZES}" ${LG_SIZE_CLASS_GROUP} > "${objroot}include/jemalloc/internal/size_classes.h"
   1568 ], [
   1569   srcdir="${srcdir}"
   1570   objroot="${objroot}"
   1571   LG_QUANTA="${LG_QUANTA}"
   1572   LG_TINY_MIN=${LG_TINY_MIN}
   1573   LG_PAGE_SIZES="${LG_PAGE_SIZES}"
   1574   LG_SIZE_CLASS_GROUP=${LG_SIZE_CLASS_GROUP}
   1575 ])
   1576 AC_CONFIG_COMMANDS([include/jemalloc/jemalloc_protos_jet.h], [
   1577   mkdir -p "${objroot}include/jemalloc"
   1578   cat "${srcdir}/include/jemalloc/jemalloc_protos.h.in" | sed -e 's/@je_@/jet_/g' > "${objroot}include/jemalloc/jemalloc_protos_jet.h"
   1579 ], [
   1580   srcdir="${srcdir}"
   1581   objroot="${objroot}"
   1582 ])
   1583 AC_CONFIG_COMMANDS([include/jemalloc/jemalloc_rename.h], [
   1584   mkdir -p "${objroot}include/jemalloc"
   1585   "${srcdir}/include/jemalloc/jemalloc_rename.sh" "${objroot}include/jemalloc/internal/public_symbols.txt" > "${objroot}include/jemalloc/jemalloc_rename.h"
   1586 ], [
   1587   srcdir="${srcdir}"
   1588   objroot="${objroot}"
   1589 ])
   1590 AC_CONFIG_COMMANDS([include/jemalloc/jemalloc_mangle.h], [
   1591   mkdir -p "${objroot}include/jemalloc"
   1592   "${srcdir}/include/jemalloc/jemalloc_mangle.sh" "${objroot}include/jemalloc/internal/public_symbols.txt" je_ > "${objroot}include/jemalloc/jemalloc_mangle.h"
   1593 ], [
   1594   srcdir="${srcdir}"
   1595   objroot="${objroot}"
   1596 ])
   1597 AC_CONFIG_COMMANDS([include/jemalloc/jemalloc_mangle_jet.h], [
   1598   mkdir -p "${objroot}include/jemalloc"
   1599   "${srcdir}/include/jemalloc/jemalloc_mangle.sh" "${objroot}include/jemalloc/internal/public_symbols.txt" jet_ > "${objroot}include/jemalloc/jemalloc_mangle_jet.h"
   1600 ], [
   1601   srcdir="${srcdir}"
   1602   objroot="${objroot}"
   1603 ])
   1604 AC_CONFIG_COMMANDS([include/jemalloc/jemalloc.h], [
   1605   mkdir -p "${objroot}include/jemalloc"
   1606   "${srcdir}/include/jemalloc/jemalloc.sh" "${objroot}" > "${objroot}include/jemalloc/jemalloc${install_suffix}.h"
   1607 ], [
   1608   srcdir="${srcdir}"
   1609   objroot="${objroot}"
   1610   install_suffix="${install_suffix}"
   1611 ])
   1612 
   1613 dnl Process .in files.
   1614 AC_SUBST([cfghdrs_in])
   1615 AC_SUBST([cfghdrs_out])
   1616 AC_CONFIG_HEADERS([$cfghdrs_tup])
   1617 
   1618 dnl ============================================================================
   1619 dnl Generate outputs.
   1620 
   1621 AC_CONFIG_FILES([$cfgoutputs_tup config.stamp bin/jemalloc-config bin/jemalloc.sh bin/jeprof])
   1622 AC_SUBST([cfgoutputs_in])
   1623 AC_SUBST([cfgoutputs_out])
   1624 AC_OUTPUT
   1625 
   1626 dnl ============================================================================
   1627 dnl Print out the results of configuration.
   1628 AC_MSG_RESULT([===============================================================================])
   1629 AC_MSG_RESULT([jemalloc version   : ${jemalloc_version}])
   1630 AC_MSG_RESULT([library revision   : ${rev}])
   1631 AC_MSG_RESULT([])
   1632 AC_MSG_RESULT([CONFIG             : ${CONFIG}])
   1633 AC_MSG_RESULT([CC                 : ${CC}])
   1634 AC_MSG_RESULT([CFLAGS             : ${CFLAGS}])
   1635 AC_MSG_RESULT([CPPFLAGS           : ${CPPFLAGS}])
   1636 AC_MSG_RESULT([LDFLAGS            : ${LDFLAGS}])
   1637 AC_MSG_RESULT([EXTRA_LDFLAGS      : ${EXTRA_LDFLAGS}])
   1638 AC_MSG_RESULT([LIBS               : ${LIBS}])
   1639 AC_MSG_RESULT([RPATH_EXTRA        : ${RPATH_EXTRA}])
   1640 AC_MSG_RESULT([])
   1641 AC_MSG_RESULT([XSLTPROC           : ${XSLTPROC}])
   1642 AC_MSG_RESULT([XSLROOT            : ${XSLROOT}])
   1643 AC_MSG_RESULT([])
   1644 AC_MSG_RESULT([PREFIX             : ${PREFIX}])
   1645 AC_MSG_RESULT([BINDIR             : ${BINDIR}])
   1646 AC_MSG_RESULT([DATADIR            : ${DATADIR}])
   1647 AC_MSG_RESULT([INCLUDEDIR         : ${INCLUDEDIR}])
   1648 AC_MSG_RESULT([LIBDIR             : ${LIBDIR}])
   1649 AC_MSG_RESULT([MANDIR             : ${MANDIR}])
   1650 AC_MSG_RESULT([])
   1651 AC_MSG_RESULT([srcroot            : ${srcroot}])
   1652 AC_MSG_RESULT([abs_srcroot        : ${abs_srcroot}])
   1653 AC_MSG_RESULT([objroot            : ${objroot}])
   1654 AC_MSG_RESULT([abs_objroot        : ${abs_objroot}])
   1655 AC_MSG_RESULT([])
   1656 AC_MSG_RESULT([JEMALLOC_PREFIX    : ${JEMALLOC_PREFIX}])
   1657 AC_MSG_RESULT([JEMALLOC_PRIVATE_NAMESPACE])
   1658 AC_MSG_RESULT([                   : ${JEMALLOC_PRIVATE_NAMESPACE}])
   1659 AC_MSG_RESULT([install_suffix     : ${install_suffix}])
   1660 AC_MSG_RESULT([autogen            : ${enable_autogen}])
   1661 AC_MSG_RESULT([cc-silence         : ${enable_cc_silence}])
   1662 AC_MSG_RESULT([debug              : ${enable_debug}])
   1663 AC_MSG_RESULT([code-coverage      : ${enable_code_coverage}])
   1664 AC_MSG_RESULT([stats              : ${enable_stats}])
   1665 AC_MSG_RESULT([prof               : ${enable_prof}])
   1666 AC_MSG_RESULT([prof-libunwind     : ${enable_prof_libunwind}])
   1667 AC_MSG_RESULT([prof-libgcc        : ${enable_prof_libgcc}])
   1668 AC_MSG_RESULT([prof-gcc           : ${enable_prof_gcc}])
   1669 AC_MSG_RESULT([tcache             : ${enable_tcache}])
   1670 AC_MSG_RESULT([fill               : ${enable_fill}])
   1671 AC_MSG_RESULT([utrace             : ${enable_utrace}])
   1672 AC_MSG_RESULT([valgrind           : ${enable_valgrind}])
   1673 AC_MSG_RESULT([xmalloc            : ${enable_xmalloc}])
   1674 AC_MSG_RESULT([munmap             : ${enable_munmap}])
   1675 AC_MSG_RESULT([lazy_lock          : ${enable_lazy_lock}])
   1676 AC_MSG_RESULT([tls                : ${enable_tls}])
   1677 AC_MSG_RESULT([cache-oblivious    : ${enable_cache_oblivious}])
   1678 AC_MSG_RESULT([===============================================================================])
   1679