1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/memory/jemalloc/src/configure.ac Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,1296 @@ 1.4 +dnl Process this file with autoconf to produce a configure script. 1.5 +AC_INIT([Makefile.in]) 1.6 + 1.7 +dnl ============================================================================ 1.8 +dnl Custom macro definitions. 1.9 + 1.10 +dnl JE_CFLAGS_APPEND(cflag) 1.11 +AC_DEFUN([JE_CFLAGS_APPEND], 1.12 +[ 1.13 +AC_MSG_CHECKING([whether compiler supports $1]) 1.14 +TCFLAGS="${CFLAGS}" 1.15 +if test "x${CFLAGS}" = "x" ; then 1.16 + CFLAGS="$1" 1.17 +else 1.18 + CFLAGS="${CFLAGS} $1" 1.19 +fi 1.20 +AC_COMPILE_IFELSE([AC_LANG_PROGRAM( 1.21 +[[ 1.22 +]], [[ 1.23 + return 0; 1.24 +]])], 1.25 + AC_MSG_RESULT([yes]), 1.26 + AC_MSG_RESULT([no]) 1.27 + [CFLAGS="${TCFLAGS}"] 1.28 +) 1.29 +]) 1.30 + 1.31 +dnl JE_COMPILABLE(label, hcode, mcode, rvar) 1.32 +dnl 1.33 +dnl Use AC_LINK_IFELSE() rather than AC_COMPILE_IFELSE() so that linker errors 1.34 +dnl cause failure. 1.35 +AC_DEFUN([JE_COMPILABLE], 1.36 +[ 1.37 +AC_CACHE_CHECK([whether $1 is compilable], 1.38 + [$4], 1.39 + [AC_LINK_IFELSE([AC_LANG_PROGRAM([$2], 1.40 + [$3])], 1.41 + [$4=yes], 1.42 + [$4=no])]) 1.43 +]) 1.44 + 1.45 +dnl ============================================================================ 1.46 + 1.47 +dnl Library revision. 1.48 +rev=1 1.49 +AC_SUBST([rev]) 1.50 + 1.51 +srcroot=$srcdir 1.52 +if test "x${srcroot}" = "x." ; then 1.53 + srcroot="" 1.54 +else 1.55 + srcroot="${srcroot}/" 1.56 +fi 1.57 +AC_SUBST([srcroot]) 1.58 +abs_srcroot="`cd \"${srcdir}\"; pwd`/" 1.59 +AC_SUBST([abs_srcroot]) 1.60 + 1.61 +objroot="" 1.62 +AC_SUBST([objroot]) 1.63 +abs_objroot="`pwd`/" 1.64 +AC_SUBST([abs_objroot]) 1.65 + 1.66 +dnl Munge install path variables. 1.67 +if test "x$prefix" = "xNONE" ; then 1.68 + prefix="/usr/local" 1.69 +fi 1.70 +if test "x$exec_prefix" = "xNONE" ; then 1.71 + exec_prefix=$prefix 1.72 +fi 1.73 +PREFIX=$prefix 1.74 +AC_SUBST([PREFIX]) 1.75 +BINDIR=`eval echo $bindir` 1.76 +BINDIR=`eval echo $BINDIR` 1.77 +AC_SUBST([BINDIR]) 1.78 +INCLUDEDIR=`eval echo $includedir` 1.79 +INCLUDEDIR=`eval echo $INCLUDEDIR` 1.80 +AC_SUBST([INCLUDEDIR]) 1.81 +LIBDIR=`eval echo $libdir` 1.82 +LIBDIR=`eval echo $LIBDIR` 1.83 +AC_SUBST([LIBDIR]) 1.84 +DATADIR=`eval echo $datadir` 1.85 +DATADIR=`eval echo $DATADIR` 1.86 +AC_SUBST([DATADIR]) 1.87 +MANDIR=`eval echo $mandir` 1.88 +MANDIR=`eval echo $MANDIR` 1.89 +AC_SUBST([MANDIR]) 1.90 + 1.91 +dnl Support for building documentation. 1.92 +AC_PATH_PROG([XSLTPROC], [xsltproc], , [$PATH]) 1.93 +if test -d "/usr/share/xml/docbook/stylesheet/docbook-xsl" ; then 1.94 + DEFAULT_XSLROOT="/usr/share/xml/docbook/stylesheet/docbook-xsl" 1.95 +elif test -d "/usr/share/sgml/docbook/xsl-stylesheets" ; then 1.96 + DEFAULT_XSLROOT="/usr/share/sgml/docbook/xsl-stylesheets" 1.97 +else 1.98 + dnl Documentation building will fail if this default gets used. 1.99 + DEFAULT_XSLROOT="" 1.100 +fi 1.101 +AC_ARG_WITH([xslroot], 1.102 + [AS_HELP_STRING([--with-xslroot=<path>], [XSL stylesheet root path])], [ 1.103 +if test "x$with_xslroot" = "xno" ; then 1.104 + XSLROOT="${DEFAULT_XSLROOT}" 1.105 +else 1.106 + XSLROOT="${with_xslroot}" 1.107 +fi 1.108 +], 1.109 + XSLROOT="${DEFAULT_XSLROOT}" 1.110 +) 1.111 +AC_SUBST([XSLROOT]) 1.112 + 1.113 +dnl If CFLAGS isn't defined, set CFLAGS to something reasonable. Otherwise, 1.114 +dnl just prevent autoconf from molesting CFLAGS. 1.115 +CFLAGS=$CFLAGS 1.116 +AC_PROG_CC 1.117 +if test "x$GCC" != "xyes" ; then 1.118 + AC_CACHE_CHECK([whether compiler is MSVC], 1.119 + [je_cv_msvc], 1.120 + [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], 1.121 + [ 1.122 +#ifndef _MSC_VER 1.123 + int fail[-1]; 1.124 +#endif 1.125 +])], 1.126 + [je_cv_msvc=yes], 1.127 + [je_cv_msvc=no])]) 1.128 +fi 1.129 + 1.130 +if test "x$CFLAGS" = "x" ; then 1.131 + no_CFLAGS="yes" 1.132 + if test "x$GCC" = "xyes" ; then 1.133 + JE_CFLAGS_APPEND([-std=gnu99]) 1.134 + JE_CFLAGS_APPEND([-Wall]) 1.135 + JE_CFLAGS_APPEND([-pipe]) 1.136 + JE_CFLAGS_APPEND([-g3]) 1.137 + elif test "x$je_cv_msvc" = "xyes" ; then 1.138 + CC="$CC -nologo" 1.139 + JE_CFLAGS_APPEND([-Zi]) 1.140 + JE_CFLAGS_APPEND([-MT]) 1.141 + JE_CFLAGS_APPEND([-W3]) 1.142 + CPPFLAGS="$CPPFLAGS -I${srcroot}/include/msvc_compat" 1.143 + fi 1.144 +fi 1.145 +dnl Append EXTRA_CFLAGS to CFLAGS, if defined. 1.146 +if test "x$EXTRA_CFLAGS" != "x" ; then 1.147 + JE_CFLAGS_APPEND([$EXTRA_CFLAGS]) 1.148 +fi 1.149 +AC_PROG_CPP 1.150 + 1.151 +AC_CHECK_SIZEOF([void *]) 1.152 +if test "x${ac_cv_sizeof_void_p}" = "x8" ; then 1.153 + LG_SIZEOF_PTR=3 1.154 +elif test "x${ac_cv_sizeof_void_p}" = "x4" ; then 1.155 + LG_SIZEOF_PTR=2 1.156 +else 1.157 + AC_MSG_ERROR([Unsupported pointer size: ${ac_cv_sizeof_void_p}]) 1.158 +fi 1.159 +AC_DEFINE_UNQUOTED([LG_SIZEOF_PTR], [$LG_SIZEOF_PTR]) 1.160 + 1.161 +AC_CHECK_SIZEOF([int]) 1.162 +if test "x${ac_cv_sizeof_int}" = "x8" ; then 1.163 + LG_SIZEOF_INT=3 1.164 +elif test "x${ac_cv_sizeof_int}" = "x4" ; then 1.165 + LG_SIZEOF_INT=2 1.166 +else 1.167 + AC_MSG_ERROR([Unsupported int size: ${ac_cv_sizeof_int}]) 1.168 +fi 1.169 +AC_DEFINE_UNQUOTED([LG_SIZEOF_INT], [$LG_SIZEOF_INT]) 1.170 + 1.171 +AC_CHECK_SIZEOF([long]) 1.172 +if test "x${ac_cv_sizeof_long}" = "x8" ; then 1.173 + LG_SIZEOF_LONG=3 1.174 +elif test "x${ac_cv_sizeof_long}" = "x4" ; then 1.175 + LG_SIZEOF_LONG=2 1.176 +else 1.177 + AC_MSG_ERROR([Unsupported long size: ${ac_cv_sizeof_long}]) 1.178 +fi 1.179 +AC_DEFINE_UNQUOTED([LG_SIZEOF_LONG], [$LG_SIZEOF_LONG]) 1.180 + 1.181 +AC_CHECK_SIZEOF([intmax_t]) 1.182 +if test "x${ac_cv_sizeof_intmax_t}" = "x16" ; then 1.183 + LG_SIZEOF_INTMAX_T=4 1.184 +elif test "x${ac_cv_sizeof_intmax_t}" = "x8" ; then 1.185 + LG_SIZEOF_INTMAX_T=3 1.186 +elif test "x${ac_cv_sizeof_intmax_t}" = "x4" ; then 1.187 + LG_SIZEOF_INTMAX_T=2 1.188 +else 1.189 + AC_MSG_ERROR([Unsupported intmax_t size: ${ac_cv_sizeof_intmax_t}]) 1.190 +fi 1.191 +AC_DEFINE_UNQUOTED([LG_SIZEOF_INTMAX_T], [$LG_SIZEOF_INTMAX_T]) 1.192 + 1.193 +AC_CANONICAL_HOST 1.194 +dnl CPU-specific settings. 1.195 +CPU_SPINWAIT="" 1.196 +case "${host_cpu}" in 1.197 + i[[345]]86) 1.198 + ;; 1.199 + i686) 1.200 + JE_COMPILABLE([__asm__], [], [[__asm__ volatile("pause"); return 0;]], 1.201 + [je_cv_asm]) 1.202 + if test "x${je_cv_asm}" = "xyes" ; then 1.203 + CPU_SPINWAIT='__asm__ volatile("pause")' 1.204 + fi 1.205 + ;; 1.206 + x86_64) 1.207 + JE_COMPILABLE([__asm__ syntax], [], 1.208 + [[__asm__ volatile("pause"); return 0;]], [je_cv_asm]) 1.209 + if test "x${je_cv_asm}" = "xyes" ; then 1.210 + CPU_SPINWAIT='__asm__ volatile("pause")' 1.211 + fi 1.212 + ;; 1.213 + *) 1.214 + ;; 1.215 +esac 1.216 +AC_DEFINE_UNQUOTED([CPU_SPINWAIT], [$CPU_SPINWAIT]) 1.217 + 1.218 +LD_PRELOAD_VAR="LD_PRELOAD" 1.219 +so="so" 1.220 +importlib="${so}" 1.221 +o="$ac_objext" 1.222 +a="a" 1.223 +exe="$ac_exeext" 1.224 +libprefix="lib" 1.225 +DSO_LDFLAGS='-shared -Wl,-soname,$(@F)' 1.226 +RPATH='-Wl,-rpath,$(1)' 1.227 +SOREV="${so}.${rev}" 1.228 +PIC_CFLAGS='-fPIC -DPIC' 1.229 +CTARGET='-o $@' 1.230 +LDTARGET='-o $@' 1.231 +EXTRA_LDFLAGS= 1.232 +MKLIB='ar crus $@' 1.233 +CC_MM=1 1.234 + 1.235 +dnl Platform-specific settings. abi and RPATH can probably be determined 1.236 +dnl programmatically, but doing so is error-prone, which makes it generally 1.237 +dnl not worth the trouble. 1.238 +dnl 1.239 +dnl Define cpp macros in CPPFLAGS, rather than doing AC_DEFINE(macro), since the 1.240 +dnl definitions need to be seen before any headers are included, which is a pain 1.241 +dnl to make happen otherwise. 1.242 +default_munmap="1" 1.243 +JEMALLOC_USABLE_SIZE_CONST="const" 1.244 +case "${host}" in 1.245 + *-*-darwin*) 1.246 + CFLAGS="$CFLAGS" 1.247 + abi="macho" 1.248 + AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ]) 1.249 + RPATH="" 1.250 + LD_PRELOAD_VAR="DYLD_INSERT_LIBRARIES" 1.251 + so="dylib" 1.252 + importlib="${so}" 1.253 + force_tls="0" 1.254 + DSO_LDFLAGS='-shared -Wl,-dylib_install_name,$(@F)' 1.255 + SOREV="${rev}.${so}" 1.256 + ;; 1.257 + *-*-freebsd*) 1.258 + CFLAGS="$CFLAGS" 1.259 + abi="elf" 1.260 + AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ]) 1.261 + force_lazy_lock="1" 1.262 + ;; 1.263 + *-*-linux*) 1.264 + CFLAGS="$CFLAGS" 1.265 + CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE" 1.266 + abi="elf" 1.267 + AC_DEFINE([JEMALLOC_PURGE_MADVISE_DONTNEED], [ ]) 1.268 + AC_DEFINE([JEMALLOC_THREADED_INIT], [ ]) 1.269 + JEMALLOC_USABLE_SIZE_CONST="" 1.270 + default_munmap="0" 1.271 + ;; 1.272 + *-*-netbsd*) 1.273 + AC_MSG_CHECKING([ABI]) 1.274 + AC_COMPILE_IFELSE([AC_LANG_PROGRAM( 1.275 +[[#ifdef __ELF__ 1.276 +/* ELF */ 1.277 +#else 1.278 +#error aout 1.279 +#endif 1.280 +]])], 1.281 + [CFLAGS="$CFLAGS"; abi="elf"], 1.282 + [abi="aout"]) 1.283 + AC_MSG_RESULT([$abi]) 1.284 + AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ]) 1.285 + ;; 1.286 + *-*-solaris2*) 1.287 + CFLAGS="$CFLAGS" 1.288 + abi="elf" 1.289 + RPATH='-Wl,-R,$(1)' 1.290 + dnl Solaris needs this for sigwait(). 1.291 + CPPFLAGS="$CPPFLAGS -D_POSIX_PTHREAD_SEMANTICS" 1.292 + LIBS="$LIBS -lposix4 -lsocket -lnsl" 1.293 + ;; 1.294 + *-ibm-aix*) 1.295 + if "$LG_SIZEOF_PTR" = "8"; then 1.296 + dnl 64bit AIX 1.297 + LD_PRELOAD_VAR="LDR_PRELOAD64" 1.298 + else 1.299 + dnl 32bit AIX 1.300 + LD_PRELOAD_VAR="LDR_PRELOAD" 1.301 + fi 1.302 + abi="xcoff" 1.303 + ;; 1.304 + *-*-mingw*) 1.305 + abi="pecoff" 1.306 + force_tls="0" 1.307 + RPATH="" 1.308 + so="dll" 1.309 + if test "x$je_cv_msvc" = "xyes" ; then 1.310 + importlib="lib" 1.311 + DSO_LDFLAGS="-LD" 1.312 + EXTRA_LDFLAGS="-link -DEBUG" 1.313 + CTARGET='-Fo$@' 1.314 + LDTARGET='-Fe$@' 1.315 + MKLIB='lib -nologo -out:$@' 1.316 + CC_MM= 1.317 + else 1.318 + importlib="${so}" 1.319 + DSO_LDFLAGS="-shared" 1.320 + fi 1.321 + a="lib" 1.322 + libprefix="" 1.323 + SOREV="${so}" 1.324 + PIC_CFLAGS="" 1.325 + ;; 1.326 + *) 1.327 + AC_MSG_RESULT([Unsupported operating system: ${host}]) 1.328 + abi="elf" 1.329 + ;; 1.330 +esac 1.331 +AC_DEFINE_UNQUOTED([JEMALLOC_USABLE_SIZE_CONST], [$JEMALLOC_USABLE_SIZE_CONST]) 1.332 +AC_SUBST([abi]) 1.333 +AC_SUBST([RPATH]) 1.334 +AC_SUBST([LD_PRELOAD_VAR]) 1.335 +AC_SUBST([so]) 1.336 +AC_SUBST([importlib]) 1.337 +AC_SUBST([o]) 1.338 +AC_SUBST([a]) 1.339 +AC_SUBST([exe]) 1.340 +AC_SUBST([libprefix]) 1.341 +AC_SUBST([DSO_LDFLAGS]) 1.342 +AC_SUBST([EXTRA_LDFLAGS]) 1.343 +AC_SUBST([SOREV]) 1.344 +AC_SUBST([PIC_CFLAGS]) 1.345 +AC_SUBST([CTARGET]) 1.346 +AC_SUBST([LDTARGET]) 1.347 +AC_SUBST([MKLIB]) 1.348 +AC_SUBST([CC_MM]) 1.349 + 1.350 +if test "x$abi" != "xpecoff"; then 1.351 + dnl Heap profiling uses the log(3) function. 1.352 + LIBS="$LIBS -lm" 1.353 +fi 1.354 + 1.355 +JE_COMPILABLE([__attribute__ syntax], 1.356 + [static __attribute__((unused)) void foo(void){}], 1.357 + [], 1.358 + [je_cv_attribute]) 1.359 +if test "x${je_cv_attribute}" = "xyes" ; then 1.360 + AC_DEFINE([JEMALLOC_HAVE_ATTR], [ ]) 1.361 + if test "x${GCC}" = "xyes" -a "x${abi}" = "xelf"; then 1.362 + JE_CFLAGS_APPEND([-fvisibility=hidden]) 1.363 + fi 1.364 +fi 1.365 +dnl Check for tls_model attribute support (clang 3.0 still lacks support). 1.366 +SAVED_CFLAGS="${CFLAGS}" 1.367 +JE_CFLAGS_APPEND([-Werror]) 1.368 +JE_COMPILABLE([tls_model attribute], [], 1.369 + [static __thread int 1.370 + __attribute__((tls_model("initial-exec"))) foo; 1.371 + foo = 0;], 1.372 + [je_cv_tls_model]) 1.373 +CFLAGS="${SAVED_CFLAGS}" 1.374 +if test "x${je_cv_tls_model}" = "xyes" ; then 1.375 + AC_DEFINE([JEMALLOC_TLS_MODEL], 1.376 + [__attribute__((tls_model("initial-exec")))]) 1.377 +else 1.378 + AC_DEFINE([JEMALLOC_TLS_MODEL], [ ]) 1.379 +fi 1.380 + 1.381 +dnl Support optional additions to rpath. 1.382 +AC_ARG_WITH([rpath], 1.383 + [AS_HELP_STRING([--with-rpath=<rpath>], [Colon-separated rpath (ELF systems only)])], 1.384 +if test "x$with_rpath" = "xno" ; then 1.385 + RPATH_EXTRA= 1.386 +else 1.387 + RPATH_EXTRA="`echo $with_rpath | tr \":\" \" \"`" 1.388 +fi, 1.389 + RPATH_EXTRA= 1.390 +) 1.391 +AC_SUBST([RPATH_EXTRA]) 1.392 + 1.393 +dnl Disable rules that do automatic regeneration of configure output by default. 1.394 +AC_ARG_ENABLE([autogen], 1.395 + [AS_HELP_STRING([--enable-autogen], [Automatically regenerate configure output])], 1.396 +if test "x$enable_autogen" = "xno" ; then 1.397 + enable_autogen="0" 1.398 +else 1.399 + enable_autogen="1" 1.400 +fi 1.401 +, 1.402 +enable_autogen="0" 1.403 +) 1.404 +AC_SUBST([enable_autogen]) 1.405 + 1.406 +AC_PROG_INSTALL 1.407 +AC_PROG_RANLIB 1.408 +AC_PATH_PROG([AR], [ar], , [$PATH]) 1.409 +AC_PATH_PROG([LD], [ld], , [$PATH]) 1.410 +AC_PATH_PROG([AUTOCONF], [autoconf], , [$PATH]) 1.411 + 1.412 +public_syms="malloc_conf malloc_message malloc calloc posix_memalign aligned_alloc realloc free malloc_usable_size malloc_stats_print mallctl mallctlnametomib mallctlbymib" 1.413 + 1.414 +dnl Check for allocator-related functions that should be wrapped. 1.415 +AC_CHECK_FUNC([memalign], 1.416 + [AC_DEFINE([JEMALLOC_OVERRIDE_MEMALIGN], [ ]) 1.417 + public_syms="${public_syms} memalign"]) 1.418 +AC_CHECK_FUNC([valloc], 1.419 + [AC_DEFINE([JEMALLOC_OVERRIDE_VALLOC], [ ]) 1.420 + public_syms="${public_syms} valloc"]) 1.421 + 1.422 +dnl Support the experimental API by default. 1.423 +AC_ARG_ENABLE([experimental], 1.424 + [AS_HELP_STRING([--disable-experimental], 1.425 + [Disable support for the experimental API])], 1.426 +[if test "x$enable_experimental" = "xno" ; then 1.427 + enable_experimental="0" 1.428 +else 1.429 + enable_experimental="1" 1.430 +fi 1.431 +], 1.432 +[enable_experimental="1"] 1.433 +) 1.434 +if test "x$enable_experimental" = "x1" ; then 1.435 + AC_DEFINE([JEMALLOC_EXPERIMENTAL], [ ]) 1.436 + public_syms="${public_syms} allocm dallocm nallocm rallocm sallocm" 1.437 +fi 1.438 +AC_SUBST([enable_experimental]) 1.439 + 1.440 +dnl Perform no name mangling by default. 1.441 +AC_ARG_WITH([mangling], 1.442 + [AS_HELP_STRING([--with-mangling=<map>], [Mangle symbols in <map>])], 1.443 + [mangling_map="$with_mangling"], [mangling_map=""]) 1.444 +for nm in `echo ${mangling_map} |tr ',' ' '` ; do 1.445 + k="`echo ${nm} |tr ':' ' ' |awk '{print $1}'`" 1.446 + n="je_${k}" 1.447 + m=`echo ${nm} |tr ':' ' ' |awk '{print $2}'` 1.448 + AC_DEFINE_UNQUOTED([${n}], [${m}]) 1.449 + dnl Remove key from public_syms so that it isn't redefined later. 1.450 + public_syms=`for sym in ${public_syms}; do echo "${sym}"; done |grep -v "^${k}\$" |tr '\n' ' '` 1.451 +done 1.452 + 1.453 +dnl Do not prefix public APIs by default. 1.454 +AC_ARG_WITH([jemalloc_prefix], 1.455 + [AS_HELP_STRING([--with-jemalloc-prefix=<prefix>], [Prefix to prepend to all public APIs])], 1.456 + [JEMALLOC_PREFIX="$with_jemalloc_prefix"], 1.457 + [if test "x$abi" != "xmacho" -a "x$abi" != "xpecoff"; then 1.458 + JEMALLOC_PREFIX="" 1.459 +else 1.460 + JEMALLOC_PREFIX="je_" 1.461 +fi] 1.462 +) 1.463 +if test "x$JEMALLOC_PREFIX" != "x" ; then 1.464 + JEMALLOC_CPREFIX=`echo ${JEMALLOC_PREFIX} | tr "a-z" "A-Z"` 1.465 + AC_DEFINE_UNQUOTED([JEMALLOC_PREFIX], ["$JEMALLOC_PREFIX"]) 1.466 + AC_DEFINE_UNQUOTED([JEMALLOC_CPREFIX], ["$JEMALLOC_CPREFIX"]) 1.467 +fi 1.468 +dnl Generate macros to rename public symbols. All public symbols are prefixed 1.469 +dnl with je_ in the source code, so these macro definitions are needed even if 1.470 +dnl --with-jemalloc-prefix wasn't specified. 1.471 +for stem in ${public_syms}; do 1.472 + n="je_${stem}" 1.473 + m="${JEMALLOC_PREFIX}${stem}" 1.474 + AC_DEFINE_UNQUOTED([${n}], [${m}]) 1.475 +done 1.476 + 1.477 +AC_ARG_WITH([export], 1.478 + [AS_HELP_STRING([--without-export], [disable exporting jemalloc public APIs])], 1.479 + [if test "x$with_export" = "xno"; then 1.480 + AC_DEFINE([JEMALLOC_EXPORT],[])] 1.481 +fi] 1.482 +) 1.483 + 1.484 +dnl Do not mangle library-private APIs by default. 1.485 +AC_ARG_WITH([private_namespace], 1.486 + [AS_HELP_STRING([--with-private-namespace=<prefix>], [Prefix to prepend to all library-private APIs])], 1.487 + [JEMALLOC_PRIVATE_NAMESPACE="$with_private_namespace"], 1.488 + [JEMALLOC_PRIVATE_NAMESPACE=""] 1.489 +) 1.490 +AC_DEFINE_UNQUOTED([JEMALLOC_PRIVATE_NAMESPACE], ["$JEMALLOC_PRIVATE_NAMESPACE"]) 1.491 +if test "x$JEMALLOC_PRIVATE_NAMESPACE" != "x" ; then 1.492 + AC_DEFINE_UNQUOTED([JEMALLOC_N(string_that_no_one_should_want_to_use_as_a_jemalloc_private_namespace_prefix)], [${JEMALLOC_PRIVATE_NAMESPACE}##string_that_no_one_should_want_to_use_as_a_jemalloc_private_namespace_prefix]) 1.493 +else 1.494 + AC_DEFINE_UNQUOTED([JEMALLOC_N(string_that_no_one_should_want_to_use_as_a_jemalloc_private_namespace_prefix)], [string_that_no_one_should_want_to_use_as_a_jemalloc_private_namespace_prefix]) 1.495 +fi 1.496 + 1.497 +dnl Do not add suffix to installed files by default. 1.498 +AC_ARG_WITH([install_suffix], 1.499 + [AS_HELP_STRING([--with-install-suffix=<suffix>], [Suffix to append to all installed files])], 1.500 + [INSTALL_SUFFIX="$with_install_suffix"], 1.501 + [INSTALL_SUFFIX=] 1.502 +) 1.503 +install_suffix="$INSTALL_SUFFIX" 1.504 +AC_SUBST([install_suffix]) 1.505 + 1.506 +cfgoutputs_in="${srcroot}Makefile.in" 1.507 +cfgoutputs_in="${cfgoutputs_in} ${srcroot}doc/html.xsl.in" 1.508 +cfgoutputs_in="${cfgoutputs_in} ${srcroot}doc/manpages.xsl.in" 1.509 +cfgoutputs_in="${cfgoutputs_in} ${srcroot}doc/jemalloc.xml.in" 1.510 +cfgoutputs_in="${cfgoutputs_in} ${srcroot}include/jemalloc/jemalloc.h.in" 1.511 +cfgoutputs_in="${cfgoutputs_in} ${srcroot}include/jemalloc/internal/jemalloc_internal.h.in" 1.512 +cfgoutputs_in="${cfgoutputs_in} ${srcroot}test/jemalloc_test.h.in" 1.513 + 1.514 +cfgoutputs_out="Makefile" 1.515 +cfgoutputs_out="${cfgoutputs_out} doc/html.xsl" 1.516 +cfgoutputs_out="${cfgoutputs_out} doc/manpages.xsl" 1.517 +cfgoutputs_out="${cfgoutputs_out} doc/jemalloc${install_suffix}.xml" 1.518 +cfgoutputs_out="${cfgoutputs_out} include/jemalloc/jemalloc${install_suffix}.h" 1.519 +cfgoutputs_out="${cfgoutputs_out} include/jemalloc/internal/jemalloc_internal.h" 1.520 +cfgoutputs_out="${cfgoutputs_out} test/jemalloc_test.h" 1.521 + 1.522 +cfgoutputs_tup="Makefile" 1.523 +cfgoutputs_tup="${cfgoutputs_tup} doc/html.xsl:doc/html.xsl.in" 1.524 +cfgoutputs_tup="${cfgoutputs_tup} doc/manpages.xsl:doc/manpages.xsl.in" 1.525 +cfgoutputs_tup="${cfgoutputs_tup} doc/jemalloc${install_suffix}.xml:doc/jemalloc.xml.in" 1.526 +cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/jemalloc${install_suffix}.h:include/jemalloc/jemalloc.h.in" 1.527 +cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/internal/jemalloc_internal.h" 1.528 +cfgoutputs_tup="${cfgoutputs_tup} test/jemalloc_test.h:test/jemalloc_test.h.in" 1.529 + 1.530 +cfghdrs_in="${srcroot}include/jemalloc/jemalloc_defs.h.in" 1.531 +cfghdrs_in="${cfghdrs_in} ${srcroot}include/jemalloc/internal/size_classes.sh" 1.532 + 1.533 +cfghdrs_out="include/jemalloc/jemalloc_defs${install_suffix}.h" 1.534 +cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/size_classes.h" 1.535 + 1.536 +cfghdrs_tup="include/jemalloc/jemalloc_defs${install_suffix}.h:include/jemalloc/jemalloc_defs.h.in" 1.537 + 1.538 +dnl Do not silence irrelevant compiler warnings by default, since enabling this 1.539 +dnl option incurs a performance penalty. 1.540 +AC_ARG_ENABLE([cc-silence], 1.541 + [AS_HELP_STRING([--enable-cc-silence], 1.542 + [Silence irrelevant compiler warnings])], 1.543 +[if test "x$enable_cc_silence" = "xno" ; then 1.544 + enable_cc_silence="0" 1.545 +else 1.546 + enable_cc_silence="1" 1.547 +fi 1.548 +], 1.549 +[enable_cc_silence="0"] 1.550 +) 1.551 +if test "x$enable_cc_silence" = "x1" ; then 1.552 + AC_DEFINE([JEMALLOC_CC_SILENCE], [ ]) 1.553 +fi 1.554 + 1.555 +dnl Do not compile with debugging by default. 1.556 +AC_ARG_ENABLE([debug], 1.557 + [AS_HELP_STRING([--enable-debug], [Build debugging code])], 1.558 +[if test "x$enable_debug" = "xno" ; then 1.559 + enable_debug="0" 1.560 +else 1.561 + enable_debug="1" 1.562 +fi 1.563 +], 1.564 +[enable_debug="0"] 1.565 +) 1.566 +if test "x$enable_debug" = "x1" ; then 1.567 + AC_DEFINE([JEMALLOC_DEBUG], [ ]) 1.568 + AC_DEFINE([JEMALLOC_IVSALLOC], [ ]) 1.569 +fi 1.570 +AC_SUBST([enable_debug]) 1.571 + 1.572 +dnl Only optimize if not debugging. 1.573 +if test "x$enable_debug" = "x0" -a "x$no_CFLAGS" = "xyes" ; then 1.574 + dnl Make sure that an optimization flag was not specified in EXTRA_CFLAGS. 1.575 + optimize="no" 1.576 + echo "$EXTRA_CFLAGS" | grep "\-O" >/dev/null || optimize="yes" 1.577 + if test "x${optimize}" = "xyes" ; then 1.578 + if test "x$GCC" = "xyes" ; then 1.579 + JE_CFLAGS_APPEND([-O3]) 1.580 + JE_CFLAGS_APPEND([-funroll-loops]) 1.581 + elif test "x$je_cv_msvc" = "xyes" ; then 1.582 + JE_CFLAGS_APPEND([-O2]) 1.583 + else 1.584 + JE_CFLAGS_APPEND([-O]) 1.585 + fi 1.586 + fi 1.587 +fi 1.588 + 1.589 +dnl Enable statistics calculation by default. 1.590 +AC_ARG_ENABLE([stats], 1.591 + [AS_HELP_STRING([--disable-stats], 1.592 + [Disable statistics calculation/reporting])], 1.593 +[if test "x$enable_stats" = "xno" ; then 1.594 + enable_stats="0" 1.595 +else 1.596 + enable_stats="1" 1.597 +fi 1.598 +], 1.599 +[enable_stats="1"] 1.600 +) 1.601 +if test "x$enable_stats" = "x1" ; then 1.602 + AC_DEFINE([JEMALLOC_STATS], [ ]) 1.603 +fi 1.604 +AC_SUBST([enable_stats]) 1.605 + 1.606 +dnl Do not enable profiling by default. 1.607 +AC_ARG_ENABLE([prof], 1.608 + [AS_HELP_STRING([--enable-prof], [Enable allocation profiling])], 1.609 +[if test "x$enable_prof" = "xno" ; then 1.610 + enable_prof="0" 1.611 +else 1.612 + enable_prof="1" 1.613 +fi 1.614 +], 1.615 +[enable_prof="0"] 1.616 +) 1.617 +if test "x$enable_prof" = "x1" ; then 1.618 + backtrace_method="" 1.619 +else 1.620 + backtrace_method="N/A" 1.621 +fi 1.622 + 1.623 +AC_ARG_ENABLE([prof-libunwind], 1.624 + [AS_HELP_STRING([--enable-prof-libunwind], [Use libunwind for backtracing])], 1.625 +[if test "x$enable_prof_libunwind" = "xno" ; then 1.626 + enable_prof_libunwind="0" 1.627 +else 1.628 + enable_prof_libunwind="1" 1.629 +fi 1.630 +], 1.631 +[enable_prof_libunwind="0"] 1.632 +) 1.633 +AC_ARG_WITH([static_libunwind], 1.634 + [AS_HELP_STRING([--with-static-libunwind=<libunwind.a>], 1.635 + [Path to static libunwind library; use rather than dynamically linking])], 1.636 +if test "x$with_static_libunwind" = "xno" ; then 1.637 + LUNWIND="-lunwind" 1.638 +else 1.639 + if test ! -f "$with_static_libunwind" ; then 1.640 + AC_MSG_ERROR([Static libunwind not found: $with_static_libunwind]) 1.641 + fi 1.642 + LUNWIND="$with_static_libunwind" 1.643 +fi, 1.644 + LUNWIND="-lunwind" 1.645 +) 1.646 +if test "x$backtrace_method" = "x" -a "x$enable_prof_libunwind" = "x1" ; then 1.647 + AC_CHECK_HEADERS([libunwind.h], , [enable_prof_libunwind="0"]) 1.648 + if test "x$LUNWIND" = "x-lunwind" ; then 1.649 + AC_CHECK_LIB([unwind], [backtrace], [LIBS="$LIBS $LUNWIND"], 1.650 + [enable_prof_libunwind="0"]) 1.651 + else 1.652 + LIBS="$LIBS $LUNWIND" 1.653 + fi 1.654 + if test "x${enable_prof_libunwind}" = "x1" ; then 1.655 + backtrace_method="libunwind" 1.656 + AC_DEFINE([JEMALLOC_PROF_LIBUNWIND], [ ]) 1.657 + fi 1.658 +fi 1.659 + 1.660 +AC_ARG_ENABLE([prof-libgcc], 1.661 + [AS_HELP_STRING([--disable-prof-libgcc], 1.662 + [Do not use libgcc for backtracing])], 1.663 +[if test "x$enable_prof_libgcc" = "xno" ; then 1.664 + enable_prof_libgcc="0" 1.665 +else 1.666 + enable_prof_libgcc="1" 1.667 +fi 1.668 +], 1.669 +[enable_prof_libgcc="1"] 1.670 +) 1.671 +if test "x$backtrace_method" = "x" -a "x$enable_prof_libgcc" = "x1" \ 1.672 + -a "x$GCC" = "xyes" ; then 1.673 + AC_CHECK_HEADERS([unwind.h], , [enable_prof_libgcc="0"]) 1.674 + AC_CHECK_LIB([gcc], [_Unwind_Backtrace], [LIBS="$LIBS -lgcc"], [enable_prof_libgcc="0"]) 1.675 + dnl The following is conservative, in that it only has entries for CPUs on 1.676 + dnl which jemalloc has been tested. 1.677 + AC_MSG_CHECKING([libgcc-based backtracing reliability on ${host_cpu}]) 1.678 + case "${host_cpu}" in 1.679 + i[[3456]]86) 1.680 + AC_MSG_RESULT([unreliable]) 1.681 + enable_prof_libgcc="0"; 1.682 + ;; 1.683 + x86_64) 1.684 + AC_MSG_RESULT([reliable]) 1.685 + ;; 1.686 + *) 1.687 + AC_MSG_RESULT([unreliable]) 1.688 + enable_prof_libgcc="0"; 1.689 + ;; 1.690 + esac 1.691 + if test "x${enable_prof_libgcc}" = "x1" ; then 1.692 + backtrace_method="libgcc" 1.693 + AC_DEFINE([JEMALLOC_PROF_LIBGCC], [ ]) 1.694 + fi 1.695 +else 1.696 + enable_prof_libgcc="0" 1.697 +fi 1.698 + 1.699 +AC_ARG_ENABLE([prof-gcc], 1.700 + [AS_HELP_STRING([--disable-prof-gcc], 1.701 + [Do not use gcc intrinsics for backtracing])], 1.702 +[if test "x$enable_prof_gcc" = "xno" ; then 1.703 + enable_prof_gcc="0" 1.704 +else 1.705 + enable_prof_gcc="1" 1.706 +fi 1.707 +], 1.708 +[enable_prof_gcc="1"] 1.709 +) 1.710 +if test "x$backtrace_method" = "x" -a "x$enable_prof_gcc" = "x1" \ 1.711 + -a "x$GCC" = "xyes" ; then 1.712 + backtrace_method="gcc intrinsics" 1.713 + AC_DEFINE([JEMALLOC_PROF_GCC], [ ]) 1.714 +else 1.715 + enable_prof_gcc="0" 1.716 +fi 1.717 + 1.718 +if test "x$backtrace_method" = "x" ; then 1.719 + backtrace_method="none (disabling profiling)" 1.720 + enable_prof="0" 1.721 +fi 1.722 +AC_MSG_CHECKING([configured backtracing method]) 1.723 +AC_MSG_RESULT([$backtrace_method]) 1.724 +if test "x$enable_prof" = "x1" ; then 1.725 + if test "x${force_tls}" = "x0" ; then 1.726 + AC_MSG_ERROR([Heap profiling requires TLS]); 1.727 + fi 1.728 + force_tls="1" 1.729 + AC_DEFINE([JEMALLOC_PROF], [ ]) 1.730 +fi 1.731 +AC_SUBST([enable_prof]) 1.732 + 1.733 +dnl Enable thread-specific caching by default. 1.734 +AC_ARG_ENABLE([tcache], 1.735 + [AS_HELP_STRING([--disable-tcache], [Disable per thread caches])], 1.736 +[if test "x$enable_tcache" = "xno" ; then 1.737 + enable_tcache="0" 1.738 +else 1.739 + enable_tcache="1" 1.740 +fi 1.741 +], 1.742 +[enable_tcache="1"] 1.743 +) 1.744 +if test "x$enable_tcache" = "x1" ; then 1.745 + AC_DEFINE([JEMALLOC_TCACHE], [ ]) 1.746 +fi 1.747 +AC_SUBST([enable_tcache]) 1.748 + 1.749 +dnl Disable mremap() for huge realloc() by default. 1.750 +AC_ARG_ENABLE([mremap], 1.751 + [AS_HELP_STRING([--enable-mremap], [Enable mremap(2) for huge realloc()])], 1.752 +[if test "x$enable_mremap" = "xno" ; then 1.753 + enable_mremap="0" 1.754 +else 1.755 + enable_mremap="1" 1.756 +fi 1.757 +], 1.758 +[enable_mremap="0"] 1.759 +) 1.760 +if test "x$enable_mremap" = "x1" ; then 1.761 + JE_COMPILABLE([mremap(...MREMAP_FIXED...)], [ 1.762 +#define _GNU_SOURCE 1.763 +#include <sys/mman.h> 1.764 +], [ 1.765 +void *p = mremap((void *)0, 0, 0, MREMAP_MAYMOVE|MREMAP_FIXED, (void *)0); 1.766 +], [je_cv_mremap_fixed]) 1.767 + if test "x${je_cv_mremap_fixed}" = "xno" ; then 1.768 + enable_mremap="0" 1.769 + fi 1.770 +fi 1.771 +if test "x$enable_mremap" = "x1" ; then 1.772 + AC_DEFINE([JEMALLOC_MREMAP], [ ]) 1.773 +fi 1.774 +AC_SUBST([enable_mremap]) 1.775 + 1.776 +dnl Enable VM deallocation via munmap() by default. 1.777 +AC_ARG_ENABLE([munmap], 1.778 + [AS_HELP_STRING([--disable-munmap], [Disable VM deallocation via munmap(2)])], 1.779 +[if test "x$enable_munmap" = "xno" ; then 1.780 + enable_munmap="0" 1.781 +else 1.782 + enable_munmap="1" 1.783 +fi 1.784 +], 1.785 +[enable_munmap="${default_munmap}"] 1.786 +) 1.787 +if test "x$enable_munmap" = "x1" ; then 1.788 + AC_DEFINE([JEMALLOC_MUNMAP], [ ]) 1.789 +fi 1.790 +AC_SUBST([enable_munmap]) 1.791 + 1.792 +dnl Do not enable allocation from DSS by default. 1.793 +AC_ARG_ENABLE([dss], 1.794 + [AS_HELP_STRING([--enable-dss], [Enable allocation from DSS])], 1.795 +[if test "x$enable_dss" = "xno" ; then 1.796 + enable_dss="0" 1.797 +else 1.798 + enable_dss="1" 1.799 +fi 1.800 +], 1.801 +[enable_dss="0"] 1.802 +) 1.803 +dnl Check whether the BSD/SUSv1 sbrk() exists. If not, disable DSS support. 1.804 +AC_CHECK_FUNC([sbrk], [have_sbrk="1"], [have_sbrk="0"]) 1.805 +if test "x$have_sbrk" = "x1" ; then 1.806 + AC_DEFINE([JEMALLOC_HAVE_SBRK], [ ]) 1.807 +else 1.808 + enable_dss="0" 1.809 +fi 1.810 + 1.811 +if test "x$enable_dss" = "x1" ; then 1.812 + AC_DEFINE([JEMALLOC_DSS], [ ]) 1.813 +fi 1.814 +AC_SUBST([enable_dss]) 1.815 + 1.816 +dnl Support the junk/zero filling option by default. 1.817 +AC_ARG_ENABLE([fill], 1.818 + [AS_HELP_STRING([--disable-fill], 1.819 + [Disable support for junk/zero filling, quarantine, and redzones])], 1.820 +[if test "x$enable_fill" = "xno" ; then 1.821 + enable_fill="0" 1.822 +else 1.823 + enable_fill="1" 1.824 +fi 1.825 +], 1.826 +[enable_fill="1"] 1.827 +) 1.828 +if test "x$enable_fill" = "x1" ; then 1.829 + AC_DEFINE([JEMALLOC_FILL], [ ]) 1.830 +fi 1.831 +AC_SUBST([enable_fill]) 1.832 + 1.833 +dnl Disable utrace(2)-based tracing by default. 1.834 +AC_ARG_ENABLE([utrace], 1.835 + [AS_HELP_STRING([--enable-utrace], [Enable utrace(2)-based tracing])], 1.836 +[if test "x$enable_utrace" = "xno" ; then 1.837 + enable_utrace="0" 1.838 +else 1.839 + enable_utrace="1" 1.840 +fi 1.841 +], 1.842 +[enable_utrace="0"] 1.843 +) 1.844 +JE_COMPILABLE([utrace(2)], [ 1.845 +#include <sys/types.h> 1.846 +#include <sys/param.h> 1.847 +#include <sys/time.h> 1.848 +#include <sys/uio.h> 1.849 +#include <sys/ktrace.h> 1.850 +], [ 1.851 + utrace((void *)0, 0); 1.852 +], [je_cv_utrace]) 1.853 +if test "x${je_cv_utrace}" = "xno" ; then 1.854 + enable_utrace="0" 1.855 +fi 1.856 +if test "x$enable_utrace" = "x1" ; then 1.857 + AC_DEFINE([JEMALLOC_UTRACE], [ ]) 1.858 +fi 1.859 +AC_SUBST([enable_utrace]) 1.860 + 1.861 +dnl Support Valgrind by default. 1.862 +AC_ARG_ENABLE([valgrind], 1.863 + [AS_HELP_STRING([--disable-valgrind], [Disable support for Valgrind])], 1.864 +[if test "x$enable_valgrind" = "xno" ; then 1.865 + enable_valgrind="0" 1.866 +else 1.867 + enable_valgrind="1" 1.868 +fi 1.869 +], 1.870 +[enable_valgrind="1"] 1.871 +) 1.872 +if test "x$enable_valgrind" = "x1" ; then 1.873 + JE_COMPILABLE([valgrind], [ 1.874 +#include <valgrind/valgrind.h> 1.875 +#include <valgrind/memcheck.h> 1.876 + 1.877 +#if !defined(VALGRIND_RESIZEINPLACE_BLOCK) 1.878 +# error "Incompatible Valgrind version" 1.879 +#endif 1.880 +], [], [je_cv_valgrind]) 1.881 + if test "x${je_cv_valgrind}" = "xno" ; then 1.882 + enable_valgrind="0" 1.883 + fi 1.884 + if test "x$enable_valgrind" = "x1" ; then 1.885 + AC_DEFINE([JEMALLOC_VALGRIND], [ ]) 1.886 + fi 1.887 +fi 1.888 +AC_SUBST([enable_valgrind]) 1.889 + 1.890 +dnl Do not support the xmalloc option by default. 1.891 +AC_ARG_ENABLE([xmalloc], 1.892 + [AS_HELP_STRING([--enable-xmalloc], [Support xmalloc option])], 1.893 +[if test "x$enable_xmalloc" = "xno" ; then 1.894 + enable_xmalloc="0" 1.895 +else 1.896 + enable_xmalloc="1" 1.897 +fi 1.898 +], 1.899 +[enable_xmalloc="0"] 1.900 +) 1.901 +if test "x$enable_xmalloc" = "x1" ; then 1.902 + AC_DEFINE([JEMALLOC_XMALLOC], [ ]) 1.903 +fi 1.904 +AC_SUBST([enable_xmalloc]) 1.905 + 1.906 +AC_CACHE_CHECK([STATIC_PAGE_SHIFT], 1.907 + [je_cv_static_page_shift], 1.908 + AC_RUN_IFELSE([AC_LANG_PROGRAM( 1.909 +[[ 1.910 +#include <strings.h> 1.911 +#ifdef _WIN32 1.912 +#include <windows.h> 1.913 +#else 1.914 +#include <unistd.h> 1.915 +#endif 1.916 +#include <stdio.h> 1.917 +]], 1.918 +[[ 1.919 + long result; 1.920 + FILE *f; 1.921 + 1.922 +#ifdef _WIN32 1.923 + SYSTEM_INFO si; 1.924 + GetSystemInfo(&si); 1.925 + result = si.dwPageSize; 1.926 +#else 1.927 + result = sysconf(_SC_PAGESIZE); 1.928 +#endif 1.929 + if (result == -1) { 1.930 + return 1; 1.931 + } 1.932 + result = ffsl(result) - 1; 1.933 + 1.934 + f = fopen("conftest.out", "w"); 1.935 + if (f == NULL) { 1.936 + return 1; 1.937 + } 1.938 + fprintf(f, "%u\n", result); 1.939 + fclose(f); 1.940 + 1.941 + return 0; 1.942 +]])], 1.943 + [je_cv_static_page_shift=`cat conftest.out`], 1.944 + [je_cv_static_page_shift=undefined])) 1.945 + 1.946 +if test "x$je_cv_static_page_shift" != "xundefined"; then 1.947 + AC_DEFINE_UNQUOTED([STATIC_PAGE_SHIFT], [$je_cv_static_page_shift]) 1.948 +else 1.949 + AC_MSG_ERROR([cannot determine value for STATIC_PAGE_SHIFT]) 1.950 +fi 1.951 + 1.952 +dnl ============================================================================ 1.953 +dnl jemalloc configuration. 1.954 +dnl 1.955 + 1.956 +dnl Set VERSION if source directory has an embedded git repository. 1.957 +if test -d "${srcroot}.git" ; then 1.958 + git describe --long --abbrev=40 > ${srcroot}VERSION 1.959 +fi 1.960 +jemalloc_version=`cat ${srcroot}VERSION` 1.961 +jemalloc_version_major=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]1}'` 1.962 +jemalloc_version_minor=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]2}'` 1.963 +jemalloc_version_bugfix=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]3}'` 1.964 +jemalloc_version_nrev=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]4}'` 1.965 +jemalloc_version_gid=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]5}'` 1.966 +AC_SUBST([jemalloc_version]) 1.967 +AC_SUBST([jemalloc_version_major]) 1.968 +AC_SUBST([jemalloc_version_minor]) 1.969 +AC_SUBST([jemalloc_version_bugfix]) 1.970 +AC_SUBST([jemalloc_version_nrev]) 1.971 +AC_SUBST([jemalloc_version_gid]) 1.972 + 1.973 +dnl ============================================================================ 1.974 +dnl Configure pthreads. 1.975 + 1.976 +if test "x$abi" != "xpecoff" ; then 1.977 + AC_CHECK_HEADERS([pthread.h], , [AC_MSG_ERROR([pthread.h is missing])]) 1.978 + dnl Some systems may embed pthreads functionality in libc; check for libpthread 1.979 + dnl first, but try libc too before failing. 1.980 + AC_CHECK_LIB([pthread], [pthread_create], [LIBS="$LIBS -lpthread"], 1.981 + [AC_SEARCH_LIBS([pthread_create], , , 1.982 + AC_MSG_ERROR([libpthread is missing]))]) 1.983 +fi 1.984 + 1.985 +CPPFLAGS="$CPPFLAGS -D_REENTRANT" 1.986 + 1.987 +dnl Check whether the BSD-specific _malloc_thread_cleanup() exists. If so, use 1.988 +dnl it rather than pthreads TSD cleanup functions to support cleanup during 1.989 +dnl thread exit, in order to avoid pthreads library recursion during 1.990 +dnl bootstrapping. 1.991 +AC_CHECK_FUNC([_malloc_thread_cleanup], 1.992 + [have__malloc_thread_cleanup="1"], 1.993 + [have__malloc_thread_cleanup="0"] 1.994 + ) 1.995 +if test "x$have__malloc_thread_cleanup" = "x1" ; then 1.996 + AC_DEFINE([JEMALLOC_MALLOC_THREAD_CLEANUP], [ ]) 1.997 + force_tls="1" 1.998 +fi 1.999 + 1.1000 +dnl Check whether the BSD-specific _pthread_mutex_init_calloc_cb() exists. If 1.1001 +dnl so, mutex initialization causes allocation, and we need to implement this 1.1002 +dnl callback function in order to prevent recursive allocation. 1.1003 +AC_CHECK_FUNC([_pthread_mutex_init_calloc_cb], 1.1004 + [have__pthread_mutex_init_calloc_cb="1"], 1.1005 + [have__pthread_mutex_init_calloc_cb="0"] 1.1006 + ) 1.1007 +if test "x$have__pthread_mutex_init_calloc_cb" = "x1" ; then 1.1008 + AC_DEFINE([JEMALLOC_MUTEX_INIT_CB]) 1.1009 +fi 1.1010 + 1.1011 +dnl Disable lazy locking by default. 1.1012 +AC_ARG_ENABLE([lazy_lock], 1.1013 + [AS_HELP_STRING([--enable-lazy-lock], 1.1014 + [Enable lazy locking (only lock when multi-threaded)])], 1.1015 +[if test "x$enable_lazy_lock" = "xno" ; then 1.1016 + enable_lazy_lock="0" 1.1017 +else 1.1018 + enable_lazy_lock="1" 1.1019 +fi 1.1020 +], 1.1021 +[enable_lazy_lock="0"] 1.1022 +) 1.1023 +if test "x$enable_lazy_lock" = "x0" -a "x${force_lazy_lock}" = "x1" ; then 1.1024 + AC_MSG_RESULT([Forcing lazy-lock to avoid allocator/threading bootstrap issues]) 1.1025 + enable_lazy_lock="1" 1.1026 +fi 1.1027 +if test "x$enable_lazy_lock" = "x1" ; then 1.1028 + if test "x$abi" != "xpecoff" ; then 1.1029 + AC_CHECK_HEADERS([dlfcn.h], , [AC_MSG_ERROR([dlfcn.h is missing])]) 1.1030 + AC_CHECK_FUNC([dlsym], [], 1.1031 + [AC_CHECK_LIB([dl], [dlsym], [LIBS="$LIBS -ldl"], 1.1032 + [AC_MSG_ERROR([libdl is missing])]) 1.1033 + ]) 1.1034 + fi 1.1035 + AC_DEFINE([JEMALLOC_LAZY_LOCK], [ ]) 1.1036 +fi 1.1037 +AC_SUBST([enable_lazy_lock]) 1.1038 + 1.1039 +AC_ARG_ENABLE([tls], 1.1040 + [AS_HELP_STRING([--disable-tls], [Disable thread-local storage (__thread keyword)])], 1.1041 +if test "x$enable_tls" = "xno" ; then 1.1042 + enable_tls="0" 1.1043 +else 1.1044 + enable_tls="1" 1.1045 +fi 1.1046 +, 1.1047 +enable_tls="1" 1.1048 +) 1.1049 +if test "x${enable_tls}" = "x0" -a "x${force_tls}" = "x1" ; then 1.1050 + AC_MSG_RESULT([Forcing TLS to avoid allocator/threading bootstrap issues]) 1.1051 + enable_tls="1" 1.1052 +fi 1.1053 +if test "x${enable_tls}" = "x1" -a "x${force_tls}" = "x0" ; then 1.1054 + AC_MSG_RESULT([Forcing no TLS to avoid allocator/threading bootstrap issues]) 1.1055 + enable_tls="0" 1.1056 +fi 1.1057 +if test "x${enable_tls}" = "x1" ; then 1.1058 +AC_MSG_CHECKING([for TLS]) 1.1059 +AC_COMPILE_IFELSE([AC_LANG_PROGRAM( 1.1060 +[[ 1.1061 + __thread int x; 1.1062 +]], [[ 1.1063 + x = 42; 1.1064 + 1.1065 + return 0; 1.1066 +]])], 1.1067 + AC_MSG_RESULT([yes]), 1.1068 + AC_MSG_RESULT([no]) 1.1069 + enable_tls="0") 1.1070 +fi 1.1071 +AC_SUBST([enable_tls]) 1.1072 +if test "x${enable_tls}" = "x1" ; then 1.1073 + AC_DEFINE_UNQUOTED([JEMALLOC_TLS], [ ]) 1.1074 +elif test "x${force_tls}" = "x1" ; then 1.1075 + AC_MSG_ERROR([Failed to configure TLS, which is mandatory for correct function]) 1.1076 +fi 1.1077 + 1.1078 +dnl ============================================================================ 1.1079 +dnl Check for ffsl(3), and fail if not found. This function exists on all 1.1080 +dnl platforms that jemalloc currently has a chance of functioning on without 1.1081 +dnl modification. 1.1082 +JE_COMPILABLE([a program using ffsl], [ 1.1083 +#include <strings.h> 1.1084 +#include <string.h> 1.1085 +], [ 1.1086 + { 1.1087 + int rv = ffsl(0x08); 1.1088 + } 1.1089 +], [je_cv_function_ffsl]) 1.1090 +if test "x${je_cv_function_ffsl}" != "xyes" ; then 1.1091 + AC_MSG_ERROR([Cannot build without ffsl(3)]) 1.1092 +fi 1.1093 + 1.1094 +dnl ============================================================================ 1.1095 +dnl Check for atomic(9) operations as provided on FreeBSD. 1.1096 + 1.1097 +JE_COMPILABLE([atomic(9)], [ 1.1098 +#include <sys/types.h> 1.1099 +#include <machine/atomic.h> 1.1100 +#include <inttypes.h> 1.1101 +], [ 1.1102 + { 1.1103 + uint32_t x32 = 0; 1.1104 + volatile uint32_t *x32p = &x32; 1.1105 + atomic_fetchadd_32(x32p, 1); 1.1106 + } 1.1107 + { 1.1108 + unsigned long xlong = 0; 1.1109 + volatile unsigned long *xlongp = &xlong; 1.1110 + atomic_fetchadd_long(xlongp, 1); 1.1111 + } 1.1112 +], [je_cv_atomic9]) 1.1113 +if test "x${je_cv_atomic9}" = "xyes" ; then 1.1114 + AC_DEFINE([JEMALLOC_ATOMIC9]) 1.1115 +fi 1.1116 + 1.1117 +dnl ============================================================================ 1.1118 +dnl Check for atomic(3) operations as provided on Darwin. 1.1119 + 1.1120 +JE_COMPILABLE([Darwin OSAtomic*()], [ 1.1121 +#include <libkern/OSAtomic.h> 1.1122 +#include <inttypes.h> 1.1123 +], [ 1.1124 + { 1.1125 + int32_t x32 = 0; 1.1126 + volatile int32_t *x32p = &x32; 1.1127 + OSAtomicAdd32(1, x32p); 1.1128 + } 1.1129 + { 1.1130 + int64_t x64 = 0; 1.1131 + volatile int64_t *x64p = &x64; 1.1132 + OSAtomicAdd64(1, x64p); 1.1133 + } 1.1134 +], [je_cv_osatomic]) 1.1135 +if test "x${je_cv_osatomic}" = "xyes" ; then 1.1136 + AC_DEFINE([JEMALLOC_OSATOMIC], [ ]) 1.1137 +fi 1.1138 + 1.1139 +dnl ============================================================================ 1.1140 +dnl Check whether __sync_{add,sub}_and_fetch() are available despite 1.1141 +dnl __GCC_HAVE_SYNC_COMPARE_AND_SWAP_n macros being undefined. 1.1142 + 1.1143 +AC_DEFUN([JE_SYNC_COMPARE_AND_SWAP_CHECK],[ 1.1144 + AC_CACHE_CHECK([whether to force $1-bit __sync_{add,sub}_and_fetch()], 1.1145 + [je_cv_sync_compare_and_swap_$2], 1.1146 + [AC_LINK_IFELSE([AC_LANG_PROGRAM([ 1.1147 + #include <stdint.h> 1.1148 + ], 1.1149 + [ 1.1150 + #ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_$2 1.1151 + { 1.1152 + uint$1_t x$1 = 0; 1.1153 + __sync_add_and_fetch(&x$1, 42); 1.1154 + __sync_sub_and_fetch(&x$1, 1); 1.1155 + } 1.1156 + #else 1.1157 + #error __GCC_HAVE_SYNC_COMPARE_AND_SWAP_$2 is defined, no need to force 1.1158 + #endif 1.1159 + ])], 1.1160 + [je_cv_sync_compare_and_swap_$2=yes], 1.1161 + [je_cv_sync_compare_and_swap_$2=no])]) 1.1162 + 1.1163 + if test "x${je_cv_sync_compare_and_swap_$2}" = "xyes" ; then 1.1164 + AC_DEFINE([JE_FORCE_SYNC_COMPARE_AND_SWAP_$2], [ ]) 1.1165 + fi 1.1166 +]) 1.1167 + 1.1168 +if test "x${je_cv_atomic9}" != "xyes" -a "x${je_cv_osatomic}" != "xyes" ; then 1.1169 + JE_SYNC_COMPARE_AND_SWAP_CHECK(32, 4) 1.1170 + JE_SYNC_COMPARE_AND_SWAP_CHECK(64, 8) 1.1171 +fi 1.1172 + 1.1173 +dnl ============================================================================ 1.1174 +dnl Check for spinlock(3) operations as provided on Darwin. 1.1175 + 1.1176 +JE_COMPILABLE([Darwin OSSpin*()], [ 1.1177 +#include <libkern/OSAtomic.h> 1.1178 +#include <inttypes.h> 1.1179 +], [ 1.1180 + OSSpinLock lock = 0; 1.1181 + OSSpinLockLock(&lock); 1.1182 + OSSpinLockUnlock(&lock); 1.1183 +], [je_cv_osspin]) 1.1184 +if test "x${je_cv_osspin}" = "xyes" ; then 1.1185 + AC_DEFINE([JEMALLOC_OSSPIN], [ ]) 1.1186 +fi 1.1187 + 1.1188 +dnl ============================================================================ 1.1189 +dnl Darwin-related configuration. 1.1190 + 1.1191 +if test "x${abi}" = "xmacho" ; then 1.1192 + AC_DEFINE([JEMALLOC_IVSALLOC], [ ]) 1.1193 + AC_DEFINE([JEMALLOC_ZONE], [ ]) 1.1194 + 1.1195 + dnl The szone version jumped from 3 to 6 between the OS X 10.5.x and 10.6 1.1196 + dnl releases. malloc_zone_t and malloc_introspection_t have new fields in 1.1197 + dnl 10.6, which is the only source-level indication of the change. 1.1198 + AC_MSG_CHECKING([malloc zone version]) 1.1199 + AC_DEFUN([JE_ZONE_PROGRAM], 1.1200 + [AC_LANG_PROGRAM( 1.1201 + [#include <malloc/malloc.h>], 1.1202 + [static foo[[sizeof($1) $2 sizeof(void *) * $3 ? 1 : -1]]] 1.1203 + )]) 1.1204 + 1.1205 + AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,14)],[JEMALLOC_ZONE_VERSION=3],[ 1.1206 + AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,15)],[JEMALLOC_ZONE_VERSION=5],[ 1.1207 + AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,16)],[ 1.1208 + AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_introspection_t,==,9)],[JEMALLOC_ZONE_VERSION=6],[ 1.1209 + AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_introspection_t,==,13)],[JEMALLOC_ZONE_VERSION=7],[JEMALLOC_ZONE_VERSION=] 1.1210 + )])],[ 1.1211 + AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,17)],[JEMALLOC_ZONE_VERSION=8],[ 1.1212 + AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,>,17)],[JEMALLOC_ZONE_VERSION=9],[JEMALLOC_ZONE_VERSION=] 1.1213 + )])])])]) 1.1214 + if test "x${JEMALLOC_ZONE_VERSION}" = "x"; then 1.1215 + AC_MSG_RESULT([unsupported]) 1.1216 + AC_MSG_ERROR([Unsupported malloc zone version]) 1.1217 + fi 1.1218 + if test "${JEMALLOC_ZONE_VERSION}" = 9; then 1.1219 + JEMALLOC_ZONE_VERSION=8 1.1220 + AC_MSG_RESULT([> 8]) 1.1221 + else 1.1222 + AC_MSG_RESULT([$JEMALLOC_ZONE_VERSION]) 1.1223 + fi 1.1224 + AC_DEFINE_UNQUOTED(JEMALLOC_ZONE_VERSION, [$JEMALLOC_ZONE_VERSION]) 1.1225 +fi 1.1226 + 1.1227 +dnl ============================================================================ 1.1228 +dnl Check for typedefs, structures, and compiler characteristics. 1.1229 +AC_HEADER_STDBOOL 1.1230 + 1.1231 +AC_CONFIG_COMMANDS([include/jemalloc/internal/size_classes.h], [ 1.1232 + mkdir -p "include/jemalloc/internal" 1.1233 + "${srcdir}/include/jemalloc/internal/size_classes.sh" > "${objroot}include/jemalloc/internal/size_classes.h" 1.1234 +]) 1.1235 + 1.1236 +dnl Process .in files. 1.1237 +AC_SUBST([cfghdrs_in]) 1.1238 +AC_SUBST([cfghdrs_out]) 1.1239 +AC_CONFIG_HEADERS([$cfghdrs_tup]) 1.1240 + 1.1241 +dnl ============================================================================ 1.1242 +dnl Generate outputs. 1.1243 +AC_CONFIG_FILES([$cfgoutputs_tup config.stamp bin/jemalloc.sh]) 1.1244 +AC_SUBST([cfgoutputs_in]) 1.1245 +AC_SUBST([cfgoutputs_out]) 1.1246 +AC_OUTPUT 1.1247 + 1.1248 +dnl ============================================================================ 1.1249 +dnl Print out the results of configuration. 1.1250 +AC_MSG_RESULT([===============================================================================]) 1.1251 +AC_MSG_RESULT([jemalloc version : ${jemalloc_version}]) 1.1252 +AC_MSG_RESULT([library revision : ${rev}]) 1.1253 +AC_MSG_RESULT([]) 1.1254 +AC_MSG_RESULT([CC : ${CC}]) 1.1255 +AC_MSG_RESULT([CPPFLAGS : ${CPPFLAGS}]) 1.1256 +AC_MSG_RESULT([CFLAGS : ${CFLAGS}]) 1.1257 +AC_MSG_RESULT([LDFLAGS : ${LDFLAGS}]) 1.1258 +AC_MSG_RESULT([LIBS : ${LIBS}]) 1.1259 +AC_MSG_RESULT([RPATH_EXTRA : ${RPATH_EXTRA}]) 1.1260 +AC_MSG_RESULT([]) 1.1261 +AC_MSG_RESULT([XSLTPROC : ${XSLTPROC}]) 1.1262 +AC_MSG_RESULT([XSLROOT : ${XSLROOT}]) 1.1263 +AC_MSG_RESULT([]) 1.1264 +AC_MSG_RESULT([PREFIX : ${PREFIX}]) 1.1265 +AC_MSG_RESULT([BINDIR : ${BINDIR}]) 1.1266 +AC_MSG_RESULT([INCLUDEDIR : ${INCLUDEDIR}]) 1.1267 +AC_MSG_RESULT([LIBDIR : ${LIBDIR}]) 1.1268 +AC_MSG_RESULT([DATADIR : ${DATADIR}]) 1.1269 +AC_MSG_RESULT([MANDIR : ${MANDIR}]) 1.1270 +AC_MSG_RESULT([]) 1.1271 +AC_MSG_RESULT([srcroot : ${srcroot}]) 1.1272 +AC_MSG_RESULT([abs_srcroot : ${abs_srcroot}]) 1.1273 +AC_MSG_RESULT([objroot : ${objroot}]) 1.1274 +AC_MSG_RESULT([abs_objroot : ${abs_objroot}]) 1.1275 +AC_MSG_RESULT([]) 1.1276 +AC_MSG_RESULT([JEMALLOC_PREFIX : ${JEMALLOC_PREFIX}]) 1.1277 +AC_MSG_RESULT([JEMALLOC_PRIVATE_NAMESPACE]) 1.1278 +AC_MSG_RESULT([ : ${JEMALLOC_PRIVATE_NAMESPACE}]) 1.1279 +AC_MSG_RESULT([install_suffix : ${install_suffix}]) 1.1280 +AC_MSG_RESULT([autogen : ${enable_autogen}]) 1.1281 +AC_MSG_RESULT([experimental : ${enable_experimental}]) 1.1282 +AC_MSG_RESULT([cc-silence : ${enable_cc_silence}]) 1.1283 +AC_MSG_RESULT([debug : ${enable_debug}]) 1.1284 +AC_MSG_RESULT([stats : ${enable_stats}]) 1.1285 +AC_MSG_RESULT([prof : ${enable_prof}]) 1.1286 +AC_MSG_RESULT([prof-libunwind : ${enable_prof_libunwind}]) 1.1287 +AC_MSG_RESULT([prof-libgcc : ${enable_prof_libgcc}]) 1.1288 +AC_MSG_RESULT([prof-gcc : ${enable_prof_gcc}]) 1.1289 +AC_MSG_RESULT([tcache : ${enable_tcache}]) 1.1290 +AC_MSG_RESULT([fill : ${enable_fill}]) 1.1291 +AC_MSG_RESULT([utrace : ${enable_utrace}]) 1.1292 +AC_MSG_RESULT([valgrind : ${enable_valgrind}]) 1.1293 +AC_MSG_RESULT([xmalloc : ${enable_xmalloc}]) 1.1294 +AC_MSG_RESULT([mremap : ${enable_mremap}]) 1.1295 +AC_MSG_RESULT([munmap : ${enable_munmap}]) 1.1296 +AC_MSG_RESULT([dss : ${enable_dss}]) 1.1297 +AC_MSG_RESULT([lazy_lock : ${enable_lazy_lock}]) 1.1298 +AC_MSG_RESULT([tls : ${enable_tls}]) 1.1299 +AC_MSG_RESULT([===============================================================================])