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