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