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