memory/jemalloc/src/configure.ac

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 dnl Process this file with autoconf to produce a configure script.
     2 AC_INIT([Makefile.in])
     4 dnl ============================================================================
     5 dnl Custom macro definitions.
     7 dnl JE_CFLAGS_APPEND(cflag)
     8 AC_DEFUN([JE_CFLAGS_APPEND],
     9 [
    10 AC_MSG_CHECKING([whether compiler supports $1])
    11 TCFLAGS="${CFLAGS}"
    12 if test "x${CFLAGS}" = "x" ; then
    13   CFLAGS="$1"
    14 else
    15   CFLAGS="${CFLAGS} $1"
    16 fi
    17 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
    18 [[
    19 ]], [[
    20     return 0;
    21 ]])],
    22               AC_MSG_RESULT([yes]),
    23               AC_MSG_RESULT([no])
    24               [CFLAGS="${TCFLAGS}"]
    25 )
    26 ])
    28 dnl JE_COMPILABLE(label, hcode, mcode, rvar)
    29 dnl 
    30 dnl Use AC_LINK_IFELSE() rather than AC_COMPILE_IFELSE() so that linker errors
    31 dnl cause failure.
    32 AC_DEFUN([JE_COMPILABLE],
    33 [
    34 AC_CACHE_CHECK([whether $1 is compilable],
    35                [$4],
    36                [AC_LINK_IFELSE([AC_LANG_PROGRAM([$2],
    37                                                 [$3])],
    38                                [$4=yes],
    39                                [$4=no])])
    40 ])
    42 dnl ============================================================================
    44 dnl Library revision.
    45 rev=1
    46 AC_SUBST([rev])
    48 srcroot=$srcdir
    49 if test "x${srcroot}" = "x." ; then
    50   srcroot=""
    51 else
    52   srcroot="${srcroot}/"
    53 fi
    54 AC_SUBST([srcroot])
    55 abs_srcroot="`cd \"${srcdir}\"; pwd`/"
    56 AC_SUBST([abs_srcroot])
    58 objroot=""
    59 AC_SUBST([objroot])
    60 abs_objroot="`pwd`/"
    61 AC_SUBST([abs_objroot])
    63 dnl Munge install path variables.
    64 if test "x$prefix" = "xNONE" ; then
    65   prefix="/usr/local"
    66 fi
    67 if test "x$exec_prefix" = "xNONE" ; then
    68   exec_prefix=$prefix
    69 fi
    70 PREFIX=$prefix
    71 AC_SUBST([PREFIX])
    72 BINDIR=`eval echo $bindir`
    73 BINDIR=`eval echo $BINDIR`
    74 AC_SUBST([BINDIR])
    75 INCLUDEDIR=`eval echo $includedir`
    76 INCLUDEDIR=`eval echo $INCLUDEDIR`
    77 AC_SUBST([INCLUDEDIR])
    78 LIBDIR=`eval echo $libdir`
    79 LIBDIR=`eval echo $LIBDIR`
    80 AC_SUBST([LIBDIR])
    81 DATADIR=`eval echo $datadir`
    82 DATADIR=`eval echo $DATADIR`
    83 AC_SUBST([DATADIR])
    84 MANDIR=`eval echo $mandir`
    85 MANDIR=`eval echo $MANDIR`
    86 AC_SUBST([MANDIR])
    88 dnl Support for building documentation.
    89 AC_PATH_PROG([XSLTPROC], [xsltproc], , [$PATH])
    90 if test -d "/usr/share/xml/docbook/stylesheet/docbook-xsl" ; then
    91   DEFAULT_XSLROOT="/usr/share/xml/docbook/stylesheet/docbook-xsl"
    92 elif test -d "/usr/share/sgml/docbook/xsl-stylesheets" ; then
    93   DEFAULT_XSLROOT="/usr/share/sgml/docbook/xsl-stylesheets"
    94 else
    95   dnl Documentation building will fail if this default gets used.
    96   DEFAULT_XSLROOT=""
    97 fi
    98 AC_ARG_WITH([xslroot],
    99   [AS_HELP_STRING([--with-xslroot=<path>], [XSL stylesheet root path])], [
   100 if test "x$with_xslroot" = "xno" ; then
   101   XSLROOT="${DEFAULT_XSLROOT}"
   102 else
   103   XSLROOT="${with_xslroot}"
   104 fi
   105 ],
   106   XSLROOT="${DEFAULT_XSLROOT}"
   107 )
   108 AC_SUBST([XSLROOT])
   110 dnl If CFLAGS isn't defined, set CFLAGS to something reasonable.  Otherwise,
   111 dnl just prevent autoconf from molesting CFLAGS.
   112 CFLAGS=$CFLAGS
   113 AC_PROG_CC
   114 if test "x$GCC" != "xyes" ; then
   115   AC_CACHE_CHECK([whether compiler is MSVC],
   116                  [je_cv_msvc],
   117                  [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
   118                                                      [
   119 #ifndef _MSC_VER
   120   int fail[-1];
   121 #endif
   122 ])],
   123                                [je_cv_msvc=yes],
   124                                [je_cv_msvc=no])])
   125 fi
   127 if test "x$CFLAGS" = "x" ; then
   128   no_CFLAGS="yes"
   129   if test "x$GCC" = "xyes" ; then
   130     JE_CFLAGS_APPEND([-std=gnu99])
   131     JE_CFLAGS_APPEND([-Wall])
   132     JE_CFLAGS_APPEND([-pipe])
   133     JE_CFLAGS_APPEND([-g3])
   134   elif test "x$je_cv_msvc" = "xyes" ; then
   135     CC="$CC -nologo"
   136     JE_CFLAGS_APPEND([-Zi])
   137     JE_CFLAGS_APPEND([-MT])
   138     JE_CFLAGS_APPEND([-W3])
   139     CPPFLAGS="$CPPFLAGS -I${srcroot}/include/msvc_compat"
   140   fi
   141 fi
   142 dnl Append EXTRA_CFLAGS to CFLAGS, if defined.
   143 if test "x$EXTRA_CFLAGS" != "x" ; then
   144   JE_CFLAGS_APPEND([$EXTRA_CFLAGS])
   145 fi
   146 AC_PROG_CPP
   148 AC_CHECK_SIZEOF([void *])
   149 if test "x${ac_cv_sizeof_void_p}" = "x8" ; then
   150   LG_SIZEOF_PTR=3
   151 elif test "x${ac_cv_sizeof_void_p}" = "x4" ; then
   152   LG_SIZEOF_PTR=2
   153 else
   154   AC_MSG_ERROR([Unsupported pointer size: ${ac_cv_sizeof_void_p}])
   155 fi
   156 AC_DEFINE_UNQUOTED([LG_SIZEOF_PTR], [$LG_SIZEOF_PTR])
   158 AC_CHECK_SIZEOF([int])
   159 if test "x${ac_cv_sizeof_int}" = "x8" ; then
   160   LG_SIZEOF_INT=3
   161 elif test "x${ac_cv_sizeof_int}" = "x4" ; then
   162   LG_SIZEOF_INT=2
   163 else
   164   AC_MSG_ERROR([Unsupported int size: ${ac_cv_sizeof_int}])
   165 fi
   166 AC_DEFINE_UNQUOTED([LG_SIZEOF_INT], [$LG_SIZEOF_INT])
   168 AC_CHECK_SIZEOF([long])
   169 if test "x${ac_cv_sizeof_long}" = "x8" ; then
   170   LG_SIZEOF_LONG=3
   171 elif test "x${ac_cv_sizeof_long}" = "x4" ; then
   172   LG_SIZEOF_LONG=2
   173 else
   174   AC_MSG_ERROR([Unsupported long size: ${ac_cv_sizeof_long}])
   175 fi
   176 AC_DEFINE_UNQUOTED([LG_SIZEOF_LONG], [$LG_SIZEOF_LONG])
   178 AC_CHECK_SIZEOF([intmax_t])
   179 if test "x${ac_cv_sizeof_intmax_t}" = "x16" ; then
   180   LG_SIZEOF_INTMAX_T=4
   181 elif test "x${ac_cv_sizeof_intmax_t}" = "x8" ; then
   182   LG_SIZEOF_INTMAX_T=3
   183 elif test "x${ac_cv_sizeof_intmax_t}" = "x4" ; then
   184   LG_SIZEOF_INTMAX_T=2
   185 else
   186   AC_MSG_ERROR([Unsupported intmax_t size: ${ac_cv_sizeof_intmax_t}])
   187 fi
   188 AC_DEFINE_UNQUOTED([LG_SIZEOF_INTMAX_T], [$LG_SIZEOF_INTMAX_T])
   190 AC_CANONICAL_HOST
   191 dnl CPU-specific settings.
   192 CPU_SPINWAIT=""
   193 case "${host_cpu}" in
   194   i[[345]]86)
   195 	;;
   196   i686)
   197 	JE_COMPILABLE([__asm__], [], [[__asm__ volatile("pause"); return 0;]],
   198 	              [je_cv_asm])
   199 	if test "x${je_cv_asm}" = "xyes" ; then
   200 	    CPU_SPINWAIT='__asm__ volatile("pause")'
   201 	fi
   202 	;;
   203   x86_64)
   204 	JE_COMPILABLE([__asm__ syntax], [],
   205 	              [[__asm__ volatile("pause"); return 0;]], [je_cv_asm])
   206 	if test "x${je_cv_asm}" = "xyes" ; then
   207 	    CPU_SPINWAIT='__asm__ volatile("pause")'
   208 	fi
   209 	;;
   210   *)
   211 	;;
   212 esac
   213 AC_DEFINE_UNQUOTED([CPU_SPINWAIT], [$CPU_SPINWAIT])
   215 LD_PRELOAD_VAR="LD_PRELOAD"
   216 so="so"
   217 importlib="${so}"
   218 o="$ac_objext"
   219 a="a"
   220 exe="$ac_exeext"
   221 libprefix="lib"
   222 DSO_LDFLAGS='-shared -Wl,-soname,$(@F)'
   223 RPATH='-Wl,-rpath,$(1)'
   224 SOREV="${so}.${rev}"
   225 PIC_CFLAGS='-fPIC -DPIC'
   226 CTARGET='-o $@'
   227 LDTARGET='-o $@'
   228 EXTRA_LDFLAGS=
   229 MKLIB='ar crus $@'
   230 CC_MM=1
   232 dnl Platform-specific settings.  abi and RPATH can probably be determined
   233 dnl programmatically, but doing so is error-prone, which makes it generally
   234 dnl not worth the trouble.
   235 dnl 
   236 dnl Define cpp macros in CPPFLAGS, rather than doing AC_DEFINE(macro), since the
   237 dnl definitions need to be seen before any headers are included, which is a pain
   238 dnl to make happen otherwise.
   239 default_munmap="1"
   240 JEMALLOC_USABLE_SIZE_CONST="const"
   241 case "${host}" in
   242   *-*-darwin*)
   243 	CFLAGS="$CFLAGS"
   244 	abi="macho"
   245 	AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ])
   246 	RPATH=""
   247 	LD_PRELOAD_VAR="DYLD_INSERT_LIBRARIES"
   248 	so="dylib"
   249 	importlib="${so}"
   250 	force_tls="0"
   251 	DSO_LDFLAGS='-shared -Wl,-dylib_install_name,$(@F)'
   252 	SOREV="${rev}.${so}"
   253 	;;
   254   *-*-freebsd*)
   255 	CFLAGS="$CFLAGS"
   256 	abi="elf"
   257 	AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ])
   258 	force_lazy_lock="1"
   259 	;;
   260   *-*-linux*)
   261 	CFLAGS="$CFLAGS"
   262 	CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
   263 	abi="elf"
   264 	AC_DEFINE([JEMALLOC_PURGE_MADVISE_DONTNEED], [ ])
   265 	AC_DEFINE([JEMALLOC_THREADED_INIT], [ ])
   266 	JEMALLOC_USABLE_SIZE_CONST=""
   267 	default_munmap="0"
   268 	;;
   269   *-*-netbsd*)
   270 	AC_MSG_CHECKING([ABI])
   271         AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
   272 [[#ifdef __ELF__
   273 /* ELF */
   274 #else
   275 #error aout
   276 #endif
   277 ]])],
   278                           [CFLAGS="$CFLAGS"; abi="elf"],
   279                           [abi="aout"])
   280 	AC_MSG_RESULT([$abi])
   281 	AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ])
   282 	;;
   283   *-*-solaris2*)
   284 	CFLAGS="$CFLAGS"
   285 	abi="elf"
   286 	RPATH='-Wl,-R,$(1)'
   287 	dnl Solaris needs this for sigwait().
   288 	CPPFLAGS="$CPPFLAGS -D_POSIX_PTHREAD_SEMANTICS"
   289 	LIBS="$LIBS -lposix4 -lsocket -lnsl"
   290 	;;
   291   *-ibm-aix*)
   292 	if "$LG_SIZEOF_PTR" = "8"; then
   293 	  dnl 64bit AIX
   294 	  LD_PRELOAD_VAR="LDR_PRELOAD64"
   295 	else
   296 	  dnl 32bit AIX
   297 	  LD_PRELOAD_VAR="LDR_PRELOAD"
   298 	fi
   299 	abi="xcoff"
   300 	;;
   301   *-*-mingw*)
   302 	abi="pecoff"
   303 	force_tls="0"
   304 	RPATH=""
   305 	so="dll"
   306 	if test "x$je_cv_msvc" = "xyes" ; then
   307 	  importlib="lib"
   308 	  DSO_LDFLAGS="-LD"
   309 	  EXTRA_LDFLAGS="-link -DEBUG"
   310 	  CTARGET='-Fo$@'
   311 	  LDTARGET='-Fe$@'
   312 	  MKLIB='lib -nologo -out:$@'
   313 	  CC_MM=
   314         else
   315 	  importlib="${so}"
   316 	  DSO_LDFLAGS="-shared"
   317 	fi
   318 	a="lib"
   319 	libprefix=""
   320 	SOREV="${so}"
   321 	PIC_CFLAGS=""
   322 	;;
   323   *)
   324 	AC_MSG_RESULT([Unsupported operating system: ${host}])
   325 	abi="elf"
   326 	;;
   327 esac
   328 AC_DEFINE_UNQUOTED([JEMALLOC_USABLE_SIZE_CONST], [$JEMALLOC_USABLE_SIZE_CONST])
   329 AC_SUBST([abi])
   330 AC_SUBST([RPATH])
   331 AC_SUBST([LD_PRELOAD_VAR])
   332 AC_SUBST([so])
   333 AC_SUBST([importlib])
   334 AC_SUBST([o])
   335 AC_SUBST([a])
   336 AC_SUBST([exe])
   337 AC_SUBST([libprefix])
   338 AC_SUBST([DSO_LDFLAGS])
   339 AC_SUBST([EXTRA_LDFLAGS])
   340 AC_SUBST([SOREV])
   341 AC_SUBST([PIC_CFLAGS])
   342 AC_SUBST([CTARGET])
   343 AC_SUBST([LDTARGET])
   344 AC_SUBST([MKLIB])
   345 AC_SUBST([CC_MM])
   347 if test "x$abi" != "xpecoff"; then
   348   dnl Heap profiling uses the log(3) function.
   349   LIBS="$LIBS -lm"
   350 fi
   352 JE_COMPILABLE([__attribute__ syntax],
   353               [static __attribute__((unused)) void foo(void){}],
   354               [],
   355               [je_cv_attribute])
   356 if test "x${je_cv_attribute}" = "xyes" ; then
   357   AC_DEFINE([JEMALLOC_HAVE_ATTR], [ ])
   358   if test "x${GCC}" = "xyes" -a "x${abi}" = "xelf"; then
   359     JE_CFLAGS_APPEND([-fvisibility=hidden])
   360   fi
   361 fi
   362 dnl Check for tls_model attribute support (clang 3.0 still lacks support).
   363 SAVED_CFLAGS="${CFLAGS}"
   364 JE_CFLAGS_APPEND([-Werror])
   365 JE_COMPILABLE([tls_model attribute], [],
   366               [static __thread int
   367                __attribute__((tls_model("initial-exec"))) foo;
   368                foo = 0;],
   369               [je_cv_tls_model])
   370 CFLAGS="${SAVED_CFLAGS}"
   371 if test "x${je_cv_tls_model}" = "xyes" ; then
   372   AC_DEFINE([JEMALLOC_TLS_MODEL],
   373             [__attribute__((tls_model("initial-exec")))])
   374 else
   375   AC_DEFINE([JEMALLOC_TLS_MODEL], [ ])
   376 fi
   378 dnl Support optional additions to rpath.
   379 AC_ARG_WITH([rpath],
   380   [AS_HELP_STRING([--with-rpath=<rpath>], [Colon-separated rpath (ELF systems only)])],
   381 if test "x$with_rpath" = "xno" ; then
   382   RPATH_EXTRA=
   383 else
   384   RPATH_EXTRA="`echo $with_rpath | tr \":\" \" \"`"
   385 fi,
   386   RPATH_EXTRA=
   387 )
   388 AC_SUBST([RPATH_EXTRA])
   390 dnl Disable rules that do automatic regeneration of configure output by default.
   391 AC_ARG_ENABLE([autogen],
   392   [AS_HELP_STRING([--enable-autogen], [Automatically regenerate configure output])],
   393 if test "x$enable_autogen" = "xno" ; then
   394   enable_autogen="0"
   395 else
   396   enable_autogen="1"
   397 fi
   398 ,
   399 enable_autogen="0"
   400 )
   401 AC_SUBST([enable_autogen])
   403 AC_PROG_INSTALL
   404 AC_PROG_RANLIB
   405 AC_PATH_PROG([AR], [ar], , [$PATH])
   406 AC_PATH_PROG([LD], [ld], , [$PATH])
   407 AC_PATH_PROG([AUTOCONF], [autoconf], , [$PATH])
   409 public_syms="malloc_conf malloc_message malloc calloc posix_memalign aligned_alloc realloc free malloc_usable_size malloc_stats_print mallctl mallctlnametomib mallctlbymib"
   411 dnl Check for allocator-related functions that should be wrapped.
   412 AC_CHECK_FUNC([memalign],
   413 	      [AC_DEFINE([JEMALLOC_OVERRIDE_MEMALIGN], [ ])
   414 	       public_syms="${public_syms} memalign"])
   415 AC_CHECK_FUNC([valloc],
   416 	      [AC_DEFINE([JEMALLOC_OVERRIDE_VALLOC], [ ])
   417 	       public_syms="${public_syms} valloc"])
   419 dnl Support the experimental API by default.
   420 AC_ARG_ENABLE([experimental],
   421   [AS_HELP_STRING([--disable-experimental],
   422    [Disable support for the experimental API])],
   423 [if test "x$enable_experimental" = "xno" ; then
   424   enable_experimental="0"
   425 else
   426   enable_experimental="1"
   427 fi
   428 ],
   429 [enable_experimental="1"]
   430 )
   431 if test "x$enable_experimental" = "x1" ; then
   432   AC_DEFINE([JEMALLOC_EXPERIMENTAL], [ ])
   433   public_syms="${public_syms} allocm dallocm nallocm rallocm sallocm"
   434 fi
   435 AC_SUBST([enable_experimental])
   437 dnl Perform no name mangling by default.
   438 AC_ARG_WITH([mangling],
   439   [AS_HELP_STRING([--with-mangling=<map>], [Mangle symbols in <map>])],
   440   [mangling_map="$with_mangling"], [mangling_map=""])
   441 for nm in `echo ${mangling_map} |tr ',' ' '` ; do
   442   k="`echo ${nm} |tr ':' ' ' |awk '{print $1}'`"
   443   n="je_${k}"
   444   m=`echo ${nm} |tr ':' ' ' |awk '{print $2}'`
   445   AC_DEFINE_UNQUOTED([${n}], [${m}])
   446   dnl Remove key from public_syms so that it isn't redefined later.
   447   public_syms=`for sym in ${public_syms}; do echo "${sym}"; done |grep -v "^${k}\$" |tr '\n' ' '`
   448 done
   450 dnl Do not prefix public APIs by default.
   451 AC_ARG_WITH([jemalloc_prefix],
   452   [AS_HELP_STRING([--with-jemalloc-prefix=<prefix>], [Prefix to prepend to all public APIs])],
   453   [JEMALLOC_PREFIX="$with_jemalloc_prefix"],
   454   [if test "x$abi" != "xmacho" -a "x$abi" != "xpecoff"; then
   455   JEMALLOC_PREFIX=""
   456 else
   457   JEMALLOC_PREFIX="je_"
   458 fi]
   459 )
   460 if test "x$JEMALLOC_PREFIX" != "x" ; then
   461   JEMALLOC_CPREFIX=`echo ${JEMALLOC_PREFIX} | tr "a-z" "A-Z"`
   462   AC_DEFINE_UNQUOTED([JEMALLOC_PREFIX], ["$JEMALLOC_PREFIX"])
   463   AC_DEFINE_UNQUOTED([JEMALLOC_CPREFIX], ["$JEMALLOC_CPREFIX"])
   464 fi
   465 dnl Generate macros to rename public symbols.  All public symbols are prefixed
   466 dnl with je_ in the source code, so these macro definitions are needed even if
   467 dnl --with-jemalloc-prefix wasn't specified.
   468 for stem in ${public_syms}; do
   469   n="je_${stem}"
   470   m="${JEMALLOC_PREFIX}${stem}"
   471   AC_DEFINE_UNQUOTED([${n}], [${m}])
   472 done
   474 AC_ARG_WITH([export],
   475   [AS_HELP_STRING([--without-export], [disable exporting jemalloc public APIs])],
   476   [if test "x$with_export" = "xno"; then
   477   AC_DEFINE([JEMALLOC_EXPORT],[])]
   478 fi]
   479 )
   481 dnl Do not mangle library-private APIs by default.
   482 AC_ARG_WITH([private_namespace],
   483   [AS_HELP_STRING([--with-private-namespace=<prefix>], [Prefix to prepend to all library-private APIs])],
   484   [JEMALLOC_PRIVATE_NAMESPACE="$with_private_namespace"],
   485   [JEMALLOC_PRIVATE_NAMESPACE=""]
   486 )
   487 AC_DEFINE_UNQUOTED([JEMALLOC_PRIVATE_NAMESPACE], ["$JEMALLOC_PRIVATE_NAMESPACE"])
   488 if test "x$JEMALLOC_PRIVATE_NAMESPACE" != "x" ; then
   489   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])
   490 else
   491   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])
   492 fi
   494 dnl Do not add suffix to installed files by default.
   495 AC_ARG_WITH([install_suffix],
   496   [AS_HELP_STRING([--with-install-suffix=<suffix>], [Suffix to append to all installed files])],
   497   [INSTALL_SUFFIX="$with_install_suffix"],
   498   [INSTALL_SUFFIX=]
   499 )
   500 install_suffix="$INSTALL_SUFFIX"
   501 AC_SUBST([install_suffix])
   503 cfgoutputs_in="${srcroot}Makefile.in"
   504 cfgoutputs_in="${cfgoutputs_in} ${srcroot}doc/html.xsl.in"
   505 cfgoutputs_in="${cfgoutputs_in} ${srcroot}doc/manpages.xsl.in"
   506 cfgoutputs_in="${cfgoutputs_in} ${srcroot}doc/jemalloc.xml.in"
   507 cfgoutputs_in="${cfgoutputs_in} ${srcroot}include/jemalloc/jemalloc.h.in"
   508 cfgoutputs_in="${cfgoutputs_in} ${srcroot}include/jemalloc/internal/jemalloc_internal.h.in"
   509 cfgoutputs_in="${cfgoutputs_in} ${srcroot}test/jemalloc_test.h.in"
   511 cfgoutputs_out="Makefile"
   512 cfgoutputs_out="${cfgoutputs_out} doc/html.xsl"
   513 cfgoutputs_out="${cfgoutputs_out} doc/manpages.xsl"
   514 cfgoutputs_out="${cfgoutputs_out} doc/jemalloc${install_suffix}.xml"
   515 cfgoutputs_out="${cfgoutputs_out} include/jemalloc/jemalloc${install_suffix}.h"
   516 cfgoutputs_out="${cfgoutputs_out} include/jemalloc/internal/jemalloc_internal.h"
   517 cfgoutputs_out="${cfgoutputs_out} test/jemalloc_test.h"
   519 cfgoutputs_tup="Makefile"
   520 cfgoutputs_tup="${cfgoutputs_tup} doc/html.xsl:doc/html.xsl.in"
   521 cfgoutputs_tup="${cfgoutputs_tup} doc/manpages.xsl:doc/manpages.xsl.in"
   522 cfgoutputs_tup="${cfgoutputs_tup} doc/jemalloc${install_suffix}.xml:doc/jemalloc.xml.in"
   523 cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/jemalloc${install_suffix}.h:include/jemalloc/jemalloc.h.in"
   524 cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/internal/jemalloc_internal.h"
   525 cfgoutputs_tup="${cfgoutputs_tup} test/jemalloc_test.h:test/jemalloc_test.h.in"
   527 cfghdrs_in="${srcroot}include/jemalloc/jemalloc_defs.h.in"
   528 cfghdrs_in="${cfghdrs_in} ${srcroot}include/jemalloc/internal/size_classes.sh"
   530 cfghdrs_out="include/jemalloc/jemalloc_defs${install_suffix}.h"
   531 cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/size_classes.h"
   533 cfghdrs_tup="include/jemalloc/jemalloc_defs${install_suffix}.h:include/jemalloc/jemalloc_defs.h.in"
   535 dnl Do not silence irrelevant compiler warnings by default, since enabling this
   536 dnl option incurs a performance penalty.
   537 AC_ARG_ENABLE([cc-silence],
   538   [AS_HELP_STRING([--enable-cc-silence],
   539                   [Silence irrelevant compiler warnings])],
   540 [if test "x$enable_cc_silence" = "xno" ; then
   541   enable_cc_silence="0"
   542 else
   543   enable_cc_silence="1"
   544 fi
   545 ],
   546 [enable_cc_silence="0"]
   547 )
   548 if test "x$enable_cc_silence" = "x1" ; then
   549   AC_DEFINE([JEMALLOC_CC_SILENCE], [ ])
   550 fi
   552 dnl Do not compile with debugging by default.
   553 AC_ARG_ENABLE([debug],
   554   [AS_HELP_STRING([--enable-debug], [Build debugging code])],
   555 [if test "x$enable_debug" = "xno" ; then
   556   enable_debug="0"
   557 else
   558   enable_debug="1"
   559 fi
   560 ],
   561 [enable_debug="0"]
   562 )
   563 if test "x$enable_debug" = "x1" ; then
   564   AC_DEFINE([JEMALLOC_DEBUG], [ ])
   565   AC_DEFINE([JEMALLOC_IVSALLOC], [ ])
   566 fi
   567 AC_SUBST([enable_debug])
   569 dnl Only optimize if not debugging.
   570 if test "x$enable_debug" = "x0" -a "x$no_CFLAGS" = "xyes" ; then
   571   dnl Make sure that an optimization flag was not specified in EXTRA_CFLAGS.
   572   optimize="no"
   573   echo "$EXTRA_CFLAGS" | grep "\-O" >/dev/null || optimize="yes"
   574   if test "x${optimize}" = "xyes" ; then
   575     if test "x$GCC" = "xyes" ; then
   576       JE_CFLAGS_APPEND([-O3])
   577       JE_CFLAGS_APPEND([-funroll-loops])
   578     elif test "x$je_cv_msvc" = "xyes" ; then
   579       JE_CFLAGS_APPEND([-O2])
   580     else
   581       JE_CFLAGS_APPEND([-O])
   582     fi
   583   fi
   584 fi
   586 dnl Enable statistics calculation by default.
   587 AC_ARG_ENABLE([stats],
   588   [AS_HELP_STRING([--disable-stats],
   589                   [Disable statistics calculation/reporting])],
   590 [if test "x$enable_stats" = "xno" ; then
   591   enable_stats="0"
   592 else
   593   enable_stats="1"
   594 fi
   595 ],
   596 [enable_stats="1"]
   597 )
   598 if test "x$enable_stats" = "x1" ; then
   599   AC_DEFINE([JEMALLOC_STATS], [ ])
   600 fi
   601 AC_SUBST([enable_stats])
   603 dnl Do not enable profiling by default.
   604 AC_ARG_ENABLE([prof],
   605   [AS_HELP_STRING([--enable-prof], [Enable allocation profiling])],
   606 [if test "x$enable_prof" = "xno" ; then
   607   enable_prof="0"
   608 else
   609   enable_prof="1"
   610 fi
   611 ],
   612 [enable_prof="0"]
   613 )
   614 if test "x$enable_prof" = "x1" ; then
   615   backtrace_method=""
   616 else
   617   backtrace_method="N/A"
   618 fi
   620 AC_ARG_ENABLE([prof-libunwind],
   621   [AS_HELP_STRING([--enable-prof-libunwind], [Use libunwind for backtracing])],
   622 [if test "x$enable_prof_libunwind" = "xno" ; then
   623   enable_prof_libunwind="0"
   624 else
   625   enable_prof_libunwind="1"
   626 fi
   627 ],
   628 [enable_prof_libunwind="0"]
   629 )
   630 AC_ARG_WITH([static_libunwind],
   631   [AS_HELP_STRING([--with-static-libunwind=<libunwind.a>],
   632   [Path to static libunwind library; use rather than dynamically linking])],
   633 if test "x$with_static_libunwind" = "xno" ; then
   634   LUNWIND="-lunwind"
   635 else
   636   if test ! -f "$with_static_libunwind" ; then
   637     AC_MSG_ERROR([Static libunwind not found: $with_static_libunwind])
   638   fi
   639   LUNWIND="$with_static_libunwind"
   640 fi,
   641   LUNWIND="-lunwind"
   642 )
   643 if test "x$backtrace_method" = "x" -a "x$enable_prof_libunwind" = "x1" ; then
   644   AC_CHECK_HEADERS([libunwind.h], , [enable_prof_libunwind="0"])
   645   if test "x$LUNWIND" = "x-lunwind" ; then
   646     AC_CHECK_LIB([unwind], [backtrace], [LIBS="$LIBS $LUNWIND"],
   647                  [enable_prof_libunwind="0"])
   648   else
   649     LIBS="$LIBS $LUNWIND"
   650   fi
   651   if test "x${enable_prof_libunwind}" = "x1" ; then
   652     backtrace_method="libunwind"
   653     AC_DEFINE([JEMALLOC_PROF_LIBUNWIND], [ ])
   654   fi
   655 fi
   657 AC_ARG_ENABLE([prof-libgcc],
   658   [AS_HELP_STRING([--disable-prof-libgcc],
   659   [Do not use libgcc for backtracing])],
   660 [if test "x$enable_prof_libgcc" = "xno" ; then
   661   enable_prof_libgcc="0"
   662 else
   663   enable_prof_libgcc="1"
   664 fi
   665 ],
   666 [enable_prof_libgcc="1"]
   667 )
   668 if test "x$backtrace_method" = "x" -a "x$enable_prof_libgcc" = "x1" \
   669      -a "x$GCC" = "xyes" ; then
   670   AC_CHECK_HEADERS([unwind.h], , [enable_prof_libgcc="0"])
   671   AC_CHECK_LIB([gcc], [_Unwind_Backtrace], [LIBS="$LIBS -lgcc"], [enable_prof_libgcc="0"])
   672   dnl The following is conservative, in that it only has entries for CPUs on
   673   dnl which jemalloc has been tested.
   674   AC_MSG_CHECKING([libgcc-based backtracing reliability on ${host_cpu}])
   675   case "${host_cpu}" in
   676     i[[3456]]86)
   677       AC_MSG_RESULT([unreliable])
   678       enable_prof_libgcc="0";
   679       ;;
   680     x86_64)
   681       AC_MSG_RESULT([reliable])
   682       ;;
   683     *)
   684       AC_MSG_RESULT([unreliable])
   685       enable_prof_libgcc="0";
   686       ;;
   687   esac
   688   if test "x${enable_prof_libgcc}" = "x1" ; then
   689     backtrace_method="libgcc"
   690     AC_DEFINE([JEMALLOC_PROF_LIBGCC], [ ])
   691   fi
   692 else
   693   enable_prof_libgcc="0"
   694 fi
   696 AC_ARG_ENABLE([prof-gcc],
   697   [AS_HELP_STRING([--disable-prof-gcc],
   698   [Do not use gcc intrinsics for backtracing])],
   699 [if test "x$enable_prof_gcc" = "xno" ; then
   700   enable_prof_gcc="0"
   701 else
   702   enable_prof_gcc="1"
   703 fi
   704 ],
   705 [enable_prof_gcc="1"]
   706 )
   707 if test "x$backtrace_method" = "x" -a "x$enable_prof_gcc" = "x1" \
   708      -a "x$GCC" = "xyes" ; then
   709   backtrace_method="gcc intrinsics"
   710   AC_DEFINE([JEMALLOC_PROF_GCC], [ ])
   711 else
   712   enable_prof_gcc="0"
   713 fi
   715 if test "x$backtrace_method" = "x" ; then
   716   backtrace_method="none (disabling profiling)"
   717   enable_prof="0"
   718 fi
   719 AC_MSG_CHECKING([configured backtracing method])
   720 AC_MSG_RESULT([$backtrace_method])
   721 if test "x$enable_prof" = "x1" ; then
   722   if test "x${force_tls}" = "x0" ; then
   723     AC_MSG_ERROR([Heap profiling requires TLS]);
   724   fi
   725   force_tls="1"
   726   AC_DEFINE([JEMALLOC_PROF], [ ])
   727 fi
   728 AC_SUBST([enable_prof])
   730 dnl Enable thread-specific caching by default.
   731 AC_ARG_ENABLE([tcache],
   732   [AS_HELP_STRING([--disable-tcache], [Disable per thread caches])],
   733 [if test "x$enable_tcache" = "xno" ; then
   734   enable_tcache="0"
   735 else
   736   enable_tcache="1"
   737 fi
   738 ],
   739 [enable_tcache="1"]
   740 )
   741 if test "x$enable_tcache" = "x1" ; then
   742   AC_DEFINE([JEMALLOC_TCACHE], [ ])
   743 fi
   744 AC_SUBST([enable_tcache])
   746 dnl Disable mremap() for huge realloc() by default.
   747 AC_ARG_ENABLE([mremap],
   748   [AS_HELP_STRING([--enable-mremap], [Enable mremap(2) for huge realloc()])],
   749 [if test "x$enable_mremap" = "xno" ; then
   750   enable_mremap="0"
   751 else
   752   enable_mremap="1"
   753 fi
   754 ],
   755 [enable_mremap="0"]
   756 )
   757 if test "x$enable_mremap" = "x1" ; then
   758   JE_COMPILABLE([mremap(...MREMAP_FIXED...)], [
   759 #define _GNU_SOURCE
   760 #include <sys/mman.h>
   761 ], [
   762 void *p = mremap((void *)0, 0, 0, MREMAP_MAYMOVE|MREMAP_FIXED, (void *)0);
   763 ], [je_cv_mremap_fixed])
   764   if test "x${je_cv_mremap_fixed}" = "xno" ; then
   765     enable_mremap="0"
   766   fi
   767 fi
   768 if test "x$enable_mremap" = "x1" ; then
   769   AC_DEFINE([JEMALLOC_MREMAP], [ ])
   770 fi
   771 AC_SUBST([enable_mremap])
   773 dnl Enable VM deallocation via munmap() by default.
   774 AC_ARG_ENABLE([munmap],
   775   [AS_HELP_STRING([--disable-munmap], [Disable VM deallocation via munmap(2)])],
   776 [if test "x$enable_munmap" = "xno" ; then
   777   enable_munmap="0"
   778 else
   779   enable_munmap="1"
   780 fi
   781 ],
   782 [enable_munmap="${default_munmap}"]
   783 )
   784 if test "x$enable_munmap" = "x1" ; then
   785   AC_DEFINE([JEMALLOC_MUNMAP], [ ])
   786 fi
   787 AC_SUBST([enable_munmap])
   789 dnl Do not enable allocation from DSS by default.
   790 AC_ARG_ENABLE([dss],
   791   [AS_HELP_STRING([--enable-dss], [Enable allocation from DSS])],
   792 [if test "x$enable_dss" = "xno" ; then
   793   enable_dss="0"
   794 else
   795   enable_dss="1"
   796 fi
   797 ],
   798 [enable_dss="0"]
   799 )
   800 dnl Check whether the BSD/SUSv1 sbrk() exists.  If not, disable DSS support.
   801 AC_CHECK_FUNC([sbrk], [have_sbrk="1"], [have_sbrk="0"])
   802 if test "x$have_sbrk" = "x1" ; then
   803   AC_DEFINE([JEMALLOC_HAVE_SBRK], [ ])
   804 else
   805   enable_dss="0"
   806 fi
   808 if test "x$enable_dss" = "x1" ; then
   809   AC_DEFINE([JEMALLOC_DSS], [ ])
   810 fi
   811 AC_SUBST([enable_dss])
   813 dnl Support the junk/zero filling option by default.
   814 AC_ARG_ENABLE([fill],
   815   [AS_HELP_STRING([--disable-fill],
   816                   [Disable support for junk/zero filling, quarantine, and redzones])],
   817 [if test "x$enable_fill" = "xno" ; then
   818   enable_fill="0"
   819 else
   820   enable_fill="1"
   821 fi
   822 ],
   823 [enable_fill="1"]
   824 )
   825 if test "x$enable_fill" = "x1" ; then
   826   AC_DEFINE([JEMALLOC_FILL], [ ])
   827 fi
   828 AC_SUBST([enable_fill])
   830 dnl Disable utrace(2)-based tracing by default.
   831 AC_ARG_ENABLE([utrace],
   832   [AS_HELP_STRING([--enable-utrace], [Enable utrace(2)-based tracing])],
   833 [if test "x$enable_utrace" = "xno" ; then
   834   enable_utrace="0"
   835 else
   836   enable_utrace="1"
   837 fi
   838 ],
   839 [enable_utrace="0"]
   840 )
   841 JE_COMPILABLE([utrace(2)], [
   842 #include <sys/types.h>
   843 #include <sys/param.h>
   844 #include <sys/time.h>
   845 #include <sys/uio.h>
   846 #include <sys/ktrace.h>
   847 ], [
   848 	utrace((void *)0, 0);
   849 ], [je_cv_utrace])
   850 if test "x${je_cv_utrace}" = "xno" ; then
   851   enable_utrace="0"
   852 fi
   853 if test "x$enable_utrace" = "x1" ; then
   854   AC_DEFINE([JEMALLOC_UTRACE], [ ])
   855 fi
   856 AC_SUBST([enable_utrace])
   858 dnl Support Valgrind by default.
   859 AC_ARG_ENABLE([valgrind],
   860   [AS_HELP_STRING([--disable-valgrind], [Disable support for Valgrind])],
   861 [if test "x$enable_valgrind" = "xno" ; then
   862   enable_valgrind="0"
   863 else
   864   enable_valgrind="1"
   865 fi
   866 ],
   867 [enable_valgrind="1"]
   868 )
   869 if test "x$enable_valgrind" = "x1" ; then
   870   JE_COMPILABLE([valgrind], [
   871 #include <valgrind/valgrind.h>
   872 #include <valgrind/memcheck.h>
   874 #if !defined(VALGRIND_RESIZEINPLACE_BLOCK)
   875 #  error "Incompatible Valgrind version"
   876 #endif
   877 ], [], [je_cv_valgrind])
   878   if test "x${je_cv_valgrind}" = "xno" ; then
   879     enable_valgrind="0"
   880   fi
   881   if test "x$enable_valgrind" = "x1" ; then
   882     AC_DEFINE([JEMALLOC_VALGRIND], [ ])
   883   fi
   884 fi
   885 AC_SUBST([enable_valgrind])
   887 dnl Do not support the xmalloc option by default.
   888 AC_ARG_ENABLE([xmalloc],
   889   [AS_HELP_STRING([--enable-xmalloc], [Support xmalloc option])],
   890 [if test "x$enable_xmalloc" = "xno" ; then
   891   enable_xmalloc="0"
   892 else
   893   enable_xmalloc="1"
   894 fi
   895 ],
   896 [enable_xmalloc="0"]
   897 )
   898 if test "x$enable_xmalloc" = "x1" ; then
   899   AC_DEFINE([JEMALLOC_XMALLOC], [ ])
   900 fi
   901 AC_SUBST([enable_xmalloc])
   903 AC_CACHE_CHECK([STATIC_PAGE_SHIFT],
   904                [je_cv_static_page_shift],
   905                AC_RUN_IFELSE([AC_LANG_PROGRAM(
   906 [[
   907 #include <strings.h>
   908 #ifdef _WIN32
   909 #include <windows.h>
   910 #else
   911 #include <unistd.h>
   912 #endif
   913 #include <stdio.h>
   914 ]],
   915 [[
   916     long result;
   917     FILE *f;
   919 #ifdef _WIN32
   920     SYSTEM_INFO si;
   921     GetSystemInfo(&si);
   922     result = si.dwPageSize;
   923 #else
   924     result = sysconf(_SC_PAGESIZE);
   925 #endif
   926     if (result == -1) {
   927 	return 1;
   928     }
   929     result = ffsl(result) - 1;
   931     f = fopen("conftest.out", "w");
   932     if (f == NULL) {
   933 	return 1;
   934     }
   935     fprintf(f, "%u\n", result);
   936     fclose(f);
   938     return 0;
   939 ]])],
   940                              [je_cv_static_page_shift=`cat conftest.out`],
   941                              [je_cv_static_page_shift=undefined]))
   943 if test "x$je_cv_static_page_shift" != "xundefined"; then
   944    AC_DEFINE_UNQUOTED([STATIC_PAGE_SHIFT], [$je_cv_static_page_shift])
   945 else
   946    AC_MSG_ERROR([cannot determine value for STATIC_PAGE_SHIFT])
   947 fi
   949 dnl ============================================================================
   950 dnl jemalloc configuration.
   951 dnl 
   953 dnl Set VERSION if source directory has an embedded git repository.
   954 if test -d "${srcroot}.git" ; then
   955   git describe --long --abbrev=40 > ${srcroot}VERSION
   956 fi
   957 jemalloc_version=`cat ${srcroot}VERSION`
   958 jemalloc_version_major=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]1}'`
   959 jemalloc_version_minor=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]2}'`
   960 jemalloc_version_bugfix=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]3}'`
   961 jemalloc_version_nrev=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]4}'`
   962 jemalloc_version_gid=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]5}'`
   963 AC_SUBST([jemalloc_version])
   964 AC_SUBST([jemalloc_version_major])
   965 AC_SUBST([jemalloc_version_minor])
   966 AC_SUBST([jemalloc_version_bugfix])
   967 AC_SUBST([jemalloc_version_nrev])
   968 AC_SUBST([jemalloc_version_gid])
   970 dnl ============================================================================
   971 dnl Configure pthreads.
   973 if test "x$abi" != "xpecoff" ; then
   974   AC_CHECK_HEADERS([pthread.h], , [AC_MSG_ERROR([pthread.h is missing])])
   975   dnl Some systems may embed pthreads functionality in libc; check for libpthread
   976   dnl first, but try libc too before failing.
   977   AC_CHECK_LIB([pthread], [pthread_create], [LIBS="$LIBS -lpthread"],
   978                [AC_SEARCH_LIBS([pthread_create], , ,
   979                                AC_MSG_ERROR([libpthread is missing]))])
   980 fi
   982 CPPFLAGS="$CPPFLAGS -D_REENTRANT"
   984 dnl Check whether the BSD-specific _malloc_thread_cleanup() exists.  If so, use
   985 dnl it rather than pthreads TSD cleanup functions to support cleanup during
   986 dnl thread exit, in order to avoid pthreads library recursion during
   987 dnl bootstrapping.
   988 AC_CHECK_FUNC([_malloc_thread_cleanup],
   989               [have__malloc_thread_cleanup="1"],
   990               [have__malloc_thread_cleanup="0"]
   991              )
   992 if test "x$have__malloc_thread_cleanup" = "x1" ; then
   993   AC_DEFINE([JEMALLOC_MALLOC_THREAD_CLEANUP], [ ])
   994   force_tls="1"
   995 fi
   997 dnl Check whether the BSD-specific _pthread_mutex_init_calloc_cb() exists.  If
   998 dnl so, mutex initialization causes allocation, and we need to implement this
   999 dnl callback function in order to prevent recursive allocation.
  1000 AC_CHECK_FUNC([_pthread_mutex_init_calloc_cb],
  1001               [have__pthread_mutex_init_calloc_cb="1"],
  1002               [have__pthread_mutex_init_calloc_cb="0"]
  1004 if test "x$have__pthread_mutex_init_calloc_cb" = "x1" ; then
  1005   AC_DEFINE([JEMALLOC_MUTEX_INIT_CB])
  1006 fi
  1008 dnl Disable lazy locking by default.
  1009 AC_ARG_ENABLE([lazy_lock],
  1010   [AS_HELP_STRING([--enable-lazy-lock],
  1011   [Enable lazy locking (only lock when multi-threaded)])],
  1012 [if test "x$enable_lazy_lock" = "xno" ; then
  1013   enable_lazy_lock="0"
  1014 else
  1015   enable_lazy_lock="1"
  1016 fi
  1017 ],
  1018 [enable_lazy_lock="0"]
  1020 if test "x$enable_lazy_lock" = "x0" -a "x${force_lazy_lock}" = "x1" ; then
  1021   AC_MSG_RESULT([Forcing lazy-lock to avoid allocator/threading bootstrap issues])
  1022   enable_lazy_lock="1"
  1023 fi
  1024 if test "x$enable_lazy_lock" = "x1" ; then
  1025   if test "x$abi" != "xpecoff" ; then
  1026     AC_CHECK_HEADERS([dlfcn.h], , [AC_MSG_ERROR([dlfcn.h is missing])])
  1027     AC_CHECK_FUNC([dlsym], [],
  1028       [AC_CHECK_LIB([dl], [dlsym], [LIBS="$LIBS -ldl"],
  1029                     [AC_MSG_ERROR([libdl is missing])])
  1030       ])
  1031   fi
  1032   AC_DEFINE([JEMALLOC_LAZY_LOCK], [ ])
  1033 fi
  1034 AC_SUBST([enable_lazy_lock])
  1036 AC_ARG_ENABLE([tls],
  1037   [AS_HELP_STRING([--disable-tls], [Disable thread-local storage (__thread keyword)])],
  1038 if test "x$enable_tls" = "xno" ; then
  1039   enable_tls="0"
  1040 else
  1041   enable_tls="1"
  1042 fi
  1044 enable_tls="1"
  1046 if test "x${enable_tls}" = "x0" -a "x${force_tls}" = "x1" ; then
  1047   AC_MSG_RESULT([Forcing TLS to avoid allocator/threading bootstrap issues])
  1048   enable_tls="1"
  1049 fi
  1050 if test "x${enable_tls}" = "x1" -a "x${force_tls}" = "x0" ; then
  1051   AC_MSG_RESULT([Forcing no TLS to avoid allocator/threading bootstrap issues])
  1052   enable_tls="0"
  1053 fi
  1054 if test "x${enable_tls}" = "x1" ; then
  1055 AC_MSG_CHECKING([for TLS])
  1056 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
  1057 [[
  1058     __thread int x;
  1059 ]], [[
  1060     x = 42;
  1062     return 0;
  1063 ]])],
  1064               AC_MSG_RESULT([yes]),
  1065               AC_MSG_RESULT([no])
  1066               enable_tls="0")
  1067 fi
  1068 AC_SUBST([enable_tls])
  1069 if test "x${enable_tls}" = "x1" ; then
  1070   AC_DEFINE_UNQUOTED([JEMALLOC_TLS], [ ])
  1071 elif test "x${force_tls}" = "x1" ; then
  1072   AC_MSG_ERROR([Failed to configure TLS, which is mandatory for correct function])
  1073 fi
  1075 dnl ============================================================================
  1076 dnl Check for ffsl(3), and fail if not found.  This function exists on all
  1077 dnl platforms that jemalloc currently has a chance of functioning on without
  1078 dnl modification.
  1079 JE_COMPILABLE([a program using ffsl], [
  1080 #include <strings.h>
  1081 #include <string.h>
  1082 ], [
  1084 		int rv = ffsl(0x08);
  1086 ], [je_cv_function_ffsl])
  1087 if test "x${je_cv_function_ffsl}" != "xyes" ; then
  1088    AC_MSG_ERROR([Cannot build without ffsl(3)])
  1089 fi
  1091 dnl ============================================================================
  1092 dnl Check for atomic(9) operations as provided on FreeBSD.
  1094 JE_COMPILABLE([atomic(9)], [
  1095 #include <sys/types.h>
  1096 #include <machine/atomic.h>
  1097 #include <inttypes.h>
  1098 ], [
  1100 		uint32_t x32 = 0;
  1101 		volatile uint32_t *x32p = &x32;
  1102 		atomic_fetchadd_32(x32p, 1);
  1105 		unsigned long xlong = 0;
  1106 		volatile unsigned long *xlongp = &xlong;
  1107 		atomic_fetchadd_long(xlongp, 1);
  1109 ], [je_cv_atomic9])
  1110 if test "x${je_cv_atomic9}" = "xyes" ; then
  1111   AC_DEFINE([JEMALLOC_ATOMIC9])
  1112 fi
  1114 dnl ============================================================================
  1115 dnl Check for atomic(3) operations as provided on Darwin.
  1117 JE_COMPILABLE([Darwin OSAtomic*()], [
  1118 #include <libkern/OSAtomic.h>
  1119 #include <inttypes.h>
  1120 ], [
  1122 		int32_t x32 = 0;
  1123 		volatile int32_t *x32p = &x32;
  1124 		OSAtomicAdd32(1, x32p);
  1127 		int64_t x64 = 0;
  1128 		volatile int64_t *x64p = &x64;
  1129 		OSAtomicAdd64(1, x64p);
  1131 ], [je_cv_osatomic])
  1132 if test "x${je_cv_osatomic}" = "xyes" ; then
  1133   AC_DEFINE([JEMALLOC_OSATOMIC], [ ])
  1134 fi
  1136 dnl ============================================================================
  1137 dnl Check whether __sync_{add,sub}_and_fetch() are available despite
  1138 dnl __GCC_HAVE_SYNC_COMPARE_AND_SWAP_n macros being undefined.
  1140 AC_DEFUN([JE_SYNC_COMPARE_AND_SWAP_CHECK],[
  1141   AC_CACHE_CHECK([whether to force $1-bit __sync_{add,sub}_and_fetch()],
  1142                [je_cv_sync_compare_and_swap_$2],
  1143                [AC_LINK_IFELSE([AC_LANG_PROGRAM([
  1144                                                  #include <stdint.h>
  1145                                                 ],
  1147                                                  #ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_$2
  1149                                                     uint$1_t x$1 = 0;
  1150                                                     __sync_add_and_fetch(&x$1, 42);
  1151                                                     __sync_sub_and_fetch(&x$1, 1);
  1153                                                  #else
  1154                                                  #error __GCC_HAVE_SYNC_COMPARE_AND_SWAP_$2 is defined, no need to force
  1155                                                  #endif
  1156                                                 ])],
  1157                                [je_cv_sync_compare_and_swap_$2=yes],
  1158                                [je_cv_sync_compare_and_swap_$2=no])])
  1160   if test "x${je_cv_sync_compare_and_swap_$2}" = "xyes" ; then
  1161     AC_DEFINE([JE_FORCE_SYNC_COMPARE_AND_SWAP_$2], [ ])
  1162   fi
  1163 ])
  1165 if test "x${je_cv_atomic9}" != "xyes" -a "x${je_cv_osatomic}" != "xyes" ; then
  1166   JE_SYNC_COMPARE_AND_SWAP_CHECK(32, 4)
  1167   JE_SYNC_COMPARE_AND_SWAP_CHECK(64, 8)
  1168 fi
  1170 dnl ============================================================================
  1171 dnl Check for spinlock(3) operations as provided on Darwin.
  1173 JE_COMPILABLE([Darwin OSSpin*()], [
  1174 #include <libkern/OSAtomic.h>
  1175 #include <inttypes.h>
  1176 ], [
  1177 	OSSpinLock lock = 0;
  1178 	OSSpinLockLock(&lock);
  1179 	OSSpinLockUnlock(&lock);
  1180 ], [je_cv_osspin])
  1181 if test "x${je_cv_osspin}" = "xyes" ; then
  1182   AC_DEFINE([JEMALLOC_OSSPIN], [ ])
  1183 fi
  1185 dnl ============================================================================
  1186 dnl Darwin-related configuration.
  1188 if test "x${abi}" = "xmacho" ; then
  1189   AC_DEFINE([JEMALLOC_IVSALLOC], [ ])
  1190   AC_DEFINE([JEMALLOC_ZONE], [ ])
  1192   dnl The szone version jumped from 3 to 6 between the OS X 10.5.x and 10.6
  1193   dnl releases.  malloc_zone_t and malloc_introspection_t have new fields in
  1194   dnl 10.6, which is the only source-level indication of the change.
  1195   AC_MSG_CHECKING([malloc zone version])
  1196   AC_DEFUN([JE_ZONE_PROGRAM],
  1197     [AC_LANG_PROGRAM(
  1198       [#include <malloc/malloc.h>],
  1199       [static foo[[sizeof($1) $2 sizeof(void *) * $3 ? 1 : -1]]]
  1200     )])
  1202   AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,14)],[JEMALLOC_ZONE_VERSION=3],[
  1203   AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,15)],[JEMALLOC_ZONE_VERSION=5],[
  1204   AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,16)],[
  1205     AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_introspection_t,==,9)],[JEMALLOC_ZONE_VERSION=6],[
  1206     AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_introspection_t,==,13)],[JEMALLOC_ZONE_VERSION=7],[JEMALLOC_ZONE_VERSION=]
  1207   )])],[
  1208   AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,17)],[JEMALLOC_ZONE_VERSION=8],[
  1209   AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,>,17)],[JEMALLOC_ZONE_VERSION=9],[JEMALLOC_ZONE_VERSION=]
  1210   )])])])])
  1211   if test "x${JEMALLOC_ZONE_VERSION}" = "x"; then
  1212     AC_MSG_RESULT([unsupported])
  1213     AC_MSG_ERROR([Unsupported malloc zone version])
  1214   fi
  1215   if test "${JEMALLOC_ZONE_VERSION}" = 9; then
  1216     JEMALLOC_ZONE_VERSION=8
  1217     AC_MSG_RESULT([> 8])
  1218   else
  1219     AC_MSG_RESULT([$JEMALLOC_ZONE_VERSION])
  1220   fi
  1221   AC_DEFINE_UNQUOTED(JEMALLOC_ZONE_VERSION, [$JEMALLOC_ZONE_VERSION])
  1222 fi
  1224 dnl ============================================================================
  1225 dnl Check for typedefs, structures, and compiler characteristics.
  1226 AC_HEADER_STDBOOL
  1228 AC_CONFIG_COMMANDS([include/jemalloc/internal/size_classes.h], [
  1229   mkdir -p "include/jemalloc/internal"
  1230   "${srcdir}/include/jemalloc/internal/size_classes.sh" > "${objroot}include/jemalloc/internal/size_classes.h"
  1231 ])
  1233 dnl Process .in files.
  1234 AC_SUBST([cfghdrs_in])
  1235 AC_SUBST([cfghdrs_out])
  1236 AC_CONFIG_HEADERS([$cfghdrs_tup])
  1238 dnl ============================================================================
  1239 dnl Generate outputs.
  1240 AC_CONFIG_FILES([$cfgoutputs_tup config.stamp bin/jemalloc.sh])
  1241 AC_SUBST([cfgoutputs_in])
  1242 AC_SUBST([cfgoutputs_out])
  1243 AC_OUTPUT
  1245 dnl ============================================================================
  1246 dnl Print out the results of configuration.
  1247 AC_MSG_RESULT([===============================================================================])
  1248 AC_MSG_RESULT([jemalloc version   : ${jemalloc_version}])
  1249 AC_MSG_RESULT([library revision   : ${rev}])
  1250 AC_MSG_RESULT([])
  1251 AC_MSG_RESULT([CC                 : ${CC}])
  1252 AC_MSG_RESULT([CPPFLAGS           : ${CPPFLAGS}])
  1253 AC_MSG_RESULT([CFLAGS             : ${CFLAGS}])
  1254 AC_MSG_RESULT([LDFLAGS            : ${LDFLAGS}])
  1255 AC_MSG_RESULT([LIBS               : ${LIBS}])
  1256 AC_MSG_RESULT([RPATH_EXTRA        : ${RPATH_EXTRA}])
  1257 AC_MSG_RESULT([])
  1258 AC_MSG_RESULT([XSLTPROC           : ${XSLTPROC}])
  1259 AC_MSG_RESULT([XSLROOT            : ${XSLROOT}])
  1260 AC_MSG_RESULT([])
  1261 AC_MSG_RESULT([PREFIX             : ${PREFIX}])
  1262 AC_MSG_RESULT([BINDIR             : ${BINDIR}])
  1263 AC_MSG_RESULT([INCLUDEDIR         : ${INCLUDEDIR}])
  1264 AC_MSG_RESULT([LIBDIR             : ${LIBDIR}])
  1265 AC_MSG_RESULT([DATADIR            : ${DATADIR}])
  1266 AC_MSG_RESULT([MANDIR             : ${MANDIR}])
  1267 AC_MSG_RESULT([])
  1268 AC_MSG_RESULT([srcroot            : ${srcroot}])
  1269 AC_MSG_RESULT([abs_srcroot        : ${abs_srcroot}])
  1270 AC_MSG_RESULT([objroot            : ${objroot}])
  1271 AC_MSG_RESULT([abs_objroot        : ${abs_objroot}])
  1272 AC_MSG_RESULT([])
  1273 AC_MSG_RESULT([JEMALLOC_PREFIX    : ${JEMALLOC_PREFIX}])
  1274 AC_MSG_RESULT([JEMALLOC_PRIVATE_NAMESPACE])
  1275 AC_MSG_RESULT([                   : ${JEMALLOC_PRIVATE_NAMESPACE}])
  1276 AC_MSG_RESULT([install_suffix     : ${install_suffix}])
  1277 AC_MSG_RESULT([autogen            : ${enable_autogen}])
  1278 AC_MSG_RESULT([experimental       : ${enable_experimental}])
  1279 AC_MSG_RESULT([cc-silence         : ${enable_cc_silence}])
  1280 AC_MSG_RESULT([debug              : ${enable_debug}])
  1281 AC_MSG_RESULT([stats              : ${enable_stats}])
  1282 AC_MSG_RESULT([prof               : ${enable_prof}])
  1283 AC_MSG_RESULT([prof-libunwind     : ${enable_prof_libunwind}])
  1284 AC_MSG_RESULT([prof-libgcc        : ${enable_prof_libgcc}])
  1285 AC_MSG_RESULT([prof-gcc           : ${enable_prof_gcc}])
  1286 AC_MSG_RESULT([tcache             : ${enable_tcache}])
  1287 AC_MSG_RESULT([fill               : ${enable_fill}])
  1288 AC_MSG_RESULT([utrace             : ${enable_utrace}])
  1289 AC_MSG_RESULT([valgrind           : ${enable_valgrind}])
  1290 AC_MSG_RESULT([xmalloc            : ${enable_xmalloc}])
  1291 AC_MSG_RESULT([mremap             : ${enable_mremap}])
  1292 AC_MSG_RESULT([munmap             : ${enable_munmap}])
  1293 AC_MSG_RESULT([dss                : ${enable_dss}])
  1294 AC_MSG_RESULT([lazy_lock          : ${enable_lazy_lock}])
  1295 AC_MSG_RESULT([tls                : ${enable_tls}])
  1296 AC_MSG_RESULT([===============================================================================])

mercurial