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