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