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