1<<<<<<< HEAD 2dnl Process this file with autoconf to produce a configure script. 3AC_PREREQ(2.68) 4AC_INIT([Makefile.in]) 5 6AC_CONFIG_AUX_DIR([build-aux]) 7 8dnl ============================================================================ 9dnl Custom macro definitions. 10 11dnl JE_CONCAT_VVV(r, a, b) 12dnl 13dnl Set $r to the concatenation of $a and $b, with a space separating them iff 14dnl both $a and $b are non-empty. 15AC_DEFUN([JE_CONCAT_VVV], 16if test "x[$]{$2}" = "x" -o "x[$]{$3}" = "x" ; then 17 $1="[$]{$2}[$]{$3}" 18else 19 $1="[$]{$2} [$]{$3}" 20fi 21) 22 23dnl JE_APPEND_VS(a, b) 24dnl 25dnl Set $a to the concatenation of $a and b, with a space separating them iff 26dnl both $a and b are non-empty. 27AC_DEFUN([JE_APPEND_VS], 28 T_APPEND_V=$2 29 JE_CONCAT_VVV($1, $1, T_APPEND_V) 30) 31 32CONFIGURE_CFLAGS= 33SPECIFIED_CFLAGS="${CFLAGS}" 34dnl JE_CFLAGS_ADD(cflag) 35dnl 36dnl CFLAGS is the concatenation of CONFIGURE_CFLAGS and SPECIFIED_CFLAGS 37dnl (ignoring EXTRA_CFLAGS, which does not impact configure tests. This macro 38dnl appends to CONFIGURE_CFLAGS and regenerates CFLAGS. 39AC_DEFUN([JE_CFLAGS_ADD], 40[ 41AC_MSG_CHECKING([whether compiler supports $1]) 42T_CONFIGURE_CFLAGS="${CONFIGURE_CFLAGS}" 43JE_APPEND_VS(CONFIGURE_CFLAGS, $1) 44JE_CONCAT_VVV(CFLAGS, CONFIGURE_CFLAGS, SPECIFIED_CFLAGS) 45AC_COMPILE_IFELSE([AC_LANG_PROGRAM( 46[[ 47]], [[ 48 return 0; 49]])], 50 [je_cv_cflags_added=$1] 51 AC_MSG_RESULT([yes]), 52 [je_cv_cflags_added=] 53 AC_MSG_RESULT([no]) 54 [CONFIGURE_CFLAGS="${T_CONFIGURE_CFLAGS}"] 55) 56JE_CONCAT_VVV(CFLAGS, CONFIGURE_CFLAGS, SPECIFIED_CFLAGS) 57]) 58 59dnl JE_CFLAGS_SAVE() 60dnl JE_CFLAGS_RESTORE() 61dnl 62dnl Save/restore CFLAGS. Nesting is not supported. 63AC_DEFUN([JE_CFLAGS_SAVE], 64SAVED_CONFIGURE_CFLAGS="${CONFIGURE_CFLAGS}" 65) 66AC_DEFUN([JE_CFLAGS_RESTORE], 67CONFIGURE_CFLAGS="${SAVED_CONFIGURE_CFLAGS}" 68JE_CONCAT_VVV(CFLAGS, CONFIGURE_CFLAGS, SPECIFIED_CFLAGS) 69) 70 71CONFIGURE_CXXFLAGS= 72SPECIFIED_CXXFLAGS="${CXXFLAGS}" 73dnl JE_CXXFLAGS_ADD(cxxflag) 74AC_DEFUN([JE_CXXFLAGS_ADD], 75[ 76AC_MSG_CHECKING([whether compiler supports $1]) 77T_CONFIGURE_CXXFLAGS="${CONFIGURE_CXXFLAGS}" 78JE_APPEND_VS(CONFIGURE_CXXFLAGS, $1) 79JE_CONCAT_VVV(CXXFLAGS, CONFIGURE_CXXFLAGS, SPECIFIED_CXXFLAGS) 80AC_LANG_PUSH([C++]) 81AC_COMPILE_IFELSE([AC_LANG_PROGRAM( 82[[ 83]], [[ 84 return 0; 85]])], 86 [je_cv_cxxflags_added=$1] 87 AC_MSG_RESULT([yes]), 88 [je_cv_cxxflags_added=] 89 AC_MSG_RESULT([no]) 90 [CONFIGURE_CXXFLAGS="${T_CONFIGURE_CXXFLAGS}"] 91) 92AC_LANG_POP([C++]) 93JE_CONCAT_VVV(CXXFLAGS, CONFIGURE_CXXFLAGS, SPECIFIED_CXXFLAGS) 94]) 95 96dnl JE_COMPILABLE(label, hcode, mcode, rvar) 97dnl 98dnl Use AC_LINK_IFELSE() rather than AC_COMPILE_IFELSE() so that linker errors 99dnl cause failure. 100AC_DEFUN([JE_COMPILABLE], 101[ 102AC_CACHE_CHECK([whether $1 is compilable], 103 [$4], 104 [AC_LINK_IFELSE([AC_LANG_PROGRAM([$2], 105 [$3])], 106 [$4=yes], 107 [$4=no])]) 108]) 109 110dnl ============================================================================ 111 112CONFIG=`echo ${ac_configure_args} | sed -e 's#'"'"'\([^ ]*\)'"'"'#\1#g'` 113AC_SUBST([CONFIG]) 114 115dnl Library revision. 116rev=2 117AC_SUBST([rev]) 118 119srcroot=$srcdir 120if test "x${srcroot}" = "x." ; then 121 srcroot="" 122else 123 srcroot="${srcroot}/" 124fi 125AC_SUBST([srcroot]) 126abs_srcroot="`cd \"${srcdir}\"; pwd`/" 127AC_SUBST([abs_srcroot]) 128 129objroot="" 130AC_SUBST([objroot]) 131abs_objroot="`pwd`/" 132AC_SUBST([abs_objroot]) 133 134dnl Munge install path variables. 135case "$prefix" in 136 *\ * ) AC_MSG_ERROR([Prefix should not contain spaces]) ;; 137 "NONE" ) prefix="/usr/local" ;; 138esac 139case "$exec_prefix" in 140 *\ * ) AC_MSG_ERROR([Exec prefix should not contain spaces]) ;; 141 "NONE" ) exec_prefix=$prefix ;; 142esac 143PREFIX=$prefix 144AC_SUBST([PREFIX]) 145BINDIR=`eval echo $bindir` 146BINDIR=`eval echo $BINDIR` 147AC_SUBST([BINDIR]) 148INCLUDEDIR=`eval echo $includedir` 149INCLUDEDIR=`eval echo $INCLUDEDIR` 150AC_SUBST([INCLUDEDIR]) 151LIBDIR=`eval echo $libdir` 152LIBDIR=`eval echo $LIBDIR` 153AC_SUBST([LIBDIR]) 154DATADIR=`eval echo $datadir` 155DATADIR=`eval echo $DATADIR` 156AC_SUBST([DATADIR]) 157MANDIR=`eval echo $mandir` 158MANDIR=`eval echo $MANDIR` 159AC_SUBST([MANDIR]) 160 161dnl Support for building documentation. 162AC_PATH_PROG([XSLTPROC], [xsltproc], [false], [$PATH]) 163if test -d "/usr/share/xml/docbook/stylesheet/docbook-xsl" ; then 164 DEFAULT_XSLROOT="/usr/share/xml/docbook/stylesheet/docbook-xsl" 165elif test -d "/usr/share/sgml/docbook/xsl-stylesheets" ; then 166 DEFAULT_XSLROOT="/usr/share/sgml/docbook/xsl-stylesheets" 167else 168 dnl Documentation building will fail if this default gets used. 169 DEFAULT_XSLROOT="" 170fi 171AC_ARG_WITH([xslroot], 172 [AS_HELP_STRING([--with-xslroot=<path>], [XSL stylesheet root path])], [ 173if test "x$with_xslroot" = "xno" ; then 174 XSLROOT="${DEFAULT_XSLROOT}" 175else 176 XSLROOT="${with_xslroot}" 177fi 178], 179 XSLROOT="${DEFAULT_XSLROOT}" 180) 181if test "x$XSLTPROC" = "xfalse" ; then 182 XSLROOT="" 183fi 184AC_SUBST([XSLROOT]) 185 186dnl If CFLAGS isn't defined, set CFLAGS to something reasonable. Otherwise, 187dnl just prevent autoconf from molesting CFLAGS. 188CFLAGS=$CFLAGS 189AC_PROG_CC 190 191if test "x$GCC" != "xyes" ; then 192 AC_CACHE_CHECK([whether compiler is MSVC], 193 [je_cv_msvc], 194 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], 195 [ 196#ifndef _MSC_VER 197 int fail[-1]; 198#endif 199])], 200 [je_cv_msvc=yes], 201 [je_cv_msvc=no])]) 202fi 203 204dnl check if a cray prgenv wrapper compiler is being used 205je_cv_cray_prgenv_wrapper="" 206if test "x${PE_ENV}" != "x" ; then 207 case "${CC}" in 208 CC|cc) 209 je_cv_cray_prgenv_wrapper="yes" 210 ;; 211 *) 212 ;; 213 esac 214fi 215 216AC_CACHE_CHECK([whether compiler is cray], 217 [je_cv_cray], 218 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], 219 [ 220#ifndef _CRAYC 221 int fail[-1]; 222#endif 223])], 224 [je_cv_cray=yes], 225 [je_cv_cray=no])]) 226 227if test "x${je_cv_cray}" = "xyes" ; then 228 AC_CACHE_CHECK([whether cray compiler version is 8.4], 229 [je_cv_cray_84], 230 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], 231 [ 232#if !(_RELEASE_MAJOR == 8 && _RELEASE_MINOR == 4) 233 int fail[-1]; 234#endif 235])], 236 [je_cv_cray_84=yes], 237 [je_cv_cray_84=no])]) 238fi 239 240if test "x$GCC" = "xyes" ; then 241 JE_CFLAGS_ADD([-std=gnu11]) 242 if test "x$je_cv_cflags_added" = "x-std=gnu11" ; then 243 AC_DEFINE_UNQUOTED([JEMALLOC_HAS_RESTRICT], [ ], [ ]) 244 else 245 JE_CFLAGS_ADD([-std=gnu99]) 246 if test "x$je_cv_cflags_added" = "x-std=gnu99" ; then 247 AC_DEFINE_UNQUOTED([JEMALLOC_HAS_RESTRICT], [ ], [ ]) 248 fi 249 fi 250 JE_CFLAGS_ADD([-Werror=unknown-warning-option]) 251 JE_CFLAGS_ADD([-Wall]) 252 JE_CFLAGS_ADD([-Wextra]) 253 JE_CFLAGS_ADD([-Wshorten-64-to-32]) 254 JE_CFLAGS_ADD([-Wsign-compare]) 255 JE_CFLAGS_ADD([-Wundef]) 256 JE_CFLAGS_ADD([-Wno-format-zero-length]) 257 JE_CFLAGS_ADD([-Wpointer-arith]) 258 dnl This warning triggers on the use of the universal zero initializer, which 259 dnl is a very handy idiom for things like the tcache static initializer (which 260 dnl has lots of nested structs). See the discussion at. 261 dnl https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53119 262 JE_CFLAGS_ADD([-Wno-missing-braces]) 263 dnl This one too. 264 JE_CFLAGS_ADD([-Wno-missing-field-initializers]) 265 JE_CFLAGS_ADD([-Wno-missing-attributes]) 266 JE_CFLAGS_ADD([-pipe]) 267 JE_CFLAGS_ADD([-g3]) 268elif test "x$je_cv_msvc" = "xyes" ; then 269 CC="$CC -nologo" 270 JE_CFLAGS_ADD([-Zi]) 271 JE_CFLAGS_ADD([-MT]) 272 JE_CFLAGS_ADD([-W3]) 273 JE_CFLAGS_ADD([-FS]) 274 JE_APPEND_VS(CPPFLAGS, -I${srcdir}/include/msvc_compat) 275fi 276if test "x$je_cv_cray" = "xyes" ; then 277 dnl cray compiler 8.4 has an inlining bug 278 if test "x$je_cv_cray_84" = "xyes" ; then 279 JE_CFLAGS_ADD([-hipa2]) 280 JE_CFLAGS_ADD([-hnognu]) 281 fi 282 dnl ignore unreachable code warning 283 JE_CFLAGS_ADD([-hnomessage=128]) 284 dnl ignore redefinition of "malloc", "free", etc warning 285 JE_CFLAGS_ADD([-hnomessage=1357]) 286fi 287AC_SUBST([CONFIGURE_CFLAGS]) 288AC_SUBST([SPECIFIED_CFLAGS]) 289AC_SUBST([EXTRA_CFLAGS]) 290AC_PROG_CPP 291 292AC_ARG_ENABLE([cxx], 293 [AS_HELP_STRING([--disable-cxx], [Disable C++ integration])], 294if test "x$enable_cxx" = "xno" ; then 295 enable_cxx="0" 296else 297 enable_cxx="1" 298fi 299, 300enable_cxx="1" 301) 302if test "x$enable_cxx" = "x1" ; then 303 dnl Require at least c++14, which is the first version to support sized 304 dnl deallocation. C++ support is not compiled otherwise. 305 m4_include([m4/ax_cxx_compile_stdcxx.m4]) 306 AX_CXX_COMPILE_STDCXX([17], [noext], [optional]) 307 if test "x${HAVE_CXX17}" != "x1"; then 308 AX_CXX_COMPILE_STDCXX([14], [noext], [optional]) 309 fi 310 if test "x${HAVE_CXX14}" = "x1" -o "x${HAVE_CXX17}" = "x1"; then 311 JE_CXXFLAGS_ADD([-Wall]) 312 JE_CXXFLAGS_ADD([-Wextra]) 313 JE_CXXFLAGS_ADD([-g3]) 314 315 SAVED_LIBS="${LIBS}" 316 JE_APPEND_VS(LIBS, -lstdc++) 317 JE_COMPILABLE([libstdc++ linkage], [ 318#include <stdlib.h> 319], [[ 320 int *arr = (int *)malloc(sizeof(int) * 42); 321 if (arr == NULL) 322 return 1; 323]], [je_cv_libstdcxx]) 324 if test "x${je_cv_libstdcxx}" = "xno" ; then 325 LIBS="${SAVED_LIBS}" 326 fi 327 else 328 enable_cxx="0" 329 fi 330fi 331if test "x$enable_cxx" = "x1"; then 332 AC_DEFINE([JEMALLOC_ENABLE_CXX], [ ], [ ]) 333fi 334AC_SUBST([enable_cxx]) 335AC_SUBST([CONFIGURE_CXXFLAGS]) 336AC_SUBST([SPECIFIED_CXXFLAGS]) 337AC_SUBST([EXTRA_CXXFLAGS]) 338 339AC_C_BIGENDIAN([ac_cv_big_endian=1], [ac_cv_big_endian=0]) 340if test "x${ac_cv_big_endian}" = "x1" ; then 341 AC_DEFINE_UNQUOTED([JEMALLOC_BIG_ENDIAN], [ ], [ ]) 342fi 343 344if test "x${je_cv_msvc}" = "xyes" -a "x${ac_cv_header_inttypes_h}" = "xno"; then 345 JE_APPEND_VS(CPPFLAGS, -I${srcdir}/include/msvc_compat/C99) 346fi 347 348if test "x${je_cv_msvc}" = "xyes" ; then 349 LG_SIZEOF_PTR=LG_SIZEOF_PTR_WIN 350 AC_MSG_RESULT([Using a predefined value for sizeof(void *): 4 for 32-bit, 8 for 64-bit]) 351else 352 AC_CHECK_SIZEOF([void *]) 353 if test "x${ac_cv_sizeof_void_p}" = "x8" ; then 354 LG_SIZEOF_PTR=3 355 elif test "x${ac_cv_sizeof_void_p}" = "x4" ; then 356 LG_SIZEOF_PTR=2 357 else 358 AC_MSG_ERROR([Unsupported pointer size: ${ac_cv_sizeof_void_p}]) 359 fi 360fi 361AC_DEFINE_UNQUOTED([LG_SIZEOF_PTR], [$LG_SIZEOF_PTR], [ ]) 362 363AC_CHECK_SIZEOF([int]) 364if test "x${ac_cv_sizeof_int}" = "x8" ; then 365 LG_SIZEOF_INT=3 366elif test "x${ac_cv_sizeof_int}" = "x4" ; then 367 LG_SIZEOF_INT=2 368else 369 AC_MSG_ERROR([Unsupported int size: ${ac_cv_sizeof_int}]) 370fi 371AC_DEFINE_UNQUOTED([LG_SIZEOF_INT], [$LG_SIZEOF_INT], [ ]) 372 373AC_CHECK_SIZEOF([long]) 374if test "x${ac_cv_sizeof_long}" = "x8" ; then 375 LG_SIZEOF_LONG=3 376elif test "x${ac_cv_sizeof_long}" = "x4" ; then 377 LG_SIZEOF_LONG=2 378else 379 AC_MSG_ERROR([Unsupported long size: ${ac_cv_sizeof_long}]) 380fi 381AC_DEFINE_UNQUOTED([LG_SIZEOF_LONG], [$LG_SIZEOF_LONG], [ ]) 382 383AC_CHECK_SIZEOF([long long]) 384if test "x${ac_cv_sizeof_long_long}" = "x8" ; then 385 LG_SIZEOF_LONG_LONG=3 386elif test "x${ac_cv_sizeof_long_long}" = "x4" ; then 387 LG_SIZEOF_LONG_LONG=2 388else 389 AC_MSG_ERROR([Unsupported long long size: ${ac_cv_sizeof_long_long}]) 390fi 391AC_DEFINE_UNQUOTED([LG_SIZEOF_LONG_LONG], [$LG_SIZEOF_LONG_LONG], [ ]) 392 393AC_CHECK_SIZEOF([intmax_t]) 394if test "x${ac_cv_sizeof_intmax_t}" = "x16" ; then 395 LG_SIZEOF_INTMAX_T=4 396elif test "x${ac_cv_sizeof_intmax_t}" = "x8" ; then 397 LG_SIZEOF_INTMAX_T=3 398elif test "x${ac_cv_sizeof_intmax_t}" = "x4" ; then 399 LG_SIZEOF_INTMAX_T=2 400else 401 AC_MSG_ERROR([Unsupported intmax_t size: ${ac_cv_sizeof_intmax_t}]) 402fi 403AC_DEFINE_UNQUOTED([LG_SIZEOF_INTMAX_T], [$LG_SIZEOF_INTMAX_T], [ ]) 404 405AC_CANONICAL_HOST 406dnl CPU-specific settings. 407CPU_SPINWAIT="" 408case "${host_cpu}" in 409 i686|x86_64) 410 HAVE_CPU_SPINWAIT=1 411 if test "x${je_cv_msvc}" = "xyes" ; then 412 AC_CACHE_VAL([je_cv_pause_msvc], 413 [JE_COMPILABLE([pause instruction MSVC], [], 414 [[_mm_pause(); return 0;]], 415 [je_cv_pause_msvc])]) 416 if test "x${je_cv_pause_msvc}" = "xyes" ; then 417 CPU_SPINWAIT='_mm_pause()' 418 fi 419 else 420 AC_CACHE_VAL([je_cv_pause], 421 [JE_COMPILABLE([pause instruction], [], 422 [[__asm__ volatile("pause"); return 0;]], 423 [je_cv_pause])]) 424 if test "x${je_cv_pause}" = "xyes" ; then 425 CPU_SPINWAIT='__asm__ volatile("pause")' 426 fi 427 fi 428 ;; 429 aarch64|arm*) 430 HAVE_CPU_SPINWAIT=1 431 dnl isb is a better equivalent to the pause instruction on x86. 432 AC_CACHE_VAL([je_cv_isb], 433 [JE_COMPILABLE([isb instruction], [], 434 [[__asm__ volatile("isb"); return 0;]], 435 [je_cv_isb])]) 436 if test "x${je_cv_isb}" = "xyes" ; then 437 CPU_SPINWAIT='__asm__ volatile("isb")' 438 fi 439 ;; 440 *) 441 HAVE_CPU_SPINWAIT=0 442 ;; 443esac 444AC_DEFINE_UNQUOTED([HAVE_CPU_SPINWAIT], [$HAVE_CPU_SPINWAIT], [ ]) 445AC_DEFINE_UNQUOTED([CPU_SPINWAIT], [$CPU_SPINWAIT], [ ]) 446 447AC_ARG_WITH([lg_vaddr], 448 [AS_HELP_STRING([--with-lg-vaddr=<lg-vaddr>], [Number of significant virtual address bits])], 449 [LG_VADDR="$with_lg_vaddr"], [LG_VADDR="detect"]) 450 451case "${host_cpu}" in 452 aarch64) 453 if test "x$LG_VADDR" = "xdetect"; then 454 AC_MSG_CHECKING([number of significant virtual address bits]) 455 if test "x${LG_SIZEOF_PTR}" = "x2" ; then 456 #aarch64 ILP32 457 LG_VADDR=32 458 else 459 #aarch64 LP64 460 LG_VADDR=48 461 fi 462 AC_MSG_RESULT([$LG_VADDR]) 463 fi 464 ;; 465 x86_64) 466 if test "x$LG_VADDR" = "xdetect"; then 467 AC_CACHE_CHECK([number of significant virtual address bits], 468 [je_cv_lg_vaddr], 469 AC_RUN_IFELSE([AC_LANG_PROGRAM( 470[[ 471#include <stdio.h> 472#ifdef _WIN32 473#include <limits.h> 474#include <intrin.h> 475typedef unsigned __int32 uint32_t; 476#else 477#include <stdint.h> 478#endif 479]], [[ 480 uint32_t r[[4]]; 481 uint32_t eax_in = 0x80000008U; 482#ifdef _WIN32 483 __cpuid((int *)r, (int)eax_in); 484#else 485 asm volatile ("cpuid" 486 : "=a" (r[[0]]), "=b" (r[[1]]), "=c" (r[[2]]), "=d" (r[[3]]) 487 : "a" (eax_in), "c" (0) 488 ); 489#endif 490 uint32_t eax_out = r[[0]]; 491 uint32_t vaddr = ((eax_out & 0x0000ff00U) >> 8); 492 FILE *f = fopen("conftest.out", "w"); 493 if (f == NULL) { 494 return 1; 495 } 496 if (vaddr > (sizeof(void *) << 3)) { 497 vaddr = sizeof(void *) << 3; 498 } 499 fprintf(f, "%u", vaddr); 500 fclose(f); 501 return 0; 502]])], 503 [je_cv_lg_vaddr=`cat conftest.out`], 504 [je_cv_lg_vaddr=error], 505 [je_cv_lg_vaddr=57])) 506 if test "x${je_cv_lg_vaddr}" != "x" ; then 507 LG_VADDR="${je_cv_lg_vaddr}" 508 fi 509 if test "x${LG_VADDR}" != "xerror" ; then 510 AC_DEFINE_UNQUOTED([LG_VADDR], [$LG_VADDR], [ ]) 511 else 512 AC_MSG_ERROR([cannot determine number of significant virtual address bits]) 513 fi 514 fi 515 ;; 516 *) 517 if test "x$LG_VADDR" = "xdetect"; then 518 AC_MSG_CHECKING([number of significant virtual address bits]) 519 if test "x${LG_SIZEOF_PTR}" = "x3" ; then 520 LG_VADDR=64 521 elif test "x${LG_SIZEOF_PTR}" = "x2" ; then 522 LG_VADDR=32 523 elif test "x${LG_SIZEOF_PTR}" = "xLG_SIZEOF_PTR_WIN" ; then 524 LG_VADDR="(1U << (LG_SIZEOF_PTR_WIN+3))" 525 else 526 AC_MSG_ERROR([Unsupported lg(pointer size): ${LG_SIZEOF_PTR}]) 527 fi 528 AC_MSG_RESULT([$LG_VADDR]) 529 fi 530 ;; 531esac 532AC_DEFINE_UNQUOTED([LG_VADDR], [$LG_VADDR], [ ]) 533 534LD_PRELOAD_VAR="LD_PRELOAD" 535so="so" 536importlib="${so}" 537o="$ac_objext" 538a="a" 539exe="$ac_exeext" 540libprefix="lib" 541link_whole_archive="0" 542DSO_LDFLAGS='-shared -Wl,-soname,$(@F)' 543RPATH='-Wl,-rpath,$(1)' 544SOREV="${so}.${rev}" 545PIC_CFLAGS='-fPIC -DPIC' 546CTARGET='-o $@' 547LDTARGET='-o $@' 548TEST_LD_MODE= 549EXTRA_LDFLAGS= 550ARFLAGS='crus' 551AROUT=' $@' 552CC_MM=1 553 554if test "x$je_cv_cray_prgenv_wrapper" = "xyes" ; then 555 TEST_LD_MODE='-dynamic' 556fi 557 558if test "x${je_cv_cray}" = "xyes" ; then 559 CC_MM= 560fi 561 562AN_MAKEVAR([AR], [AC_PROG_AR]) 563AN_PROGRAM([ar], [AC_PROG_AR]) 564AC_DEFUN([AC_PROG_AR], [AC_CHECK_TOOL(AR, ar, :)]) 565AC_PROG_AR 566 567AN_MAKEVAR([NM], [AC_PROG_NM]) 568AN_PROGRAM([nm], [AC_PROG_NM]) 569AC_DEFUN([AC_PROG_NM], [AC_CHECK_TOOL(NM, nm, :)]) 570AC_PROG_NM 571 572AC_PROG_AWK 573 574dnl ============================================================================ 575dnl jemalloc version. 576dnl 577 578AC_ARG_WITH([version], 579 [AS_HELP_STRING([--with-version=<major>.<minor>.<bugfix>-<nrev>-g<gid>], 580 [Version string])], 581 [ 582 echo "${with_version}" | grep ['^[0-9]\+\.[0-9]\+\.[0-9]\+-[0-9]\+-g[0-9a-f]\+$'] 2>&1 1>/dev/null 583 if test $? -eq 0 ; then 584 echo "$with_version" > "${objroot}VERSION" 585 else 586 echo "${with_version}" | grep ['^VERSION$'] 2>&1 1>/dev/null 587 if test $? -ne 0 ; then 588 AC_MSG_ERROR([${with_version} does not match <major>.<minor>.<bugfix>-<nrev>-g<gid> or VERSION]) 589 fi 590 fi 591 ], [ 592 dnl Set VERSION if source directory is inside a git repository. 593 if test "x`test ! \"${srcroot}\" && cd \"${srcroot}\"; git rev-parse --is-inside-work-tree 2>/dev/null`" = "xtrue" ; then 594 dnl Pattern globs aren't powerful enough to match both single- and 595 dnl double-digit version numbers, so iterate over patterns to support up 596 dnl to version 99.99.99 without any accidental matches. 597 for pattern in ['[0-9].[0-9].[0-9]' '[0-9].[0-9].[0-9][0-9]' \ 598 '[0-9].[0-9][0-9].[0-9]' '[0-9].[0-9][0-9].[0-9][0-9]' \ 599 '[0-9][0-9].[0-9].[0-9]' '[0-9][0-9].[0-9].[0-9][0-9]' \ 600 '[0-9][0-9].[0-9][0-9].[0-9]' \ 601 '[0-9][0-9].[0-9][0-9].[0-9][0-9]']; do 602 (test ! "${srcroot}" && cd "${srcroot}"; git describe --long --abbrev=40 --match="${pattern}") > "${objroot}VERSION.tmp" 2>/dev/null 603 if test $? -eq 0 ; then 604 mv "${objroot}VERSION.tmp" "${objroot}VERSION" 605 break 606 fi 607 done 608 fi 609 rm -f "${objroot}VERSION.tmp" 610 ]) 611 612if test ! -e "${objroot}VERSION" ; then 613 if test ! -e "${srcroot}VERSION" ; then 614 AC_MSG_RESULT( 615 [Missing VERSION file, and unable to generate it; creating bogus VERSION]) 616 echo "0.0.0-0-g000000missing_version_try_git_fetch_tags" > "${objroot}VERSION" 617 else 618 cp ${srcroot}VERSION ${objroot}VERSION 619 fi 620fi 621jemalloc_version=`cat "${objroot}VERSION"` 622jemalloc_version_major=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]1}'` 623jemalloc_version_minor=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]2}'` 624jemalloc_version_bugfix=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]3}'` 625jemalloc_version_nrev=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]4}'` 626jemalloc_version_gid=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]5}'` 627AC_SUBST([jemalloc_version]) 628AC_SUBST([jemalloc_version_major]) 629AC_SUBST([jemalloc_version_minor]) 630AC_SUBST([jemalloc_version_bugfix]) 631AC_SUBST([jemalloc_version_nrev]) 632AC_SUBST([jemalloc_version_gid]) 633 634dnl Platform-specific settings. abi and RPATH can probably be determined 635dnl programmatically, but doing so is error-prone, which makes it generally 636dnl not worth the trouble. 637dnl 638dnl Define cpp macros in CPPFLAGS, rather than doing AC_DEFINE(macro), since the 639dnl definitions need to be seen before any headers are included, which is a pain 640dnl to make happen otherwise. 641default_retain="0" 642zero_realloc_default_free="0" 643maps_coalesce="1" 644DUMP_SYMS="${NM} -a" 645SYM_PREFIX="" 646case "${host}" in 647 *-*-darwin* | *-*-ios*) 648 abi="macho" 649 RPATH="" 650 LD_PRELOAD_VAR="DYLD_INSERT_LIBRARIES" 651 so="dylib" 652 importlib="${so}" 653 force_tls="0" 654 DSO_LDFLAGS='-shared -Wl,-install_name,$(LIBDIR)/$(@F)' 655 SOREV="${rev}.${so}" 656 sbrk_deprecated="1" 657 SYM_PREFIX="_" 658 ;; 659 *-*-freebsd*) 660 JE_APPEND_VS(CPPFLAGS, -D_BSD_SOURCE) 661 abi="elf" 662 AC_DEFINE([JEMALLOC_SYSCTL_VM_OVERCOMMIT], [ ], [ ]) 663 force_lazy_lock="1" 664 ;; 665 *-*-dragonfly*) 666 abi="elf" 667 ;; 668 *-*-openbsd*) 669 abi="elf" 670 force_tls="0" 671 ;; 672 *-*-bitrig*) 673 abi="elf" 674 ;; 675 *-*-linux-android*) 676 dnl syscall(2) and secure_getenv(3) are exposed by _GNU_SOURCE. 677 JE_APPEND_VS(CPPFLAGS, -D_GNU_SOURCE) 678 abi="elf" 679 glibc="0" 680 AC_DEFINE([JEMALLOC_PURGE_MADVISE_DONTNEED_ZEROS], [ ], [ ]) 681 AC_DEFINE([JEMALLOC_HAS_ALLOCA_H], [ ], [ ]) 682 AC_DEFINE([JEMALLOC_PROC_SYS_VM_OVERCOMMIT_MEMORY], [ ], [ ]) 683 AC_DEFINE([JEMALLOC_THREADED_INIT], [ ], [ ]) 684 AC_DEFINE([JEMALLOC_C11_ATOMICS], [ ], [ ]) 685 force_tls="0" 686 if test "${LG_SIZEOF_PTR}" = "3"; then 687 default_retain="1" 688 fi 689 zero_realloc_default_free="1" 690 ;; 691 *-*-linux*) 692 dnl syscall(2) and secure_getenv(3) are exposed by _GNU_SOURCE. 693 JE_APPEND_VS(CPPFLAGS, -D_GNU_SOURCE) 694 abi="elf" 695 glibc="1" 696 AC_DEFINE([JEMALLOC_PURGE_MADVISE_DONTNEED_ZEROS], [ ], [ ]) 697 AC_DEFINE([JEMALLOC_HAS_ALLOCA_H], [ ], [ ]) 698 AC_DEFINE([JEMALLOC_PROC_SYS_VM_OVERCOMMIT_MEMORY], [ ], [ ]) 699 AC_DEFINE([JEMALLOC_THREADED_INIT], [ ], [ ]) 700 AC_DEFINE([JEMALLOC_USE_CXX_THROW], [ ], [ ]) 701 if test "${LG_SIZEOF_PTR}" = "3"; then 702 default_retain="1" 703 fi 704 zero_realloc_default_free="1" 705 ;; 706 *-*-kfreebsd*) 707 dnl syscall(2) and secure_getenv(3) are exposed by _GNU_SOURCE. 708 JE_APPEND_VS(CPPFLAGS, -D_GNU_SOURCE) 709 abi="elf" 710 AC_DEFINE([JEMALLOC_HAS_ALLOCA_H], [ ], [ ]) 711 AC_DEFINE([JEMALLOC_SYSCTL_VM_OVERCOMMIT], [ ], [ ]) 712 AC_DEFINE([JEMALLOC_THREADED_INIT], [ ], [ ]) 713 AC_DEFINE([JEMALLOC_USE_CXX_THROW], [ ], [ ]) 714 ;; 715 *-*-netbsd*) 716 AC_MSG_CHECKING([ABI]) 717 AC_COMPILE_IFELSE([AC_LANG_PROGRAM( 718[[#ifdef __ELF__ 719/* ELF */ 720#else 721#error aout 722#endif 723]])], 724 [abi="elf"], 725 [abi="aout"]) 726 AC_MSG_RESULT([$abi]) 727 ;; 728 *-*-solaris2*) 729 abi="elf" 730 RPATH='-Wl,-R,$(1)' 731 dnl Solaris needs this for sigwait(). 732 JE_APPEND_VS(CPPFLAGS, -D_POSIX_PTHREAD_SEMANTICS) 733 JE_APPEND_VS(LIBS, -lposix4 -lsocket -lnsl) 734 ;; 735 *-ibm-aix*) 736 if test "${LG_SIZEOF_PTR}" = "3"; then 737 dnl 64bit AIX 738 LD_PRELOAD_VAR="LDR_PRELOAD64" 739 else 740 dnl 32bit AIX 741 LD_PRELOAD_VAR="LDR_PRELOAD" 742 fi 743 abi="xcoff" 744 ;; 745 *-*-mingw* | *-*-cygwin*) 746 abi="pecoff" 747 force_tls="0" 748 maps_coalesce="0" 749 RPATH="" 750 so="dll" 751 if test "x$je_cv_msvc" = "xyes" ; then 752 importlib="lib" 753 DSO_LDFLAGS="-LD" 754 EXTRA_LDFLAGS="-link -DEBUG" 755 CTARGET='-Fo$@' 756 LDTARGET='-Fe$@' 757 AR='lib' 758 ARFLAGS='-nologo -out:' 759 AROUT='$@' 760 CC_MM= 761 else 762 importlib="${so}" 763 DSO_LDFLAGS="-shared" 764 link_whole_archive="1" 765 fi 766 case "${host}" in 767 *-*-cygwin*) 768 DUMP_SYMS="dumpbin /SYMBOLS" 769 ;; 770 *) 771 ;; 772 esac 773 a="lib" 774 libprefix="" 775 SOREV="${so}" 776 PIC_CFLAGS="" 777 if test "${LG_SIZEOF_PTR}" = "3"; then 778 default_retain="1" 779 fi 780 zero_realloc_default_free="1" 781 ;; 782 *-*-nto-qnx) 783 abi="elf" 784 force_tls="0" 785 AC_DEFINE([JEMALLOC_HAS_ALLOCA_H], [ ], [ ]) 786 ;; 787 *) 788 AC_MSG_RESULT([Unsupported operating system: ${host}]) 789 abi="elf" 790 ;; 791esac 792 793JEMALLOC_USABLE_SIZE_CONST=const 794AC_CHECK_HEADERS([malloc.h], [ 795 AC_MSG_CHECKING([whether malloc_usable_size definition can use const argument]) 796 AC_COMPILE_IFELSE([AC_LANG_PROGRAM( 797 [#include <malloc.h> 798 #include <stddef.h> 799 size_t malloc_usable_size(const void *ptr); 800 ], 801 [])],[ 802 AC_MSG_RESULT([yes]) 803 ],[ 804 JEMALLOC_USABLE_SIZE_CONST= 805 AC_MSG_RESULT([no]) 806 ]) 807]) 808AC_DEFINE_UNQUOTED([JEMALLOC_USABLE_SIZE_CONST], [$JEMALLOC_USABLE_SIZE_CONST], [ ]) 809AC_SUBST([abi]) 810AC_SUBST([RPATH]) 811AC_SUBST([LD_PRELOAD_VAR]) 812AC_SUBST([so]) 813AC_SUBST([importlib]) 814AC_SUBST([o]) 815AC_SUBST([a]) 816AC_SUBST([exe]) 817AC_SUBST([libprefix]) 818AC_SUBST([link_whole_archive]) 819AC_SUBST([DSO_LDFLAGS]) 820AC_SUBST([EXTRA_LDFLAGS]) 821AC_SUBST([SOREV]) 822AC_SUBST([PIC_CFLAGS]) 823AC_SUBST([CTARGET]) 824AC_SUBST([LDTARGET]) 825AC_SUBST([TEST_LD_MODE]) 826AC_SUBST([MKLIB]) 827AC_SUBST([ARFLAGS]) 828AC_SUBST([AROUT]) 829AC_SUBST([DUMP_SYMS]) 830AC_SUBST([CC_MM]) 831 832dnl Determine whether libm must be linked to use e.g. log(3). 833AC_SEARCH_LIBS([log], [m], , [AC_MSG_ERROR([Missing math functions])]) 834if test "x$ac_cv_search_log" != "xnone required" ; then 835 LM="$ac_cv_search_log" 836else 837 LM= 838fi 839AC_SUBST(LM) 840 841JE_COMPILABLE([__attribute__ syntax], 842 [static __attribute__((unused)) void foo(void){}], 843 [], 844 [je_cv_attribute]) 845if test "x${je_cv_attribute}" = "xyes" ; then 846 AC_DEFINE([JEMALLOC_HAVE_ATTR], [ ], [ ]) 847 if test "x${GCC}" = "xyes" -a "x${abi}" = "xelf"; then 848 JE_CFLAGS_ADD([-fvisibility=hidden]) 849 JE_CXXFLAGS_ADD([-fvisibility=hidden]) 850 fi 851fi 852dnl Check for tls_model attribute support (clang 3.0 still lacks support). 853JE_CFLAGS_SAVE() 854JE_CFLAGS_ADD([-Werror]) 855JE_CFLAGS_ADD([-herror_on_warning]) 856JE_COMPILABLE([tls_model attribute], [], 857 [static __thread int 858 __attribute__((tls_model("initial-exec"), unused)) foo; 859 foo = 0;], 860 [je_cv_tls_model]) 861JE_CFLAGS_RESTORE() 862dnl (Setting of JEMALLOC_TLS_MODEL is done later, after we've checked for 863dnl --disable-initial-exec-tls) 864 865dnl Check for alloc_size attribute support. 866JE_CFLAGS_SAVE() 867JE_CFLAGS_ADD([-Werror]) 868JE_CFLAGS_ADD([-herror_on_warning]) 869JE_COMPILABLE([alloc_size attribute], [#include <stdlib.h>], 870 [void *foo(size_t size) __attribute__((alloc_size(1)));], 871 [je_cv_alloc_size]) 872JE_CFLAGS_RESTORE() 873if test "x${je_cv_alloc_size}" = "xyes" ; then 874 AC_DEFINE([JEMALLOC_HAVE_ATTR_ALLOC_SIZE], [ ], [ ]) 875fi 876dnl Check for format(gnu_printf, ...) attribute support. 877JE_CFLAGS_SAVE() 878JE_CFLAGS_ADD([-Werror]) 879JE_CFLAGS_ADD([-herror_on_warning]) 880JE_COMPILABLE([format(gnu_printf, ...) attribute], [#include <stdlib.h>], 881 [void *foo(const char *format, ...) __attribute__((format(gnu_printf, 1, 2)));], 882 [je_cv_format_gnu_printf]) 883JE_CFLAGS_RESTORE() 884if test "x${je_cv_format_gnu_printf}" = "xyes" ; then 885 AC_DEFINE([JEMALLOC_HAVE_ATTR_FORMAT_GNU_PRINTF], [ ], [ ]) 886fi 887dnl Check for format(printf, ...) attribute support. 888JE_CFLAGS_SAVE() 889JE_CFLAGS_ADD([-Werror]) 890JE_CFLAGS_ADD([-herror_on_warning]) 891JE_COMPILABLE([format(printf, ...) attribute], [#include <stdlib.h>], 892 [void *foo(const char *format, ...) __attribute__((format(printf, 1, 2)));], 893 [je_cv_format_printf]) 894JE_CFLAGS_RESTORE() 895if test "x${je_cv_format_printf}" = "xyes" ; then 896 AC_DEFINE([JEMALLOC_HAVE_ATTR_FORMAT_PRINTF], [ ], [ ]) 897fi 898 899dnl Check for format_arg(...) attribute support. 900JE_CFLAGS_SAVE() 901JE_CFLAGS_ADD([-Werror]) 902JE_CFLAGS_ADD([-herror_on_warning]) 903JE_COMPILABLE([format(printf, ...) attribute], [#include <stdlib.h>], 904 [const char * __attribute__((__format_arg__(1))) foo(const char *format);], 905 [je_cv_format_arg]) 906JE_CFLAGS_RESTORE() 907if test "x${je_cv_format_arg}" = "xyes" ; then 908 AC_DEFINE([JEMALLOC_HAVE_ATTR_FORMAT_ARG], [ ], [ ]) 909fi 910 911dnl Check for fallthrough attribute support. 912JE_CFLAGS_SAVE() 913JE_CFLAGS_ADD([-Wimplicit-fallthrough]) 914JE_COMPILABLE([fallthrough attribute], 915 [#if !__has_attribute(fallthrough) 916 #error "foo" 917 #endif], 918 [int x = 0; 919 switch (x) { 920 case 0: __attribute__((__fallthrough__)); 921 case 1: return 1; 922 }], 923 [je_cv_fallthrough]) 924JE_CFLAGS_RESTORE() 925if test "x${je_cv_fallthrough}" = "xyes" ; then 926 AC_DEFINE([JEMALLOC_HAVE_ATTR_FALLTHROUGH], [ ], [ ]) 927 JE_CFLAGS_ADD([-Wimplicit-fallthrough]) 928 JE_CXXFLAGS_ADD([-Wimplicit-fallthrough]) 929fi 930 931dnl Check for cold attribute support. 932JE_CFLAGS_SAVE() 933JE_CFLAGS_ADD([-Werror]) 934JE_CFLAGS_ADD([-herror_on_warning]) 935JE_COMPILABLE([cold attribute], [], 936 [__attribute__((__cold__)) void foo();], 937 [je_cv_cold]) 938JE_CFLAGS_RESTORE() 939if test "x${je_cv_cold}" = "xyes" ; then 940 AC_DEFINE([JEMALLOC_HAVE_ATTR_COLD], [ ], [ ]) 941fi 942 943dnl Check for VM_MAKE_TAG for mmap support. 944JE_COMPILABLE([vm_make_tag], 945 [#include <sys/mman.h> 946 #include <mach/vm_statistics.h>], 947 [void *p; 948 p = mmap(0, 16, PROT_READ, MAP_ANON|MAP_PRIVATE, VM_MAKE_TAG(1), 0); 949 munmap(p, 16);], 950 [je_cv_vm_make_tag]) 951if test "x${je_cv_vm_make_tag}" = "xyes" ; then 952 AC_DEFINE([JEMALLOC_HAVE_VM_MAKE_TAG], [ ], [ ]) 953fi 954 955dnl Support optional additions to rpath. 956AC_ARG_WITH([rpath], 957 [AS_HELP_STRING([--with-rpath=<rpath>], [Colon-separated rpath (ELF systems only)])], 958if test "x$with_rpath" = "xno" ; then 959 RPATH_EXTRA= 960else 961 RPATH_EXTRA="`echo $with_rpath | tr \":\" \" \"`" 962fi, 963 RPATH_EXTRA= 964) 965AC_SUBST([RPATH_EXTRA]) 966 967dnl Disable rules that do automatic regeneration of configure output by default. 968AC_ARG_ENABLE([autogen], 969 [AS_HELP_STRING([--enable-autogen], [Automatically regenerate configure output])], 970if test "x$enable_autogen" = "xno" ; then 971 enable_autogen="0" 972else 973 enable_autogen="1" 974fi 975, 976enable_autogen="0" 977) 978AC_SUBST([enable_autogen]) 979 980AC_PROG_INSTALL 981AC_PROG_RANLIB 982AC_PATH_PROG([LD], [ld], [false], [$PATH]) 983AC_PATH_PROG([AUTOCONF], [autoconf], [false], [$PATH]) 984 985dnl Enable documentation 986AC_ARG_ENABLE([doc], 987 [AS_HELP_STRING([--enable-doc], [Build documentation])], 988if test "x$enable_doc" = "xno" ; then 989 enable_doc="0" 990else 991 enable_doc="1" 992fi 993, 994enable_doc="1" 995) 996AC_SUBST([enable_doc]) 997 998dnl Enable shared libs 999AC_ARG_ENABLE([shared], 1000 [AS_HELP_STRING([--enable-shared], [Build shared libaries])], 1001if test "x$enable_shared" = "xno" ; then 1002 enable_shared="0" 1003else 1004 enable_shared="1" 1005fi 1006, 1007enable_shared="1" 1008) 1009AC_SUBST([enable_shared]) 1010 1011dnl Enable static libs 1012AC_ARG_ENABLE([static], 1013 [AS_HELP_STRING([--enable-static], [Build static libaries])], 1014if test "x$enable_static" = "xno" ; then 1015 enable_static="0" 1016else 1017 enable_static="1" 1018fi 1019, 1020enable_static="1" 1021) 1022AC_SUBST([enable_static]) 1023 1024if test "$enable_shared$enable_static" = "00" ; then 1025 AC_MSG_ERROR([Please enable one of shared or static builds]) 1026fi 1027 1028dnl Perform no name mangling by default. 1029AC_ARG_WITH([mangling], 1030 [AS_HELP_STRING([--with-mangling=<map>], [Mangle symbols in <map>])], 1031 [mangling_map="$with_mangling"], [mangling_map=""]) 1032 1033dnl Do not prefix public APIs by default. 1034AC_ARG_WITH([jemalloc_prefix], 1035 [AS_HELP_STRING([--with-jemalloc-prefix=<prefix>], [Prefix to prepend to all public APIs])], 1036 [JEMALLOC_PREFIX="$with_jemalloc_prefix"], 1037 [if test "x$abi" != "xmacho" -a "x$abi" != "xpecoff"; then 1038 JEMALLOC_PREFIX="" 1039else 1040 JEMALLOC_PREFIX="je_" 1041fi] 1042) 1043if test "x$JEMALLOC_PREFIX" = "x" ; then 1044 AC_DEFINE([JEMALLOC_IS_MALLOC], [ ], [ ]) 1045else 1046 JEMALLOC_CPREFIX=`echo ${JEMALLOC_PREFIX} | tr "a-z" "A-Z"` 1047 AC_DEFINE_UNQUOTED([JEMALLOC_PREFIX], ["$JEMALLOC_PREFIX"], [ ]) 1048 AC_DEFINE_UNQUOTED([JEMALLOC_CPREFIX], ["$JEMALLOC_CPREFIX"], [ ]) 1049fi 1050AC_SUBST([JEMALLOC_PREFIX]) 1051AC_SUBST([JEMALLOC_CPREFIX]) 1052 1053AC_ARG_WITH([export], 1054 [AS_HELP_STRING([--without-export], [disable exporting jemalloc public APIs])], 1055 [if test "x$with_export" = "xno"; then 1056 AC_DEFINE([JEMALLOC_EXPORT],[], [ ]) 1057fi] 1058) 1059 1060public_syms="aligned_alloc calloc dallocx free mallctl mallctlbymib mallctlnametomib malloc malloc_conf malloc_conf_2_conf_harder malloc_message malloc_stats_print malloc_usable_size mallocx smallocx_${jemalloc_version_gid} nallocx posix_memalign rallocx realloc sallocx sdallocx xallocx" 1061dnl Check for additional platform-specific public API functions. 1062AC_CHECK_FUNC([memalign], 1063 [AC_DEFINE([JEMALLOC_OVERRIDE_MEMALIGN], [ ], [ ]) 1064 public_syms="${public_syms} memalign"]) 1065AC_CHECK_FUNC([valloc], 1066 [AC_DEFINE([JEMALLOC_OVERRIDE_VALLOC], [ ], [ ]) 1067 public_syms="${public_syms} valloc"]) 1068AC_CHECK_FUNC([malloc_size], 1069 [AC_DEFINE([JEMALLOC_HAVE_MALLOC_SIZE], [ ], [ ]) 1070 public_syms="${public_syms} malloc_size"]) 1071 1072dnl Check for allocator-related functions that should be wrapped. 1073wrap_syms= 1074if test "x${JEMALLOC_PREFIX}" = "x" ; then 1075 AC_CHECK_FUNC([__libc_calloc], 1076 [AC_DEFINE([JEMALLOC_OVERRIDE___LIBC_CALLOC], [ ], [ ]) 1077 wrap_syms="${wrap_syms} __libc_calloc"]) 1078 AC_CHECK_FUNC([__libc_free], 1079 [AC_DEFINE([JEMALLOC_OVERRIDE___LIBC_FREE], [ ], [ ]) 1080 wrap_syms="${wrap_syms} __libc_free"]) 1081 AC_CHECK_FUNC([__libc_malloc], 1082 [AC_DEFINE([JEMALLOC_OVERRIDE___LIBC_MALLOC], [ ], [ ]) 1083 wrap_syms="${wrap_syms} __libc_malloc"]) 1084 AC_CHECK_FUNC([__libc_memalign], 1085 [AC_DEFINE([JEMALLOC_OVERRIDE___LIBC_MEMALIGN], [ ], [ ]) 1086 wrap_syms="${wrap_syms} __libc_memalign"]) 1087 AC_CHECK_FUNC([__libc_realloc], 1088 [AC_DEFINE([JEMALLOC_OVERRIDE___LIBC_REALLOC], [ ], [ ]) 1089 wrap_syms="${wrap_syms} __libc_realloc"]) 1090 AC_CHECK_FUNC([__libc_valloc], 1091 [AC_DEFINE([JEMALLOC_OVERRIDE___LIBC_VALLOC], [ ], [ ]) 1092 wrap_syms="${wrap_syms} __libc_valloc"]) 1093 AC_CHECK_FUNC([__posix_memalign], 1094 [AC_DEFINE([JEMALLOC_OVERRIDE___POSIX_MEMALIGN], [ ], [ ]) 1095 wrap_syms="${wrap_syms} __posix_memalign"]) 1096fi 1097 1098case "${host}" in 1099 *-*-mingw* | *-*-cygwin*) 1100 wrap_syms="${wrap_syms} tls_callback" 1101 ;; 1102 *) 1103 ;; 1104esac 1105 1106dnl Mangle library-private APIs. 1107AC_ARG_WITH([private_namespace], 1108 [AS_HELP_STRING([--with-private-namespace=<prefix>], [Prefix to prepend to all library-private APIs])], 1109 [JEMALLOC_PRIVATE_NAMESPACE="${with_private_namespace}je_"], 1110 [JEMALLOC_PRIVATE_NAMESPACE="je_"] 1111) 1112AC_DEFINE_UNQUOTED([JEMALLOC_PRIVATE_NAMESPACE], [$JEMALLOC_PRIVATE_NAMESPACE], [ ]) 1113private_namespace="$JEMALLOC_PRIVATE_NAMESPACE" 1114AC_SUBST([private_namespace]) 1115 1116dnl Do not add suffix to installed files by default. 1117AC_ARG_WITH([install_suffix], 1118 [AS_HELP_STRING([--with-install-suffix=<suffix>], [Suffix to append to all installed files])], 1119 [case "$with_install_suffix" in 1120 *\ * ) AC_MSG_ERROR([Install suffix should not contain spaces]) ;; 1121 * ) INSTALL_SUFFIX="$with_install_suffix" ;; 1122esac], 1123 [INSTALL_SUFFIX=] 1124) 1125install_suffix="$INSTALL_SUFFIX" 1126AC_SUBST([install_suffix]) 1127 1128dnl Specify default malloc_conf. 1129AC_ARG_WITH([malloc_conf], 1130 [AS_HELP_STRING([--with-malloc-conf=<malloc_conf>], [config.malloc_conf options string])], 1131 [JEMALLOC_CONFIG_MALLOC_CONF="$with_malloc_conf"], 1132 [JEMALLOC_CONFIG_MALLOC_CONF=""] 1133) 1134config_malloc_conf="$JEMALLOC_CONFIG_MALLOC_CONF" 1135AC_DEFINE_UNQUOTED([JEMALLOC_CONFIG_MALLOC_CONF], ["$config_malloc_conf"], [ ]) 1136 1137dnl Substitute @je_@ in jemalloc_protos.h.in, primarily to make generation of 1138dnl jemalloc_protos_jet.h easy. 1139je_="je_" 1140AC_SUBST([je_]) 1141 1142cfgoutputs_in="Makefile.in" 1143cfgoutputs_in="${cfgoutputs_in} jemalloc.pc.in" 1144cfgoutputs_in="${cfgoutputs_in} doc/html.xsl.in" 1145cfgoutputs_in="${cfgoutputs_in} doc/manpages.xsl.in" 1146cfgoutputs_in="${cfgoutputs_in} doc/jemalloc.xml.in" 1147cfgoutputs_in="${cfgoutputs_in} include/jemalloc/jemalloc_macros.h.in" 1148cfgoutputs_in="${cfgoutputs_in} include/jemalloc/jemalloc_protos.h.in" 1149cfgoutputs_in="${cfgoutputs_in} include/jemalloc/jemalloc_typedefs.h.in" 1150cfgoutputs_in="${cfgoutputs_in} include/jemalloc/internal/jemalloc_preamble.h.in" 1151cfgoutputs_in="${cfgoutputs_in} test/test.sh.in" 1152cfgoutputs_in="${cfgoutputs_in} test/include/test/jemalloc_test.h.in" 1153 1154cfgoutputs_out="Makefile" 1155cfgoutputs_out="${cfgoutputs_out} jemalloc.pc" 1156cfgoutputs_out="${cfgoutputs_out} doc/html.xsl" 1157cfgoutputs_out="${cfgoutputs_out} doc/manpages.xsl" 1158cfgoutputs_out="${cfgoutputs_out} doc/jemalloc.xml" 1159cfgoutputs_out="${cfgoutputs_out} include/jemalloc/jemalloc_macros.h" 1160cfgoutputs_out="${cfgoutputs_out} include/jemalloc/jemalloc_protos.h" 1161cfgoutputs_out="${cfgoutputs_out} include/jemalloc/jemalloc_typedefs.h" 1162cfgoutputs_out="${cfgoutputs_out} include/jemalloc/internal/jemalloc_preamble.h" 1163cfgoutputs_out="${cfgoutputs_out} test/test.sh" 1164cfgoutputs_out="${cfgoutputs_out} test/include/test/jemalloc_test.h" 1165 1166cfgoutputs_tup="Makefile" 1167cfgoutputs_tup="${cfgoutputs_tup} jemalloc.pc:jemalloc.pc.in" 1168cfgoutputs_tup="${cfgoutputs_tup} doc/html.xsl:doc/html.xsl.in" 1169cfgoutputs_tup="${cfgoutputs_tup} doc/manpages.xsl:doc/manpages.xsl.in" 1170cfgoutputs_tup="${cfgoutputs_tup} doc/jemalloc.xml:doc/jemalloc.xml.in" 1171cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/jemalloc_macros.h:include/jemalloc/jemalloc_macros.h.in" 1172cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/jemalloc_protos.h:include/jemalloc/jemalloc_protos.h.in" 1173cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/jemalloc_typedefs.h:include/jemalloc/jemalloc_typedefs.h.in" 1174cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/internal/jemalloc_preamble.h" 1175cfgoutputs_tup="${cfgoutputs_tup} test/test.sh:test/test.sh.in" 1176cfgoutputs_tup="${cfgoutputs_tup} test/include/test/jemalloc_test.h:test/include/test/jemalloc_test.h.in" 1177 1178cfghdrs_in="include/jemalloc/jemalloc_defs.h.in" 1179cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/jemalloc_internal_defs.h.in" 1180cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/private_symbols.sh" 1181cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/private_namespace.sh" 1182cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/public_namespace.sh" 1183cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/public_unnamespace.sh" 1184cfghdrs_in="${cfghdrs_in} include/jemalloc/jemalloc_rename.sh" 1185cfghdrs_in="${cfghdrs_in} include/jemalloc/jemalloc_mangle.sh" 1186cfghdrs_in="${cfghdrs_in} include/jemalloc/jemalloc.sh" 1187cfghdrs_in="${cfghdrs_in} test/include/test/jemalloc_test_defs.h.in" 1188 1189cfghdrs_out="include/jemalloc/jemalloc_defs.h" 1190cfghdrs_out="${cfghdrs_out} include/jemalloc/jemalloc${install_suffix}.h" 1191cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/private_symbols.awk" 1192cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/private_symbols_jet.awk" 1193cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/public_symbols.txt" 1194cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/public_namespace.h" 1195cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/public_unnamespace.h" 1196cfghdrs_out="${cfghdrs_out} include/jemalloc/jemalloc_protos_jet.h" 1197cfghdrs_out="${cfghdrs_out} include/jemalloc/jemalloc_rename.h" 1198cfghdrs_out="${cfghdrs_out} include/jemalloc/jemalloc_mangle.h" 1199cfghdrs_out="${cfghdrs_out} include/jemalloc/jemalloc_mangle_jet.h" 1200cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/jemalloc_internal_defs.h" 1201cfghdrs_out="${cfghdrs_out} test/include/test/jemalloc_test_defs.h" 1202 1203cfghdrs_tup="include/jemalloc/jemalloc_defs.h:include/jemalloc/jemalloc_defs.h.in" 1204cfghdrs_tup="${cfghdrs_tup} include/jemalloc/internal/jemalloc_internal_defs.h:include/jemalloc/internal/jemalloc_internal_defs.h.in" 1205cfghdrs_tup="${cfghdrs_tup} test/include/test/jemalloc_test_defs.h:test/include/test/jemalloc_test_defs.h.in" 1206 1207dnl ============================================================================ 1208dnl jemalloc build options. 1209dnl 1210 1211dnl Do not compile with debugging by default. 1212AC_ARG_ENABLE([debug], 1213 [AS_HELP_STRING([--enable-debug], 1214 [Build debugging code])], 1215[if test "x$enable_debug" = "xno" ; then 1216 enable_debug="0" 1217else 1218 enable_debug="1" 1219fi 1220], 1221[enable_debug="0"] 1222) 1223if test "x$enable_debug" = "x1" ; then 1224 AC_DEFINE([JEMALLOC_DEBUG], [ ], [ ]) 1225fi 1226AC_SUBST([enable_debug]) 1227 1228dnl Only optimize if not debugging. 1229if test "x$enable_debug" = "x0" ; then 1230 if test "x$GCC" = "xyes" ; then 1231 JE_CFLAGS_ADD([-O3]) 1232 JE_CXXFLAGS_ADD([-O3]) 1233 JE_CFLAGS_ADD([-funroll-loops]) 1234 elif test "x$je_cv_msvc" = "xyes" ; then 1235 JE_CFLAGS_ADD([-O2]) 1236 JE_CXXFLAGS_ADD([-O2]) 1237 else 1238 JE_CFLAGS_ADD([-O]) 1239 JE_CXXFLAGS_ADD([-O]) 1240 fi 1241fi 1242 1243dnl Enable statistics calculation by default. 1244AC_ARG_ENABLE([stats], 1245 [AS_HELP_STRING([--disable-stats], 1246 [Disable statistics calculation/reporting])], 1247[if test "x$enable_stats" = "xno" ; then 1248 enable_stats="0" 1249else 1250 enable_stats="1" 1251fi 1252], 1253[enable_stats="1"] 1254) 1255if test "x$enable_stats" = "x1" ; then 1256 AC_DEFINE([JEMALLOC_STATS], [ ], [ ]) 1257fi 1258AC_SUBST([enable_stats]) 1259 1260dnl Do not enable smallocx by default. 1261AC_ARG_ENABLE([experimental_smallocx], 1262 [AS_HELP_STRING([--enable-experimental-smallocx], [Enable experimental smallocx API])], 1263[if test "x$enable_experimental_smallocx" = "xno" ; then 1264enable_experimental_smallocx="0" 1265else 1266enable_experimental_smallocx="1" 1267fi 1268], 1269[enable_experimental_smallocx="0"] 1270) 1271if test "x$enable_experimental_smallocx" = "x1" ; then 1272 AC_DEFINE([JEMALLOC_EXPERIMENTAL_SMALLOCX_API], [ ], [ ]) 1273fi 1274AC_SUBST([enable_experimental_smallocx]) 1275 1276dnl Do not enable profiling by default. 1277AC_ARG_ENABLE([prof], 1278 [AS_HELP_STRING([--enable-prof], [Enable allocation profiling])], 1279[if test "x$enable_prof" = "xno" ; then 1280 enable_prof="0" 1281else 1282 enable_prof="1" 1283fi 1284], 1285[enable_prof="0"] 1286) 1287if test "x$enable_prof" = "x1" ; then 1288 backtrace_method="" 1289else 1290 backtrace_method="N/A" 1291fi 1292 1293AC_ARG_ENABLE([prof-libunwind], 1294 [AS_HELP_STRING([--enable-prof-libunwind], [Use libunwind for backtracing])], 1295[if test "x$enable_prof_libunwind" = "xno" ; then 1296 enable_prof_libunwind="0" 1297else 1298 enable_prof_libunwind="1" 1299 if test "x$enable_prof" = "x0" ; then 1300 AC_MSG_ERROR([--enable-prof-libunwind should only be used with --enable-prof]) 1301 fi 1302fi 1303], 1304[enable_prof_libunwind="0"] 1305) 1306AC_ARG_WITH([static_libunwind], 1307 [AS_HELP_STRING([--with-static-libunwind=<libunwind.a>], 1308 [Path to static libunwind library; use rather than dynamically linking])], 1309if test "x$with_static_libunwind" = "xno" ; then 1310 LUNWIND="-lunwind" 1311else 1312 if test ! -f "$with_static_libunwind" ; then 1313 AC_MSG_ERROR([Static libunwind not found: $with_static_libunwind]) 1314 fi 1315 LUNWIND="$with_static_libunwind" 1316fi, 1317 LUNWIND="-lunwind" 1318) 1319if test "x$backtrace_method" = "x" -a "x$enable_prof_libunwind" = "x1" ; then 1320 AC_CHECK_HEADERS([libunwind.h], , [enable_prof_libunwind="0"]) 1321 if test "x$LUNWIND" = "x-lunwind" ; then 1322 AC_CHECK_LIB([unwind], [unw_backtrace], [JE_APPEND_VS(LIBS, $LUNWIND)], 1323 [enable_prof_libunwind="0"]) 1324 else 1325 JE_APPEND_VS(LIBS, $LUNWIND) 1326 fi 1327 if test "x${enable_prof_libunwind}" = "x1" ; then 1328 backtrace_method="libunwind" 1329 AC_DEFINE([JEMALLOC_PROF_LIBUNWIND], [ ], [ ]) 1330 fi 1331fi 1332 1333AC_ARG_ENABLE([prof-libgcc], 1334 [AS_HELP_STRING([--disable-prof-libgcc], 1335 [Do not use libgcc for backtracing])], 1336[if test "x$enable_prof_libgcc" = "xno" ; then 1337 enable_prof_libgcc="0" 1338else 1339 enable_prof_libgcc="1" 1340fi 1341], 1342[enable_prof_libgcc="1"] 1343) 1344if test "x$backtrace_method" = "x" -a "x$enable_prof_libgcc" = "x1" \ 1345 -a "x$GCC" = "xyes" ; then 1346 AC_CHECK_HEADERS([unwind.h], , [enable_prof_libgcc="0"]) 1347 if test "x${enable_prof_libgcc}" = "x1" ; then 1348 AC_CHECK_LIB([gcc], [_Unwind_Backtrace], [JE_APPEND_VS(LIBS, -lgcc)], [enable_prof_libgcc="0"]) 1349 fi 1350 if test "x${enable_prof_libgcc}" = "x1" ; then 1351 backtrace_method="libgcc" 1352 AC_DEFINE([JEMALLOC_PROF_LIBGCC], [ ], [ ]) 1353 fi 1354else 1355 enable_prof_libgcc="0" 1356fi 1357 1358AC_ARG_ENABLE([prof-gcc], 1359 [AS_HELP_STRING([--disable-prof-gcc], 1360 [Do not use gcc intrinsics for backtracing])], 1361[if test "x$enable_prof_gcc" = "xno" ; then 1362 enable_prof_gcc="0" 1363else 1364 enable_prof_gcc="1" 1365fi 1366], 1367[enable_prof_gcc="1"] 1368) 1369if test "x$backtrace_method" = "x" -a "x$enable_prof_gcc" = "x1" \ 1370 -a "x$GCC" = "xyes" ; then 1371 JE_CFLAGS_ADD([-fno-omit-frame-pointer]) 1372 backtrace_method="gcc intrinsics" 1373 AC_DEFINE([JEMALLOC_PROF_GCC], [ ], [ ]) 1374else 1375 enable_prof_gcc="0" 1376fi 1377 1378if test "x$backtrace_method" = "x" ; then 1379 backtrace_method="none (disabling profiling)" 1380 enable_prof="0" 1381fi 1382AC_MSG_CHECKING([configured backtracing method]) 1383AC_MSG_RESULT([$backtrace_method]) 1384if test "x$enable_prof" = "x1" ; then 1385 dnl Heap profiling uses the log(3) function. 1386 JE_APPEND_VS(LIBS, $LM) 1387 1388 AC_DEFINE([JEMALLOC_PROF], [ ], [ ]) 1389fi 1390AC_SUBST([enable_prof]) 1391 1392dnl Indicate whether adjacent virtual memory mappings automatically coalesce 1393dnl (and fragment on demand). 1394if test "x${maps_coalesce}" = "x1" ; then 1395 AC_DEFINE([JEMALLOC_MAPS_COALESCE], [ ], [ ]) 1396fi 1397 1398dnl Indicate whether to retain memory (rather than using munmap()) by default. 1399if test "x$default_retain" = "x1" ; then 1400 AC_DEFINE([JEMALLOC_RETAIN], [ ], [ ]) 1401fi 1402 1403dnl Indicate whether realloc(ptr, 0) defaults to the "alloc" behavior. 1404if test "x$zero_realloc_default_free" = "x1" ; then 1405 AC_DEFINE([JEMALLOC_ZERO_REALLOC_DEFAULT_FREE], [ ], [ ]) 1406fi 1407 1408dnl Enable allocation from DSS if supported by the OS. 1409have_dss="1" 1410dnl Check whether the BSD/SUSv1 sbrk() exists. If not, disable DSS support. 1411AC_CHECK_FUNC([sbrk], [have_sbrk="1"], [have_sbrk="0"]) 1412if test "x$have_sbrk" = "x1" ; then 1413 if test "x$sbrk_deprecated" = "x1" ; then 1414 AC_MSG_RESULT([Disabling dss allocation because sbrk is deprecated]) 1415 have_dss="0" 1416 fi 1417else 1418 have_dss="0" 1419fi 1420 1421if test "x$have_dss" = "x1" ; then 1422 AC_DEFINE([JEMALLOC_DSS], [ ], [ ]) 1423fi 1424 1425dnl Support the junk/zero filling option by default. 1426AC_ARG_ENABLE([fill], 1427 [AS_HELP_STRING([--disable-fill], [Disable support for junk/zero filling])], 1428[if test "x$enable_fill" = "xno" ; then 1429 enable_fill="0" 1430else 1431 enable_fill="1" 1432fi 1433], 1434[enable_fill="1"] 1435) 1436if test "x$enable_fill" = "x1" ; then 1437 AC_DEFINE([JEMALLOC_FILL], [ ], [ ]) 1438fi 1439AC_SUBST([enable_fill]) 1440 1441dnl Disable utrace(2)-based tracing by default. 1442AC_ARG_ENABLE([utrace], 1443 [AS_HELP_STRING([--enable-utrace], [Enable utrace(2)-based tracing])], 1444[if test "x$enable_utrace" = "xno" ; then 1445 enable_utrace="0" 1446else 1447 enable_utrace="1" 1448fi 1449], 1450[enable_utrace="0"] 1451) 1452JE_COMPILABLE([utrace(2)], [ 1453#include <sys/types.h> 1454#include <sys/param.h> 1455#include <sys/time.h> 1456#include <sys/uio.h> 1457#include <sys/ktrace.h> 1458], [ 1459 utrace((void *)0, 0); 1460], [je_cv_utrace]) 1461if test "x${je_cv_utrace}" = "xno" ; then 1462 JE_COMPILABLE([utrace(2) with label], [ 1463 #include <sys/types.h> 1464 #include <sys/param.h> 1465 #include <sys/time.h> 1466 #include <sys/uio.h> 1467 #include <sys/ktrace.h> 1468 ], [ 1469 utrace((void *)0, (void *)0, 0); 1470 ], [je_cv_utrace_label]) 1471 if test "x${je_cv_utrace_label}" = "xno"; then 1472 enable_utrace="0" 1473 fi 1474 if test "x$enable_utrace" = "x1" ; then 1475 AC_DEFINE([JEMALLOC_UTRACE_LABEL], [ ], [ ]) 1476 fi 1477else 1478 if test "x$enable_utrace" = "x1" ; then 1479 AC_DEFINE([JEMALLOC_UTRACE], [ ], [ ]) 1480 fi 1481fi 1482AC_SUBST([enable_utrace]) 1483 1484dnl Do not support the xmalloc option by default. 1485AC_ARG_ENABLE([xmalloc], 1486 [AS_HELP_STRING([--enable-xmalloc], [Support xmalloc option])], 1487[if test "x$enable_xmalloc" = "xno" ; then 1488 enable_xmalloc="0" 1489else 1490 enable_xmalloc="1" 1491fi 1492], 1493[enable_xmalloc="0"] 1494) 1495if test "x$enable_xmalloc" = "x1" ; then 1496 AC_DEFINE([JEMALLOC_XMALLOC], [ ], [ ]) 1497fi 1498AC_SUBST([enable_xmalloc]) 1499 1500dnl Support cache-oblivious allocation alignment by default. 1501AC_ARG_ENABLE([cache-oblivious], 1502 [AS_HELP_STRING([--disable-cache-oblivious], 1503 [Disable support for cache-oblivious allocation alignment])], 1504[if test "x$enable_cache_oblivious" = "xno" ; then 1505 enable_cache_oblivious="0" 1506else 1507 enable_cache_oblivious="1" 1508fi 1509], 1510[enable_cache_oblivious="1"] 1511) 1512if test "x$enable_cache_oblivious" = "x1" ; then 1513 AC_DEFINE([JEMALLOC_CACHE_OBLIVIOUS], [ ], [ ]) 1514fi 1515AC_SUBST([enable_cache_oblivious]) 1516 1517dnl Do not log by default. 1518AC_ARG_ENABLE([log], 1519 [AS_HELP_STRING([--enable-log], [Support debug logging])], 1520[if test "x$enable_log" = "xno" ; then 1521 enable_log="0" 1522else 1523 enable_log="1" 1524fi 1525], 1526[enable_log="0"] 1527) 1528if test "x$enable_log" = "x1" ; then 1529 AC_DEFINE([JEMALLOC_LOG], [ ], [ ]) 1530fi 1531AC_SUBST([enable_log]) 1532 1533dnl Do not use readlinkat by default 1534AC_ARG_ENABLE([readlinkat], 1535 [AS_HELP_STRING([--enable-readlinkat], [Use readlinkat over readlink])], 1536[if test "x$enable_readlinkat" = "xno" ; then 1537 enable_readlinkat="0" 1538else 1539 enable_readlinkat="1" 1540fi 1541], 1542[enable_readlinkat="0"] 1543) 1544if test "x$enable_readlinkat" = "x1" ; then 1545 AC_DEFINE([JEMALLOC_READLINKAT], [ ], [ ]) 1546fi 1547AC_SUBST([enable_readlinkat]) 1548 1549dnl Avoid extra safety checks by default 1550AC_ARG_ENABLE([opt-safety-checks], 1551 [AS_HELP_STRING([--enable-opt-safety-checks], 1552 [Perform certain low-overhead checks, even in opt mode])], 1553[if test "x$enable_opt_safety_checks" = "xno" ; then 1554 enable_opt_safety_checks="0" 1555else 1556 enable_opt_safety_checks="1" 1557fi 1558], 1559[enable_opt_safety_checks="0"] 1560) 1561if test "x$enable_opt_safety_checks" = "x1" ; then 1562 AC_DEFINE([JEMALLOC_OPT_SAFETY_CHECKS], [ ], [ ]) 1563fi 1564AC_SUBST([enable_opt_safety_checks]) 1565 1566dnl Look for sized-deallocation bugs while otherwise being in opt mode. 1567AC_ARG_ENABLE([opt-size-checks], 1568 [AS_HELP_STRING([--enable-opt-size-checks], 1569 [Perform sized-deallocation argument checks, even in opt mode])], 1570[if test "x$enable_opt_size_checks" = "xno" ; then 1571 enable_opt_size_checks="0" 1572else 1573 enable_opt_size_checks="1" 1574fi 1575], 1576[enable_opt_size_checks="0"] 1577) 1578if test "x$enable_opt_size_checks" = "x1" ; then 1579 AC_DEFINE([JEMALLOC_OPT_SIZE_CHECKS], [ ], [ ]) 1580fi 1581AC_SUBST([enable_opt_size_checks]) 1582 1583dnl Do not check for use-after-free by default. 1584AC_ARG_ENABLE([uaf-detection], 1585 [AS_HELP_STRING([--enable-uaf-detection], 1586 [Allow sampled junk-filling on deallocation to detect use-after-free])], 1587[if test "x$enable_uaf_detection" = "xno" ; then 1588 enable_uaf_detection="0" 1589else 1590 enable_uaf_detection="1" 1591fi 1592], 1593[enable_uaf_detection="0"] 1594) 1595if test "x$enable_uaf_detection" = "x1" ; then 1596 AC_DEFINE([JEMALLOC_UAF_DETECTION], [ ]) 1597fi 1598AC_SUBST([enable_uaf_detection]) 1599 1600JE_COMPILABLE([a program using __builtin_unreachable], [ 1601void foo (void) { 1602 __builtin_unreachable(); 1603} 1604], [ 1605 { 1606 foo(); 1607 } 1608], [je_cv_gcc_builtin_unreachable]) 1609if test "x${je_cv_gcc_builtin_unreachable}" = "xyes" ; then 1610 AC_DEFINE([JEMALLOC_INTERNAL_UNREACHABLE], [__builtin_unreachable], [ ]) 1611else 1612 AC_DEFINE([JEMALLOC_INTERNAL_UNREACHABLE], [abort], [ ]) 1613fi 1614 1615dnl ============================================================================ 1616dnl Check for __builtin_ffsl(), then ffsl(3), and fail if neither are found. 1617dnl One of those two functions should (theoretically) exist on all platforms 1618dnl that jemalloc currently has a chance of functioning on without modification. 1619dnl We additionally assume ffs[ll]() or __builtin_ffs[ll]() are defined if 1620dnl ffsl() or __builtin_ffsl() are defined, respectively. 1621JE_COMPILABLE([a program using __builtin_ffsl], [ 1622#include <stdio.h> 1623#include <strings.h> 1624#include <string.h> 1625], [ 1626 { 1627 int rv = __builtin_ffsl(0x08); 1628 printf("%d\n", rv); 1629 } 1630], [je_cv_gcc_builtin_ffsl]) 1631if test "x${je_cv_gcc_builtin_ffsl}" = "xyes" ; then 1632 AC_DEFINE([JEMALLOC_INTERNAL_FFSLL], [__builtin_ffsll], [ ]) 1633 AC_DEFINE([JEMALLOC_INTERNAL_FFSL], [__builtin_ffsl], [ ]) 1634 AC_DEFINE([JEMALLOC_INTERNAL_FFS], [__builtin_ffs], [ ]) 1635else 1636 JE_COMPILABLE([a program using ffsl], [ 1637 #include <stdio.h> 1638 #include <strings.h> 1639 #include <string.h> 1640 ], [ 1641 { 1642 int rv = ffsl(0x08); 1643 printf("%d\n", rv); 1644 } 1645 ], [je_cv_function_ffsl]) 1646 if test "x${je_cv_function_ffsl}" = "xyes" ; then 1647 AC_DEFINE([JEMALLOC_INTERNAL_FFSLL], [ffsll], [ ]) 1648 AC_DEFINE([JEMALLOC_INTERNAL_FFSL], [ffsl], [ ]) 1649 AC_DEFINE([JEMALLOC_INTERNAL_FFS], [ffs], [ ]) 1650 else 1651 AC_MSG_ERROR([Cannot build without ffsl(3) or __builtin_ffsl()]) 1652 fi 1653fi 1654 1655JE_COMPILABLE([a program using __builtin_popcountl], [ 1656#include <stdio.h> 1657#include <strings.h> 1658#include <string.h> 1659], [ 1660 { 1661 int rv = __builtin_popcountl(0x08); 1662 printf("%d\n", rv); 1663 } 1664], [je_cv_gcc_builtin_popcountl]) 1665if test "x${je_cv_gcc_builtin_popcountl}" = "xyes" ; then 1666 AC_DEFINE([JEMALLOC_INTERNAL_POPCOUNT], [__builtin_popcount], [ ]) 1667 AC_DEFINE([JEMALLOC_INTERNAL_POPCOUNTL], [__builtin_popcountl], [ ]) 1668 AC_DEFINE([JEMALLOC_INTERNAL_POPCOUNTLL], [__builtin_popcountll], [ ]) 1669fi 1670 1671AC_ARG_WITH([lg_quantum], 1672 [AS_HELP_STRING([--with-lg-quantum=<lg-quantum>], 1673 [Base 2 log of minimum allocation alignment])]) 1674if test "x$with_lg_quantum" != "x" ; then 1675 AC_DEFINE_UNQUOTED([LG_QUANTUM], [$with_lg_quantum], [ ]) 1676fi 1677 1678AC_ARG_WITH([lg_slab_maxregs], 1679 [AS_HELP_STRING([--with-lg-slab-maxregs=<lg-slab-maxregs>], 1680 [Base 2 log of maximum number of regions in a slab (used with malloc_conf slab_sizes)])], 1681 [CONFIG_LG_SLAB_MAXREGS="with_lg_slab_maxregs"], 1682 [CONFIG_LG_SLAB_MAXREGS=""]) 1683if test "x$with_lg_slab_maxregs" != "x" ; then 1684 AC_DEFINE_UNQUOTED([CONFIG_LG_SLAB_MAXREGS], [$with_lg_slab_maxregs], [ ]) 1685fi 1686 1687AC_ARG_WITH([lg_page], 1688 [AS_HELP_STRING([--with-lg-page=<lg-page>], [Base 2 log of system page size])], 1689 [LG_PAGE="$with_lg_page"], [LG_PAGE="detect"]) 1690case "${host}" in 1691 aarch64-apple-darwin*) 1692 dnl When cross-compile for Apple M1 and no page size specified, use the 1693 dnl default and skip detecting the page size (which is likely incorrect). 1694 if test "x${host}" != "x${build}" -a "x$LG_PAGE" = "xdetect"; then 1695 LG_PAGE=14 1696 fi 1697 ;; 1698esac 1699if test "x$LG_PAGE" = "xdetect"; then 1700 AC_CACHE_CHECK([LG_PAGE], 1701 [je_cv_lg_page], 1702 AC_RUN_IFELSE([AC_LANG_PROGRAM( 1703[[ 1704#include <strings.h> 1705#ifdef _WIN32 1706#include <windows.h> 1707#else 1708#include <unistd.h> 1709#endif 1710#include <stdio.h> 1711]], 1712[[ 1713 int result; 1714 FILE *f; 1715 1716#ifdef _WIN32 1717 SYSTEM_INFO si; 1718 GetSystemInfo(&si); 1719 result = si.dwPageSize; 1720#else 1721 result = sysconf(_SC_PAGESIZE); 1722#endif 1723 if (result == -1) { 1724 return 1; 1725 } 1726 result = JEMALLOC_INTERNAL_FFSL(result) - 1; 1727 1728 f = fopen("conftest.out", "w"); 1729 if (f == NULL) { 1730 return 1; 1731 } 1732 fprintf(f, "%d", result); 1733 fclose(f); 1734 1735 return 0; 1736]])], 1737 [je_cv_lg_page=`cat conftest.out`], 1738 [je_cv_lg_page=undefined], 1739 [je_cv_lg_page=12])) 1740fi 1741if test "x${je_cv_lg_page}" != "x" ; then 1742 LG_PAGE="${je_cv_lg_page}" 1743fi 1744if test "x${LG_PAGE}" != "xundefined" ; then 1745 AC_DEFINE_UNQUOTED([LG_PAGE], [$LG_PAGE], [ ]) 1746else 1747 AC_MSG_ERROR([cannot determine value for LG_PAGE]) 1748fi 1749 1750AC_ARG_WITH([lg_hugepage], 1751 [AS_HELP_STRING([--with-lg-hugepage=<lg-hugepage>], 1752 [Base 2 log of system huge page size])], 1753 [je_cv_lg_hugepage="${with_lg_hugepage}"], 1754 [je_cv_lg_hugepage=""]) 1755if test "x${je_cv_lg_hugepage}" = "x" ; then 1756 dnl Look in /proc/meminfo (Linux-specific) for information on the default huge 1757 dnl page size, if any. The relevant line looks like: 1758 dnl 1759 dnl Hugepagesize: 2048 kB 1760 if test -e "/proc/meminfo" ; then 1761 hpsk=[`cat /proc/meminfo 2>/dev/null | \ 1762 grep -e '^Hugepagesize:[[:space:]]\+[0-9]\+[[:space:]]kB$' | \ 1763 awk '{print $2}'`] 1764 if test "x${hpsk}" != "x" ; then 1765 je_cv_lg_hugepage=10 1766 while test "${hpsk}" -gt 1 ; do 1767 hpsk="$((hpsk / 2))" 1768 je_cv_lg_hugepage="$((je_cv_lg_hugepage + 1))" 1769 done 1770 fi 1771 fi 1772 1773 dnl Set default if unable to automatically configure. 1774 if test "x${je_cv_lg_hugepage}" = "x" ; then 1775 je_cv_lg_hugepage=21 1776 fi 1777fi 1778if test "x${LG_PAGE}" != "xundefined" -a \ 1779 "${je_cv_lg_hugepage}" -lt "${LG_PAGE}" ; then 1780 AC_MSG_ERROR([Huge page size (2^${je_cv_lg_hugepage}) must be at least page size (2^${LG_PAGE})]) 1781fi 1782AC_DEFINE_UNQUOTED([LG_HUGEPAGE], [${je_cv_lg_hugepage}], [ ]) 1783 1784dnl ============================================================================ 1785dnl Enable libdl by default. 1786AC_ARG_ENABLE([libdl], 1787 [AS_HELP_STRING([--disable-libdl], 1788 [Do not use libdl])], 1789[if test "x$enable_libdl" = "xno" ; then 1790 enable_libdl="0" 1791else 1792 enable_libdl="1" 1793fi 1794], 1795[enable_libdl="1"] 1796) 1797AC_SUBST([libdl]) 1798 1799dnl ============================================================================ 1800dnl Configure pthreads. 1801 1802if test "x$abi" != "xpecoff" ; then 1803 AC_DEFINE([JEMALLOC_HAVE_PTHREAD], [ ], [ ]) 1804 AC_CHECK_HEADERS([pthread.h], , [AC_MSG_ERROR([pthread.h is missing])]) 1805 dnl Some systems may embed pthreads functionality in libc; check for libpthread 1806 dnl first, but try libc too before failing. 1807 AC_CHECK_LIB([pthread], [pthread_create], [JE_APPEND_VS(LIBS, -pthread)], 1808 [AC_SEARCH_LIBS([pthread_create], , , 1809 AC_MSG_ERROR([libpthread is missing]))]) 1810 wrap_syms="${wrap_syms} pthread_create" 1811 have_pthread="1" 1812 1813dnl Check if we have dlsym support. 1814 if test "x$enable_libdl" = "x1" ; then 1815 have_dlsym="1" 1816 AC_CHECK_HEADERS([dlfcn.h], 1817 AC_CHECK_FUNC([dlsym], [], 1818 [AC_CHECK_LIB([dl], [dlsym], [LIBS="$LIBS -ldl"], [have_dlsym="0"])]), 1819 [have_dlsym="0"]) 1820 if test "x$have_dlsym" = "x1" ; then 1821 AC_DEFINE([JEMALLOC_HAVE_DLSYM], [ ], [ ]) 1822 fi 1823 else 1824 have_dlsym="0" 1825 fi 1826 1827 JE_COMPILABLE([pthread_atfork(3)], [ 1828#include <pthread.h> 1829], [ 1830 pthread_atfork((void *)0, (void *)0, (void *)0); 1831], [je_cv_pthread_atfork]) 1832 if test "x${je_cv_pthread_atfork}" = "xyes" ; then 1833 AC_DEFINE([JEMALLOC_HAVE_PTHREAD_ATFORK], [ ], [ ]) 1834 fi 1835 dnl Check if pthread_setname_np is available with the expected API. 1836 JE_COMPILABLE([pthread_setname_np(3)], [ 1837#include <pthread.h> 1838], [ 1839 pthread_setname_np(pthread_self(), "setname_test"); 1840], [je_cv_pthread_setname_np]) 1841 if test "x${je_cv_pthread_setname_np}" = "xyes" ; then 1842 AC_DEFINE([JEMALLOC_HAVE_PTHREAD_SETNAME_NP], [ ], [ ]) 1843 fi 1844 dnl Check if pthread_getname_np is not necessarily present despite 1845 dnl the pthread_setname_np counterpart 1846 JE_COMPILABLE([pthread_getname_np(3)], [ 1847#include <pthread.h> 1848#include <stdlib.h> 1849], [ 1850 { 1851 char *name = malloc(16); 1852 pthread_getname_np(pthread_self(), name, 16); 1853 free(name); 1854 } 1855], [je_cv_pthread_getname_np]) 1856 if test "x${je_cv_pthread_getname_np}" = "xyes" ; then 1857 AC_DEFINE([JEMALLOC_HAVE_PTHREAD_GETNAME_NP], [ ], [ ]) 1858 fi 1859 dnl Check if pthread_get_name_np is not necessarily present despite 1860 dnl the pthread_set_name_np counterpart 1861 JE_COMPILABLE([pthread_get_name_np(3)], [ 1862#include <pthread.h> 1863#include <pthread_np.h> 1864#include <stdlib.h> 1865], [ 1866 { 1867 char *name = malloc(16); 1868 pthread_get_name_np(pthread_self(), name, 16); 1869 free(name); 1870 } 1871], [je_cv_pthread_get_name_np]) 1872 if test "x${je_cv_pthread_get_name_np}" = "xyes" ; then 1873 AC_DEFINE([JEMALLOC_HAVE_PTHREAD_GET_NAME_NP], [ ], [ ]) 1874 fi 1875fi 1876 1877JE_APPEND_VS(CPPFLAGS, -D_REENTRANT) 1878 1879dnl Check whether clock_gettime(2) is in libc or librt. 1880AC_SEARCH_LIBS([clock_gettime], [rt]) 1881 1882dnl Cray wrapper compiler often adds `-lrt` when using `-static`. Check with 1883dnl `-dynamic` as well in case a user tries to dynamically link in jemalloc 1884if test "x$je_cv_cray_prgenv_wrapper" = "xyes" ; then 1885 if test "$ac_cv_search_clock_gettime" != "-lrt"; then 1886 JE_CFLAGS_SAVE() 1887 1888 unset ac_cv_search_clock_gettime 1889 JE_CFLAGS_ADD([-dynamic]) 1890 AC_SEARCH_LIBS([clock_gettime], [rt]) 1891 1892 JE_CFLAGS_RESTORE() 1893 fi 1894fi 1895 1896dnl check for CLOCK_MONOTONIC_COARSE (Linux-specific). 1897JE_COMPILABLE([clock_gettime(CLOCK_MONOTONIC_COARSE, ...)], [ 1898#include <time.h> 1899], [ 1900 struct timespec ts; 1901 1902 clock_gettime(CLOCK_MONOTONIC_COARSE, &ts); 1903], [je_cv_clock_monotonic_coarse]) 1904if test "x${je_cv_clock_monotonic_coarse}" = "xyes" ; then 1905 AC_DEFINE([JEMALLOC_HAVE_CLOCK_MONOTONIC_COARSE], [ ], [ ]) 1906fi 1907 1908dnl check for CLOCK_MONOTONIC. 1909JE_COMPILABLE([clock_gettime(CLOCK_MONOTONIC, ...)], [ 1910#include <unistd.h> 1911#include <time.h> 1912], [ 1913 struct timespec ts; 1914 1915 clock_gettime(CLOCK_MONOTONIC, &ts); 1916#if !defined(_POSIX_MONOTONIC_CLOCK) || _POSIX_MONOTONIC_CLOCK < 0 1917# error _POSIX_MONOTONIC_CLOCK missing/invalid 1918#endif 1919], [je_cv_clock_monotonic]) 1920if test "x${je_cv_clock_monotonic}" = "xyes" ; then 1921 AC_DEFINE([JEMALLOC_HAVE_CLOCK_MONOTONIC], [ ], [ ]) 1922fi 1923 1924dnl Check for mach_absolute_time(). 1925JE_COMPILABLE([mach_absolute_time()], [ 1926#include <mach/mach_time.h> 1927], [ 1928 mach_absolute_time(); 1929], [je_cv_mach_absolute_time]) 1930if test "x${je_cv_mach_absolute_time}" = "xyes" ; then 1931 AC_DEFINE([JEMALLOC_HAVE_MACH_ABSOLUTE_TIME], [ ], [ ]) 1932fi 1933 1934dnl check for CLOCK_REALTIME (always should be available on Linux) 1935JE_COMPILABLE([clock_gettime(CLOCK_REALTIME, ...)], [ 1936#include <time.h> 1937], [ 1938 struct timespec ts; 1939 1940 clock_gettime(CLOCK_REALTIME, &ts); 1941], [je_cv_clock_realtime]) 1942if test "x${je_cv_clock_realtime}" = "xyes" ; then 1943 AC_DEFINE([JEMALLOC_HAVE_CLOCK_REALTIME], [ ], [ ]) 1944fi 1945 1946dnl Use syscall(2) (if available) by default. 1947AC_ARG_ENABLE([syscall], 1948 [AS_HELP_STRING([--disable-syscall], [Disable use of syscall(2)])], 1949[if test "x$enable_syscall" = "xno" ; then 1950 enable_syscall="0" 1951else 1952 enable_syscall="1" 1953fi 1954], 1955[enable_syscall="1"] 1956) 1957if test "x$enable_syscall" = "x1" ; then 1958 dnl Check if syscall(2) is usable. Treat warnings as errors, so that e.g. OS 1959 dnl X 10.12's deprecation warning prevents use. 1960 JE_CFLAGS_SAVE() 1961 JE_CFLAGS_ADD([-Werror]) 1962 JE_COMPILABLE([syscall(2)], [ 1963#include <sys/syscall.h> 1964#include <unistd.h> 1965], [ 1966 syscall(SYS_write, 2, "hello", 5); 1967], 1968 [je_cv_syscall]) 1969 JE_CFLAGS_RESTORE() 1970 if test "x$je_cv_syscall" = "xyes" ; then 1971 AC_DEFINE([JEMALLOC_USE_SYSCALL], [ ], [ ]) 1972 fi 1973fi 1974 1975dnl Check if the GNU-specific secure_getenv function exists. 1976AC_CHECK_FUNC([secure_getenv], 1977 [have_secure_getenv="1"], 1978 [have_secure_getenv="0"] 1979 ) 1980if test "x$have_secure_getenv" = "x1" ; then 1981 AC_DEFINE([JEMALLOC_HAVE_SECURE_GETENV], [ ], [ ]) 1982fi 1983 1984dnl Check if the GNU-specific sched_getcpu function exists. 1985AC_CHECK_FUNC([sched_getcpu], 1986 [have_sched_getcpu="1"], 1987 [have_sched_getcpu="0"] 1988 ) 1989if test "x$have_sched_getcpu" = "x1" ; then 1990 AC_DEFINE([JEMALLOC_HAVE_SCHED_GETCPU], [ ], [ ]) 1991fi 1992 1993dnl Check if the GNU-specific sched_setaffinity function exists. 1994AC_CHECK_FUNC([sched_setaffinity], 1995 [have_sched_setaffinity="1"], 1996 [have_sched_setaffinity="0"] 1997 ) 1998if test "x$have_sched_setaffinity" = "x1" ; then 1999 AC_DEFINE([JEMALLOC_HAVE_SCHED_SETAFFINITY], [ ], [ ]) 2000fi 2001 2002dnl Check if the Solaris/BSD issetugid function exists. 2003AC_CHECK_FUNC([issetugid], 2004 [have_issetugid="1"], 2005 [have_issetugid="0"] 2006 ) 2007if test "x$have_issetugid" = "x1" ; then 2008 AC_DEFINE([JEMALLOC_HAVE_ISSETUGID], [ ], [ ]) 2009fi 2010 2011dnl Check whether the BSD-specific _malloc_thread_cleanup() exists. If so, use 2012dnl it rather than pthreads TSD cleanup functions to support cleanup during 2013dnl thread exit, in order to avoid pthreads library recursion during 2014dnl bootstrapping. 2015AC_CHECK_FUNC([_malloc_thread_cleanup], 2016 [have__malloc_thread_cleanup="1"], 2017 [have__malloc_thread_cleanup="0"] 2018 ) 2019if test "x$have__malloc_thread_cleanup" = "x1" ; then 2020 AC_DEFINE([JEMALLOC_MALLOC_THREAD_CLEANUP], [ ], [ ]) 2021 wrap_syms="${wrap_syms} _malloc_thread_cleanup _malloc_tsd_cleanup_register" 2022 force_tls="1" 2023fi 2024 2025dnl Check whether the BSD-specific _pthread_mutex_init_calloc_cb() exists. If 2026dnl so, mutex initialization causes allocation, and we need to implement this 2027dnl callback function in order to prevent recursive allocation. 2028AC_CHECK_FUNC([_pthread_mutex_init_calloc_cb], 2029 [have__pthread_mutex_init_calloc_cb="1"], 2030 [have__pthread_mutex_init_calloc_cb="0"] 2031 ) 2032if test "x$have__pthread_mutex_init_calloc_cb" = "x1" ; then 2033 AC_DEFINE([JEMALLOC_MUTEX_INIT_CB], [ ], [ ]) 2034 wrap_syms="${wrap_syms} _malloc_prefork _malloc_postfork" 2035fi 2036 2037AC_CHECK_FUNC([memcntl], 2038 [have_memcntl="1"], 2039 [have_memcntl="0"], 2040 ) 2041if test "x$have_memcntl" = "x1" ; then 2042 AC_DEFINE([JEMALLOC_HAVE_MEMCNTL], [ ], [ ]) 2043fi 2044 2045dnl Disable lazy locking by default. 2046AC_ARG_ENABLE([lazy_lock], 2047 [AS_HELP_STRING([--enable-lazy-lock], 2048 [Enable lazy locking (only lock when multi-threaded)])], 2049[if test "x$enable_lazy_lock" = "xno" ; then 2050 enable_lazy_lock="0" 2051else 2052 enable_lazy_lock="1" 2053fi 2054], 2055[enable_lazy_lock=""] 2056) 2057if test "x${enable_lazy_lock}" = "x" ; then 2058 if test "x${force_lazy_lock}" = "x1" ; then 2059 AC_MSG_RESULT([Forcing lazy-lock to avoid allocator/threading bootstrap issues]) 2060 enable_lazy_lock="1" 2061 else 2062 enable_lazy_lock="0" 2063 fi 2064fi 2065if test "x${enable_lazy_lock}" = "x1" -a "x${abi}" = "xpecoff" ; then 2066 AC_MSG_RESULT([Forcing no lazy-lock because thread creation monitoring is unimplemented]) 2067 enable_lazy_lock="0" 2068fi 2069if test "x$enable_lazy_lock" = "x1" ; then 2070 if test "x$have_dlsym" = "x1" ; then 2071 AC_DEFINE([JEMALLOC_LAZY_LOCK], [ ], [ ]) 2072 else 2073 AC_MSG_ERROR([Missing dlsym support: lazy-lock cannot be enabled.]) 2074 fi 2075fi 2076AC_SUBST([enable_lazy_lock]) 2077 2078dnl Automatically configure TLS. 2079if test "x${force_tls}" = "x1" ; then 2080 enable_tls="1" 2081elif test "x${force_tls}" = "x0" ; then 2082 enable_tls="0" 2083else 2084 enable_tls="1" 2085fi 2086if test "x${enable_tls}" = "x1" ; then 2087AC_MSG_CHECKING([for TLS]) 2088AC_COMPILE_IFELSE([AC_LANG_PROGRAM( 2089[[ 2090 __thread int x; 2091]], [[ 2092 x = 42; 2093 2094 return 0; 2095]])], 2096 AC_MSG_RESULT([yes]), 2097 AC_MSG_RESULT([no]) 2098 enable_tls="0") 2099else 2100 enable_tls="0" 2101fi 2102AC_SUBST([enable_tls]) 2103if test "x${enable_tls}" = "x1" ; then 2104 AC_DEFINE_UNQUOTED([JEMALLOC_TLS], [ ], [ ]) 2105fi 2106 2107dnl ============================================================================ 2108dnl Check for C11 atomics. 2109 2110JE_COMPILABLE([C11 atomics], [ 2111#include <stdint.h> 2112#if (__STDC_VERSION__ >= 201112L) && !defined(__STDC_NO_ATOMICS__) 2113#include <stdatomic.h> 2114#else 2115#error Atomics not available 2116#endif 2117], [ 2118 uint64_t *p = (uint64_t *)0; 2119 uint64_t x = 1; 2120 volatile atomic_uint_least64_t *a = (volatile atomic_uint_least64_t *)p; 2121 uint64_t r = atomic_fetch_add(a, x) + x; 2122 return r == 0; 2123], [je_cv_c11_atomics]) 2124if test "x${je_cv_c11_atomics}" = "xyes" ; then 2125 AC_DEFINE([JEMALLOC_C11_ATOMICS], [ ], [ ]) 2126fi 2127 2128dnl ============================================================================ 2129dnl Check for GCC-style __atomic atomics. 2130 2131JE_COMPILABLE([GCC __atomic atomics], [ 2132], [ 2133 int x = 0; 2134 int val = 1; 2135 int y = __atomic_fetch_add(&x, val, __ATOMIC_RELAXED); 2136 int after_add = x; 2137 return after_add == 1; 2138], [je_cv_gcc_atomic_atomics]) 2139if test "x${je_cv_gcc_atomic_atomics}" = "xyes" ; then 2140 AC_DEFINE([JEMALLOC_GCC_ATOMIC_ATOMICS], [ ], [ ]) 2141 2142 dnl check for 8-bit atomic support 2143 JE_COMPILABLE([GCC 8-bit __atomic atomics], [ 2144 ], [ 2145 unsigned char x = 0; 2146 int val = 1; 2147 int y = __atomic_fetch_add(&x, val, __ATOMIC_RELAXED); 2148 int after_add = (int)x; 2149 return after_add == 1; 2150 ], [je_cv_gcc_u8_atomic_atomics]) 2151 if test "x${je_cv_gcc_u8_atomic_atomics}" = "xyes" ; then 2152 AC_DEFINE([JEMALLOC_GCC_U8_ATOMIC_ATOMICS], [ ], [ ]) 2153 fi 2154fi 2155 2156dnl ============================================================================ 2157dnl Check for GCC-style __sync atomics. 2158 2159JE_COMPILABLE([GCC __sync atomics], [ 2160], [ 2161 int x = 0; 2162 int before_add = __sync_fetch_and_add(&x, 1); 2163 int after_add = x; 2164 return (before_add == 0) && (after_add == 1); 2165], [je_cv_gcc_sync_atomics]) 2166if test "x${je_cv_gcc_sync_atomics}" = "xyes" ; then 2167 AC_DEFINE([JEMALLOC_GCC_SYNC_ATOMICS], [ ], [ ]) 2168 2169 dnl check for 8-bit atomic support 2170 JE_COMPILABLE([GCC 8-bit __sync atomics], [ 2171 ], [ 2172 unsigned char x = 0; 2173 int before_add = __sync_fetch_and_add(&x, 1); 2174 int after_add = (int)x; 2175 return (before_add == 0) && (after_add == 1); 2176 ], [je_cv_gcc_u8_sync_atomics]) 2177 if test "x${je_cv_gcc_u8_sync_atomics}" = "xyes" ; then 2178 AC_DEFINE([JEMALLOC_GCC_U8_SYNC_ATOMICS], [ ], [ ]) 2179 fi 2180fi 2181 2182dnl ============================================================================ 2183dnl Check for atomic(3) operations as provided on Darwin. 2184dnl We need this not for the atomic operations (which are provided above), but 2185dnl rather for the OS_unfair_lock type it exposes. 2186 2187JE_COMPILABLE([Darwin OSAtomic*()], [ 2188#include <libkern/OSAtomic.h> 2189#include <inttypes.h> 2190], [ 2191 { 2192 int32_t x32 = 0; 2193 volatile int32_t *x32p = &x32; 2194 OSAtomicAdd32(1, x32p); 2195 } 2196 { 2197 int64_t x64 = 0; 2198 volatile int64_t *x64p = &x64; 2199 OSAtomicAdd64(1, x64p); 2200 } 2201], [je_cv_osatomic]) 2202if test "x${je_cv_osatomic}" = "xyes" ; then 2203 AC_DEFINE([JEMALLOC_OSATOMIC], [ ], [ ]) 2204fi 2205 2206dnl ============================================================================ 2207dnl Check for madvise(2). 2208 2209JE_COMPILABLE([madvise(2)], [ 2210#include <sys/mman.h> 2211], [ 2212 madvise((void *)0, 0, 0); 2213], [je_cv_madvise]) 2214if test "x${je_cv_madvise}" = "xyes" ; then 2215 AC_DEFINE([JEMALLOC_HAVE_MADVISE], [ ], [ ]) 2216 2217 dnl Check for madvise(..., MADV_FREE). 2218 JE_COMPILABLE([madvise(..., MADV_FREE)], [ 2219#include <sys/mman.h> 2220], [ 2221 madvise((void *)0, 0, MADV_FREE); 2222], [je_cv_madv_free]) 2223 if test "x${je_cv_madv_free}" = "xyes" ; then 2224 AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ], [ ]) 2225 elif test "x${je_cv_madvise}" = "xyes" ; then 2226 case "${host_cpu}" in i686|x86_64) 2227 case "${host}" in *-*-linux*) 2228 AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ], [ ]) 2229 AC_DEFINE([JEMALLOC_DEFINE_MADVISE_FREE], [ ], [ ]) 2230 ;; 2231 esac 2232 ;; 2233 esac 2234 fi 2235 2236 dnl Check for madvise(..., MADV_DONTNEED). 2237 JE_COMPILABLE([madvise(..., MADV_DONTNEED)], [ 2238#include <sys/mman.h> 2239], [ 2240 madvise((void *)0, 0, MADV_DONTNEED); 2241], [je_cv_madv_dontneed]) 2242 if test "x${je_cv_madv_dontneed}" = "xyes" ; then 2243 AC_DEFINE([JEMALLOC_PURGE_MADVISE_DONTNEED], [ ], [ ]) 2244 fi 2245 2246 dnl Check for madvise(..., MADV_DO[NT]DUMP). 2247 JE_COMPILABLE([madvise(..., MADV_DO[[NT]]DUMP)], [ 2248#include <sys/mman.h> 2249], [ 2250 madvise((void *)0, 0, MADV_DONTDUMP); 2251 madvise((void *)0, 0, MADV_DODUMP); 2252], [je_cv_madv_dontdump]) 2253 if test "x${je_cv_madv_dontdump}" = "xyes" ; then 2254 AC_DEFINE([JEMALLOC_MADVISE_DONTDUMP], [ ], [ ]) 2255 fi 2256 2257 dnl Check for madvise(..., MADV_[NO]HUGEPAGE). 2258 JE_COMPILABLE([madvise(..., MADV_[[NO]]HUGEPAGE)], [ 2259#include <sys/mman.h> 2260], [ 2261 madvise((void *)0, 0, MADV_HUGEPAGE); 2262 madvise((void *)0, 0, MADV_NOHUGEPAGE); 2263], [je_cv_thp]) 2264 dnl Check for madvise(..., MADV_[NO]CORE). 2265 JE_COMPILABLE([madvise(..., MADV_[[NO]]CORE)], [ 2266#include <sys/mman.h> 2267], [ 2268 madvise((void *)0, 0, MADV_NOCORE); 2269 madvise((void *)0, 0, MADV_CORE); 2270], [je_cv_madv_nocore]) 2271 if test "x${je_cv_madv_nocore}" = "xyes" ; then 2272 AC_DEFINE([JEMALLOC_MADVISE_NOCORE], [ ], [ ]) 2273 fi 2274case "${host_cpu}" in 2275 arm*) 2276 ;; 2277 *) 2278 if test "x${je_cv_thp}" = "xyes" ; then 2279 AC_DEFINE([JEMALLOC_HAVE_MADVISE_HUGE], [ ], [ ]) 2280 fi 2281 ;; 2282esac 2283else 2284 dnl Check for posix_madvise. 2285 JE_COMPILABLE([posix_madvise], [ 2286 #include <sys/mman.h> 2287 ], [ 2288 posix_madvise((void *)0, 0, 0); 2289 ], [je_cv_posix_madvise]) 2290 if test "x${je_cv_posix_madvise}" = "xyes" ; then 2291 AC_DEFINE([JEMALLOC_HAVE_POSIX_MADVISE], [ ], [ ]) 2292 2293 dnl Check for posix_madvise(..., POSIX_MADV_DONTNEED). 2294 JE_COMPILABLE([posix_madvise(..., POSIX_MADV_DONTNEED)], [ 2295 #include <sys/mman.h> 2296 ], [ 2297 posix_madvise((void *)0, 0, POSIX_MADV_DONTNEED); 2298 ], [je_cv_posix_madv_dontneed]) 2299 if test "x${je_cv_posix_madv_dontneed}" = "xyes" ; then 2300 AC_DEFINE([JEMALLOC_PURGE_POSIX_MADVISE_DONTNEED], [ ], [ ]) 2301 fi 2302 fi 2303fi 2304 2305dnl ============================================================================ 2306dnl Check for mprotect(2). 2307 2308JE_COMPILABLE([mprotect(2)], [ 2309#include <sys/mman.h> 2310], [ 2311 mprotect((void *)0, 0, PROT_NONE); 2312], [je_cv_mprotect]) 2313if test "x${je_cv_mprotect}" = "xyes" ; then 2314 AC_DEFINE([JEMALLOC_HAVE_MPROTECT], [ ], [ ]) 2315fi 2316 2317dnl ============================================================================ 2318dnl Check for __builtin_clz(), __builtin_clzl(), and __builtin_clzll(). 2319 2320AC_CACHE_CHECK([for __builtin_clz], 2321 [je_cv_builtin_clz], 2322 [AC_LINK_IFELSE([AC_LANG_PROGRAM([], 2323 [ 2324 { 2325 unsigned x = 0; 2326 int y = __builtin_clz(x); 2327 } 2328 { 2329 unsigned long x = 0; 2330 int y = __builtin_clzl(x); 2331 } 2332 { 2333 unsigned long long x = 0; 2334 int y = __builtin_clzll(x); 2335 } 2336 ])], 2337 [je_cv_builtin_clz=yes], 2338 [je_cv_builtin_clz=no])]) 2339 2340if test "x${je_cv_builtin_clz}" = "xyes" ; then 2341 AC_DEFINE([JEMALLOC_HAVE_BUILTIN_CLZ], [ ], [ ]) 2342fi 2343 2344dnl ============================================================================ 2345dnl Check for os_unfair_lock operations as provided on Darwin. 2346 2347JE_COMPILABLE([Darwin os_unfair_lock_*()], [ 2348#include <os/lock.h> 2349#include <AvailabilityMacros.h> 2350], [ 2351 #if MAC_OS_X_VERSION_MIN_REQUIRED < 101200 2352 #error "os_unfair_lock is not supported" 2353 #else 2354 os_unfair_lock lock = OS_UNFAIR_LOCK_INIT; 2355 os_unfair_lock_lock(&lock); 2356 os_unfair_lock_unlock(&lock); 2357 #endif 2358], [je_cv_os_unfair_lock]) 2359if test "x${je_cv_os_unfair_lock}" = "xyes" ; then 2360 AC_DEFINE([JEMALLOC_OS_UNFAIR_LOCK], [ ], [ ]) 2361fi 2362 2363dnl ============================================================================ 2364dnl Darwin-related configuration. 2365 2366AC_ARG_ENABLE([zone-allocator], 2367 [AS_HELP_STRING([--disable-zone-allocator], 2368 [Disable zone allocator for Darwin])], 2369[if test "x$enable_zone_allocator" = "xno" ; then 2370 enable_zone_allocator="0" 2371else 2372 enable_zone_allocator="1" 2373fi 2374], 2375[if test "x${abi}" = "xmacho"; then 2376 enable_zone_allocator="1" 2377fi 2378] 2379) 2380AC_SUBST([enable_zone_allocator]) 2381 2382if test "x${enable_zone_allocator}" = "x1" ; then 2383 if test "x${abi}" != "xmacho"; then 2384 AC_MSG_ERROR([--enable-zone-allocator is only supported on Darwin]) 2385 fi 2386 AC_DEFINE([JEMALLOC_ZONE], [ ], [ ]) 2387fi 2388 2389dnl ============================================================================ 2390dnl Use initial-exec TLS by default. 2391AC_ARG_ENABLE([initial-exec-tls], 2392 [AS_HELP_STRING([--disable-initial-exec-tls], 2393 [Disable the initial-exec tls model])], 2394[if test "x$enable_initial_exec_tls" = "xno" ; then 2395 enable_initial_exec_tls="0" 2396else 2397 enable_initial_exec_tls="1" 2398fi 2399], 2400[enable_initial_exec_tls="1"] 2401) 2402AC_SUBST([enable_initial_exec_tls]) 2403 2404if test "x${je_cv_tls_model}" = "xyes" -a \ 2405 "x${enable_initial_exec_tls}" = "x1" ; then 2406 AC_DEFINE([JEMALLOC_TLS_MODEL], 2407 [__attribute__((tls_model("initial-exec")))], 2408 [ ]) 2409else 2410 AC_DEFINE([JEMALLOC_TLS_MODEL], [ ], [ ]) 2411fi 2412 2413dnl ============================================================================ 2414dnl Enable background threads if possible. 2415 2416if test "x${have_pthread}" = "x1" -a "x${je_cv_os_unfair_lock}" != "xyes" -a \ 2417 "x${abi}" != "xmacho" ; then 2418 AC_DEFINE([JEMALLOC_BACKGROUND_THREAD], [ ], [ ]) 2419fi 2420 2421dnl ============================================================================ 2422dnl Check for glibc malloc hooks 2423 2424if test "x$glibc" = "x1" ; then 2425 JE_COMPILABLE([glibc malloc hook], [ 2426 #include <stddef.h> 2427 2428 extern void (* __free_hook)(void *ptr); 2429 extern void *(* __malloc_hook)(size_t size); 2430 extern void *(* __realloc_hook)(void *ptr, size_t size); 2431], [ 2432 void *ptr = 0L; 2433 if (__malloc_hook) ptr = __malloc_hook(1); 2434 if (__realloc_hook) ptr = __realloc_hook(ptr, 2); 2435 if (__free_hook && ptr) __free_hook(ptr); 2436], [je_cv_glibc_malloc_hook]) 2437 if test "x${je_cv_glibc_malloc_hook}" = "xyes" ; then 2438 if test "x${JEMALLOC_PREFIX}" = "x" ; then 2439 AC_DEFINE([JEMALLOC_GLIBC_MALLOC_HOOK], [ ], [ ]) 2440 wrap_syms="${wrap_syms} __free_hook __malloc_hook __realloc_hook" 2441 fi 2442 fi 2443 2444 JE_COMPILABLE([glibc memalign hook], [ 2445 #include <stddef.h> 2446 2447 extern void *(* __memalign_hook)(size_t alignment, size_t size); 2448], [ 2449 void *ptr = 0L; 2450 if (__memalign_hook) ptr = __memalign_hook(16, 7); 2451], [je_cv_glibc_memalign_hook]) 2452 if test "x${je_cv_glibc_memalign_hook}" = "xyes" ; then 2453 if test "x${JEMALLOC_PREFIX}" = "x" ; then 2454 AC_DEFINE([JEMALLOC_GLIBC_MEMALIGN_HOOK], [ ], [ ]) 2455 wrap_syms="${wrap_syms} __memalign_hook" 2456 fi 2457 fi 2458fi 2459 2460JE_COMPILABLE([pthreads adaptive mutexes], [ 2461#include <pthread.h> 2462], [ 2463 pthread_mutexattr_t attr; 2464 pthread_mutexattr_init(&attr); 2465 pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ADAPTIVE_NP); 2466 pthread_mutexattr_destroy(&attr); 2467], [je_cv_pthread_mutex_adaptive_np]) 2468if test "x${je_cv_pthread_mutex_adaptive_np}" = "xyes" ; then 2469 AC_DEFINE([JEMALLOC_HAVE_PTHREAD_MUTEX_ADAPTIVE_NP], [ ], [ ]) 2470fi 2471 2472JE_CFLAGS_SAVE() 2473JE_CFLAGS_ADD([-D_GNU_SOURCE]) 2474JE_CFLAGS_ADD([-Werror]) 2475JE_CFLAGS_ADD([-herror_on_warning]) 2476JE_COMPILABLE([strerror_r returns char with gnu source], [ 2477#include <errno.h> 2478#include <stdio.h> 2479#include <stdlib.h> 2480#include <string.h> 2481], [ 2482 char *buffer = (char *) malloc(100); 2483 char *error = strerror_r(EINVAL, buffer, 100); 2484 printf("%s\n", error); 2485], [je_cv_strerror_r_returns_char_with_gnu_source]) 2486JE_CFLAGS_RESTORE() 2487if test "x${je_cv_strerror_r_returns_char_with_gnu_source}" = "xyes" ; then 2488 AC_DEFINE([JEMALLOC_STRERROR_R_RETURNS_CHAR_WITH_GNU_SOURCE], [ ], [ ]) 2489fi 2490 2491dnl ============================================================================ 2492dnl Check for typedefs, structures, and compiler characteristics. 2493AC_HEADER_STDBOOL 2494 2495dnl ============================================================================ 2496dnl Define commands that generate output files. 2497 2498AC_CONFIG_COMMANDS([include/jemalloc/internal/public_symbols.txt], [ 2499 f="${objroot}include/jemalloc/internal/public_symbols.txt" 2500 mkdir -p "${objroot}include/jemalloc/internal" 2501 cp /dev/null "${f}" 2502 for nm in `echo ${mangling_map} |tr ',' ' '` ; do 2503 n=`echo ${nm} |tr ':' ' ' |awk '{print $[]1}'` 2504 m=`echo ${nm} |tr ':' ' ' |awk '{print $[]2}'` 2505 echo "${n}:${m}" >> "${f}" 2506 dnl Remove name from public_syms so that it isn't redefined later. 2507 public_syms=`for sym in ${public_syms}; do echo "${sym}"; done |grep -v "^${n}\$" |tr '\n' ' '` 2508 done 2509 for sym in ${public_syms} ; do 2510 n="${sym}" 2511 m="${JEMALLOC_PREFIX}${sym}" 2512 echo "${n}:${m}" >> "${f}" 2513 done 2514], [ 2515 srcdir="${srcdir}" 2516 objroot="${objroot}" 2517 mangling_map="${mangling_map}" 2518 public_syms="${public_syms}" 2519 JEMALLOC_PREFIX="${JEMALLOC_PREFIX}" 2520]) 2521AC_CONFIG_COMMANDS([include/jemalloc/internal/private_symbols.awk], [ 2522 f="${objroot}include/jemalloc/internal/private_symbols.awk" 2523 mkdir -p "${objroot}include/jemalloc/internal" 2524 export_syms=`for sym in ${public_syms}; do echo "${JEMALLOC_PREFIX}${sym}"; done; for sym in ${wrap_syms}; do echo "${sym}"; done;` 2525 "${srcdir}/include/jemalloc/internal/private_symbols.sh" "${SYM_PREFIX}" ${export_syms} > "${objroot}include/jemalloc/internal/private_symbols.awk" 2526], [ 2527 srcdir="${srcdir}" 2528 objroot="${objroot}" 2529 public_syms="${public_syms}" 2530 wrap_syms="${wrap_syms}" 2531 SYM_PREFIX="${SYM_PREFIX}" 2532 JEMALLOC_PREFIX="${JEMALLOC_PREFIX}" 2533]) 2534AC_CONFIG_COMMANDS([include/jemalloc/internal/private_symbols_jet.awk], [ 2535 f="${objroot}include/jemalloc/internal/private_symbols_jet.awk" 2536 mkdir -p "${objroot}include/jemalloc/internal" 2537 export_syms=`for sym in ${public_syms}; do echo "jet_${sym}"; done; for sym in ${wrap_syms}; do echo "${sym}"; done;` 2538 "${srcdir}/include/jemalloc/internal/private_symbols.sh" "${SYM_PREFIX}" ${export_syms} > "${objroot}include/jemalloc/internal/private_symbols_jet.awk" 2539], [ 2540 srcdir="${srcdir}" 2541 objroot="${objroot}" 2542 public_syms="${public_syms}" 2543 wrap_syms="${wrap_syms}" 2544 SYM_PREFIX="${SYM_PREFIX}" 2545]) 2546AC_CONFIG_COMMANDS([include/jemalloc/internal/public_namespace.h], [ 2547 mkdir -p "${objroot}include/jemalloc/internal" 2548 "${srcdir}/include/jemalloc/internal/public_namespace.sh" "${objroot}include/jemalloc/internal/public_symbols.txt" > "${objroot}include/jemalloc/internal/public_namespace.h" 2549], [ 2550 srcdir="${srcdir}" 2551 objroot="${objroot}" 2552]) 2553AC_CONFIG_COMMANDS([include/jemalloc/internal/public_unnamespace.h], [ 2554 mkdir -p "${objroot}include/jemalloc/internal" 2555 "${srcdir}/include/jemalloc/internal/public_unnamespace.sh" "${objroot}include/jemalloc/internal/public_symbols.txt" > "${objroot}include/jemalloc/internal/public_unnamespace.h" 2556], [ 2557 srcdir="${srcdir}" 2558 objroot="${objroot}" 2559]) 2560AC_CONFIG_COMMANDS([include/jemalloc/jemalloc_protos_jet.h], [ 2561 mkdir -p "${objroot}include/jemalloc" 2562 cat "${srcdir}/include/jemalloc/jemalloc_protos.h.in" | sed -e 's/@je_@/jet_/g' > "${objroot}include/jemalloc/jemalloc_protos_jet.h" 2563], [ 2564 srcdir="${srcdir}" 2565 objroot="${objroot}" 2566]) 2567AC_CONFIG_COMMANDS([include/jemalloc/jemalloc_rename.h], [ 2568 mkdir -p "${objroot}include/jemalloc" 2569 "${srcdir}/include/jemalloc/jemalloc_rename.sh" "${objroot}include/jemalloc/internal/public_symbols.txt" > "${objroot}include/jemalloc/jemalloc_rename.h" 2570], [ 2571 srcdir="${srcdir}" 2572 objroot="${objroot}" 2573]) 2574AC_CONFIG_COMMANDS([include/jemalloc/jemalloc_mangle.h], [ 2575 mkdir -p "${objroot}include/jemalloc" 2576 "${srcdir}/include/jemalloc/jemalloc_mangle.sh" "${objroot}include/jemalloc/internal/public_symbols.txt" je_ > "${objroot}include/jemalloc/jemalloc_mangle.h" 2577], [ 2578 srcdir="${srcdir}" 2579 objroot="${objroot}" 2580]) 2581AC_CONFIG_COMMANDS([include/jemalloc/jemalloc_mangle_jet.h], [ 2582 mkdir -p "${objroot}include/jemalloc" 2583 "${srcdir}/include/jemalloc/jemalloc_mangle.sh" "${objroot}include/jemalloc/internal/public_symbols.txt" jet_ > "${objroot}include/jemalloc/jemalloc_mangle_jet.h" 2584], [ 2585 srcdir="${srcdir}" 2586 objroot="${objroot}" 2587]) 2588AC_CONFIG_COMMANDS([include/jemalloc/jemalloc.h], [ 2589 mkdir -p "${objroot}include/jemalloc" 2590 "${srcdir}/include/jemalloc/jemalloc.sh" "${objroot}" > "${objroot}include/jemalloc/jemalloc${install_suffix}.h" 2591], [ 2592 srcdir="${srcdir}" 2593 objroot="${objroot}" 2594 install_suffix="${install_suffix}" 2595]) 2596 2597dnl Process .in files. 2598AC_SUBST([cfghdrs_in]) 2599AC_SUBST([cfghdrs_out]) 2600AC_CONFIG_HEADERS([$cfghdrs_tup]) 2601 2602dnl ============================================================================ 2603dnl Generate outputs. 2604 2605AC_CONFIG_FILES([$cfgoutputs_tup config.stamp bin/jemalloc-config bin/jemalloc.sh bin/jeprof]) 2606AC_SUBST([cfgoutputs_in]) 2607AC_SUBST([cfgoutputs_out]) 2608AC_OUTPUT 2609 2610dnl ============================================================================ 2611dnl Print out the results of configuration. 2612AC_MSG_RESULT([===============================================================================]) 2613AC_MSG_RESULT([jemalloc version : ${jemalloc_version}]) 2614AC_MSG_RESULT([library revision : ${rev}]) 2615AC_MSG_RESULT([]) 2616AC_MSG_RESULT([CONFIG : ${CONFIG}]) 2617AC_MSG_RESULT([CC : ${CC}]) 2618AC_MSG_RESULT([CONFIGURE_CFLAGS : ${CONFIGURE_CFLAGS}]) 2619AC_MSG_RESULT([SPECIFIED_CFLAGS : ${SPECIFIED_CFLAGS}]) 2620AC_MSG_RESULT([EXTRA_CFLAGS : ${EXTRA_CFLAGS}]) 2621AC_MSG_RESULT([CPPFLAGS : ${CPPFLAGS}]) 2622AC_MSG_RESULT([CXX : ${CXX}]) 2623AC_MSG_RESULT([CONFIGURE_CXXFLAGS : ${CONFIGURE_CXXFLAGS}]) 2624AC_MSG_RESULT([SPECIFIED_CXXFLAGS : ${SPECIFIED_CXXFLAGS}]) 2625AC_MSG_RESULT([EXTRA_CXXFLAGS : ${EXTRA_CXXFLAGS}]) 2626AC_MSG_RESULT([LDFLAGS : ${LDFLAGS}]) 2627AC_MSG_RESULT([EXTRA_LDFLAGS : ${EXTRA_LDFLAGS}]) 2628AC_MSG_RESULT([DSO_LDFLAGS : ${DSO_LDFLAGS}]) 2629AC_MSG_RESULT([LIBS : ${LIBS}]) 2630AC_MSG_RESULT([RPATH_EXTRA : ${RPATH_EXTRA}]) 2631AC_MSG_RESULT([]) 2632AC_MSG_RESULT([XSLTPROC : ${XSLTPROC}]) 2633AC_MSG_RESULT([XSLROOT : ${XSLROOT}]) 2634AC_MSG_RESULT([]) 2635AC_MSG_RESULT([PREFIX : ${PREFIX}]) 2636AC_MSG_RESULT([BINDIR : ${BINDIR}]) 2637AC_MSG_RESULT([DATADIR : ${DATADIR}]) 2638AC_MSG_RESULT([INCLUDEDIR : ${INCLUDEDIR}]) 2639AC_MSG_RESULT([LIBDIR : ${LIBDIR}]) 2640AC_MSG_RESULT([MANDIR : ${MANDIR}]) 2641AC_MSG_RESULT([]) 2642AC_MSG_RESULT([srcroot : ${srcroot}]) 2643AC_MSG_RESULT([abs_srcroot : ${abs_srcroot}]) 2644AC_MSG_RESULT([objroot : ${objroot}]) 2645AC_MSG_RESULT([abs_objroot : ${abs_objroot}]) 2646AC_MSG_RESULT([]) 2647AC_MSG_RESULT([JEMALLOC_PREFIX : ${JEMALLOC_PREFIX}]) 2648AC_MSG_RESULT([JEMALLOC_PRIVATE_NAMESPACE]) 2649AC_MSG_RESULT([ : ${JEMALLOC_PRIVATE_NAMESPACE}]) 2650AC_MSG_RESULT([install_suffix : ${install_suffix}]) 2651AC_MSG_RESULT([malloc_conf : ${config_malloc_conf}]) 2652AC_MSG_RESULT([documentation : ${enable_doc}]) 2653AC_MSG_RESULT([shared libs : ${enable_shared}]) 2654AC_MSG_RESULT([static libs : ${enable_static}]) 2655AC_MSG_RESULT([autogen : ${enable_autogen}]) 2656AC_MSG_RESULT([debug : ${enable_debug}]) 2657AC_MSG_RESULT([stats : ${enable_stats}]) 2658AC_MSG_RESULT([experimental_smallocx : ${enable_experimental_smallocx}]) 2659AC_MSG_RESULT([prof : ${enable_prof}]) 2660AC_MSG_RESULT([prof-libunwind : ${enable_prof_libunwind}]) 2661AC_MSG_RESULT([prof-libgcc : ${enable_prof_libgcc}]) 2662AC_MSG_RESULT([prof-gcc : ${enable_prof_gcc}]) 2663AC_MSG_RESULT([fill : ${enable_fill}]) 2664AC_MSG_RESULT([utrace : ${enable_utrace}]) 2665AC_MSG_RESULT([xmalloc : ${enable_xmalloc}]) 2666AC_MSG_RESULT([log : ${enable_log}]) 2667AC_MSG_RESULT([lazy_lock : ${enable_lazy_lock}]) 2668AC_MSG_RESULT([cache-oblivious : ${enable_cache_oblivious}]) 2669AC_MSG_RESULT([cxx : ${enable_cxx}]) 2670AC_MSG_RESULT([===============================================================================]) 2671||||||| dec341af7695 2672======= 2673dnl Process this file with autoconf to produce a configure script. 2674AC_PREREQ(2.68) 2675AC_INIT([Makefile.in]) 2676 2677AC_CONFIG_AUX_DIR([build-aux]) 2678 2679dnl ============================================================================ 2680dnl Custom macro definitions. 2681 2682dnl JE_CONCAT_VVV(r, a, b) 2683dnl 2684dnl Set $r to the concatenation of $a and $b, with a space separating them iff 2685dnl both $a and $b are non-empty. 2686AC_DEFUN([JE_CONCAT_VVV], 2687if test "x[$]{$2}" = "x" -o "x[$]{$3}" = "x" ; then 2688 $1="[$]{$2}[$]{$3}" 2689else 2690 $1="[$]{$2} [$]{$3}" 2691fi 2692) 2693 2694dnl JE_APPEND_VS(a, b) 2695dnl 2696dnl Set $a to the concatenation of $a and b, with a space separating them iff 2697dnl both $a and b are non-empty. 2698AC_DEFUN([JE_APPEND_VS], 2699 T_APPEND_V=$2 2700 JE_CONCAT_VVV($1, $1, T_APPEND_V) 2701) 2702 2703CONFIGURE_CFLAGS= 2704SPECIFIED_CFLAGS="${CFLAGS}" 2705dnl JE_CFLAGS_ADD(cflag) 2706dnl 2707dnl CFLAGS is the concatenation of CONFIGURE_CFLAGS and SPECIFIED_CFLAGS 2708dnl (ignoring EXTRA_CFLAGS, which does not impact configure tests. This macro 2709dnl appends to CONFIGURE_CFLAGS and regenerates CFLAGS. 2710AC_DEFUN([JE_CFLAGS_ADD], 2711[ 2712AC_MSG_CHECKING([whether compiler supports $1]) 2713T_CONFIGURE_CFLAGS="${CONFIGURE_CFLAGS}" 2714JE_APPEND_VS(CONFIGURE_CFLAGS, $1) 2715JE_CONCAT_VVV(CFLAGS, CONFIGURE_CFLAGS, SPECIFIED_CFLAGS) 2716AC_COMPILE_IFELSE([AC_LANG_PROGRAM( 2717[[ 2718]], [[ 2719 return 0; 2720]])], 2721 [je_cv_cflags_added=$1] 2722 AC_MSG_RESULT([yes]), 2723 [je_cv_cflags_added=] 2724 AC_MSG_RESULT([no]) 2725 [CONFIGURE_CFLAGS="${T_CONFIGURE_CFLAGS}"] 2726) 2727JE_CONCAT_VVV(CFLAGS, CONFIGURE_CFLAGS, SPECIFIED_CFLAGS) 2728]) 2729 2730dnl JE_CFLAGS_SAVE() 2731dnl JE_CFLAGS_RESTORE() 2732dnl 2733dnl Save/restore CFLAGS. Nesting is not supported. 2734AC_DEFUN([JE_CFLAGS_SAVE], 2735SAVED_CONFIGURE_CFLAGS="${CONFIGURE_CFLAGS}" 2736) 2737AC_DEFUN([JE_CFLAGS_RESTORE], 2738CONFIGURE_CFLAGS="${SAVED_CONFIGURE_CFLAGS}" 2739JE_CONCAT_VVV(CFLAGS, CONFIGURE_CFLAGS, SPECIFIED_CFLAGS) 2740) 2741 2742CONFIGURE_CXXFLAGS= 2743SPECIFIED_CXXFLAGS="${CXXFLAGS}" 2744dnl JE_CXXFLAGS_ADD(cxxflag) 2745AC_DEFUN([JE_CXXFLAGS_ADD], 2746[ 2747AC_MSG_CHECKING([whether compiler supports $1]) 2748T_CONFIGURE_CXXFLAGS="${CONFIGURE_CXXFLAGS}" 2749JE_APPEND_VS(CONFIGURE_CXXFLAGS, $1) 2750JE_CONCAT_VVV(CXXFLAGS, CONFIGURE_CXXFLAGS, SPECIFIED_CXXFLAGS) 2751AC_LANG_PUSH([C++]) 2752AC_COMPILE_IFELSE([AC_LANG_PROGRAM( 2753[[ 2754]], [[ 2755 return 0; 2756]])], 2757 [je_cv_cxxflags_added=$1] 2758 AC_MSG_RESULT([yes]), 2759 [je_cv_cxxflags_added=] 2760 AC_MSG_RESULT([no]) 2761 [CONFIGURE_CXXFLAGS="${T_CONFIGURE_CXXFLAGS}"] 2762) 2763AC_LANG_POP([C++]) 2764JE_CONCAT_VVV(CXXFLAGS, CONFIGURE_CXXFLAGS, SPECIFIED_CXXFLAGS) 2765]) 2766 2767dnl JE_COMPILABLE(label, hcode, mcode, rvar) 2768dnl 2769dnl Use AC_LINK_IFELSE() rather than AC_COMPILE_IFELSE() so that linker errors 2770dnl cause failure. 2771AC_DEFUN([JE_COMPILABLE], 2772[ 2773AC_CACHE_CHECK([whether $1 is compilable], 2774 [$4], 2775 [AC_LINK_IFELSE([AC_LANG_PROGRAM([$2], 2776 [$3])], 2777 [$4=yes], 2778 [$4=no])]) 2779]) 2780 2781dnl ============================================================================ 2782 2783CONFIG=`echo ${ac_configure_args} | sed -e 's#'"'"'\([^ ]*\)'"'"'#\1#g'` 2784AC_SUBST([CONFIG]) 2785 2786dnl Library revision. 2787rev=2 2788AC_SUBST([rev]) 2789 2790srcroot=$srcdir 2791if test "x${srcroot}" = "x." ; then 2792 srcroot="" 2793else 2794 srcroot="${srcroot}/" 2795fi 2796AC_SUBST([srcroot]) 2797abs_srcroot="`cd \"${srcdir}\"; pwd`/" 2798AC_SUBST([abs_srcroot]) 2799 2800objroot="" 2801AC_SUBST([objroot]) 2802abs_objroot="`pwd`/" 2803AC_SUBST([abs_objroot]) 2804 2805dnl Munge install path variables. 2806if test "x$prefix" = "xNONE" ; then 2807 prefix="/usr/local" 2808fi 2809if test "x$exec_prefix" = "xNONE" ; then 2810 exec_prefix=$prefix 2811fi 2812PREFIX=$prefix 2813AC_SUBST([PREFIX]) 2814BINDIR=`eval echo $bindir` 2815BINDIR=`eval echo $BINDIR` 2816AC_SUBST([BINDIR]) 2817INCLUDEDIR=`eval echo $includedir` 2818INCLUDEDIR=`eval echo $INCLUDEDIR` 2819AC_SUBST([INCLUDEDIR]) 2820LIBDIR=`eval echo $libdir` 2821LIBDIR=`eval echo $LIBDIR` 2822AC_SUBST([LIBDIR]) 2823DATADIR=`eval echo $datadir` 2824DATADIR=`eval echo $DATADIR` 2825AC_SUBST([DATADIR]) 2826MANDIR=`eval echo $mandir` 2827MANDIR=`eval echo $MANDIR` 2828AC_SUBST([MANDIR]) 2829 2830dnl Support for building documentation. 2831AC_PATH_PROG([XSLTPROC], [xsltproc], [false], [$PATH]) 2832if test -d "/usr/share/xml/docbook/stylesheet/docbook-xsl" ; then 2833 DEFAULT_XSLROOT="/usr/share/xml/docbook/stylesheet/docbook-xsl" 2834elif test -d "/usr/share/sgml/docbook/xsl-stylesheets" ; then 2835 DEFAULT_XSLROOT="/usr/share/sgml/docbook/xsl-stylesheets" 2836else 2837 dnl Documentation building will fail if this default gets used. 2838 DEFAULT_XSLROOT="" 2839fi 2840AC_ARG_WITH([xslroot], 2841 [AS_HELP_STRING([--with-xslroot=<path>], [XSL stylesheet root path])], [ 2842if test "x$with_xslroot" = "xno" ; then 2843 XSLROOT="${DEFAULT_XSLROOT}" 2844else 2845 XSLROOT="${with_xslroot}" 2846fi 2847], 2848 XSLROOT="${DEFAULT_XSLROOT}" 2849) 2850if test "x$XSLTPROC" = "xfalse" ; then 2851 XSLROOT="" 2852fi 2853AC_SUBST([XSLROOT]) 2854 2855dnl If CFLAGS isn't defined, set CFLAGS to something reasonable. Otherwise, 2856dnl just prevent autoconf from molesting CFLAGS. 2857CFLAGS=$CFLAGS 2858AC_PROG_CC 2859 2860if test "x$GCC" != "xyes" ; then 2861 AC_CACHE_CHECK([whether compiler is MSVC], 2862 [je_cv_msvc], 2863 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], 2864 [ 2865#ifndef _MSC_VER 2866 int fail[-1]; 2867#endif 2868])], 2869 [je_cv_msvc=yes], 2870 [je_cv_msvc=no])]) 2871fi 2872 2873dnl check if a cray prgenv wrapper compiler is being used 2874je_cv_cray_prgenv_wrapper="" 2875if test "x${PE_ENV}" != "x" ; then 2876 case "${CC}" in 2877 CC|cc) 2878 je_cv_cray_prgenv_wrapper="yes" 2879 ;; 2880 *) 2881 ;; 2882 esac 2883fi 2884 2885AC_CACHE_CHECK([whether compiler is cray], 2886 [je_cv_cray], 2887 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], 2888 [ 2889#ifndef _CRAYC 2890 int fail[-1]; 2891#endif 2892])], 2893 [je_cv_cray=yes], 2894 [je_cv_cray=no])]) 2895 2896if test "x${je_cv_cray}" = "xyes" ; then 2897 AC_CACHE_CHECK([whether cray compiler version is 8.4], 2898 [je_cv_cray_84], 2899 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], 2900 [ 2901#if !(_RELEASE_MAJOR == 8 && _RELEASE_MINOR == 4) 2902 int fail[-1]; 2903#endif 2904])], 2905 [je_cv_cray_84=yes], 2906 [je_cv_cray_84=no])]) 2907fi 2908 2909if test "x$GCC" = "xyes" ; then 2910 JE_CFLAGS_ADD([-std=gnu11]) 2911 if test "x$je_cv_cflags_added" = "x-std=gnu11" ; then 2912 AC_DEFINE_UNQUOTED([JEMALLOC_HAS_RESTRICT]) 2913 else 2914 JE_CFLAGS_ADD([-std=gnu99]) 2915 if test "x$je_cv_cflags_added" = "x-std=gnu99" ; then 2916 AC_DEFINE_UNQUOTED([JEMALLOC_HAS_RESTRICT]) 2917 fi 2918 fi 2919 JE_CFLAGS_ADD([-Wall]) 2920 JE_CFLAGS_ADD([-Wextra]) 2921 JE_CFLAGS_ADD([-Wshorten-64-to-32]) 2922 JE_CFLAGS_ADD([-Wsign-compare]) 2923 JE_CFLAGS_ADD([-Wundef]) 2924 JE_CFLAGS_ADD([-Wno-format-zero-length]) 2925 JE_CFLAGS_ADD([-pipe]) 2926 JE_CFLAGS_ADD([-g3]) 2927elif test "x$je_cv_msvc" = "xyes" ; then 2928 CC="$CC -nologo" 2929 JE_CFLAGS_ADD([-Zi]) 2930 JE_CFLAGS_ADD([-MT]) 2931 JE_CFLAGS_ADD([-W3]) 2932 JE_CFLAGS_ADD([-FS]) 2933 JE_APPEND_VS(CPPFLAGS, -I${srcdir}/include/msvc_compat) 2934fi 2935if test "x$je_cv_cray" = "xyes" ; then 2936 dnl cray compiler 8.4 has an inlining bug 2937 if test "x$je_cv_cray_84" = "xyes" ; then 2938 JE_CFLAGS_ADD([-hipa2]) 2939 JE_CFLAGS_ADD([-hnognu]) 2940 fi 2941 dnl ignore unreachable code warning 2942 JE_CFLAGS_ADD([-hnomessage=128]) 2943 dnl ignore redefinition of "malloc", "free", etc warning 2944 JE_CFLAGS_ADD([-hnomessage=1357]) 2945fi 2946AC_SUBST([CONFIGURE_CFLAGS]) 2947AC_SUBST([SPECIFIED_CFLAGS]) 2948AC_SUBST([EXTRA_CFLAGS]) 2949AC_PROG_CPP 2950 2951AC_ARG_ENABLE([cxx], 2952 [AS_HELP_STRING([--disable-cxx], [Disable C++ integration])], 2953if test "x$enable_cxx" = "xno" ; then 2954 enable_cxx="0" 2955else 2956 enable_cxx="1" 2957fi 2958, 2959enable_cxx="1" 2960) 2961if test "x$enable_cxx" = "x1" ; then 2962 dnl Require at least c++14, which is the first version to support sized 2963 dnl deallocation. C++ support is not compiled otherwise. 2964 m4_include([m4/ax_cxx_compile_stdcxx.m4]) 2965 AX_CXX_COMPILE_STDCXX([14], [noext], [optional]) 2966 if test "x${HAVE_CXX14}" = "x1" ; then 2967 JE_CXXFLAGS_ADD([-Wall]) 2968 JE_CXXFLAGS_ADD([-Wextra]) 2969 JE_CXXFLAGS_ADD([-g3]) 2970 2971 SAVED_LIBS="${LIBS}" 2972 JE_APPEND_VS(LIBS, -lstdc++) 2973 JE_COMPILABLE([libstdc++ linkage], [ 2974#include <stdlib.h> 2975], [[ 2976 int *arr = (int *)malloc(sizeof(int) * 42); 2977 if (arr == NULL) 2978 return 1; 2979]], [je_cv_libstdcxx]) 2980 if test "x${je_cv_libstdcxx}" = "xno" ; then 2981 LIBS="${SAVED_LIBS}" 2982 fi 2983 else 2984 enable_cxx="0" 2985 fi 2986fi 2987AC_SUBST([enable_cxx]) 2988AC_SUBST([CONFIGURE_CXXFLAGS]) 2989AC_SUBST([SPECIFIED_CXXFLAGS]) 2990AC_SUBST([EXTRA_CXXFLAGS]) 2991 2992AC_C_BIGENDIAN([ac_cv_big_endian=1], [ac_cv_big_endian=0]) 2993if test "x${ac_cv_big_endian}" = "x1" ; then 2994 AC_DEFINE_UNQUOTED([JEMALLOC_BIG_ENDIAN], [ ]) 2995fi 2996 2997if test "x${je_cv_msvc}" = "xyes" -a "x${ac_cv_header_inttypes_h}" = "xno"; then 2998 JE_APPEND_VS(CPPFLAGS, -I${srcdir}/include/msvc_compat/C99) 2999fi 3000 3001if test "x${je_cv_msvc}" = "xyes" ; then 3002 LG_SIZEOF_PTR=LG_SIZEOF_PTR_WIN 3003 AC_MSG_RESULT([Using a predefined value for sizeof(void *): 4 for 32-bit, 8 for 64-bit]) 3004else 3005 AC_CHECK_SIZEOF([void *]) 3006 if test "x${ac_cv_sizeof_void_p}" = "x8" ; then 3007 LG_SIZEOF_PTR=3 3008 elif test "x${ac_cv_sizeof_void_p}" = "x4" ; then 3009 LG_SIZEOF_PTR=2 3010 else 3011 AC_MSG_ERROR([Unsupported pointer size: ${ac_cv_sizeof_void_p}]) 3012 fi 3013fi 3014AC_DEFINE_UNQUOTED([LG_SIZEOF_PTR], [$LG_SIZEOF_PTR]) 3015 3016AC_CHECK_SIZEOF([int]) 3017if test "x${ac_cv_sizeof_int}" = "x8" ; then 3018 LG_SIZEOF_INT=3 3019elif test "x${ac_cv_sizeof_int}" = "x4" ; then 3020 LG_SIZEOF_INT=2 3021else 3022 AC_MSG_ERROR([Unsupported int size: ${ac_cv_sizeof_int}]) 3023fi 3024AC_DEFINE_UNQUOTED([LG_SIZEOF_INT], [$LG_SIZEOF_INT]) 3025 3026AC_CHECK_SIZEOF([long]) 3027if test "x${ac_cv_sizeof_long}" = "x8" ; then 3028 LG_SIZEOF_LONG=3 3029elif test "x${ac_cv_sizeof_long}" = "x4" ; then 3030 LG_SIZEOF_LONG=2 3031else 3032 AC_MSG_ERROR([Unsupported long size: ${ac_cv_sizeof_long}]) 3033fi 3034AC_DEFINE_UNQUOTED([LG_SIZEOF_LONG], [$LG_SIZEOF_LONG]) 3035 3036AC_CHECK_SIZEOF([long long]) 3037if test "x${ac_cv_sizeof_long_long}" = "x8" ; then 3038 LG_SIZEOF_LONG_LONG=3 3039elif test "x${ac_cv_sizeof_long_long}" = "x4" ; then 3040 LG_SIZEOF_LONG_LONG=2 3041else 3042 AC_MSG_ERROR([Unsupported long long size: ${ac_cv_sizeof_long_long}]) 3043fi 3044AC_DEFINE_UNQUOTED([LG_SIZEOF_LONG_LONG], [$LG_SIZEOF_LONG_LONG]) 3045 3046AC_CHECK_SIZEOF([intmax_t]) 3047if test "x${ac_cv_sizeof_intmax_t}" = "x16" ; then 3048 LG_SIZEOF_INTMAX_T=4 3049elif test "x${ac_cv_sizeof_intmax_t}" = "x8" ; then 3050 LG_SIZEOF_INTMAX_T=3 3051elif test "x${ac_cv_sizeof_intmax_t}" = "x4" ; then 3052 LG_SIZEOF_INTMAX_T=2 3053else 3054 AC_MSG_ERROR([Unsupported intmax_t size: ${ac_cv_sizeof_intmax_t}]) 3055fi 3056AC_DEFINE_UNQUOTED([LG_SIZEOF_INTMAX_T], [$LG_SIZEOF_INTMAX_T]) 3057 3058AC_CANONICAL_HOST 3059dnl CPU-specific settings. 3060CPU_SPINWAIT="" 3061case "${host_cpu}" in 3062 i686|x86_64) 3063 HAVE_CPU_SPINWAIT=1 3064 if test "x${je_cv_msvc}" = "xyes" ; then 3065 AC_CACHE_VAL([je_cv_pause_msvc], 3066 [JE_COMPILABLE([pause instruction MSVC], [], 3067 [[_mm_pause(); return 0;]], 3068 [je_cv_pause_msvc])]) 3069 if test "x${je_cv_pause_msvc}" = "xyes" ; then 3070 CPU_SPINWAIT='_mm_pause()' 3071 fi 3072 else 3073 AC_CACHE_VAL([je_cv_pause], 3074 [JE_COMPILABLE([pause instruction], [], 3075 [[__asm__ volatile("pause"); return 0;]], 3076 [je_cv_pause])]) 3077 if test "x${je_cv_pause}" = "xyes" ; then 3078 CPU_SPINWAIT='__asm__ volatile("pause")' 3079 fi 3080 fi 3081 ;; 3082 *) 3083 HAVE_CPU_SPINWAIT=0 3084 ;; 3085esac 3086AC_DEFINE_UNQUOTED([HAVE_CPU_SPINWAIT], [$HAVE_CPU_SPINWAIT]) 3087AC_DEFINE_UNQUOTED([CPU_SPINWAIT], [$CPU_SPINWAIT]) 3088 3089AC_ARG_WITH([lg_vaddr], 3090 [AS_HELP_STRING([--with-lg-vaddr=<lg-vaddr>], [Number of significant virtual address bits])], 3091 [LG_VADDR="$with_lg_vaddr"], [LG_VADDR="detect"]) 3092 3093case "${host_cpu}" in 3094 aarch64) 3095 if test "x$LG_VADDR" = "xdetect"; then 3096 AC_MSG_CHECKING([number of significant virtual address bits]) 3097 if test "x${LG_SIZEOF_PTR}" = "x2" ; then 3098 #aarch64 ILP32 3099 LG_VADDR=32 3100 else 3101 #aarch64 LP64 3102 LG_VADDR=48 3103 fi 3104 AC_MSG_RESULT([$LG_VADDR]) 3105 fi 3106 ;; 3107 x86_64) 3108 if test "x$LG_VADDR" = "xdetect"; then 3109 AC_CACHE_CHECK([number of significant virtual address bits], 3110 [je_cv_lg_vaddr], 3111 AC_RUN_IFELSE([AC_LANG_PROGRAM( 3112[[ 3113#include <stdio.h> 3114#ifdef _WIN32 3115#include <limits.h> 3116#include <intrin.h> 3117typedef unsigned __int32 uint32_t; 3118#else 3119#include <stdint.h> 3120#endif 3121]], [[ 3122 uint32_t r[[4]]; 3123 uint32_t eax_in = 0x80000008U; 3124#ifdef _WIN32 3125 __cpuid((int *)r, (int)eax_in); 3126#else 3127 asm volatile ("cpuid" 3128 : "=a" (r[[0]]), "=b" (r[[1]]), "=c" (r[[2]]), "=d" (r[[3]]) 3129 : "a" (eax_in), "c" (0) 3130 ); 3131#endif 3132 uint32_t eax_out = r[[0]]; 3133 uint32_t vaddr = ((eax_out & 0x0000ff00U) >> 8); 3134 FILE *f = fopen("conftest.out", "w"); 3135 if (f == NULL) { 3136 return 1; 3137 } 3138 if (vaddr > (sizeof(void *) << 3)) { 3139 vaddr = sizeof(void *) << 3; 3140 } 3141 fprintf(f, "%u", vaddr); 3142 fclose(f); 3143 return 0; 3144]])], 3145 [je_cv_lg_vaddr=`cat conftest.out`], 3146 [je_cv_lg_vaddr=error], 3147 [je_cv_lg_vaddr=57])) 3148 if test "x${je_cv_lg_vaddr}" != "x" ; then 3149 LG_VADDR="${je_cv_lg_vaddr}" 3150 fi 3151 if test "x${LG_VADDR}" != "xerror" ; then 3152 AC_DEFINE_UNQUOTED([LG_VADDR], [$LG_VADDR]) 3153 else 3154 AC_MSG_ERROR([cannot determine number of significant virtual address bits]) 3155 fi 3156 fi 3157 ;; 3158 *) 3159 if test "x$LG_VADDR" = "xdetect"; then 3160 AC_MSG_CHECKING([number of significant virtual address bits]) 3161 if test "x${LG_SIZEOF_PTR}" = "x3" ; then 3162 LG_VADDR=64 3163 elif test "x${LG_SIZEOF_PTR}" = "x2" ; then 3164 LG_VADDR=32 3165 elif test "x${LG_SIZEOF_PTR}" = "xLG_SIZEOF_PTR_WIN" ; then 3166 LG_VADDR="(1U << (LG_SIZEOF_PTR_WIN+3))" 3167 else 3168 AC_MSG_ERROR([Unsupported lg(pointer size): ${LG_SIZEOF_PTR}]) 3169 fi 3170 AC_MSG_RESULT([$LG_VADDR]) 3171 fi 3172 ;; 3173esac 3174AC_DEFINE_UNQUOTED([LG_VADDR], [$LG_VADDR]) 3175 3176LD_PRELOAD_VAR="LD_PRELOAD" 3177so="so" 3178importlib="${so}" 3179o="$ac_objext" 3180a="a" 3181exe="$ac_exeext" 3182libprefix="lib" 3183link_whole_archive="0" 3184DSO_LDFLAGS='-shared -Wl,-soname,$(@F)' 3185RPATH='-Wl,-rpath,$(1)' 3186SOREV="${so}.${rev}" 3187PIC_CFLAGS='-fPIC -DPIC' 3188CTARGET='-o $@' 3189LDTARGET='-o $@' 3190TEST_LD_MODE= 3191EXTRA_LDFLAGS= 3192ARFLAGS='crus' 3193AROUT=' $@' 3194CC_MM=1 3195 3196if test "x$je_cv_cray_prgenv_wrapper" = "xyes" ; then 3197 TEST_LD_MODE='-dynamic' 3198fi 3199 3200if test "x${je_cv_cray}" = "xyes" ; then 3201 CC_MM= 3202fi 3203 3204AN_MAKEVAR([AR], [AC_PROG_AR]) 3205AN_PROGRAM([ar], [AC_PROG_AR]) 3206AC_DEFUN([AC_PROG_AR], [AC_CHECK_TOOL(AR, ar, :)]) 3207AC_PROG_AR 3208 3209AN_MAKEVAR([NM], [AC_PROG_NM]) 3210AN_PROGRAM([nm], [AC_PROG_NM]) 3211AC_DEFUN([AC_PROG_NM], [AC_CHECK_TOOL(NM, nm, :)]) 3212AC_PROG_NM 3213 3214AC_PROG_AWK 3215 3216dnl ============================================================================ 3217dnl jemalloc version. 3218dnl 3219 3220AC_ARG_WITH([version], 3221 [AS_HELP_STRING([--with-version=<major>.<minor>.<bugfix>-<nrev>-g<gid>], 3222 [Version string])], 3223 [ 3224 echo "${with_version}" | grep ['^[0-9]\+\.[0-9]\+\.[0-9]\+-[0-9]\+-g[0-9a-f]\+$'] 2>&1 1>/dev/null 3225 if test $? -eq 0 ; then 3226 echo "$with_version" > "${objroot}VERSION" 3227 else 3228 echo "${with_version}" | grep ['^VERSION$'] 2>&1 1>/dev/null 3229 if test $? -ne 0 ; then 3230 AC_MSG_ERROR([${with_version} does not match <major>.<minor>.<bugfix>-<nrev>-g<gid> or VERSION]) 3231 fi 3232 fi 3233 ], [ 3234 dnl Set VERSION if source directory is inside a git repository. 3235 if test "x`test ! \"${srcroot}\" && cd \"${srcroot}\"; git rev-parse --is-inside-work-tree 2>/dev/null`" = "xtrue" ; then 3236 dnl Pattern globs aren't powerful enough to match both single- and 3237 dnl double-digit version numbers, so iterate over patterns to support up 3238 dnl to version 99.99.99 without any accidental matches. 3239 for pattern in ['[0-9].[0-9].[0-9]' '[0-9].[0-9].[0-9][0-9]' \ 3240 '[0-9].[0-9][0-9].[0-9]' '[0-9].[0-9][0-9].[0-9][0-9]' \ 3241 '[0-9][0-9].[0-9].[0-9]' '[0-9][0-9].[0-9].[0-9][0-9]' \ 3242 '[0-9][0-9].[0-9][0-9].[0-9]' \ 3243 '[0-9][0-9].[0-9][0-9].[0-9][0-9]']; do 3244 (test ! "${srcroot}" && cd "${srcroot}"; git describe --long --abbrev=40 --match="${pattern}") > "${objroot}VERSION.tmp" 2>/dev/null 3245 if test $? -eq 0 ; then 3246 mv "${objroot}VERSION.tmp" "${objroot}VERSION" 3247 break 3248 fi 3249 done 3250 fi 3251 rm -f "${objroot}VERSION.tmp" 3252 ]) 3253 3254if test ! -e "${objroot}VERSION" ; then 3255 if test ! -e "${srcroot}VERSION" ; then 3256 AC_MSG_RESULT( 3257 [Missing VERSION file, and unable to generate it; creating bogus VERSION]) 3258 echo "0.0.0-0-g0000000000000000000000000000000000000000" > "${objroot}VERSION" 3259 else 3260 cp ${srcroot}VERSION ${objroot}VERSION 3261 fi 3262fi 3263jemalloc_version=`cat "${objroot}VERSION"` 3264jemalloc_version_major=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]1}'` 3265jemalloc_version_minor=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]2}'` 3266jemalloc_version_bugfix=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]3}'` 3267jemalloc_version_nrev=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]4}'` 3268jemalloc_version_gid=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]5}'` 3269AC_SUBST([jemalloc_version]) 3270AC_SUBST([jemalloc_version_major]) 3271AC_SUBST([jemalloc_version_minor]) 3272AC_SUBST([jemalloc_version_bugfix]) 3273AC_SUBST([jemalloc_version_nrev]) 3274AC_SUBST([jemalloc_version_gid]) 3275 3276dnl Platform-specific settings. abi and RPATH can probably be determined 3277dnl programmatically, but doing so is error-prone, which makes it generally 3278dnl not worth the trouble. 3279dnl 3280dnl Define cpp macros in CPPFLAGS, rather than doing AC_DEFINE(macro), since the 3281dnl definitions need to be seen before any headers are included, which is a pain 3282dnl to make happen otherwise. 3283default_retain="0" 3284maps_coalesce="1" 3285DUMP_SYMS="${NM} -a" 3286SYM_PREFIX="" 3287case "${host}" in 3288 *-*-darwin* | *-*-ios*) 3289 abi="macho" 3290 RPATH="" 3291 LD_PRELOAD_VAR="DYLD_INSERT_LIBRARIES" 3292 so="dylib" 3293 importlib="${so}" 3294 force_tls="0" 3295 DSO_LDFLAGS='-shared -Wl,-install_name,$(LIBDIR)/$(@F)' 3296 SOREV="${rev}.${so}" 3297 sbrk_deprecated="1" 3298 SYM_PREFIX="_" 3299 ;; 3300 *-*-freebsd*) 3301 abi="elf" 3302 AC_DEFINE([JEMALLOC_SYSCTL_VM_OVERCOMMIT], [ ]) 3303 force_lazy_lock="1" 3304 ;; 3305 *-*-dragonfly*) 3306 abi="elf" 3307 ;; 3308 *-*-openbsd*) 3309 abi="elf" 3310 force_tls="0" 3311 ;; 3312 *-*-bitrig*) 3313 abi="elf" 3314 ;; 3315 *-*-linux-android) 3316 dnl syscall(2) and secure_getenv(3) are exposed by _GNU_SOURCE. 3317 JE_APPEND_VS(CPPFLAGS, -D_GNU_SOURCE) 3318 abi="elf" 3319 AC_DEFINE([JEMALLOC_PURGE_MADVISE_DONTNEED_ZEROS], [ ]) 3320 AC_DEFINE([JEMALLOC_HAS_ALLOCA_H]) 3321 AC_DEFINE([JEMALLOC_PROC_SYS_VM_OVERCOMMIT_MEMORY], [ ]) 3322 AC_DEFINE([JEMALLOC_THREADED_INIT], [ ]) 3323 AC_DEFINE([JEMALLOC_C11_ATOMICS]) 3324 force_tls="0" 3325 if test "${LG_SIZEOF_PTR}" = "3"; then 3326 default_retain="1" 3327 fi 3328 ;; 3329 *-*-linux*) 3330 dnl syscall(2) and secure_getenv(3) are exposed by _GNU_SOURCE. 3331 JE_APPEND_VS(CPPFLAGS, -D_GNU_SOURCE) 3332 abi="elf" 3333 AC_DEFINE([JEMALLOC_PURGE_MADVISE_DONTNEED_ZEROS], [ ]) 3334 AC_DEFINE([JEMALLOC_HAS_ALLOCA_H]) 3335 AC_DEFINE([JEMALLOC_PROC_SYS_VM_OVERCOMMIT_MEMORY], [ ]) 3336 AC_DEFINE([JEMALLOC_THREADED_INIT], [ ]) 3337 AC_DEFINE([JEMALLOC_USE_CXX_THROW], [ ]) 3338 if test "${LG_SIZEOF_PTR}" = "3"; then 3339 default_retain="1" 3340 fi 3341 ;; 3342 *-*-kfreebsd*) 3343 dnl syscall(2) and secure_getenv(3) are exposed by _GNU_SOURCE. 3344 JE_APPEND_VS(CPPFLAGS, -D_GNU_SOURCE) 3345 abi="elf" 3346 AC_DEFINE([JEMALLOC_HAS_ALLOCA_H]) 3347 AC_DEFINE([JEMALLOC_SYSCTL_VM_OVERCOMMIT], [ ]) 3348 AC_DEFINE([JEMALLOC_THREADED_INIT], [ ]) 3349 AC_DEFINE([JEMALLOC_USE_CXX_THROW], [ ]) 3350 ;; 3351 *-*-netbsd*) 3352 AC_MSG_CHECKING([ABI]) 3353 AC_COMPILE_IFELSE([AC_LANG_PROGRAM( 3354[[#ifdef __ELF__ 3355/* ELF */ 3356#else 3357#error aout 3358#endif 3359]])], 3360 [abi="elf"], 3361 [abi="aout"]) 3362 AC_MSG_RESULT([$abi]) 3363 ;; 3364 *-*-solaris2*) 3365 abi="elf" 3366 RPATH='-Wl,-R,$(1)' 3367 dnl Solaris needs this for sigwait(). 3368 JE_APPEND_VS(CPPFLAGS, -D_POSIX_PTHREAD_SEMANTICS) 3369 JE_APPEND_VS(LIBS, -lposix4 -lsocket -lnsl) 3370 ;; 3371 *-ibm-aix*) 3372 if test "${LG_SIZEOF_PTR}" = "3"; then 3373 dnl 64bit AIX 3374 LD_PRELOAD_VAR="LDR_PRELOAD64" 3375 else 3376 dnl 32bit AIX 3377 LD_PRELOAD_VAR="LDR_PRELOAD" 3378 fi 3379 abi="xcoff" 3380 ;; 3381 *-*-mingw* | *-*-cygwin*) 3382 abi="pecoff" 3383 force_tls="0" 3384 maps_coalesce="0" 3385 RPATH="" 3386 so="dll" 3387 if test "x$je_cv_msvc" = "xyes" ; then 3388 importlib="lib" 3389 DSO_LDFLAGS="-LD" 3390 EXTRA_LDFLAGS="-link -DEBUG" 3391 CTARGET='-Fo$@' 3392 LDTARGET='-Fe$@' 3393 AR='lib' 3394 ARFLAGS='-nologo -out:' 3395 AROUT='$@' 3396 CC_MM= 3397 else 3398 importlib="${so}" 3399 DSO_LDFLAGS="-shared" 3400 link_whole_archive="1" 3401 fi 3402 case "${host}" in 3403 *-*-cygwin*) 3404 DUMP_SYMS="dumpbin /SYMBOLS" 3405 ;; 3406 *) 3407 ;; 3408 esac 3409 a="lib" 3410 libprefix="" 3411 SOREV="${so}" 3412 PIC_CFLAGS="" 3413 if test "${LG_SIZEOF_PTR}" = "3"; then 3414 default_retain="1" 3415 fi 3416 ;; 3417 *) 3418 AC_MSG_RESULT([Unsupported operating system: ${host}]) 3419 abi="elf" 3420 ;; 3421esac 3422 3423JEMALLOC_USABLE_SIZE_CONST=const 3424AC_CHECK_HEADERS([malloc.h], [ 3425 AC_MSG_CHECKING([whether malloc_usable_size definition can use const argument]) 3426 AC_COMPILE_IFELSE([AC_LANG_PROGRAM( 3427 [#include <malloc.h> 3428 #include <stddef.h> 3429 size_t malloc_usable_size(const void *ptr); 3430 ], 3431 [])],[ 3432 AC_MSG_RESULT([yes]) 3433 ],[ 3434 JEMALLOC_USABLE_SIZE_CONST= 3435 AC_MSG_RESULT([no]) 3436 ]) 3437]) 3438AC_DEFINE_UNQUOTED([JEMALLOC_USABLE_SIZE_CONST], [$JEMALLOC_USABLE_SIZE_CONST]) 3439AC_SUBST([abi]) 3440AC_SUBST([RPATH]) 3441AC_SUBST([LD_PRELOAD_VAR]) 3442AC_SUBST([so]) 3443AC_SUBST([importlib]) 3444AC_SUBST([o]) 3445AC_SUBST([a]) 3446AC_SUBST([exe]) 3447AC_SUBST([libprefix]) 3448AC_SUBST([link_whole_archive]) 3449AC_SUBST([DSO_LDFLAGS]) 3450AC_SUBST([EXTRA_LDFLAGS]) 3451AC_SUBST([SOREV]) 3452AC_SUBST([PIC_CFLAGS]) 3453AC_SUBST([CTARGET]) 3454AC_SUBST([LDTARGET]) 3455AC_SUBST([TEST_LD_MODE]) 3456AC_SUBST([MKLIB]) 3457AC_SUBST([ARFLAGS]) 3458AC_SUBST([AROUT]) 3459AC_SUBST([DUMP_SYMS]) 3460AC_SUBST([CC_MM]) 3461 3462dnl Determine whether libm must be linked to use e.g. log(3). 3463AC_SEARCH_LIBS([log], [m], , [AC_MSG_ERROR([Missing math functions])]) 3464if test "x$ac_cv_search_log" != "xnone required" ; then 3465 LM="$ac_cv_search_log" 3466else 3467 LM= 3468fi 3469AC_SUBST(LM) 3470 3471JE_COMPILABLE([__attribute__ syntax], 3472 [static __attribute__((unused)) void foo(void){}], 3473 [], 3474 [je_cv_attribute]) 3475if test "x${je_cv_attribute}" = "xyes" ; then 3476 AC_DEFINE([JEMALLOC_HAVE_ATTR], [ ]) 3477 if test "x${GCC}" = "xyes" -a "x${abi}" = "xelf"; then 3478 JE_CFLAGS_ADD([-fvisibility=hidden]) 3479 JE_CXXFLAGS_ADD([-fvisibility=hidden]) 3480 fi 3481fi 3482dnl Check for tls_model attribute support (clang 3.0 still lacks support). 3483JE_CFLAGS_SAVE() 3484JE_CFLAGS_ADD([-Werror]) 3485JE_CFLAGS_ADD([-herror_on_warning]) 3486JE_COMPILABLE([tls_model attribute], [], 3487 [static __thread int 3488 __attribute__((tls_model("initial-exec"), unused)) foo; 3489 foo = 0;], 3490 [je_cv_tls_model]) 3491JE_CFLAGS_RESTORE() 3492dnl (Setting of JEMALLOC_TLS_MODEL is done later, after we've checked for 3493dnl --disable-initial-exec-tls) 3494 3495dnl Check for alloc_size attribute support. 3496JE_CFLAGS_SAVE() 3497JE_CFLAGS_ADD([-Werror]) 3498JE_CFLAGS_ADD([-herror_on_warning]) 3499JE_COMPILABLE([alloc_size attribute], [#include <stdlib.h>], 3500 [void *foo(size_t size) __attribute__((alloc_size(1)));], 3501 [je_cv_alloc_size]) 3502JE_CFLAGS_RESTORE() 3503if test "x${je_cv_alloc_size}" = "xyes" ; then 3504 AC_DEFINE([JEMALLOC_HAVE_ATTR_ALLOC_SIZE], [ ]) 3505fi 3506dnl Check for format(gnu_printf, ...) attribute support. 3507JE_CFLAGS_SAVE() 3508JE_CFLAGS_ADD([-Werror]) 3509JE_CFLAGS_ADD([-herror_on_warning]) 3510JE_COMPILABLE([format(gnu_printf, ...) attribute], [#include <stdlib.h>], 3511 [void *foo(const char *format, ...) __attribute__((format(gnu_printf, 1, 2)));], 3512 [je_cv_format_gnu_printf]) 3513JE_CFLAGS_RESTORE() 3514if test "x${je_cv_format_gnu_printf}" = "xyes" ; then 3515 AC_DEFINE([JEMALLOC_HAVE_ATTR_FORMAT_GNU_PRINTF], [ ]) 3516fi 3517dnl Check for format(printf, ...) attribute support. 3518JE_CFLAGS_SAVE() 3519JE_CFLAGS_ADD([-Werror]) 3520JE_CFLAGS_ADD([-herror_on_warning]) 3521JE_COMPILABLE([format(printf, ...) attribute], [#include <stdlib.h>], 3522 [void *foo(const char *format, ...) __attribute__((format(printf, 1, 2)));], 3523 [je_cv_format_printf]) 3524JE_CFLAGS_RESTORE() 3525if test "x${je_cv_format_printf}" = "xyes" ; then 3526 AC_DEFINE([JEMALLOC_HAVE_ATTR_FORMAT_PRINTF], [ ]) 3527fi 3528 3529dnl Check for format_arg(...) attribute support. 3530JE_CFLAGS_SAVE() 3531JE_CFLAGS_ADD([-Werror]) 3532JE_CFLAGS_ADD([-herror_on_warning]) 3533JE_COMPILABLE([format(printf, ...) attribute], [#include <stdlib.h>], 3534 [const char * __attribute__((__format_arg__(1))) foo(const char *format);], 3535 [je_cv_format_arg]) 3536JE_CFLAGS_RESTORE() 3537if test "x${je_cv_format_arg}" = "xyes" ; then 3538 AC_DEFINE([JEMALLOC_HAVE_ATTR_FORMAT_ARG], [ ]) 3539fi 3540 3541dnl Support optional additions to rpath. 3542AC_ARG_WITH([rpath], 3543 [AS_HELP_STRING([--with-rpath=<rpath>], [Colon-separated rpath (ELF systems only)])], 3544if test "x$with_rpath" = "xno" ; then 3545 RPATH_EXTRA= 3546else 3547 RPATH_EXTRA="`echo $with_rpath | tr \":\" \" \"`" 3548fi, 3549 RPATH_EXTRA= 3550) 3551AC_SUBST([RPATH_EXTRA]) 3552 3553dnl Disable rules that do automatic regeneration of configure output by default. 3554AC_ARG_ENABLE([autogen], 3555 [AS_HELP_STRING([--enable-autogen], [Automatically regenerate configure output])], 3556if test "x$enable_autogen" = "xno" ; then 3557 enable_autogen="0" 3558else 3559 enable_autogen="1" 3560fi 3561, 3562enable_autogen="0" 3563) 3564AC_SUBST([enable_autogen]) 3565 3566AC_PROG_INSTALL 3567AC_PROG_RANLIB 3568AC_PATH_PROG([LD], [ld], [false], [$PATH]) 3569AC_PATH_PROG([AUTOCONF], [autoconf], [false], [$PATH]) 3570 3571dnl Enable documentation 3572AC_ARG_ENABLE([doc], 3573 [AS_HELP_STRING([--enable-documentation], [Build documentation])], 3574if test "x$enable_doc" = "xno" ; then 3575 enable_doc="0" 3576else 3577 enable_doc="1" 3578fi 3579, 3580enable_doc="1" 3581) 3582AC_SUBST([enable_doc]) 3583 3584dnl Enable shared libs 3585AC_ARG_ENABLE([shared], 3586 [AS_HELP_STRING([--enable-shared], [Build shared libaries])], 3587if test "x$enable_shared" = "xno" ; then 3588 enable_shared="0" 3589else 3590 enable_shared="1" 3591fi 3592, 3593enable_shared="1" 3594) 3595AC_SUBST([enable_shared]) 3596 3597dnl Enable static libs 3598AC_ARG_ENABLE([static], 3599 [AS_HELP_STRING([--enable-static], [Build static libaries])], 3600if test "x$enable_static" = "xno" ; then 3601 enable_static="0" 3602else 3603 enable_static="1" 3604fi 3605, 3606enable_static="1" 3607) 3608AC_SUBST([enable_static]) 3609 3610if test "$enable_shared$enable_static" = "00" ; then 3611 AC_MSG_ERROR([Please enable one of shared or static builds]) 3612fi 3613 3614dnl Perform no name mangling by default. 3615AC_ARG_WITH([mangling], 3616 [AS_HELP_STRING([--with-mangling=<map>], [Mangle symbols in <map>])], 3617 [mangling_map="$with_mangling"], [mangling_map=""]) 3618 3619dnl Do not prefix public APIs by default. 3620AC_ARG_WITH([jemalloc_prefix], 3621 [AS_HELP_STRING([--with-jemalloc-prefix=<prefix>], [Prefix to prepend to all public APIs])], 3622 [JEMALLOC_PREFIX="$with_jemalloc_prefix"], 3623 [if test "x$abi" != "xmacho" -a "x$abi" != "xpecoff"; then 3624 JEMALLOC_PREFIX="" 3625else 3626 JEMALLOC_PREFIX="je_" 3627fi] 3628) 3629if test "x$JEMALLOC_PREFIX" = "x" ; then 3630 AC_DEFINE([JEMALLOC_IS_MALLOC]) 3631else 3632 JEMALLOC_CPREFIX=`echo ${JEMALLOC_PREFIX} | tr "a-z" "A-Z"` 3633 AC_DEFINE_UNQUOTED([JEMALLOC_PREFIX], ["$JEMALLOC_PREFIX"]) 3634 AC_DEFINE_UNQUOTED([JEMALLOC_CPREFIX], ["$JEMALLOC_CPREFIX"]) 3635fi 3636AC_SUBST([JEMALLOC_PREFIX]) 3637AC_SUBST([JEMALLOC_CPREFIX]) 3638 3639AC_ARG_WITH([export], 3640 [AS_HELP_STRING([--without-export], [disable exporting jemalloc public APIs])], 3641 [if test "x$with_export" = "xno"; then 3642 AC_DEFINE([JEMALLOC_EXPORT],[]) 3643fi] 3644) 3645 3646public_syms="aligned_alloc calloc dallocx free mallctl mallctlbymib mallctlnametomib malloc malloc_conf malloc_message malloc_stats_print malloc_usable_size mallocx smallocx_${jemalloc_version_gid} nallocx posix_memalign rallocx realloc sallocx sdallocx xallocx" 3647dnl Check for additional platform-specific public API functions. 3648AC_CHECK_FUNC([memalign], 3649 [AC_DEFINE([JEMALLOC_OVERRIDE_MEMALIGN], [ ]) 3650 public_syms="${public_syms} memalign"]) 3651AC_CHECK_FUNC([valloc], 3652 [AC_DEFINE([JEMALLOC_OVERRIDE_VALLOC], [ ]) 3653 public_syms="${public_syms} valloc"]) 3654 3655dnl Check for allocator-related functions that should be wrapped. 3656wrap_syms= 3657if test "x${JEMALLOC_PREFIX}" = "x" ; then 3658 AC_CHECK_FUNC([__libc_calloc], 3659 [AC_DEFINE([JEMALLOC_OVERRIDE___LIBC_CALLOC], [ ]) 3660 wrap_syms="${wrap_syms} __libc_calloc"]) 3661 AC_CHECK_FUNC([__libc_free], 3662 [AC_DEFINE([JEMALLOC_OVERRIDE___LIBC_FREE], [ ]) 3663 wrap_syms="${wrap_syms} __libc_free"]) 3664 AC_CHECK_FUNC([__libc_malloc], 3665 [AC_DEFINE([JEMALLOC_OVERRIDE___LIBC_MALLOC], [ ]) 3666 wrap_syms="${wrap_syms} __libc_malloc"]) 3667 AC_CHECK_FUNC([__libc_memalign], 3668 [AC_DEFINE([JEMALLOC_OVERRIDE___LIBC_MEMALIGN], [ ]) 3669 wrap_syms="${wrap_syms} __libc_memalign"]) 3670 AC_CHECK_FUNC([__libc_realloc], 3671 [AC_DEFINE([JEMALLOC_OVERRIDE___LIBC_REALLOC], [ ]) 3672 wrap_syms="${wrap_syms} __libc_realloc"]) 3673 AC_CHECK_FUNC([__libc_valloc], 3674 [AC_DEFINE([JEMALLOC_OVERRIDE___LIBC_VALLOC], [ ]) 3675 wrap_syms="${wrap_syms} __libc_valloc"]) 3676 AC_CHECK_FUNC([__posix_memalign], 3677 [AC_DEFINE([JEMALLOC_OVERRIDE___POSIX_MEMALIGN], [ ]) 3678 wrap_syms="${wrap_syms} __posix_memalign"]) 3679fi 3680 3681case "${host}" in 3682 *-*-mingw* | *-*-cygwin*) 3683 wrap_syms="${wrap_syms} tls_callback" 3684 ;; 3685 *) 3686 ;; 3687esac 3688 3689dnl Mangle library-private APIs. 3690AC_ARG_WITH([private_namespace], 3691 [AS_HELP_STRING([--with-private-namespace=<prefix>], [Prefix to prepend to all library-private APIs])], 3692 [JEMALLOC_PRIVATE_NAMESPACE="${with_private_namespace}je_"], 3693 [JEMALLOC_PRIVATE_NAMESPACE="je_"] 3694) 3695AC_DEFINE_UNQUOTED([JEMALLOC_PRIVATE_NAMESPACE], [$JEMALLOC_PRIVATE_NAMESPACE]) 3696private_namespace="$JEMALLOC_PRIVATE_NAMESPACE" 3697AC_SUBST([private_namespace]) 3698 3699dnl Do not add suffix to installed files by default. 3700AC_ARG_WITH([install_suffix], 3701 [AS_HELP_STRING([--with-install-suffix=<suffix>], [Suffix to append to all installed files])], 3702 [INSTALL_SUFFIX="$with_install_suffix"], 3703 [INSTALL_SUFFIX=] 3704) 3705install_suffix="$INSTALL_SUFFIX" 3706AC_SUBST([install_suffix]) 3707 3708dnl Specify default malloc_conf. 3709AC_ARG_WITH([malloc_conf], 3710 [AS_HELP_STRING([--with-malloc-conf=<malloc_conf>], [config.malloc_conf options string])], 3711 [JEMALLOC_CONFIG_MALLOC_CONF="$with_malloc_conf"], 3712 [JEMALLOC_CONFIG_MALLOC_CONF=""] 3713) 3714config_malloc_conf="$JEMALLOC_CONFIG_MALLOC_CONF" 3715AC_DEFINE_UNQUOTED([JEMALLOC_CONFIG_MALLOC_CONF], ["$config_malloc_conf"]) 3716 3717dnl Substitute @je_@ in jemalloc_protos.h.in, primarily to make generation of 3718dnl jemalloc_protos_jet.h easy. 3719je_="je_" 3720AC_SUBST([je_]) 3721 3722cfgoutputs_in="Makefile.in" 3723cfgoutputs_in="${cfgoutputs_in} jemalloc.pc.in" 3724cfgoutputs_in="${cfgoutputs_in} doc/html.xsl.in" 3725cfgoutputs_in="${cfgoutputs_in} doc/manpages.xsl.in" 3726cfgoutputs_in="${cfgoutputs_in} doc/jemalloc.xml.in" 3727cfgoutputs_in="${cfgoutputs_in} include/jemalloc/jemalloc_macros.h.in" 3728cfgoutputs_in="${cfgoutputs_in} include/jemalloc/jemalloc_protos.h.in" 3729cfgoutputs_in="${cfgoutputs_in} include/jemalloc/jemalloc_typedefs.h.in" 3730cfgoutputs_in="${cfgoutputs_in} include/jemalloc/internal/jemalloc_preamble.h.in" 3731cfgoutputs_in="${cfgoutputs_in} test/test.sh.in" 3732cfgoutputs_in="${cfgoutputs_in} test/include/test/jemalloc_test.h.in" 3733 3734cfgoutputs_out="Makefile" 3735cfgoutputs_out="${cfgoutputs_out} jemalloc.pc" 3736cfgoutputs_out="${cfgoutputs_out} doc/html.xsl" 3737cfgoutputs_out="${cfgoutputs_out} doc/manpages.xsl" 3738cfgoutputs_out="${cfgoutputs_out} doc/jemalloc.xml" 3739cfgoutputs_out="${cfgoutputs_out} include/jemalloc/jemalloc_macros.h" 3740cfgoutputs_out="${cfgoutputs_out} include/jemalloc/jemalloc_protos.h" 3741cfgoutputs_out="${cfgoutputs_out} include/jemalloc/jemalloc_typedefs.h" 3742cfgoutputs_out="${cfgoutputs_out} include/jemalloc/internal/jemalloc_preamble.h" 3743cfgoutputs_out="${cfgoutputs_out} test/test.sh" 3744cfgoutputs_out="${cfgoutputs_out} test/include/test/jemalloc_test.h" 3745 3746cfgoutputs_tup="Makefile" 3747cfgoutputs_tup="${cfgoutputs_tup} jemalloc.pc:jemalloc.pc.in" 3748cfgoutputs_tup="${cfgoutputs_tup} doc/html.xsl:doc/html.xsl.in" 3749cfgoutputs_tup="${cfgoutputs_tup} doc/manpages.xsl:doc/manpages.xsl.in" 3750cfgoutputs_tup="${cfgoutputs_tup} doc/jemalloc.xml:doc/jemalloc.xml.in" 3751cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/jemalloc_macros.h:include/jemalloc/jemalloc_macros.h.in" 3752cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/jemalloc_protos.h:include/jemalloc/jemalloc_protos.h.in" 3753cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/jemalloc_typedefs.h:include/jemalloc/jemalloc_typedefs.h.in" 3754cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/internal/jemalloc_preamble.h" 3755cfgoutputs_tup="${cfgoutputs_tup} test/test.sh:test/test.sh.in" 3756cfgoutputs_tup="${cfgoutputs_tup} test/include/test/jemalloc_test.h:test/include/test/jemalloc_test.h.in" 3757 3758cfghdrs_in="include/jemalloc/jemalloc_defs.h.in" 3759cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/jemalloc_internal_defs.h.in" 3760cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/private_symbols.sh" 3761cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/private_namespace.sh" 3762cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/public_namespace.sh" 3763cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/public_unnamespace.sh" 3764cfghdrs_in="${cfghdrs_in} include/jemalloc/jemalloc_rename.sh" 3765cfghdrs_in="${cfghdrs_in} include/jemalloc/jemalloc_mangle.sh" 3766cfghdrs_in="${cfghdrs_in} include/jemalloc/jemalloc.sh" 3767cfghdrs_in="${cfghdrs_in} test/include/test/jemalloc_test_defs.h.in" 3768 3769cfghdrs_out="include/jemalloc/jemalloc_defs.h" 3770cfghdrs_out="${cfghdrs_out} include/jemalloc/jemalloc${install_suffix}.h" 3771cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/private_symbols.awk" 3772cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/private_symbols_jet.awk" 3773cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/public_symbols.txt" 3774cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/public_namespace.h" 3775cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/public_unnamespace.h" 3776cfghdrs_out="${cfghdrs_out} include/jemalloc/jemalloc_protos_jet.h" 3777cfghdrs_out="${cfghdrs_out} include/jemalloc/jemalloc_rename.h" 3778cfghdrs_out="${cfghdrs_out} include/jemalloc/jemalloc_mangle.h" 3779cfghdrs_out="${cfghdrs_out} include/jemalloc/jemalloc_mangle_jet.h" 3780cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/jemalloc_internal_defs.h" 3781cfghdrs_out="${cfghdrs_out} test/include/test/jemalloc_test_defs.h" 3782 3783cfghdrs_tup="include/jemalloc/jemalloc_defs.h:include/jemalloc/jemalloc_defs.h.in" 3784cfghdrs_tup="${cfghdrs_tup} include/jemalloc/internal/jemalloc_internal_defs.h:include/jemalloc/internal/jemalloc_internal_defs.h.in" 3785cfghdrs_tup="${cfghdrs_tup} test/include/test/jemalloc_test_defs.h:test/include/test/jemalloc_test_defs.h.in" 3786 3787dnl ============================================================================ 3788dnl jemalloc build options. 3789dnl 3790 3791dnl Do not compile with debugging by default. 3792AC_ARG_ENABLE([debug], 3793 [AS_HELP_STRING([--enable-debug], 3794 [Build debugging code])], 3795[if test "x$enable_debug" = "xno" ; then 3796 enable_debug="0" 3797else 3798 enable_debug="1" 3799fi 3800], 3801[enable_debug="0"] 3802) 3803if test "x$enable_debug" = "x1" ; then 3804 AC_DEFINE([JEMALLOC_DEBUG], [ ]) 3805fi 3806if test "x$enable_debug" = "x1" ; then 3807 AC_DEFINE([JEMALLOC_DEBUG], [ ]) 3808fi 3809AC_SUBST([enable_debug]) 3810 3811dnl Only optimize if not debugging. 3812if test "x$enable_debug" = "x0" ; then 3813 if test "x$GCC" = "xyes" ; then 3814 JE_CFLAGS_ADD([-O3]) 3815 JE_CXXFLAGS_ADD([-O3]) 3816 JE_CFLAGS_ADD([-funroll-loops]) 3817 elif test "x$je_cv_msvc" = "xyes" ; then 3818 JE_CFLAGS_ADD([-O2]) 3819 JE_CXXFLAGS_ADD([-O2]) 3820 else 3821 JE_CFLAGS_ADD([-O]) 3822 JE_CXXFLAGS_ADD([-O]) 3823 fi 3824fi 3825 3826dnl Enable statistics calculation by default. 3827AC_ARG_ENABLE([stats], 3828 [AS_HELP_STRING([--disable-stats], 3829 [Disable statistics calculation/reporting])], 3830[if test "x$enable_stats" = "xno" ; then 3831 enable_stats="0" 3832else 3833 enable_stats="1" 3834fi 3835], 3836[enable_stats="1"] 3837) 3838if test "x$enable_stats" = "x1" ; then 3839 AC_DEFINE([JEMALLOC_STATS], [ ]) 3840fi 3841AC_SUBST([enable_stats]) 3842 3843dnl Do not enable smallocx by default. 3844AC_ARG_ENABLE([experimental_smallocx], 3845 [AS_HELP_STRING([--enable-experimental-smallocx], [Enable experimental smallocx API])], 3846[if test "x$enable_experimental_smallocx" = "xno" ; then 3847enable_experimental_smallocx="0" 3848else 3849enable_experimental_smallocx="1" 3850fi 3851], 3852[enable_experimental_smallocx="0"] 3853) 3854if test "x$enable_experimental_smallocx" = "x1" ; then 3855 AC_DEFINE([JEMALLOC_EXPERIMENTAL_SMALLOCX_API]) 3856fi 3857AC_SUBST([enable_experimental_smallocx]) 3858 3859dnl Do not enable profiling by default. 3860AC_ARG_ENABLE([prof], 3861 [AS_HELP_STRING([--enable-prof], [Enable allocation profiling])], 3862[if test "x$enable_prof" = "xno" ; then 3863 enable_prof="0" 3864else 3865 enable_prof="1" 3866fi 3867], 3868[enable_prof="0"] 3869) 3870if test "x$enable_prof" = "x1" ; then 3871 backtrace_method="" 3872else 3873 backtrace_method="N/A" 3874fi 3875 3876AC_ARG_ENABLE([prof-libunwind], 3877 [AS_HELP_STRING([--enable-prof-libunwind], [Use libunwind for backtracing])], 3878[if test "x$enable_prof_libunwind" = "xno" ; then 3879 enable_prof_libunwind="0" 3880else 3881 enable_prof_libunwind="1" 3882fi 3883], 3884[enable_prof_libunwind="0"] 3885) 3886AC_ARG_WITH([static_libunwind], 3887 [AS_HELP_STRING([--with-static-libunwind=<libunwind.a>], 3888 [Path to static libunwind library; use rather than dynamically linking])], 3889if test "x$with_static_libunwind" = "xno" ; then 3890 LUNWIND="-lunwind" 3891else 3892 if test ! -f "$with_static_libunwind" ; then 3893 AC_MSG_ERROR([Static libunwind not found: $with_static_libunwind]) 3894 fi 3895 LUNWIND="$with_static_libunwind" 3896fi, 3897 LUNWIND="-lunwind" 3898) 3899if test "x$backtrace_method" = "x" -a "x$enable_prof_libunwind" = "x1" ; then 3900 AC_CHECK_HEADERS([libunwind.h], , [enable_prof_libunwind="0"]) 3901 if test "x$LUNWIND" = "x-lunwind" ; then 3902 AC_CHECK_LIB([unwind], [unw_backtrace], [JE_APPEND_VS(LIBS, $LUNWIND)], 3903 [enable_prof_libunwind="0"]) 3904 else 3905 JE_APPEND_VS(LIBS, $LUNWIND) 3906 fi 3907 if test "x${enable_prof_libunwind}" = "x1" ; then 3908 backtrace_method="libunwind" 3909 AC_DEFINE([JEMALLOC_PROF_LIBUNWIND], [ ]) 3910 fi 3911fi 3912 3913AC_ARG_ENABLE([prof-libgcc], 3914 [AS_HELP_STRING([--disable-prof-libgcc], 3915 [Do not use libgcc for backtracing])], 3916[if test "x$enable_prof_libgcc" = "xno" ; then 3917 enable_prof_libgcc="0" 3918else 3919 enable_prof_libgcc="1" 3920fi 3921], 3922[enable_prof_libgcc="1"] 3923) 3924if test "x$backtrace_method" = "x" -a "x$enable_prof_libgcc" = "x1" \ 3925 -a "x$GCC" = "xyes" ; then 3926 AC_CHECK_HEADERS([unwind.h], , [enable_prof_libgcc="0"]) 3927 if test "x${enable_prof_libgcc}" = "x1" ; then 3928 AC_CHECK_LIB([gcc], [_Unwind_Backtrace], [JE_APPEND_VS(LIBS, -lgcc)], [enable_prof_libgcc="0"]) 3929 fi 3930 if test "x${enable_prof_libgcc}" = "x1" ; then 3931 backtrace_method="libgcc" 3932 AC_DEFINE([JEMALLOC_PROF_LIBGCC], [ ]) 3933 fi 3934else 3935 enable_prof_libgcc="0" 3936fi 3937 3938AC_ARG_ENABLE([prof-gcc], 3939 [AS_HELP_STRING([--disable-prof-gcc], 3940 [Do not use gcc intrinsics for backtracing])], 3941[if test "x$enable_prof_gcc" = "xno" ; then 3942 enable_prof_gcc="0" 3943else 3944 enable_prof_gcc="1" 3945fi 3946], 3947[enable_prof_gcc="1"] 3948) 3949if test "x$backtrace_method" = "x" -a "x$enable_prof_gcc" = "x1" \ 3950 -a "x$GCC" = "xyes" ; then 3951 JE_CFLAGS_ADD([-fno-omit-frame-pointer]) 3952 backtrace_method="gcc intrinsics" 3953 AC_DEFINE([JEMALLOC_PROF_GCC], [ ]) 3954else 3955 enable_prof_gcc="0" 3956fi 3957 3958if test "x$backtrace_method" = "x" ; then 3959 backtrace_method="none (disabling profiling)" 3960 enable_prof="0" 3961fi 3962AC_MSG_CHECKING([configured backtracing method]) 3963AC_MSG_RESULT([$backtrace_method]) 3964if test "x$enable_prof" = "x1" ; then 3965 dnl Heap profiling uses the log(3) function. 3966 JE_APPEND_VS(LIBS, $LM) 3967 3968 AC_DEFINE([JEMALLOC_PROF], [ ]) 3969fi 3970AC_SUBST([enable_prof]) 3971 3972dnl Indicate whether adjacent virtual memory mappings automatically coalesce 3973dnl (and fragment on demand). 3974if test "x${maps_coalesce}" = "x1" ; then 3975 AC_DEFINE([JEMALLOC_MAPS_COALESCE], [ ]) 3976fi 3977 3978dnl Indicate whether to retain memory (rather than using munmap()) by default. 3979if test "x$default_retain" = "x1" ; then 3980 AC_DEFINE([JEMALLOC_RETAIN], [ ]) 3981fi 3982 3983dnl Enable allocation from DSS if supported by the OS. 3984have_dss="1" 3985dnl Check whether the BSD/SUSv1 sbrk() exists. If not, disable DSS support. 3986AC_CHECK_FUNC([sbrk], [have_sbrk="1"], [have_sbrk="0"]) 3987if test "x$have_sbrk" = "x1" ; then 3988 if test "x$sbrk_deprecated" = "x1" ; then 3989 AC_MSG_RESULT([Disabling dss allocation because sbrk is deprecated]) 3990 have_dss="0" 3991 fi 3992else 3993 have_dss="0" 3994fi 3995 3996if test "x$have_dss" = "x1" ; then 3997 AC_DEFINE([JEMALLOC_DSS], [ ]) 3998fi 3999 4000dnl Support the junk/zero filling option by default. 4001AC_ARG_ENABLE([fill], 4002 [AS_HELP_STRING([--disable-fill], [Disable support for junk/zero filling])], 4003[if test "x$enable_fill" = "xno" ; then 4004 enable_fill="0" 4005else 4006 enable_fill="1" 4007fi 4008], 4009[enable_fill="1"] 4010) 4011if test "x$enable_fill" = "x1" ; then 4012 AC_DEFINE([JEMALLOC_FILL], [ ]) 4013fi 4014AC_SUBST([enable_fill]) 4015 4016dnl Disable utrace(2)-based tracing by default. 4017AC_ARG_ENABLE([utrace], 4018 [AS_HELP_STRING([--enable-utrace], [Enable utrace(2)-based tracing])], 4019[if test "x$enable_utrace" = "xno" ; then 4020 enable_utrace="0" 4021else 4022 enable_utrace="1" 4023fi 4024], 4025[enable_utrace="0"] 4026) 4027JE_COMPILABLE([utrace(2)], [ 4028#include <sys/types.h> 4029#include <sys/param.h> 4030#include <sys/time.h> 4031#include <sys/uio.h> 4032#include <sys/ktrace.h> 4033], [ 4034 utrace((void *)0, 0); 4035], [je_cv_utrace]) 4036if test "x${je_cv_utrace}" = "xno" ; then 4037 enable_utrace="0" 4038fi 4039if test "x$enable_utrace" = "x1" ; then 4040 AC_DEFINE([JEMALLOC_UTRACE], [ ]) 4041fi 4042AC_SUBST([enable_utrace]) 4043 4044dnl Do not support the xmalloc option by default. 4045AC_ARG_ENABLE([xmalloc], 4046 [AS_HELP_STRING([--enable-xmalloc], [Support xmalloc option])], 4047[if test "x$enable_xmalloc" = "xno" ; then 4048 enable_xmalloc="0" 4049else 4050 enable_xmalloc="1" 4051fi 4052], 4053[enable_xmalloc="0"] 4054) 4055if test "x$enable_xmalloc" = "x1" ; then 4056 AC_DEFINE([JEMALLOC_XMALLOC], [ ]) 4057fi 4058AC_SUBST([enable_xmalloc]) 4059 4060dnl Support cache-oblivious allocation alignment by default. 4061AC_ARG_ENABLE([cache-oblivious], 4062 [AS_HELP_STRING([--disable-cache-oblivious], 4063 [Disable support for cache-oblivious allocation alignment])], 4064[if test "x$enable_cache_oblivious" = "xno" ; then 4065 enable_cache_oblivious="0" 4066else 4067 enable_cache_oblivious="1" 4068fi 4069], 4070[enable_cache_oblivious="1"] 4071) 4072if test "x$enable_cache_oblivious" = "x1" ; then 4073 AC_DEFINE([JEMALLOC_CACHE_OBLIVIOUS], [ ]) 4074fi 4075AC_SUBST([enable_cache_oblivious]) 4076 4077dnl Do not log by default. 4078AC_ARG_ENABLE([log], 4079 [AS_HELP_STRING([--enable-log], [Support debug logging])], 4080[if test "x$enable_log" = "xno" ; then 4081 enable_log="0" 4082else 4083 enable_log="1" 4084fi 4085], 4086[enable_log="0"] 4087) 4088if test "x$enable_log" = "x1" ; then 4089 AC_DEFINE([JEMALLOC_LOG], [ ]) 4090fi 4091AC_SUBST([enable_log]) 4092 4093dnl Do not use readlinkat by default 4094AC_ARG_ENABLE([readlinkat], 4095 [AS_HELP_STRING([--enable-readlinkat], [Use readlinkat over readlink])], 4096[if test "x$enable_readlinkat" = "xno" ; then 4097 enable_readlinkat="0" 4098else 4099 enable_readlinkat="1" 4100fi 4101], 4102[enable_readlinkat="0"] 4103) 4104if test "x$enable_readlinkat" = "x1" ; then 4105 AC_DEFINE([JEMALLOC_READLINKAT], [ ]) 4106fi 4107AC_SUBST([enable_readlinkat]) 4108 4109dnl Avoid extra safety checks by default 4110AC_ARG_ENABLE([opt-safety-checks], 4111 [AS_HELP_STRING([--enable-opt-safety-checks], 4112 [Perform certain low-overhead checks, even in opt mode])], 4113[if test "x$enable_opt_safety_checks" = "xno" ; then 4114 enable_opt_safety_checks="0" 4115else 4116 enable_opt_safety_checks="1" 4117fi 4118], 4119[enable_opt_safety_checks="0"] 4120) 4121if test "x$enable_opt_safety_checks" = "x1" ; then 4122 AC_DEFINE([JEMALLOC_OPT_SAFETY_CHECKS], [ ]) 4123fi 4124AC_SUBST([enable_opt_safety_checks]) 4125 4126JE_COMPILABLE([a program using __builtin_unreachable], [ 4127void foo (void) { 4128 __builtin_unreachable(); 4129} 4130], [ 4131 { 4132 foo(); 4133 } 4134], [je_cv_gcc_builtin_unreachable]) 4135if test "x${je_cv_gcc_builtin_unreachable}" = "xyes" ; then 4136 AC_DEFINE([JEMALLOC_INTERNAL_UNREACHABLE], [__builtin_unreachable]) 4137else 4138 AC_DEFINE([JEMALLOC_INTERNAL_UNREACHABLE], [abort]) 4139fi 4140 4141dnl ============================================================================ 4142dnl Check for __builtin_ffsl(), then ffsl(3), and fail if neither are found. 4143dnl One of those two functions should (theoretically) exist on all platforms 4144dnl that jemalloc currently has a chance of functioning on without modification. 4145dnl We additionally assume ffs[ll]() or __builtin_ffs[ll]() are defined if 4146dnl ffsl() or __builtin_ffsl() are defined, respectively. 4147JE_COMPILABLE([a program using __builtin_ffsl], [ 4148#include <stdio.h> 4149#include <strings.h> 4150#include <string.h> 4151], [ 4152 { 4153 int rv = __builtin_ffsl(0x08); 4154 printf("%d\n", rv); 4155 } 4156], [je_cv_gcc_builtin_ffsl]) 4157if test "x${je_cv_gcc_builtin_ffsl}" = "xyes" ; then 4158 AC_DEFINE([JEMALLOC_INTERNAL_FFSLL], [__builtin_ffsll]) 4159 AC_DEFINE([JEMALLOC_INTERNAL_FFSL], [__builtin_ffsl]) 4160 AC_DEFINE([JEMALLOC_INTERNAL_FFS], [__builtin_ffs]) 4161else 4162 JE_COMPILABLE([a program using ffsl], [ 4163 #include <stdio.h> 4164 #include <strings.h> 4165 #include <string.h> 4166 ], [ 4167 { 4168 int rv = ffsl(0x08); 4169 printf("%d\n", rv); 4170 } 4171 ], [je_cv_function_ffsl]) 4172 if test "x${je_cv_function_ffsl}" = "xyes" ; then 4173 AC_DEFINE([JEMALLOC_INTERNAL_FFSLL], [ffsll]) 4174 AC_DEFINE([JEMALLOC_INTERNAL_FFSL], [ffsl]) 4175 AC_DEFINE([JEMALLOC_INTERNAL_FFS], [ffs]) 4176 else 4177 AC_MSG_ERROR([Cannot build without ffsl(3) or __builtin_ffsl()]) 4178 fi 4179fi 4180 4181JE_COMPILABLE([a program using __builtin_popcountl], [ 4182#include <stdio.h> 4183#include <strings.h> 4184#include <string.h> 4185], [ 4186 { 4187 int rv = __builtin_popcountl(0x08); 4188 printf("%d\n", rv); 4189 } 4190], [je_cv_gcc_builtin_popcountl]) 4191if test "x${je_cv_gcc_builtin_popcountl}" = "xyes" ; then 4192 AC_DEFINE([JEMALLOC_INTERNAL_POPCOUNT], [__builtin_popcount]) 4193 AC_DEFINE([JEMALLOC_INTERNAL_POPCOUNTL], [__builtin_popcountl]) 4194fi 4195 4196AC_ARG_WITH([lg_quantum], 4197 [AS_HELP_STRING([--with-lg-quantum=<lg-quantum>], 4198 [Base 2 log of minimum allocation alignment])], 4199 [LG_QUANTA="$with_lg_quantum"], 4200 [LG_QUANTA="3 4"]) 4201if test "x$with_lg_quantum" != "x" ; then 4202 AC_DEFINE_UNQUOTED([LG_QUANTUM], [$with_lg_quantum]) 4203fi 4204 4205AC_ARG_WITH([lg_page], 4206 [AS_HELP_STRING([--with-lg-page=<lg-page>], [Base 2 log of system page size])], 4207 [LG_PAGE="$with_lg_page"], [LG_PAGE="detect"]) 4208if test "x$LG_PAGE" = "xdetect"; then 4209 AC_CACHE_CHECK([LG_PAGE], 4210 [je_cv_lg_page], 4211 AC_RUN_IFELSE([AC_LANG_PROGRAM( 4212[[ 4213#include <strings.h> 4214#ifdef _WIN32 4215#include <windows.h> 4216#else 4217#include <unistd.h> 4218#endif 4219#include <stdio.h> 4220]], 4221[[ 4222 int result; 4223 FILE *f; 4224 4225#ifdef _WIN32 4226 SYSTEM_INFO si; 4227 GetSystemInfo(&si); 4228 result = si.dwPageSize; 4229#else 4230 result = sysconf(_SC_PAGESIZE); 4231#endif 4232 if (result == -1) { 4233 return 1; 4234 } 4235 result = JEMALLOC_INTERNAL_FFSL(result) - 1; 4236 4237 f = fopen("conftest.out", "w"); 4238 if (f == NULL) { 4239 return 1; 4240 } 4241 fprintf(f, "%d", result); 4242 fclose(f); 4243 4244 return 0; 4245]])], 4246 [je_cv_lg_page=`cat conftest.out`], 4247 [je_cv_lg_page=undefined], 4248 [je_cv_lg_page=12])) 4249fi 4250if test "x${je_cv_lg_page}" != "x" ; then 4251 LG_PAGE="${je_cv_lg_page}" 4252fi 4253if test "x${LG_PAGE}" != "xundefined" ; then 4254 AC_DEFINE_UNQUOTED([LG_PAGE], [$LG_PAGE]) 4255else 4256 AC_MSG_ERROR([cannot determine value for LG_PAGE]) 4257fi 4258 4259AC_ARG_WITH([lg_hugepage], 4260 [AS_HELP_STRING([--with-lg-hugepage=<lg-hugepage>], 4261 [Base 2 log of system huge page size])], 4262 [je_cv_lg_hugepage="${with_lg_hugepage}"], 4263 [je_cv_lg_hugepage=""]) 4264if test "x${je_cv_lg_hugepage}" = "x" ; then 4265 dnl Look in /proc/meminfo (Linux-specific) for information on the default huge 4266 dnl page size, if any. The relevant line looks like: 4267 dnl 4268 dnl Hugepagesize: 2048 kB 4269 if test -e "/proc/meminfo" ; then 4270 hpsk=[`cat /proc/meminfo 2>/dev/null | \ 4271 grep -e '^Hugepagesize:[[:space:]]\+[0-9]\+[[:space:]]kB$' | \ 4272 awk '{print $2}'`] 4273 if test "x${hpsk}" != "x" ; then 4274 je_cv_lg_hugepage=10 4275 while test "${hpsk}" -gt 1 ; do 4276 hpsk="$((hpsk / 2))" 4277 je_cv_lg_hugepage="$((je_cv_lg_hugepage + 1))" 4278 done 4279 fi 4280 fi 4281 4282 dnl Set default if unable to automatically configure. 4283 if test "x${je_cv_lg_hugepage}" = "x" ; then 4284 je_cv_lg_hugepage=21 4285 fi 4286fi 4287if test "x${LG_PAGE}" != "xundefined" -a \ 4288 "${je_cv_lg_hugepage}" -lt "${LG_PAGE}" ; then 4289 AC_MSG_ERROR([Huge page size (2^${je_cv_lg_hugepage}) must be at least page size (2^${LG_PAGE})]) 4290fi 4291AC_DEFINE_UNQUOTED([LG_HUGEPAGE], [${je_cv_lg_hugepage}]) 4292 4293dnl ============================================================================ 4294dnl Enable libdl by default. 4295AC_ARG_ENABLE([libdl], 4296 [AS_HELP_STRING([--disable-libdl], 4297 [Do not use libdl])], 4298[if test "x$enable_libdl" = "xno" ; then 4299 enable_libdl="0" 4300else 4301 enable_libdl="1" 4302fi 4303], 4304[enable_libdl="1"] 4305) 4306AC_SUBST([libdl]) 4307 4308dnl ============================================================================ 4309dnl Configure pthreads. 4310 4311if test "x$abi" != "xpecoff" ; then 4312 AC_DEFINE([JEMALLOC_HAVE_PTHREAD], [ ]) 4313 AC_CHECK_HEADERS([pthread.h], , [AC_MSG_ERROR([pthread.h is missing])]) 4314 dnl Some systems may embed pthreads functionality in libc; check for libpthread 4315 dnl first, but try libc too before failing. 4316 AC_CHECK_LIB([pthread], [pthread_create], [JE_APPEND_VS(LIBS, -pthread)], 4317 [AC_SEARCH_LIBS([pthread_create], , , 4318 AC_MSG_ERROR([libpthread is missing]))]) 4319 wrap_syms="${wrap_syms} pthread_create" 4320 have_pthread="1" 4321 4322dnl Check if we have dlsym support. 4323 if test "x$enable_libdl" = "x1" ; then 4324 have_dlsym="1" 4325 AC_CHECK_HEADERS([dlfcn.h], 4326 AC_CHECK_FUNC([dlsym], [], 4327 [AC_CHECK_LIB([dl], [dlsym], [LIBS="$LIBS -ldl"], [have_dlsym="0"])]), 4328 [have_dlsym="0"]) 4329 if test "x$have_dlsym" = "x1" ; then 4330 AC_DEFINE([JEMALLOC_HAVE_DLSYM], [ ]) 4331 fi 4332 else 4333 have_dlsym="0" 4334 fi 4335 4336 JE_COMPILABLE([pthread_atfork(3)], [ 4337#include <pthread.h> 4338], [ 4339 pthread_atfork((void *)0, (void *)0, (void *)0); 4340], [je_cv_pthread_atfork]) 4341 if test "x${je_cv_pthread_atfork}" = "xyes" ; then 4342 AC_DEFINE([JEMALLOC_HAVE_PTHREAD_ATFORK], [ ]) 4343 fi 4344 dnl Check if pthread_setname_np is available with the expected API. 4345 JE_COMPILABLE([pthread_setname_np(3)], [ 4346#include <pthread.h> 4347], [ 4348 pthread_setname_np(pthread_self(), "setname_test"); 4349], [je_cv_pthread_setname_np]) 4350 if test "x${je_cv_pthread_setname_np}" = "xyes" ; then 4351 AC_DEFINE([JEMALLOC_HAVE_PTHREAD_SETNAME_NP], [ ]) 4352 fi 4353fi 4354 4355JE_APPEND_VS(CPPFLAGS, -D_REENTRANT) 4356 4357dnl Check whether clock_gettime(2) is in libc or librt. 4358AC_SEARCH_LIBS([clock_gettime], [rt]) 4359 4360dnl Cray wrapper compiler often adds `-lrt` when using `-static`. Check with 4361dnl `-dynamic` as well in case a user tries to dynamically link in jemalloc 4362if test "x$je_cv_cray_prgenv_wrapper" = "xyes" ; then 4363 if test "$ac_cv_search_clock_gettime" != "-lrt"; then 4364 JE_CFLAGS_SAVE() 4365 4366 unset ac_cv_search_clock_gettime 4367 JE_CFLAGS_ADD([-dynamic]) 4368 AC_SEARCH_LIBS([clock_gettime], [rt]) 4369 4370 JE_CFLAGS_RESTORE() 4371 fi 4372fi 4373 4374dnl check for CLOCK_MONOTONIC_COARSE (Linux-specific). 4375JE_COMPILABLE([clock_gettime(CLOCK_MONOTONIC_COARSE, ...)], [ 4376#include <time.h> 4377], [ 4378 struct timespec ts; 4379 4380 clock_gettime(CLOCK_MONOTONIC_COARSE, &ts); 4381], [je_cv_clock_monotonic_coarse]) 4382if test "x${je_cv_clock_monotonic_coarse}" = "xyes" ; then 4383 AC_DEFINE([JEMALLOC_HAVE_CLOCK_MONOTONIC_COARSE]) 4384fi 4385 4386dnl check for CLOCK_MONOTONIC. 4387JE_COMPILABLE([clock_gettime(CLOCK_MONOTONIC, ...)], [ 4388#include <unistd.h> 4389#include <time.h> 4390], [ 4391 struct timespec ts; 4392 4393 clock_gettime(CLOCK_MONOTONIC, &ts); 4394#if !defined(_POSIX_MONOTONIC_CLOCK) || _POSIX_MONOTONIC_CLOCK < 0 4395# error _POSIX_MONOTONIC_CLOCK missing/invalid 4396#endif 4397], [je_cv_clock_monotonic]) 4398if test "x${je_cv_clock_monotonic}" = "xyes" ; then 4399 AC_DEFINE([JEMALLOC_HAVE_CLOCK_MONOTONIC]) 4400fi 4401 4402dnl Check for mach_absolute_time(). 4403JE_COMPILABLE([mach_absolute_time()], [ 4404#include <mach/mach_time.h> 4405], [ 4406 mach_absolute_time(); 4407], [je_cv_mach_absolute_time]) 4408if test "x${je_cv_mach_absolute_time}" = "xyes" ; then 4409 AC_DEFINE([JEMALLOC_HAVE_MACH_ABSOLUTE_TIME]) 4410fi 4411 4412dnl Use syscall(2) (if available) by default. 4413AC_ARG_ENABLE([syscall], 4414 [AS_HELP_STRING([--disable-syscall], [Disable use of syscall(2)])], 4415[if test "x$enable_syscall" = "xno" ; then 4416 enable_syscall="0" 4417else 4418 enable_syscall="1" 4419fi 4420], 4421[enable_syscall="1"] 4422) 4423if test "x$enable_syscall" = "x1" ; then 4424 dnl Check if syscall(2) is usable. Treat warnings as errors, so that e.g. OS 4425 dnl X 10.12's deprecation warning prevents use. 4426 JE_CFLAGS_SAVE() 4427 JE_CFLAGS_ADD([-Werror]) 4428 JE_COMPILABLE([syscall(2)], [ 4429#include <sys/syscall.h> 4430#include <unistd.h> 4431], [ 4432 syscall(SYS_write, 2, "hello", 5); 4433], 4434 [je_cv_syscall]) 4435 JE_CFLAGS_RESTORE() 4436 if test "x$je_cv_syscall" = "xyes" ; then 4437 AC_DEFINE([JEMALLOC_USE_SYSCALL], [ ]) 4438 fi 4439fi 4440 4441dnl Check if the GNU-specific secure_getenv function exists. 4442AC_CHECK_FUNC([secure_getenv], 4443 [have_secure_getenv="1"], 4444 [have_secure_getenv="0"] 4445 ) 4446if test "x$have_secure_getenv" = "x1" ; then 4447 AC_DEFINE([JEMALLOC_HAVE_SECURE_GETENV], [ ]) 4448fi 4449 4450dnl Check if the GNU-specific sched_getcpu function exists. 4451AC_CHECK_FUNC([sched_getcpu], 4452 [have_sched_getcpu="1"], 4453 [have_sched_getcpu="0"] 4454 ) 4455if test "x$have_sched_getcpu" = "x1" ; then 4456 AC_DEFINE([JEMALLOC_HAVE_SCHED_GETCPU], [ ]) 4457fi 4458 4459dnl Check if the GNU-specific sched_setaffinity function exists. 4460AC_CHECK_FUNC([sched_setaffinity], 4461 [have_sched_setaffinity="1"], 4462 [have_sched_setaffinity="0"] 4463 ) 4464if test "x$have_sched_setaffinity" = "x1" ; then 4465 AC_DEFINE([JEMALLOC_HAVE_SCHED_SETAFFINITY], [ ]) 4466fi 4467 4468dnl Check if the Solaris/BSD issetugid function exists. 4469AC_CHECK_FUNC([issetugid], 4470 [have_issetugid="1"], 4471 [have_issetugid="0"] 4472 ) 4473if test "x$have_issetugid" = "x1" ; then 4474 AC_DEFINE([JEMALLOC_HAVE_ISSETUGID], [ ]) 4475fi 4476 4477dnl Check whether the BSD-specific _malloc_thread_cleanup() exists. If so, use 4478dnl it rather than pthreads TSD cleanup functions to support cleanup during 4479dnl thread exit, in order to avoid pthreads library recursion during 4480dnl bootstrapping. 4481AC_CHECK_FUNC([_malloc_thread_cleanup], 4482 [have__malloc_thread_cleanup="1"], 4483 [have__malloc_thread_cleanup="0"] 4484 ) 4485if test "x$have__malloc_thread_cleanup" = "x1" ; then 4486 AC_DEFINE([JEMALLOC_MALLOC_THREAD_CLEANUP], [ ]) 4487 wrap_syms="${wrap_syms} _malloc_thread_cleanup" 4488 force_tls="1" 4489fi 4490 4491dnl Check whether the BSD-specific _pthread_mutex_init_calloc_cb() exists. If 4492dnl so, mutex initialization causes allocation, and we need to implement this 4493dnl callback function in order to prevent recursive allocation. 4494AC_CHECK_FUNC([_pthread_mutex_init_calloc_cb], 4495 [have__pthread_mutex_init_calloc_cb="1"], 4496 [have__pthread_mutex_init_calloc_cb="0"] 4497 ) 4498if test "x$have__pthread_mutex_init_calloc_cb" = "x1" ; then 4499 AC_DEFINE([JEMALLOC_MUTEX_INIT_CB]) 4500 wrap_syms="${wrap_syms} _malloc_prefork _malloc_postfork" 4501fi 4502 4503dnl Disable lazy locking by default. 4504AC_ARG_ENABLE([lazy_lock], 4505 [AS_HELP_STRING([--enable-lazy-lock], 4506 [Enable lazy locking (only lock when multi-threaded)])], 4507[if test "x$enable_lazy_lock" = "xno" ; then 4508 enable_lazy_lock="0" 4509else 4510 enable_lazy_lock="1" 4511fi 4512], 4513[enable_lazy_lock=""] 4514) 4515if test "x${enable_lazy_lock}" = "x" ; then 4516 if test "x${force_lazy_lock}" = "x1" ; then 4517 AC_MSG_RESULT([Forcing lazy-lock to avoid allocator/threading bootstrap issues]) 4518 enable_lazy_lock="1" 4519 else 4520 enable_lazy_lock="0" 4521 fi 4522fi 4523if test "x${enable_lazy_lock}" = "x1" -a "x${abi}" = "xpecoff" ; then 4524 AC_MSG_RESULT([Forcing no lazy-lock because thread creation monitoring is unimplemented]) 4525 enable_lazy_lock="0" 4526fi 4527if test "x$enable_lazy_lock" = "x1" ; then 4528 if test "x$have_dlsym" = "x1" ; then 4529 AC_DEFINE([JEMALLOC_LAZY_LOCK], [ ]) 4530 else 4531 AC_MSG_ERROR([Missing dlsym support: lazy-lock cannot be enabled.]) 4532 fi 4533fi 4534AC_SUBST([enable_lazy_lock]) 4535 4536dnl Automatically configure TLS. 4537if test "x${force_tls}" = "x1" ; then 4538 enable_tls="1" 4539elif test "x${force_tls}" = "x0" ; then 4540 enable_tls="0" 4541else 4542 enable_tls="1" 4543fi 4544if test "x${enable_tls}" = "x1" ; then 4545AC_MSG_CHECKING([for TLS]) 4546AC_COMPILE_IFELSE([AC_LANG_PROGRAM( 4547[[ 4548 __thread int x; 4549]], [[ 4550 x = 42; 4551 4552 return 0; 4553]])], 4554 AC_MSG_RESULT([yes]), 4555 AC_MSG_RESULT([no]) 4556 enable_tls="0") 4557else 4558 enable_tls="0" 4559fi 4560AC_SUBST([enable_tls]) 4561if test "x${enable_tls}" = "x1" ; then 4562 AC_DEFINE_UNQUOTED([JEMALLOC_TLS], [ ]) 4563fi 4564 4565dnl ============================================================================ 4566dnl Check for C11 atomics. 4567 4568JE_COMPILABLE([C11 atomics], [ 4569#include <stdint.h> 4570#if (__STDC_VERSION__ >= 201112L) && !defined(__STDC_NO_ATOMICS__) 4571#include <stdatomic.h> 4572#else 4573#error Atomics not available 4574#endif 4575], [ 4576 uint64_t *p = (uint64_t *)0; 4577 uint64_t x = 1; 4578 volatile atomic_uint_least64_t *a = (volatile atomic_uint_least64_t *)p; 4579 uint64_t r = atomic_fetch_add(a, x) + x; 4580 return r == 0; 4581], [je_cv_c11_atomics]) 4582if test "x${je_cv_c11_atomics}" = "xyes" ; then 4583 AC_DEFINE([JEMALLOC_C11_ATOMICS]) 4584fi 4585 4586dnl ============================================================================ 4587dnl Check for GCC-style __atomic atomics. 4588 4589JE_COMPILABLE([GCC __atomic atomics], [ 4590], [ 4591 int x = 0; 4592 int val = 1; 4593 int y = __atomic_fetch_add(&x, val, __ATOMIC_RELAXED); 4594 int after_add = x; 4595 return after_add == 1; 4596], [je_cv_gcc_atomic_atomics]) 4597if test "x${je_cv_gcc_atomic_atomics}" = "xyes" ; then 4598 AC_DEFINE([JEMALLOC_GCC_ATOMIC_ATOMICS]) 4599 4600 dnl check for 8-bit atomic support 4601 JE_COMPILABLE([GCC 8-bit __atomic atomics], [ 4602 ], [ 4603 unsigned char x = 0; 4604 int val = 1; 4605 int y = __atomic_fetch_add(&x, val, __ATOMIC_RELAXED); 4606 int after_add = (int)x; 4607 return after_add == 1; 4608 ], [je_cv_gcc_u8_atomic_atomics]) 4609 if test "x${je_cv_gcc_u8_atomic_atomics}" = "xyes" ; then 4610 AC_DEFINE([JEMALLOC_GCC_U8_ATOMIC_ATOMICS]) 4611 fi 4612fi 4613 4614dnl ============================================================================ 4615dnl Check for GCC-style __sync atomics. 4616 4617JE_COMPILABLE([GCC __sync atomics], [ 4618], [ 4619 int x = 0; 4620 int before_add = __sync_fetch_and_add(&x, 1); 4621 int after_add = x; 4622 return (before_add == 0) && (after_add == 1); 4623], [je_cv_gcc_sync_atomics]) 4624if test "x${je_cv_gcc_sync_atomics}" = "xyes" ; then 4625 AC_DEFINE([JEMALLOC_GCC_SYNC_ATOMICS]) 4626 4627 dnl check for 8-bit atomic support 4628 JE_COMPILABLE([GCC 8-bit __sync atomics], [ 4629 ], [ 4630 unsigned char x = 0; 4631 int before_add = __sync_fetch_and_add(&x, 1); 4632 int after_add = (int)x; 4633 return (before_add == 0) && (after_add == 1); 4634 ], [je_cv_gcc_u8_sync_atomics]) 4635 if test "x${je_cv_gcc_u8_sync_atomics}" = "xyes" ; then 4636 AC_DEFINE([JEMALLOC_GCC_U8_SYNC_ATOMICS]) 4637 fi 4638fi 4639 4640dnl ============================================================================ 4641dnl Check for atomic(3) operations as provided on Darwin. 4642dnl We need this not for the atomic operations (which are provided above), but 4643dnl rather for the OS_unfair_lock type it exposes. 4644 4645JE_COMPILABLE([Darwin OSAtomic*()], [ 4646#include <libkern/OSAtomic.h> 4647#include <inttypes.h> 4648], [ 4649 { 4650 int32_t x32 = 0; 4651 volatile int32_t *x32p = &x32; 4652 OSAtomicAdd32(1, x32p); 4653 } 4654 { 4655 int64_t x64 = 0; 4656 volatile int64_t *x64p = &x64; 4657 OSAtomicAdd64(1, x64p); 4658 } 4659], [je_cv_osatomic]) 4660if test "x${je_cv_osatomic}" = "xyes" ; then 4661 AC_DEFINE([JEMALLOC_OSATOMIC], [ ]) 4662fi 4663 4664dnl ============================================================================ 4665dnl Check for madvise(2). 4666 4667JE_COMPILABLE([madvise(2)], [ 4668#include <sys/mman.h> 4669], [ 4670 madvise((void *)0, 0, 0); 4671], [je_cv_madvise]) 4672if test "x${je_cv_madvise}" = "xyes" ; then 4673 AC_DEFINE([JEMALLOC_HAVE_MADVISE], [ ]) 4674 4675 dnl Check for madvise(..., MADV_FREE). 4676 JE_COMPILABLE([madvise(..., MADV_FREE)], [ 4677#include <sys/mman.h> 4678], [ 4679 madvise((void *)0, 0, MADV_FREE); 4680], [je_cv_madv_free]) 4681 if test "x${je_cv_madv_free}" = "xyes" ; then 4682 AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ]) 4683 elif test "x${je_cv_madvise}" = "xyes" ; then 4684 case "${host_cpu}" in i686|x86_64) 4685 case "${host}" in *-*-linux*) 4686 AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ]) 4687 AC_DEFINE([JEMALLOC_DEFINE_MADVISE_FREE], [ ]) 4688 ;; 4689 esac 4690 ;; 4691 esac 4692 fi 4693 4694 dnl Check for madvise(..., MADV_DONTNEED). 4695 JE_COMPILABLE([madvise(..., MADV_DONTNEED)], [ 4696#include <sys/mman.h> 4697], [ 4698 madvise((void *)0, 0, MADV_DONTNEED); 4699], [je_cv_madv_dontneed]) 4700 if test "x${je_cv_madv_dontneed}" = "xyes" ; then 4701 AC_DEFINE([JEMALLOC_PURGE_MADVISE_DONTNEED], [ ]) 4702 fi 4703 4704 dnl Check for madvise(..., MADV_DO[NT]DUMP). 4705 JE_COMPILABLE([madvise(..., MADV_DO[[NT]]DUMP)], [ 4706#include <sys/mman.h> 4707], [ 4708 madvise((void *)0, 0, MADV_DONTDUMP); 4709 madvise((void *)0, 0, MADV_DODUMP); 4710], [je_cv_madv_dontdump]) 4711 if test "x${je_cv_madv_dontdump}" = "xyes" ; then 4712 AC_DEFINE([JEMALLOC_MADVISE_DONTDUMP], [ ]) 4713 fi 4714 4715 dnl Check for madvise(..., MADV_[NO]HUGEPAGE). 4716 JE_COMPILABLE([madvise(..., MADV_[[NO]]HUGEPAGE)], [ 4717#include <sys/mman.h> 4718], [ 4719 madvise((void *)0, 0, MADV_HUGEPAGE); 4720 madvise((void *)0, 0, MADV_NOHUGEPAGE); 4721], [je_cv_thp]) 4722case "${host_cpu}" in 4723 arm*) 4724 ;; 4725 *) 4726 if test "x${je_cv_thp}" = "xyes" ; then 4727 AC_DEFINE([JEMALLOC_HAVE_MADVISE_HUGE], [ ]) 4728 fi 4729 ;; 4730esac 4731fi 4732 4733dnl ============================================================================ 4734dnl Check for __builtin_clz() and __builtin_clzl(). 4735 4736AC_CACHE_CHECK([for __builtin_clz], 4737 [je_cv_builtin_clz], 4738 [AC_LINK_IFELSE([AC_LANG_PROGRAM([], 4739 [ 4740 { 4741 unsigned x = 0; 4742 int y = __builtin_clz(x); 4743 } 4744 { 4745 unsigned long x = 0; 4746 int y = __builtin_clzl(x); 4747 } 4748 ])], 4749 [je_cv_builtin_clz=yes], 4750 [je_cv_builtin_clz=no])]) 4751 4752if test "x${je_cv_builtin_clz}" = "xyes" ; then 4753 AC_DEFINE([JEMALLOC_HAVE_BUILTIN_CLZ], [ ]) 4754fi 4755 4756dnl ============================================================================ 4757dnl Check for os_unfair_lock operations as provided on Darwin. 4758 4759JE_COMPILABLE([Darwin os_unfair_lock_*()], [ 4760#include <os/lock.h> 4761#include <AvailabilityMacros.h> 4762], [ 4763 #if MAC_OS_X_VERSION_MIN_REQUIRED < 101200 4764 #error "os_unfair_lock is not supported" 4765 #else 4766 os_unfair_lock lock = OS_UNFAIR_LOCK_INIT; 4767 os_unfair_lock_lock(&lock); 4768 os_unfair_lock_unlock(&lock); 4769 #endif 4770], [je_cv_os_unfair_lock]) 4771if test "x${je_cv_os_unfair_lock}" = "xyes" ; then 4772 AC_DEFINE([JEMALLOC_OS_UNFAIR_LOCK], [ ]) 4773fi 4774 4775dnl ============================================================================ 4776dnl Darwin-related configuration. 4777 4778AC_ARG_ENABLE([zone-allocator], 4779 [AS_HELP_STRING([--disable-zone-allocator], 4780 [Disable zone allocator for Darwin])], 4781[if test "x$enable_zone_allocator" = "xno" ; then 4782 enable_zone_allocator="0" 4783else 4784 enable_zone_allocator="1" 4785fi 4786], 4787[if test "x${abi}" = "xmacho"; then 4788 enable_zone_allocator="1" 4789fi 4790] 4791) 4792AC_SUBST([enable_zone_allocator]) 4793 4794if test "x${enable_zone_allocator}" = "x1" ; then 4795 if test "x${abi}" != "xmacho"; then 4796 AC_MSG_ERROR([--enable-zone-allocator is only supported on Darwin]) 4797 fi 4798 AC_DEFINE([JEMALLOC_ZONE], [ ]) 4799fi 4800 4801dnl ============================================================================ 4802dnl Use initial-exec TLS by default. 4803AC_ARG_ENABLE([initial-exec-tls], 4804 [AS_HELP_STRING([--disable-initial-exec-tls], 4805 [Disable the initial-exec tls model])], 4806[if test "x$enable_initial_exec_tls" = "xno" ; then 4807 enable_initial_exec_tls="0" 4808else 4809 enable_initial_exec_tls="1" 4810fi 4811], 4812[enable_initial_exec_tls="1"] 4813) 4814AC_SUBST([enable_initial_exec_tls]) 4815 4816if test "x${je_cv_tls_model}" = "xyes" -a \ 4817 "x${enable_initial_exec_tls}" = "x1" ; then 4818 AC_DEFINE([JEMALLOC_TLS_MODEL], 4819 [__attribute__((tls_model("initial-exec")))]) 4820else 4821 AC_DEFINE([JEMALLOC_TLS_MODEL], [ ]) 4822fi 4823 4824dnl ============================================================================ 4825dnl Enable background threads if possible. 4826 4827if test "x${have_pthread}" = "x1" -a "x${je_cv_os_unfair_lock}" != "xyes" ; then 4828 AC_DEFINE([JEMALLOC_BACKGROUND_THREAD]) 4829fi 4830 4831dnl ============================================================================ 4832dnl Check for glibc malloc hooks 4833 4834JE_COMPILABLE([glibc malloc hook], [ 4835#include <stddef.h> 4836 4837extern void (* __free_hook)(void *ptr); 4838extern void *(* __malloc_hook)(size_t size); 4839extern void *(* __realloc_hook)(void *ptr, size_t size); 4840], [ 4841 void *ptr = 0L; 4842 if (__malloc_hook) ptr = __malloc_hook(1); 4843 if (__realloc_hook) ptr = __realloc_hook(ptr, 2); 4844 if (__free_hook && ptr) __free_hook(ptr); 4845], [je_cv_glibc_malloc_hook]) 4846if test "x${je_cv_glibc_malloc_hook}" = "xyes" ; then 4847 if test "x${JEMALLOC_PREFIX}" = "x" ; then 4848 AC_DEFINE([JEMALLOC_GLIBC_MALLOC_HOOK], [ ]) 4849 wrap_syms="${wrap_syms} __free_hook __malloc_hook __realloc_hook" 4850 fi 4851fi 4852 4853JE_COMPILABLE([glibc memalign hook], [ 4854#include <stddef.h> 4855 4856extern void *(* __memalign_hook)(size_t alignment, size_t size); 4857], [ 4858 void *ptr = 0L; 4859 if (__memalign_hook) ptr = __memalign_hook(16, 7); 4860], [je_cv_glibc_memalign_hook]) 4861if test "x${je_cv_glibc_memalign_hook}" = "xyes" ; then 4862 if test "x${JEMALLOC_PREFIX}" = "x" ; then 4863 AC_DEFINE([JEMALLOC_GLIBC_MEMALIGN_HOOK], [ ]) 4864 wrap_syms="${wrap_syms} __memalign_hook" 4865 fi 4866fi 4867 4868JE_COMPILABLE([pthreads adaptive mutexes], [ 4869#include <pthread.h> 4870], [ 4871 pthread_mutexattr_t attr; 4872 pthread_mutexattr_init(&attr); 4873 pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ADAPTIVE_NP); 4874 pthread_mutexattr_destroy(&attr); 4875], [je_cv_pthread_mutex_adaptive_np]) 4876if test "x${je_cv_pthread_mutex_adaptive_np}" = "xyes" ; then 4877 AC_DEFINE([JEMALLOC_HAVE_PTHREAD_MUTEX_ADAPTIVE_NP], [ ]) 4878fi 4879 4880JE_CFLAGS_SAVE() 4881JE_CFLAGS_ADD([-D_GNU_SOURCE]) 4882JE_CFLAGS_ADD([-Werror]) 4883JE_CFLAGS_ADD([-herror_on_warning]) 4884JE_COMPILABLE([strerror_r returns char with gnu source], [ 4885#include <errno.h> 4886#include <stdio.h> 4887#include <stdlib.h> 4888#include <string.h> 4889], [ 4890 char *buffer = (char *) malloc(100); 4891 char *error = strerror_r(EINVAL, buffer, 100); 4892 printf("%s\n", error); 4893], [je_cv_strerror_r_returns_char_with_gnu_source]) 4894JE_CFLAGS_RESTORE() 4895if test "x${je_cv_strerror_r_returns_char_with_gnu_source}" = "xyes" ; then 4896 AC_DEFINE([JEMALLOC_STRERROR_R_RETURNS_CHAR_WITH_GNU_SOURCE], [ ]) 4897fi 4898 4899dnl ============================================================================ 4900dnl Check for typedefs, structures, and compiler characteristics. 4901AC_HEADER_STDBOOL 4902 4903dnl ============================================================================ 4904dnl Define commands that generate output files. 4905 4906AC_CONFIG_COMMANDS([include/jemalloc/internal/public_symbols.txt], [ 4907 f="${objroot}include/jemalloc/internal/public_symbols.txt" 4908 mkdir -p "${objroot}include/jemalloc/internal" 4909 cp /dev/null "${f}" 4910 for nm in `echo ${mangling_map} |tr ',' ' '` ; do 4911 n=`echo ${nm} |tr ':' ' ' |awk '{print $[]1}'` 4912 m=`echo ${nm} |tr ':' ' ' |awk '{print $[]2}'` 4913 echo "${n}:${m}" >> "${f}" 4914 dnl Remove name from public_syms so that it isn't redefined later. 4915 public_syms=`for sym in ${public_syms}; do echo "${sym}"; done |grep -v "^${n}\$" |tr '\n' ' '` 4916 done 4917 for sym in ${public_syms} ; do 4918 n="${sym}" 4919 m="${JEMALLOC_PREFIX}${sym}" 4920 echo "${n}:${m}" >> "${f}" 4921 done 4922], [ 4923 srcdir="${srcdir}" 4924 objroot="${objroot}" 4925 mangling_map="${mangling_map}" 4926 public_syms="${public_syms}" 4927 JEMALLOC_PREFIX="${JEMALLOC_PREFIX}" 4928]) 4929AC_CONFIG_COMMANDS([include/jemalloc/internal/private_symbols.awk], [ 4930 f="${objroot}include/jemalloc/internal/private_symbols.awk" 4931 mkdir -p "${objroot}include/jemalloc/internal" 4932 export_syms=`for sym in ${public_syms}; do echo "${JEMALLOC_PREFIX}${sym}"; done; for sym in ${wrap_syms}; do echo "${sym}"; done;` 4933 "${srcdir}/include/jemalloc/internal/private_symbols.sh" "${SYM_PREFIX}" ${export_syms} > "${objroot}include/jemalloc/internal/private_symbols.awk" 4934], [ 4935 srcdir="${srcdir}" 4936 objroot="${objroot}" 4937 public_syms="${public_syms}" 4938 wrap_syms="${wrap_syms}" 4939 SYM_PREFIX="${SYM_PREFIX}" 4940 JEMALLOC_PREFIX="${JEMALLOC_PREFIX}" 4941]) 4942AC_CONFIG_COMMANDS([include/jemalloc/internal/private_symbols_jet.awk], [ 4943 f="${objroot}include/jemalloc/internal/private_symbols_jet.awk" 4944 mkdir -p "${objroot}include/jemalloc/internal" 4945 export_syms=`for sym in ${public_syms}; do echo "jet_${sym}"; done; for sym in ${wrap_syms}; do echo "${sym}"; done;` 4946 "${srcdir}/include/jemalloc/internal/private_symbols.sh" "${SYM_PREFIX}" ${export_syms} > "${objroot}include/jemalloc/internal/private_symbols_jet.awk" 4947], [ 4948 srcdir="${srcdir}" 4949 objroot="${objroot}" 4950 public_syms="${public_syms}" 4951 wrap_syms="${wrap_syms}" 4952 SYM_PREFIX="${SYM_PREFIX}" 4953]) 4954AC_CONFIG_COMMANDS([include/jemalloc/internal/public_namespace.h], [ 4955 mkdir -p "${objroot}include/jemalloc/internal" 4956 "${srcdir}/include/jemalloc/internal/public_namespace.sh" "${objroot}include/jemalloc/internal/public_symbols.txt" > "${objroot}include/jemalloc/internal/public_namespace.h" 4957], [ 4958 srcdir="${srcdir}" 4959 objroot="${objroot}" 4960]) 4961AC_CONFIG_COMMANDS([include/jemalloc/internal/public_unnamespace.h], [ 4962 mkdir -p "${objroot}include/jemalloc/internal" 4963 "${srcdir}/include/jemalloc/internal/public_unnamespace.sh" "${objroot}include/jemalloc/internal/public_symbols.txt" > "${objroot}include/jemalloc/internal/public_unnamespace.h" 4964], [ 4965 srcdir="${srcdir}" 4966 objroot="${objroot}" 4967]) 4968AC_CONFIG_COMMANDS([include/jemalloc/jemalloc_protos_jet.h], [ 4969 mkdir -p "${objroot}include/jemalloc" 4970 cat "${srcdir}/include/jemalloc/jemalloc_protos.h.in" | sed -e 's/@je_@/jet_/g' > "${objroot}include/jemalloc/jemalloc_protos_jet.h" 4971], [ 4972 srcdir="${srcdir}" 4973 objroot="${objroot}" 4974]) 4975AC_CONFIG_COMMANDS([include/jemalloc/jemalloc_rename.h], [ 4976 mkdir -p "${objroot}include/jemalloc" 4977 "${srcdir}/include/jemalloc/jemalloc_rename.sh" "${objroot}include/jemalloc/internal/public_symbols.txt" > "${objroot}include/jemalloc/jemalloc_rename.h" 4978], [ 4979 srcdir="${srcdir}" 4980 objroot="${objroot}" 4981]) 4982AC_CONFIG_COMMANDS([include/jemalloc/jemalloc_mangle.h], [ 4983 mkdir -p "${objroot}include/jemalloc" 4984 "${srcdir}/include/jemalloc/jemalloc_mangle.sh" "${objroot}include/jemalloc/internal/public_symbols.txt" je_ > "${objroot}include/jemalloc/jemalloc_mangle.h" 4985], [ 4986 srcdir="${srcdir}" 4987 objroot="${objroot}" 4988]) 4989AC_CONFIG_COMMANDS([include/jemalloc/jemalloc_mangle_jet.h], [ 4990 mkdir -p "${objroot}include/jemalloc" 4991 "${srcdir}/include/jemalloc/jemalloc_mangle.sh" "${objroot}include/jemalloc/internal/public_symbols.txt" jet_ > "${objroot}include/jemalloc/jemalloc_mangle_jet.h" 4992], [ 4993 srcdir="${srcdir}" 4994 objroot="${objroot}" 4995]) 4996AC_CONFIG_COMMANDS([include/jemalloc/jemalloc.h], [ 4997 mkdir -p "${objroot}include/jemalloc" 4998 "${srcdir}/include/jemalloc/jemalloc.sh" "${objroot}" > "${objroot}include/jemalloc/jemalloc${install_suffix}.h" 4999], [ 5000 srcdir="${srcdir}" 5001 objroot="${objroot}" 5002 install_suffix="${install_suffix}" 5003]) 5004 5005dnl Process .in files. 5006AC_SUBST([cfghdrs_in]) 5007AC_SUBST([cfghdrs_out]) 5008AC_CONFIG_HEADERS([$cfghdrs_tup]) 5009 5010dnl ============================================================================ 5011dnl Generate outputs. 5012 5013AC_CONFIG_FILES([$cfgoutputs_tup config.stamp bin/jemalloc-config bin/jemalloc.sh bin/jeprof]) 5014AC_SUBST([cfgoutputs_in]) 5015AC_SUBST([cfgoutputs_out]) 5016AC_OUTPUT 5017 5018dnl ============================================================================ 5019dnl Print out the results of configuration. 5020AC_MSG_RESULT([===============================================================================]) 5021AC_MSG_RESULT([jemalloc version : ${jemalloc_version}]) 5022AC_MSG_RESULT([library revision : ${rev}]) 5023AC_MSG_RESULT([]) 5024AC_MSG_RESULT([CONFIG : ${CONFIG}]) 5025AC_MSG_RESULT([CC : ${CC}]) 5026AC_MSG_RESULT([CONFIGURE_CFLAGS : ${CONFIGURE_CFLAGS}]) 5027AC_MSG_RESULT([SPECIFIED_CFLAGS : ${SPECIFIED_CFLAGS}]) 5028AC_MSG_RESULT([EXTRA_CFLAGS : ${EXTRA_CFLAGS}]) 5029AC_MSG_RESULT([CPPFLAGS : ${CPPFLAGS}]) 5030AC_MSG_RESULT([CXX : ${CXX}]) 5031AC_MSG_RESULT([CONFIGURE_CXXFLAGS : ${CONFIGURE_CXXFLAGS}]) 5032AC_MSG_RESULT([SPECIFIED_CXXFLAGS : ${SPECIFIED_CXXFLAGS}]) 5033AC_MSG_RESULT([EXTRA_CXXFLAGS : ${EXTRA_CXXFLAGS}]) 5034AC_MSG_RESULT([LDFLAGS : ${LDFLAGS}]) 5035AC_MSG_RESULT([EXTRA_LDFLAGS : ${EXTRA_LDFLAGS}]) 5036AC_MSG_RESULT([DSO_LDFLAGS : ${DSO_LDFLAGS}]) 5037AC_MSG_RESULT([LIBS : ${LIBS}]) 5038AC_MSG_RESULT([RPATH_EXTRA : ${RPATH_EXTRA}]) 5039AC_MSG_RESULT([]) 5040AC_MSG_RESULT([XSLTPROC : ${XSLTPROC}]) 5041AC_MSG_RESULT([XSLROOT : ${XSLROOT}]) 5042AC_MSG_RESULT([]) 5043AC_MSG_RESULT([PREFIX : ${PREFIX}]) 5044AC_MSG_RESULT([BINDIR : ${BINDIR}]) 5045AC_MSG_RESULT([DATADIR : ${DATADIR}]) 5046AC_MSG_RESULT([INCLUDEDIR : ${INCLUDEDIR}]) 5047AC_MSG_RESULT([LIBDIR : ${LIBDIR}]) 5048AC_MSG_RESULT([MANDIR : ${MANDIR}]) 5049AC_MSG_RESULT([]) 5050AC_MSG_RESULT([srcroot : ${srcroot}]) 5051AC_MSG_RESULT([abs_srcroot : ${abs_srcroot}]) 5052AC_MSG_RESULT([objroot : ${objroot}]) 5053AC_MSG_RESULT([abs_objroot : ${abs_objroot}]) 5054AC_MSG_RESULT([]) 5055AC_MSG_RESULT([JEMALLOC_PREFIX : ${JEMALLOC_PREFIX}]) 5056AC_MSG_RESULT([JEMALLOC_PRIVATE_NAMESPACE]) 5057AC_MSG_RESULT([ : ${JEMALLOC_PRIVATE_NAMESPACE}]) 5058AC_MSG_RESULT([install_suffix : ${install_suffix}]) 5059AC_MSG_RESULT([malloc_conf : ${config_malloc_conf}]) 5060AC_MSG_RESULT([documentation : ${enable_doc}]) 5061AC_MSG_RESULT([shared libs : ${enable_shared}]) 5062AC_MSG_RESULT([static libs : ${enable_static}]) 5063AC_MSG_RESULT([autogen : ${enable_autogen}]) 5064AC_MSG_RESULT([debug : ${enable_debug}]) 5065AC_MSG_RESULT([stats : ${enable_stats}]) 5066AC_MSG_RESULT([experimetal_smallocx : ${enable_experimental_smallocx}]) 5067AC_MSG_RESULT([prof : ${enable_prof}]) 5068AC_MSG_RESULT([prof-libunwind : ${enable_prof_libunwind}]) 5069AC_MSG_RESULT([prof-libgcc : ${enable_prof_libgcc}]) 5070AC_MSG_RESULT([prof-gcc : ${enable_prof_gcc}]) 5071AC_MSG_RESULT([fill : ${enable_fill}]) 5072AC_MSG_RESULT([utrace : ${enable_utrace}]) 5073AC_MSG_RESULT([xmalloc : ${enable_xmalloc}]) 5074AC_MSG_RESULT([log : ${enable_log}]) 5075AC_MSG_RESULT([lazy_lock : ${enable_lazy_lock}]) 5076AC_MSG_RESULT([cache-oblivious : ${enable_cache_oblivious}]) 5077AC_MSG_RESULT([cxx : ${enable_cxx}]) 5078AC_MSG_RESULT([===============================================================================]) 5079>>>>>>> main 5080