1dnl Process this file with autoconf to produce a configure script. 2AC_PREREQ(2.68) 3AC_INIT([Makefile.in]) 4 5AC_CONFIG_AUX_DIR([build-aux]) 6 7dnl ============================================================================ 8dnl Custom macro definitions. 9 10dnl JE_CONCAT_VVV(r, a, b) 11dnl 12dnl Set $r to the concatenation of $a and $b, with a space separating them iff 13dnl both $a and $b are non-empty. 14AC_DEFUN([JE_CONCAT_VVV], 15if test "x[$]{$2}" = "x" -o "x[$]{$3}" = "x" ; then 16 $1="[$]{$2}[$]{$3}" 17else 18 $1="[$]{$2} [$]{$3}" 19fi 20) 21 22dnl JE_APPEND_VS(a, b) 23dnl 24dnl Set $a to the concatenation of $a and b, with a space separating them iff 25dnl both $a and b are non-empty. 26AC_DEFUN([JE_APPEND_VS], 27 T_APPEND_V=$2 28 JE_CONCAT_VVV($1, $1, T_APPEND_V) 29) 30 31CONFIGURE_CFLAGS= 32SPECIFIED_CFLAGS="${CFLAGS}" 33dnl JE_CFLAGS_ADD(cflag) 34dnl 35dnl CFLAGS is the concatenation of CONFIGURE_CFLAGS and SPECIFIED_CFLAGS 36dnl (ignoring EXTRA_CFLAGS, which does not impact configure tests. This macro 37dnl appends to CONFIGURE_CFLAGS and regenerates CFLAGS. 38AC_DEFUN([JE_CFLAGS_ADD], 39[ 40AC_MSG_CHECKING([whether compiler supports $1]) 41T_CONFIGURE_CFLAGS="${CONFIGURE_CFLAGS}" 42JE_APPEND_VS(CONFIGURE_CFLAGS, $1) 43JE_CONCAT_VVV(CFLAGS, CONFIGURE_CFLAGS, SPECIFIED_CFLAGS) 44AC_COMPILE_IFELSE([AC_LANG_PROGRAM( 45[[ 46]], [[ 47 return 0; 48]])], 49 [je_cv_cflags_added=$1] 50 AC_MSG_RESULT([yes]), 51 [je_cv_cflags_added=] 52 AC_MSG_RESULT([no]) 53 [CONFIGURE_CFLAGS="${T_CONFIGURE_CFLAGS}"] 54) 55JE_CONCAT_VVV(CFLAGS, CONFIGURE_CFLAGS, SPECIFIED_CFLAGS) 56]) 57 58dnl JE_CFLAGS_SAVE() 59dnl JE_CFLAGS_RESTORE() 60dnl 61dnl Save/restore CFLAGS. Nesting is not supported. 62AC_DEFUN([JE_CFLAGS_SAVE], 63SAVED_CONFIGURE_CFLAGS="${CONFIGURE_CFLAGS}" 64) 65AC_DEFUN([JE_CFLAGS_RESTORE], 66CONFIGURE_CFLAGS="${SAVED_CONFIGURE_CFLAGS}" 67JE_CONCAT_VVV(CFLAGS, CONFIGURE_CFLAGS, SPECIFIED_CFLAGS) 68) 69 70CONFIGURE_CXXFLAGS= 71SPECIFIED_CXXFLAGS="${CXXFLAGS}" 72dnl JE_CXXFLAGS_ADD(cxxflag) 73AC_DEFUN([JE_CXXFLAGS_ADD], 74[ 75AC_MSG_CHECKING([whether compiler supports $1]) 76T_CONFIGURE_CXXFLAGS="${CONFIGURE_CXXFLAGS}" 77JE_APPEND_VS(CONFIGURE_CXXFLAGS, $1) 78JE_CONCAT_VVV(CXXFLAGS, CONFIGURE_CXXFLAGS, SPECIFIED_CXXFLAGS) 79AC_LANG_PUSH([C++]) 80AC_COMPILE_IFELSE([AC_LANG_PROGRAM( 81[[ 82]], [[ 83 return 0; 84]])], 85 [je_cv_cxxflags_added=$1] 86 AC_MSG_RESULT([yes]), 87 [je_cv_cxxflags_added=] 88 AC_MSG_RESULT([no]) 89 [CONFIGURE_CXXFLAGS="${T_CONFIGURE_CXXFLAGS}"] 90) 91AC_LANG_POP([C++]) 92JE_CONCAT_VVV(CXXFLAGS, CONFIGURE_CXXFLAGS, SPECIFIED_CXXFLAGS) 93]) 94 95dnl JE_COMPILABLE(label, hcode, mcode, rvar) 96dnl 97dnl Use AC_LINK_IFELSE() rather than AC_COMPILE_IFELSE() so that linker errors 98dnl cause failure. 99AC_DEFUN([JE_COMPILABLE], 100[ 101AC_CACHE_CHECK([whether $1 is compilable], 102 [$4], 103 [AC_LINK_IFELSE([AC_LANG_PROGRAM([$2], 104 [$3])], 105 [$4=yes], 106 [$4=no])]) 107]) 108 109dnl ============================================================================ 110 111CONFIG=`echo ${ac_configure_args} | sed -e 's#'"'"'\([^ ]*\)'"'"'#\1#g'` 112AC_SUBST([CONFIG]) 113 114dnl Library revision. 115rev=2 116AC_SUBST([rev]) 117 118srcroot=$srcdir 119if test "x${srcroot}" = "x." ; then 120 srcroot="" 121else 122 srcroot="${srcroot}/" 123fi 124AC_SUBST([srcroot]) 125abs_srcroot="`cd \"${srcdir}\"; pwd`/" 126AC_SUBST([abs_srcroot]) 127 128objroot="" 129AC_SUBST([objroot]) 130abs_objroot="`pwd`/" 131AC_SUBST([abs_objroot]) 132 133dnl Munge install path variables. 134if test "x$prefix" = "xNONE" ; then 135 prefix="/usr/local" 136fi 137if test "x$exec_prefix" = "xNONE" ; then 138 exec_prefix=$prefix 139fi 140PREFIX=$prefix 141AC_SUBST([PREFIX]) 142BINDIR=`eval echo $bindir` 143BINDIR=`eval echo $BINDIR` 144AC_SUBST([BINDIR]) 145INCLUDEDIR=`eval echo $includedir` 146INCLUDEDIR=`eval echo $INCLUDEDIR` 147AC_SUBST([INCLUDEDIR]) 148LIBDIR=`eval echo $libdir` 149LIBDIR=`eval echo $LIBDIR` 150AC_SUBST([LIBDIR]) 151DATADIR=`eval echo $datadir` 152DATADIR=`eval echo $DATADIR` 153AC_SUBST([DATADIR]) 154MANDIR=`eval echo $mandir` 155MANDIR=`eval echo $MANDIR` 156AC_SUBST([MANDIR]) 157 158dnl Support for building documentation. 159AC_PATH_PROG([XSLTPROC], [xsltproc], [false], [$PATH]) 160if test -d "/usr/share/xml/docbook/stylesheet/docbook-xsl" ; then 161 DEFAULT_XSLROOT="/usr/share/xml/docbook/stylesheet/docbook-xsl" 162elif test -d "/usr/share/sgml/docbook/xsl-stylesheets" ; then 163 DEFAULT_XSLROOT="/usr/share/sgml/docbook/xsl-stylesheets" 164else 165 dnl Documentation building will fail if this default gets used. 166 DEFAULT_XSLROOT="" 167fi 168AC_ARG_WITH([xslroot], 169 [AS_HELP_STRING([--with-xslroot=<path>], [XSL stylesheet root path])], [ 170if test "x$with_xslroot" = "xno" ; then 171 XSLROOT="${DEFAULT_XSLROOT}" 172else 173 XSLROOT="${with_xslroot}" 174fi 175], 176 XSLROOT="${DEFAULT_XSLROOT}" 177) 178if test "x$XSLTPROC" = "xfalse" ; then 179 XSLROOT="" 180fi 181AC_SUBST([XSLROOT]) 182 183dnl If CFLAGS isn't defined, set CFLAGS to something reasonable. Otherwise, 184dnl just prevent autoconf from molesting CFLAGS. 185CFLAGS=$CFLAGS 186AC_PROG_CC 187 188if test "x$GCC" != "xyes" ; then 189 AC_CACHE_CHECK([whether compiler is MSVC], 190 [je_cv_msvc], 191 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], 192 [ 193#ifndef _MSC_VER 194 int fail[-1]; 195#endif 196])], 197 [je_cv_msvc=yes], 198 [je_cv_msvc=no])]) 199fi 200 201dnl check if a cray prgenv wrapper compiler is being used 202je_cv_cray_prgenv_wrapper="" 203if test "x${PE_ENV}" != "x" ; then 204 case "${CC}" in 205 CC|cc) 206 je_cv_cray_prgenv_wrapper="yes" 207 ;; 208 *) 209 ;; 210 esac 211fi 212 213AC_CACHE_CHECK([whether compiler is cray], 214 [je_cv_cray], 215 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], 216 [ 217#ifndef _CRAYC 218 int fail[-1]; 219#endif 220])], 221 [je_cv_cray=yes], 222 [je_cv_cray=no])]) 223 224if test "x${je_cv_cray}" = "xyes" ; then 225 AC_CACHE_CHECK([whether cray compiler version is 8.4], 226 [je_cv_cray_84], 227 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], 228 [ 229#if !(_RELEASE_MAJOR == 8 && _RELEASE_MINOR == 4) 230 int fail[-1]; 231#endif 232])], 233 [je_cv_cray_84=yes], 234 [je_cv_cray_84=no])]) 235fi 236 237if test "x$GCC" = "xyes" ; then 238 JE_CFLAGS_ADD([-std=gnu11]) 239 if test "x$je_cv_cflags_added" = "x-std=gnu11" ; then 240 AC_DEFINE_UNQUOTED([JEMALLOC_HAS_RESTRICT]) 241 else 242 JE_CFLAGS_ADD([-std=gnu99]) 243 if test "x$je_cv_cflags_added" = "x-std=gnu99" ; then 244 AC_DEFINE_UNQUOTED([JEMALLOC_HAS_RESTRICT]) 245 fi 246 fi 247 JE_CFLAGS_ADD([-Wall]) 248 JE_CFLAGS_ADD([-Wextra]) 249 JE_CFLAGS_ADD([-Wshorten-64-to-32]) 250 JE_CFLAGS_ADD([-Wsign-compare]) 251 JE_CFLAGS_ADD([-Wundef]) 252 JE_CFLAGS_ADD([-Wno-format-zero-length]) 253 JE_CFLAGS_ADD([-pipe]) 254 JE_CFLAGS_ADD([-g3]) 255elif test "x$je_cv_msvc" = "xyes" ; then 256 CC="$CC -nologo" 257 JE_CFLAGS_ADD([-Zi]) 258 JE_CFLAGS_ADD([-MT]) 259 JE_CFLAGS_ADD([-W3]) 260 JE_CFLAGS_ADD([-FS]) 261 JE_APPEND_VS(CPPFLAGS, -I${srcdir}/include/msvc_compat) 262fi 263if test "x$je_cv_cray" = "xyes" ; then 264 dnl cray compiler 8.4 has an inlining bug 265 if test "x$je_cv_cray_84" = "xyes" ; then 266 JE_CFLAGS_ADD([-hipa2]) 267 JE_CFLAGS_ADD([-hnognu]) 268 fi 269 dnl ignore unreachable code warning 270 JE_CFLAGS_ADD([-hnomessage=128]) 271 dnl ignore redefinition of "malloc", "free", etc warning 272 JE_CFLAGS_ADD([-hnomessage=1357]) 273fi 274AC_SUBST([CONFIGURE_CFLAGS]) 275AC_SUBST([SPECIFIED_CFLAGS]) 276AC_SUBST([EXTRA_CFLAGS]) 277AC_PROG_CPP 278 279AC_ARG_ENABLE([cxx], 280 [AS_HELP_STRING([--disable-cxx], [Disable C++ integration])], 281if test "x$enable_cxx" = "xno" ; then 282 enable_cxx="0" 283else 284 enable_cxx="1" 285fi 286, 287enable_cxx="1" 288) 289if test "x$enable_cxx" = "x1" ; then 290 dnl Require at least c++14, which is the first version to support sized 291 dnl deallocation. C++ support is not compiled otherwise. 292 m4_include([m4/ax_cxx_compile_stdcxx.m4]) 293 AX_CXX_COMPILE_STDCXX([14], [noext], [optional]) 294 if test "x${HAVE_CXX14}" = "x1" ; then 295 JE_CXXFLAGS_ADD([-Wall]) 296 JE_CXXFLAGS_ADD([-Wextra]) 297 JE_CXXFLAGS_ADD([-g3]) 298 299 SAVED_LIBS="${LIBS}" 300 JE_APPEND_VS(LIBS, -lstdc++) 301 JE_COMPILABLE([libstdc++ linkage], [ 302#include <stdlib.h> 303], [[ 304 int *arr = (int *)malloc(sizeof(int) * 42); 305 if (arr == NULL) 306 return 1; 307]], [je_cv_libstdcxx]) 308 if test "x${je_cv_libstdcxx}" = "xno" ; then 309 LIBS="${SAVED_LIBS}" 310 fi 311 else 312 enable_cxx="0" 313 fi 314fi 315AC_SUBST([enable_cxx]) 316AC_SUBST([CONFIGURE_CXXFLAGS]) 317AC_SUBST([SPECIFIED_CXXFLAGS]) 318AC_SUBST([EXTRA_CXXFLAGS]) 319 320AC_C_BIGENDIAN([ac_cv_big_endian=1], [ac_cv_big_endian=0]) 321if test "x${ac_cv_big_endian}" = "x1" ; then 322 AC_DEFINE_UNQUOTED([JEMALLOC_BIG_ENDIAN], [ ]) 323fi 324 325if test "x${je_cv_msvc}" = "xyes" -a "x${ac_cv_header_inttypes_h}" = "xno"; then 326 JE_APPEND_VS(CPPFLAGS, -I${srcdir}/include/msvc_compat/C99) 327fi 328 329if test "x${je_cv_msvc}" = "xyes" ; then 330 LG_SIZEOF_PTR=LG_SIZEOF_PTR_WIN 331 AC_MSG_RESULT([Using a predefined value for sizeof(void *): 4 for 32-bit, 8 for 64-bit]) 332else 333 AC_CHECK_SIZEOF([void *]) 334 if test "x${ac_cv_sizeof_void_p}" = "x8" ; then 335 LG_SIZEOF_PTR=3 336 elif test "x${ac_cv_sizeof_void_p}" = "x4" ; then 337 LG_SIZEOF_PTR=2 338 else 339 AC_MSG_ERROR([Unsupported pointer size: ${ac_cv_sizeof_void_p}]) 340 fi 341fi 342AC_DEFINE_UNQUOTED([LG_SIZEOF_PTR], [$LG_SIZEOF_PTR]) 343 344AC_CHECK_SIZEOF([int]) 345if test "x${ac_cv_sizeof_int}" = "x8" ; then 346 LG_SIZEOF_INT=3 347elif test "x${ac_cv_sizeof_int}" = "x4" ; then 348 LG_SIZEOF_INT=2 349else 350 AC_MSG_ERROR([Unsupported int size: ${ac_cv_sizeof_int}]) 351fi 352AC_DEFINE_UNQUOTED([LG_SIZEOF_INT], [$LG_SIZEOF_INT]) 353 354AC_CHECK_SIZEOF([long]) 355if test "x${ac_cv_sizeof_long}" = "x8" ; then 356 LG_SIZEOF_LONG=3 357elif test "x${ac_cv_sizeof_long}" = "x4" ; then 358 LG_SIZEOF_LONG=2 359else 360 AC_MSG_ERROR([Unsupported long size: ${ac_cv_sizeof_long}]) 361fi 362AC_DEFINE_UNQUOTED([LG_SIZEOF_LONG], [$LG_SIZEOF_LONG]) 363 364AC_CHECK_SIZEOF([long long]) 365if test "x${ac_cv_sizeof_long_long}" = "x8" ; then 366 LG_SIZEOF_LONG_LONG=3 367elif test "x${ac_cv_sizeof_long_long}" = "x4" ; then 368 LG_SIZEOF_LONG_LONG=2 369else 370 AC_MSG_ERROR([Unsupported long long size: ${ac_cv_sizeof_long_long}]) 371fi 372AC_DEFINE_UNQUOTED([LG_SIZEOF_LONG_LONG], [$LG_SIZEOF_LONG_LONG]) 373 374AC_CHECK_SIZEOF([intmax_t]) 375if test "x${ac_cv_sizeof_intmax_t}" = "x16" ; then 376 LG_SIZEOF_INTMAX_T=4 377elif test "x${ac_cv_sizeof_intmax_t}" = "x8" ; then 378 LG_SIZEOF_INTMAX_T=3 379elif test "x${ac_cv_sizeof_intmax_t}" = "x4" ; then 380 LG_SIZEOF_INTMAX_T=2 381else 382 AC_MSG_ERROR([Unsupported intmax_t size: ${ac_cv_sizeof_intmax_t}]) 383fi 384AC_DEFINE_UNQUOTED([LG_SIZEOF_INTMAX_T], [$LG_SIZEOF_INTMAX_T]) 385 386AC_CANONICAL_HOST 387dnl CPU-specific settings. 388CPU_SPINWAIT="" 389case "${host_cpu}" in 390 i686|x86_64) 391 HAVE_CPU_SPINWAIT=1 392 if test "x${je_cv_msvc}" = "xyes" ; then 393 AC_CACHE_VAL([je_cv_pause_msvc], 394 [JE_COMPILABLE([pause instruction MSVC], [], 395 [[_mm_pause(); return 0;]], 396 [je_cv_pause_msvc])]) 397 if test "x${je_cv_pause_msvc}" = "xyes" ; then 398 CPU_SPINWAIT='_mm_pause()' 399 fi 400 else 401 AC_CACHE_VAL([je_cv_pause], 402 [JE_COMPILABLE([pause instruction], [], 403 [[__asm__ volatile("pause"); return 0;]], 404 [je_cv_pause])]) 405 if test "x${je_cv_pause}" = "xyes" ; then 406 CPU_SPINWAIT='__asm__ volatile("pause")' 407 fi 408 fi 409 ;; 410 *) 411 HAVE_CPU_SPINWAIT=0 412 ;; 413esac 414AC_DEFINE_UNQUOTED([HAVE_CPU_SPINWAIT], [$HAVE_CPU_SPINWAIT]) 415AC_DEFINE_UNQUOTED([CPU_SPINWAIT], [$CPU_SPINWAIT]) 416 417AC_ARG_WITH([lg_vaddr], 418 [AS_HELP_STRING([--with-lg-vaddr=<lg-vaddr>], [Number of significant virtual address bits])], 419 [LG_VADDR="$with_lg_vaddr"], [LG_VADDR="detect"]) 420 421case "${host_cpu}" in 422 aarch64) 423 if test "x$LG_VADDR" = "xdetect"; then 424 AC_MSG_CHECKING([number of significant virtual address bits]) 425 if test "x${LG_SIZEOF_PTR}" = "x2" ; then 426 #aarch64 ILP32 427 LG_VADDR=32 428 else 429 #aarch64 LP64 430 LG_VADDR=48 431 fi 432 AC_MSG_RESULT([$LG_VADDR]) 433 fi 434 ;; 435 x86_64) 436 if test "x$LG_VADDR" = "xdetect"; then 437 AC_CACHE_CHECK([number of significant virtual address bits], 438 [je_cv_lg_vaddr], 439 AC_RUN_IFELSE([AC_LANG_PROGRAM( 440[[ 441#include <stdio.h> 442#ifdef _WIN32 443#include <limits.h> 444#include <intrin.h> 445typedef unsigned __int32 uint32_t; 446#else 447#include <stdint.h> 448#endif 449]], [[ 450 uint32_t r[[4]]; 451 uint32_t eax_in = 0x80000008U; 452#ifdef _WIN32 453 __cpuid((int *)r, (int)eax_in); 454#else 455 asm volatile ("cpuid" 456 : "=a" (r[[0]]), "=b" (r[[1]]), "=c" (r[[2]]), "=d" (r[[3]]) 457 : "a" (eax_in), "c" (0) 458 ); 459#endif 460 uint32_t eax_out = r[[0]]; 461 uint32_t vaddr = ((eax_out & 0x0000ff00U) >> 8); 462 FILE *f = fopen("conftest.out", "w"); 463 if (f == NULL) { 464 return 1; 465 } 466 if (vaddr > (sizeof(void *) << 3)) { 467 vaddr = sizeof(void *) << 3; 468 } 469 fprintf(f, "%u", vaddr); 470 fclose(f); 471 return 0; 472]])], 473 [je_cv_lg_vaddr=`cat conftest.out`], 474 [je_cv_lg_vaddr=error], 475 [je_cv_lg_vaddr=57])) 476 if test "x${je_cv_lg_vaddr}" != "x" ; then 477 LG_VADDR="${je_cv_lg_vaddr}" 478 fi 479 if test "x${LG_VADDR}" != "xerror" ; then 480 AC_DEFINE_UNQUOTED([LG_VADDR], [$LG_VADDR]) 481 else 482 AC_MSG_ERROR([cannot determine number of significant virtual address bits]) 483 fi 484 fi 485 ;; 486 *) 487 if test "x$LG_VADDR" = "xdetect"; then 488 AC_MSG_CHECKING([number of significant virtual address bits]) 489 if test "x${LG_SIZEOF_PTR}" = "x3" ; then 490 LG_VADDR=64 491 elif test "x${LG_SIZEOF_PTR}" = "x2" ; then 492 LG_VADDR=32 493 elif test "x${LG_SIZEOF_PTR}" = "xLG_SIZEOF_PTR_WIN" ; then 494 LG_VADDR="(1U << (LG_SIZEOF_PTR_WIN+3))" 495 else 496 AC_MSG_ERROR([Unsupported lg(pointer size): ${LG_SIZEOF_PTR}]) 497 fi 498 AC_MSG_RESULT([$LG_VADDR]) 499 fi 500 ;; 501esac 502AC_DEFINE_UNQUOTED([LG_VADDR], [$LG_VADDR]) 503 504LD_PRELOAD_VAR="LD_PRELOAD" 505so="so" 506importlib="${so}" 507o="$ac_objext" 508a="a" 509exe="$ac_exeext" 510libprefix="lib" 511link_whole_archive="0" 512DSO_LDFLAGS='-shared -Wl,-soname,$(@F)' 513RPATH='-Wl,-rpath,$(1)' 514SOREV="${so}.${rev}" 515PIC_CFLAGS='-fPIC -DPIC' 516CTARGET='-o $@' 517LDTARGET='-o $@' 518TEST_LD_MODE= 519EXTRA_LDFLAGS= 520ARFLAGS='crus' 521AROUT=' $@' 522CC_MM=1 523 524if test "x$je_cv_cray_prgenv_wrapper" = "xyes" ; then 525 TEST_LD_MODE='-dynamic' 526fi 527 528if test "x${je_cv_cray}" = "xyes" ; then 529 CC_MM= 530fi 531 532AN_MAKEVAR([AR], [AC_PROG_AR]) 533AN_PROGRAM([ar], [AC_PROG_AR]) 534AC_DEFUN([AC_PROG_AR], [AC_CHECK_TOOL(AR, ar, :)]) 535AC_PROG_AR 536 537AN_MAKEVAR([NM], [AC_PROG_NM]) 538AN_PROGRAM([nm], [AC_PROG_NM]) 539AC_DEFUN([AC_PROG_NM], [AC_CHECK_TOOL(NM, nm, :)]) 540AC_PROG_NM 541 542AC_PROG_AWK 543 544dnl ============================================================================ 545dnl jemalloc version. 546dnl 547 548AC_ARG_WITH([version], 549 [AS_HELP_STRING([--with-version=<major>.<minor>.<bugfix>-<nrev>-g<gid>], 550 [Version string])], 551 [ 552 echo "${with_version}" | grep ['^[0-9]\+\.[0-9]\+\.[0-9]\+-[0-9]\+-g[0-9a-f]\+$'] 2>&1 1>/dev/null 553 if test $? -eq 0 ; then 554 echo "$with_version" > "${objroot}VERSION" 555 else 556 echo "${with_version}" | grep ['^VERSION$'] 2>&1 1>/dev/null 557 if test $? -ne 0 ; then 558 AC_MSG_ERROR([${with_version} does not match <major>.<minor>.<bugfix>-<nrev>-g<gid> or VERSION]) 559 fi 560 fi 561 ], [ 562 dnl Set VERSION if source directory is inside a git repository. 563 if test "x`test ! \"${srcroot}\" && cd \"${srcroot}\"; git rev-parse --is-inside-work-tree 2>/dev/null`" = "xtrue" ; then 564 dnl Pattern globs aren't powerful enough to match both single- and 565 dnl double-digit version numbers, so iterate over patterns to support up 566 dnl to version 99.99.99 without any accidental matches. 567 for pattern in ['[0-9].[0-9].[0-9]' '[0-9].[0-9].[0-9][0-9]' \ 568 '[0-9].[0-9][0-9].[0-9]' '[0-9].[0-9][0-9].[0-9][0-9]' \ 569 '[0-9][0-9].[0-9].[0-9]' '[0-9][0-9].[0-9].[0-9][0-9]' \ 570 '[0-9][0-9].[0-9][0-9].[0-9]' \ 571 '[0-9][0-9].[0-9][0-9].[0-9][0-9]']; do 572 (test ! "${srcroot}" && cd "${srcroot}"; git describe --long --abbrev=40 --match="${pattern}") > "${objroot}VERSION.tmp" 2>/dev/null 573 if test $? -eq 0 ; then 574 mv "${objroot}VERSION.tmp" "${objroot}VERSION" 575 break 576 fi 577 done 578 fi 579 rm -f "${objroot}VERSION.tmp" 580 ]) 581 582if test ! -e "${objroot}VERSION" ; then 583 if test ! -e "${srcroot}VERSION" ; then 584 AC_MSG_RESULT( 585 [Missing VERSION file, and unable to generate it; creating bogus VERSION]) 586 echo "0.0.0-0-g0000000000000000000000000000000000000000" > "${objroot}VERSION" 587 else 588 cp ${srcroot}VERSION ${objroot}VERSION 589 fi 590fi 591jemalloc_version=`cat "${objroot}VERSION"` 592jemalloc_version_major=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]1}'` 593jemalloc_version_minor=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]2}'` 594jemalloc_version_bugfix=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]3}'` 595jemalloc_version_nrev=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]4}'` 596jemalloc_version_gid=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]5}'` 597AC_SUBST([jemalloc_version]) 598AC_SUBST([jemalloc_version_major]) 599AC_SUBST([jemalloc_version_minor]) 600AC_SUBST([jemalloc_version_bugfix]) 601AC_SUBST([jemalloc_version_nrev]) 602AC_SUBST([jemalloc_version_gid]) 603 604dnl Platform-specific settings. abi and RPATH can probably be determined 605dnl programmatically, but doing so is error-prone, which makes it generally 606dnl not worth the trouble. 607dnl 608dnl Define cpp macros in CPPFLAGS, rather than doing AC_DEFINE(macro), since the 609dnl definitions need to be seen before any headers are included, which is a pain 610dnl to make happen otherwise. 611default_retain="0" 612maps_coalesce="1" 613DUMP_SYMS="${NM} -a" 614SYM_PREFIX="" 615case "${host}" in 616 *-*-darwin* | *-*-ios*) 617 abi="macho" 618 RPATH="" 619 LD_PRELOAD_VAR="DYLD_INSERT_LIBRARIES" 620 so="dylib" 621 importlib="${so}" 622 force_tls="0" 623 DSO_LDFLAGS='-shared -Wl,-install_name,$(LIBDIR)/$(@F)' 624 SOREV="${rev}.${so}" 625 sbrk_deprecated="1" 626 SYM_PREFIX="_" 627 ;; 628 *-*-freebsd*) 629 abi="elf" 630 AC_DEFINE([JEMALLOC_SYSCTL_VM_OVERCOMMIT], [ ]) 631 force_lazy_lock="1" 632 ;; 633 *-*-dragonfly*) 634 abi="elf" 635 ;; 636 *-*-openbsd*) 637 abi="elf" 638 force_tls="0" 639 ;; 640 *-*-bitrig*) 641 abi="elf" 642 ;; 643 *-*-linux-android) 644 dnl syscall(2) and secure_getenv(3) are exposed by _GNU_SOURCE. 645 JE_APPEND_VS(CPPFLAGS, -D_GNU_SOURCE) 646 abi="elf" 647 AC_DEFINE([JEMALLOC_PURGE_MADVISE_DONTNEED_ZEROS], [ ]) 648 AC_DEFINE([JEMALLOC_HAS_ALLOCA_H]) 649 AC_DEFINE([JEMALLOC_PROC_SYS_VM_OVERCOMMIT_MEMORY], [ ]) 650 AC_DEFINE([JEMALLOC_THREADED_INIT], [ ]) 651 AC_DEFINE([JEMALLOC_C11_ATOMICS]) 652 force_tls="0" 653 if test "${LG_SIZEOF_PTR}" = "3"; then 654 default_retain="1" 655 fi 656 ;; 657 *-*-linux*) 658 dnl syscall(2) and secure_getenv(3) are exposed by _GNU_SOURCE. 659 JE_APPEND_VS(CPPFLAGS, -D_GNU_SOURCE) 660 abi="elf" 661 AC_DEFINE([JEMALLOC_PURGE_MADVISE_DONTNEED_ZEROS], [ ]) 662 AC_DEFINE([JEMALLOC_HAS_ALLOCA_H]) 663 AC_DEFINE([JEMALLOC_PROC_SYS_VM_OVERCOMMIT_MEMORY], [ ]) 664 AC_DEFINE([JEMALLOC_THREADED_INIT], [ ]) 665 AC_DEFINE([JEMALLOC_USE_CXX_THROW], [ ]) 666 if test "${LG_SIZEOF_PTR}" = "3"; then 667 default_retain="1" 668 fi 669 ;; 670 *-*-kfreebsd*) 671 dnl syscall(2) and secure_getenv(3) are exposed by _GNU_SOURCE. 672 JE_APPEND_VS(CPPFLAGS, -D_GNU_SOURCE) 673 abi="elf" 674 AC_DEFINE([JEMALLOC_HAS_ALLOCA_H]) 675 AC_DEFINE([JEMALLOC_SYSCTL_VM_OVERCOMMIT], [ ]) 676 AC_DEFINE([JEMALLOC_THREADED_INIT], [ ]) 677 AC_DEFINE([JEMALLOC_USE_CXX_THROW], [ ]) 678 ;; 679 *-*-netbsd*) 680 AC_MSG_CHECKING([ABI]) 681 AC_COMPILE_IFELSE([AC_LANG_PROGRAM( 682[[#ifdef __ELF__ 683/* ELF */ 684#else 685#error aout 686#endif 687]])], 688 [abi="elf"], 689 [abi="aout"]) 690 AC_MSG_RESULT([$abi]) 691 ;; 692 *-*-solaris2*) 693 abi="elf" 694 RPATH='-Wl,-R,$(1)' 695 dnl Solaris needs this for sigwait(). 696 JE_APPEND_VS(CPPFLAGS, -D_POSIX_PTHREAD_SEMANTICS) 697 JE_APPEND_VS(LIBS, -lposix4 -lsocket -lnsl) 698 ;; 699 *-ibm-aix*) 700 if test "${LG_SIZEOF_PTR}" = "3"; then 701 dnl 64bit AIX 702 LD_PRELOAD_VAR="LDR_PRELOAD64" 703 else 704 dnl 32bit AIX 705 LD_PRELOAD_VAR="LDR_PRELOAD" 706 fi 707 abi="xcoff" 708 ;; 709 *-*-mingw* | *-*-cygwin*) 710 abi="pecoff" 711 force_tls="0" 712 maps_coalesce="0" 713 RPATH="" 714 so="dll" 715 if test "x$je_cv_msvc" = "xyes" ; then 716 importlib="lib" 717 DSO_LDFLAGS="-LD" 718 EXTRA_LDFLAGS="-link -DEBUG" 719 CTARGET='-Fo$@' 720 LDTARGET='-Fe$@' 721 AR='lib' 722 ARFLAGS='-nologo -out:' 723 AROUT='$@' 724 CC_MM= 725 else 726 importlib="${so}" 727 DSO_LDFLAGS="-shared" 728 link_whole_archive="1" 729 fi 730 case "${host}" in 731 *-*-cygwin*) 732 DUMP_SYMS="dumpbin /SYMBOLS" 733 ;; 734 *) 735 ;; 736 esac 737 a="lib" 738 libprefix="" 739 SOREV="${so}" 740 PIC_CFLAGS="" 741 if test "${LG_SIZEOF_PTR}" = "3"; then 742 default_retain="1" 743 fi 744 ;; 745 *) 746 AC_MSG_RESULT([Unsupported operating system: ${host}]) 747 abi="elf" 748 ;; 749esac 750 751JEMALLOC_USABLE_SIZE_CONST=const 752AC_CHECK_HEADERS([malloc.h], [ 753 AC_MSG_CHECKING([whether malloc_usable_size definition can use const argument]) 754 AC_COMPILE_IFELSE([AC_LANG_PROGRAM( 755 [#include <malloc.h> 756 #include <stddef.h> 757 size_t malloc_usable_size(const void *ptr); 758 ], 759 [])],[ 760 AC_MSG_RESULT([yes]) 761 ],[ 762 JEMALLOC_USABLE_SIZE_CONST= 763 AC_MSG_RESULT([no]) 764 ]) 765]) 766AC_DEFINE_UNQUOTED([JEMALLOC_USABLE_SIZE_CONST], [$JEMALLOC_USABLE_SIZE_CONST]) 767AC_SUBST([abi]) 768AC_SUBST([RPATH]) 769AC_SUBST([LD_PRELOAD_VAR]) 770AC_SUBST([so]) 771AC_SUBST([importlib]) 772AC_SUBST([o]) 773AC_SUBST([a]) 774AC_SUBST([exe]) 775AC_SUBST([libprefix]) 776AC_SUBST([link_whole_archive]) 777AC_SUBST([DSO_LDFLAGS]) 778AC_SUBST([EXTRA_LDFLAGS]) 779AC_SUBST([SOREV]) 780AC_SUBST([PIC_CFLAGS]) 781AC_SUBST([CTARGET]) 782AC_SUBST([LDTARGET]) 783AC_SUBST([TEST_LD_MODE]) 784AC_SUBST([MKLIB]) 785AC_SUBST([ARFLAGS]) 786AC_SUBST([AROUT]) 787AC_SUBST([DUMP_SYMS]) 788AC_SUBST([CC_MM]) 789 790dnl Determine whether libm must be linked to use e.g. log(3). 791AC_SEARCH_LIBS([log], [m], , [AC_MSG_ERROR([Missing math functions])]) 792if test "x$ac_cv_search_log" != "xnone required" ; then 793 LM="$ac_cv_search_log" 794else 795 LM= 796fi 797AC_SUBST(LM) 798 799JE_COMPILABLE([__attribute__ syntax], 800 [static __attribute__((unused)) void foo(void){}], 801 [], 802 [je_cv_attribute]) 803if test "x${je_cv_attribute}" = "xyes" ; then 804 AC_DEFINE([JEMALLOC_HAVE_ATTR], [ ]) 805 if test "x${GCC}" = "xyes" -a "x${abi}" = "xelf"; then 806 JE_CFLAGS_ADD([-fvisibility=hidden]) 807 JE_CXXFLAGS_ADD([-fvisibility=hidden]) 808 fi 809fi 810dnl Check for tls_model attribute support (clang 3.0 still lacks support). 811JE_CFLAGS_SAVE() 812JE_CFLAGS_ADD([-Werror]) 813JE_CFLAGS_ADD([-herror_on_warning]) 814JE_COMPILABLE([tls_model attribute], [], 815 [static __thread int 816 __attribute__((tls_model("initial-exec"), unused)) foo; 817 foo = 0;], 818 [je_cv_tls_model]) 819JE_CFLAGS_RESTORE() 820dnl (Setting of JEMALLOC_TLS_MODEL is done later, after we've checked for 821dnl --disable-initial-exec-tls) 822 823dnl Check for alloc_size attribute support. 824JE_CFLAGS_SAVE() 825JE_CFLAGS_ADD([-Werror]) 826JE_CFLAGS_ADD([-herror_on_warning]) 827JE_COMPILABLE([alloc_size attribute], [#include <stdlib.h>], 828 [void *foo(size_t size) __attribute__((alloc_size(1)));], 829 [je_cv_alloc_size]) 830JE_CFLAGS_RESTORE() 831if test "x${je_cv_alloc_size}" = "xyes" ; then 832 AC_DEFINE([JEMALLOC_HAVE_ATTR_ALLOC_SIZE], [ ]) 833fi 834dnl Check for format(gnu_printf, ...) attribute support. 835JE_CFLAGS_SAVE() 836JE_CFLAGS_ADD([-Werror]) 837JE_CFLAGS_ADD([-herror_on_warning]) 838JE_COMPILABLE([format(gnu_printf, ...) attribute], [#include <stdlib.h>], 839 [void *foo(const char *format, ...) __attribute__((format(gnu_printf, 1, 2)));], 840 [je_cv_format_gnu_printf]) 841JE_CFLAGS_RESTORE() 842if test "x${je_cv_format_gnu_printf}" = "xyes" ; then 843 AC_DEFINE([JEMALLOC_HAVE_ATTR_FORMAT_GNU_PRINTF], [ ]) 844fi 845dnl Check for format(printf, ...) attribute support. 846JE_CFLAGS_SAVE() 847JE_CFLAGS_ADD([-Werror]) 848JE_CFLAGS_ADD([-herror_on_warning]) 849JE_COMPILABLE([format(printf, ...) attribute], [#include <stdlib.h>], 850 [void *foo(const char *format, ...) __attribute__((format(printf, 1, 2)));], 851 [je_cv_format_printf]) 852JE_CFLAGS_RESTORE() 853if test "x${je_cv_format_printf}" = "xyes" ; then 854 AC_DEFINE([JEMALLOC_HAVE_ATTR_FORMAT_PRINTF], [ ]) 855fi 856 857dnl Check for format_arg(...) attribute support. 858JE_CFLAGS_SAVE() 859JE_CFLAGS_ADD([-Werror]) 860JE_CFLAGS_ADD([-herror_on_warning]) 861JE_COMPILABLE([format(printf, ...) attribute], [#include <stdlib.h>], 862 [const char * __attribute__((__format_arg__(1))) foo(const char *format);], 863 [je_cv_format_arg]) 864JE_CFLAGS_RESTORE() 865if test "x${je_cv_format_arg}" = "xyes" ; then 866 AC_DEFINE([JEMALLOC_HAVE_ATTR_FORMAT_ARG], [ ]) 867fi 868 869dnl Support optional additions to rpath. 870AC_ARG_WITH([rpath], 871 [AS_HELP_STRING([--with-rpath=<rpath>], [Colon-separated rpath (ELF systems only)])], 872if test "x$with_rpath" = "xno" ; then 873 RPATH_EXTRA= 874else 875 RPATH_EXTRA="`echo $with_rpath | tr \":\" \" \"`" 876fi, 877 RPATH_EXTRA= 878) 879AC_SUBST([RPATH_EXTRA]) 880 881dnl Disable rules that do automatic regeneration of configure output by default. 882AC_ARG_ENABLE([autogen], 883 [AS_HELP_STRING([--enable-autogen], [Automatically regenerate configure output])], 884if test "x$enable_autogen" = "xno" ; then 885 enable_autogen="0" 886else 887 enable_autogen="1" 888fi 889, 890enable_autogen="0" 891) 892AC_SUBST([enable_autogen]) 893 894AC_PROG_INSTALL 895AC_PROG_RANLIB 896AC_PATH_PROG([LD], [ld], [false], [$PATH]) 897AC_PATH_PROG([AUTOCONF], [autoconf], [false], [$PATH]) 898 899dnl Enable documentation 900AC_ARG_ENABLE([doc], 901 [AS_HELP_STRING([--enable-documentation], [Build documentation])], 902if test "x$enable_doc" = "xno" ; then 903 enable_doc="0" 904else 905 enable_doc="1" 906fi 907, 908enable_doc="1" 909) 910AC_SUBST([enable_doc]) 911 912dnl Enable shared libs 913AC_ARG_ENABLE([shared], 914 [AS_HELP_STRING([--enable-shared], [Build shared libaries])], 915if test "x$enable_shared" = "xno" ; then 916 enable_shared="0" 917else 918 enable_shared="1" 919fi 920, 921enable_shared="1" 922) 923AC_SUBST([enable_shared]) 924 925dnl Enable static libs 926AC_ARG_ENABLE([static], 927 [AS_HELP_STRING([--enable-static], [Build static libaries])], 928if test "x$enable_static" = "xno" ; then 929 enable_static="0" 930else 931 enable_static="1" 932fi 933, 934enable_static="1" 935) 936AC_SUBST([enable_static]) 937 938if test "$enable_shared$enable_static" = "00" ; then 939 AC_MSG_ERROR([Please enable one of shared or static builds]) 940fi 941 942dnl Perform no name mangling by default. 943AC_ARG_WITH([mangling], 944 [AS_HELP_STRING([--with-mangling=<map>], [Mangle symbols in <map>])], 945 [mangling_map="$with_mangling"], [mangling_map=""]) 946 947dnl Do not prefix public APIs by default. 948AC_ARG_WITH([jemalloc_prefix], 949 [AS_HELP_STRING([--with-jemalloc-prefix=<prefix>], [Prefix to prepend to all public APIs])], 950 [JEMALLOC_PREFIX="$with_jemalloc_prefix"], 951 [if test "x$abi" != "xmacho" -a "x$abi" != "xpecoff"; then 952 JEMALLOC_PREFIX="" 953else 954 JEMALLOC_PREFIX="je_" 955fi] 956) 957if test "x$JEMALLOC_PREFIX" = "x" ; then 958 AC_DEFINE([JEMALLOC_IS_MALLOC]) 959else 960 JEMALLOC_CPREFIX=`echo ${JEMALLOC_PREFIX} | tr "a-z" "A-Z"` 961 AC_DEFINE_UNQUOTED([JEMALLOC_PREFIX], ["$JEMALLOC_PREFIX"]) 962 AC_DEFINE_UNQUOTED([JEMALLOC_CPREFIX], ["$JEMALLOC_CPREFIX"]) 963fi 964AC_SUBST([JEMALLOC_PREFIX]) 965AC_SUBST([JEMALLOC_CPREFIX]) 966 967AC_ARG_WITH([export], 968 [AS_HELP_STRING([--without-export], [disable exporting jemalloc public APIs])], 969 [if test "x$with_export" = "xno"; then 970 AC_DEFINE([JEMALLOC_EXPORT],[]) 971fi] 972) 973 974public_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" 975dnl Check for additional platform-specific public API functions. 976AC_CHECK_FUNC([memalign], 977 [AC_DEFINE([JEMALLOC_OVERRIDE_MEMALIGN], [ ]) 978 public_syms="${public_syms} memalign"]) 979AC_CHECK_FUNC([valloc], 980 [AC_DEFINE([JEMALLOC_OVERRIDE_VALLOC], [ ]) 981 public_syms="${public_syms} valloc"]) 982 983dnl Check for allocator-related functions that should be wrapped. 984wrap_syms= 985if test "x${JEMALLOC_PREFIX}" = "x" ; then 986 AC_CHECK_FUNC([__libc_calloc], 987 [AC_DEFINE([JEMALLOC_OVERRIDE___LIBC_CALLOC], [ ]) 988 wrap_syms="${wrap_syms} __libc_calloc"]) 989 AC_CHECK_FUNC([__libc_free], 990 [AC_DEFINE([JEMALLOC_OVERRIDE___LIBC_FREE], [ ]) 991 wrap_syms="${wrap_syms} __libc_free"]) 992 AC_CHECK_FUNC([__libc_malloc], 993 [AC_DEFINE([JEMALLOC_OVERRIDE___LIBC_MALLOC], [ ]) 994 wrap_syms="${wrap_syms} __libc_malloc"]) 995 AC_CHECK_FUNC([__libc_memalign], 996 [AC_DEFINE([JEMALLOC_OVERRIDE___LIBC_MEMALIGN], [ ]) 997 wrap_syms="${wrap_syms} __libc_memalign"]) 998 AC_CHECK_FUNC([__libc_realloc], 999 [AC_DEFINE([JEMALLOC_OVERRIDE___LIBC_REALLOC], [ ]) 1000 wrap_syms="${wrap_syms} __libc_realloc"]) 1001 AC_CHECK_FUNC([__libc_valloc], 1002 [AC_DEFINE([JEMALLOC_OVERRIDE___LIBC_VALLOC], [ ]) 1003 wrap_syms="${wrap_syms} __libc_valloc"]) 1004 AC_CHECK_FUNC([__posix_memalign], 1005 [AC_DEFINE([JEMALLOC_OVERRIDE___POSIX_MEMALIGN], [ ]) 1006 wrap_syms="${wrap_syms} __posix_memalign"]) 1007fi 1008 1009case "${host}" in 1010 *-*-mingw* | *-*-cygwin*) 1011 wrap_syms="${wrap_syms} tls_callback" 1012 ;; 1013 *) 1014 ;; 1015esac 1016 1017dnl Mangle library-private APIs. 1018AC_ARG_WITH([private_namespace], 1019 [AS_HELP_STRING([--with-private-namespace=<prefix>], [Prefix to prepend to all library-private APIs])], 1020 [JEMALLOC_PRIVATE_NAMESPACE="${with_private_namespace}je_"], 1021 [JEMALLOC_PRIVATE_NAMESPACE="je_"] 1022) 1023AC_DEFINE_UNQUOTED([JEMALLOC_PRIVATE_NAMESPACE], [$JEMALLOC_PRIVATE_NAMESPACE]) 1024private_namespace="$JEMALLOC_PRIVATE_NAMESPACE" 1025AC_SUBST([private_namespace]) 1026 1027dnl Do not add suffix to installed files by default. 1028AC_ARG_WITH([install_suffix], 1029 [AS_HELP_STRING([--with-install-suffix=<suffix>], [Suffix to append to all installed files])], 1030 [INSTALL_SUFFIX="$with_install_suffix"], 1031 [INSTALL_SUFFIX=] 1032) 1033install_suffix="$INSTALL_SUFFIX" 1034AC_SUBST([install_suffix]) 1035 1036dnl Specify default malloc_conf. 1037AC_ARG_WITH([malloc_conf], 1038 [AS_HELP_STRING([--with-malloc-conf=<malloc_conf>], [config.malloc_conf options string])], 1039 [JEMALLOC_CONFIG_MALLOC_CONF="$with_malloc_conf"], 1040 [JEMALLOC_CONFIG_MALLOC_CONF=""] 1041) 1042config_malloc_conf="$JEMALLOC_CONFIG_MALLOC_CONF" 1043AC_DEFINE_UNQUOTED([JEMALLOC_CONFIG_MALLOC_CONF], ["$config_malloc_conf"]) 1044 1045dnl Substitute @je_@ in jemalloc_protos.h.in, primarily to make generation of 1046dnl jemalloc_protos_jet.h easy. 1047je_="je_" 1048AC_SUBST([je_]) 1049 1050cfgoutputs_in="Makefile.in" 1051cfgoutputs_in="${cfgoutputs_in} jemalloc.pc.in" 1052cfgoutputs_in="${cfgoutputs_in} doc/html.xsl.in" 1053cfgoutputs_in="${cfgoutputs_in} doc/manpages.xsl.in" 1054cfgoutputs_in="${cfgoutputs_in} doc/jemalloc.xml.in" 1055cfgoutputs_in="${cfgoutputs_in} include/jemalloc/jemalloc_macros.h.in" 1056cfgoutputs_in="${cfgoutputs_in} include/jemalloc/jemalloc_protos.h.in" 1057cfgoutputs_in="${cfgoutputs_in} include/jemalloc/jemalloc_typedefs.h.in" 1058cfgoutputs_in="${cfgoutputs_in} include/jemalloc/internal/jemalloc_preamble.h.in" 1059cfgoutputs_in="${cfgoutputs_in} test/test.sh.in" 1060cfgoutputs_in="${cfgoutputs_in} test/include/test/jemalloc_test.h.in" 1061 1062cfgoutputs_out="Makefile" 1063cfgoutputs_out="${cfgoutputs_out} jemalloc.pc" 1064cfgoutputs_out="${cfgoutputs_out} doc/html.xsl" 1065cfgoutputs_out="${cfgoutputs_out} doc/manpages.xsl" 1066cfgoutputs_out="${cfgoutputs_out} doc/jemalloc.xml" 1067cfgoutputs_out="${cfgoutputs_out} include/jemalloc/jemalloc_macros.h" 1068cfgoutputs_out="${cfgoutputs_out} include/jemalloc/jemalloc_protos.h" 1069cfgoutputs_out="${cfgoutputs_out} include/jemalloc/jemalloc_typedefs.h" 1070cfgoutputs_out="${cfgoutputs_out} include/jemalloc/internal/jemalloc_preamble.h" 1071cfgoutputs_out="${cfgoutputs_out} test/test.sh" 1072cfgoutputs_out="${cfgoutputs_out} test/include/test/jemalloc_test.h" 1073 1074cfgoutputs_tup="Makefile" 1075cfgoutputs_tup="${cfgoutputs_tup} jemalloc.pc:jemalloc.pc.in" 1076cfgoutputs_tup="${cfgoutputs_tup} doc/html.xsl:doc/html.xsl.in" 1077cfgoutputs_tup="${cfgoutputs_tup} doc/manpages.xsl:doc/manpages.xsl.in" 1078cfgoutputs_tup="${cfgoutputs_tup} doc/jemalloc.xml:doc/jemalloc.xml.in" 1079cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/jemalloc_macros.h:include/jemalloc/jemalloc_macros.h.in" 1080cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/jemalloc_protos.h:include/jemalloc/jemalloc_protos.h.in" 1081cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/jemalloc_typedefs.h:include/jemalloc/jemalloc_typedefs.h.in" 1082cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/internal/jemalloc_preamble.h" 1083cfgoutputs_tup="${cfgoutputs_tup} test/test.sh:test/test.sh.in" 1084cfgoutputs_tup="${cfgoutputs_tup} test/include/test/jemalloc_test.h:test/include/test/jemalloc_test.h.in" 1085 1086cfghdrs_in="include/jemalloc/jemalloc_defs.h.in" 1087cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/jemalloc_internal_defs.h.in" 1088cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/private_symbols.sh" 1089cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/private_namespace.sh" 1090cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/public_namespace.sh" 1091cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/public_unnamespace.sh" 1092cfghdrs_in="${cfghdrs_in} include/jemalloc/jemalloc_rename.sh" 1093cfghdrs_in="${cfghdrs_in} include/jemalloc/jemalloc_mangle.sh" 1094cfghdrs_in="${cfghdrs_in} include/jemalloc/jemalloc.sh" 1095cfghdrs_in="${cfghdrs_in} test/include/test/jemalloc_test_defs.h.in" 1096 1097cfghdrs_out="include/jemalloc/jemalloc_defs.h" 1098cfghdrs_out="${cfghdrs_out} include/jemalloc/jemalloc${install_suffix}.h" 1099cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/private_symbols.awk" 1100cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/private_symbols_jet.awk" 1101cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/public_symbols.txt" 1102cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/public_namespace.h" 1103cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/public_unnamespace.h" 1104cfghdrs_out="${cfghdrs_out} include/jemalloc/jemalloc_protos_jet.h" 1105cfghdrs_out="${cfghdrs_out} include/jemalloc/jemalloc_rename.h" 1106cfghdrs_out="${cfghdrs_out} include/jemalloc/jemalloc_mangle.h" 1107cfghdrs_out="${cfghdrs_out} include/jemalloc/jemalloc_mangle_jet.h" 1108cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/jemalloc_internal_defs.h" 1109cfghdrs_out="${cfghdrs_out} test/include/test/jemalloc_test_defs.h" 1110 1111cfghdrs_tup="include/jemalloc/jemalloc_defs.h:include/jemalloc/jemalloc_defs.h.in" 1112cfghdrs_tup="${cfghdrs_tup} include/jemalloc/internal/jemalloc_internal_defs.h:include/jemalloc/internal/jemalloc_internal_defs.h.in" 1113cfghdrs_tup="${cfghdrs_tup} test/include/test/jemalloc_test_defs.h:test/include/test/jemalloc_test_defs.h.in" 1114 1115dnl ============================================================================ 1116dnl jemalloc build options. 1117dnl 1118 1119dnl Do not compile with debugging by default. 1120AC_ARG_ENABLE([debug], 1121 [AS_HELP_STRING([--enable-debug], 1122 [Build debugging code])], 1123[if test "x$enable_debug" = "xno" ; then 1124 enable_debug="0" 1125else 1126 enable_debug="1" 1127fi 1128], 1129[enable_debug="0"] 1130) 1131if test "x$enable_debug" = "x1" ; then 1132 AC_DEFINE([JEMALLOC_DEBUG], [ ]) 1133fi 1134if test "x$enable_debug" = "x1" ; then 1135 AC_DEFINE([JEMALLOC_DEBUG], [ ]) 1136fi 1137AC_SUBST([enable_debug]) 1138 1139dnl Only optimize if not debugging. 1140if test "x$enable_debug" = "x0" ; then 1141 if test "x$GCC" = "xyes" ; then 1142 JE_CFLAGS_ADD([-O3]) 1143 JE_CXXFLAGS_ADD([-O3]) 1144 JE_CFLAGS_ADD([-funroll-loops]) 1145 elif test "x$je_cv_msvc" = "xyes" ; then 1146 JE_CFLAGS_ADD([-O2]) 1147 JE_CXXFLAGS_ADD([-O2]) 1148 else 1149 JE_CFLAGS_ADD([-O]) 1150 JE_CXXFLAGS_ADD([-O]) 1151 fi 1152fi 1153 1154dnl Enable statistics calculation by default. 1155AC_ARG_ENABLE([stats], 1156 [AS_HELP_STRING([--disable-stats], 1157 [Disable statistics calculation/reporting])], 1158[if test "x$enable_stats" = "xno" ; then 1159 enable_stats="0" 1160else 1161 enable_stats="1" 1162fi 1163], 1164[enable_stats="1"] 1165) 1166if test "x$enable_stats" = "x1" ; then 1167 AC_DEFINE([JEMALLOC_STATS], [ ]) 1168fi 1169AC_SUBST([enable_stats]) 1170 1171dnl Do not enable smallocx by default. 1172AC_ARG_ENABLE([experimental_smallocx], 1173 [AS_HELP_STRING([--enable-experimental-smallocx], [Enable experimental smallocx API])], 1174[if test "x$enable_experimental_smallocx" = "xno" ; then 1175enable_experimental_smallocx="0" 1176else 1177enable_experimental_smallocx="1" 1178fi 1179], 1180[enable_experimental_smallocx="0"] 1181) 1182if test "x$enable_experimental_smallocx" = "x1" ; then 1183 AC_DEFINE([JEMALLOC_EXPERIMENTAL_SMALLOCX_API]) 1184fi 1185AC_SUBST([enable_experimental_smallocx]) 1186 1187dnl Do not enable profiling by default. 1188AC_ARG_ENABLE([prof], 1189 [AS_HELP_STRING([--enable-prof], [Enable allocation profiling])], 1190[if test "x$enable_prof" = "xno" ; then 1191 enable_prof="0" 1192else 1193 enable_prof="1" 1194fi 1195], 1196[enable_prof="0"] 1197) 1198if test "x$enable_prof" = "x1" ; then 1199 backtrace_method="" 1200else 1201 backtrace_method="N/A" 1202fi 1203 1204AC_ARG_ENABLE([prof-libunwind], 1205 [AS_HELP_STRING([--enable-prof-libunwind], [Use libunwind for backtracing])], 1206[if test "x$enable_prof_libunwind" = "xno" ; then 1207 enable_prof_libunwind="0" 1208else 1209 enable_prof_libunwind="1" 1210fi 1211], 1212[enable_prof_libunwind="0"] 1213) 1214AC_ARG_WITH([static_libunwind], 1215 [AS_HELP_STRING([--with-static-libunwind=<libunwind.a>], 1216 [Path to static libunwind library; use rather than dynamically linking])], 1217if test "x$with_static_libunwind" = "xno" ; then 1218 LUNWIND="-lunwind" 1219else 1220 if test ! -f "$with_static_libunwind" ; then 1221 AC_MSG_ERROR([Static libunwind not found: $with_static_libunwind]) 1222 fi 1223 LUNWIND="$with_static_libunwind" 1224fi, 1225 LUNWIND="-lunwind" 1226) 1227if test "x$backtrace_method" = "x" -a "x$enable_prof_libunwind" = "x1" ; then 1228 AC_CHECK_HEADERS([libunwind.h], , [enable_prof_libunwind="0"]) 1229 if test "x$LUNWIND" = "x-lunwind" ; then 1230 AC_CHECK_LIB([unwind], [unw_backtrace], [JE_APPEND_VS(LIBS, $LUNWIND)], 1231 [enable_prof_libunwind="0"]) 1232 else 1233 JE_APPEND_VS(LIBS, $LUNWIND) 1234 fi 1235 if test "x${enable_prof_libunwind}" = "x1" ; then 1236 backtrace_method="libunwind" 1237 AC_DEFINE([JEMALLOC_PROF_LIBUNWIND], [ ]) 1238 fi 1239fi 1240 1241AC_ARG_ENABLE([prof-libgcc], 1242 [AS_HELP_STRING([--disable-prof-libgcc], 1243 [Do not use libgcc for backtracing])], 1244[if test "x$enable_prof_libgcc" = "xno" ; then 1245 enable_prof_libgcc="0" 1246else 1247 enable_prof_libgcc="1" 1248fi 1249], 1250[enable_prof_libgcc="1"] 1251) 1252if test "x$backtrace_method" = "x" -a "x$enable_prof_libgcc" = "x1" \ 1253 -a "x$GCC" = "xyes" ; then 1254 AC_CHECK_HEADERS([unwind.h], , [enable_prof_libgcc="0"]) 1255 if test "x${enable_prof_libgcc}" = "x1" ; then 1256 AC_CHECK_LIB([gcc], [_Unwind_Backtrace], [JE_APPEND_VS(LIBS, -lgcc)], [enable_prof_libgcc="0"]) 1257 fi 1258 if test "x${enable_prof_libgcc}" = "x1" ; then 1259 backtrace_method="libgcc" 1260 AC_DEFINE([JEMALLOC_PROF_LIBGCC], [ ]) 1261 fi 1262else 1263 enable_prof_libgcc="0" 1264fi 1265 1266AC_ARG_ENABLE([prof-gcc], 1267 [AS_HELP_STRING([--disable-prof-gcc], 1268 [Do not use gcc intrinsics for backtracing])], 1269[if test "x$enable_prof_gcc" = "xno" ; then 1270 enable_prof_gcc="0" 1271else 1272 enable_prof_gcc="1" 1273fi 1274], 1275[enable_prof_gcc="1"] 1276) 1277if test "x$backtrace_method" = "x" -a "x$enable_prof_gcc" = "x1" \ 1278 -a "x$GCC" = "xyes" ; then 1279 JE_CFLAGS_ADD([-fno-omit-frame-pointer]) 1280 backtrace_method="gcc intrinsics" 1281 AC_DEFINE([JEMALLOC_PROF_GCC], [ ]) 1282else 1283 enable_prof_gcc="0" 1284fi 1285 1286if test "x$backtrace_method" = "x" ; then 1287 backtrace_method="none (disabling profiling)" 1288 enable_prof="0" 1289fi 1290AC_MSG_CHECKING([configured backtracing method]) 1291AC_MSG_RESULT([$backtrace_method]) 1292if test "x$enable_prof" = "x1" ; then 1293 dnl Heap profiling uses the log(3) function. 1294 JE_APPEND_VS(LIBS, $LM) 1295 1296 AC_DEFINE([JEMALLOC_PROF], [ ]) 1297fi 1298AC_SUBST([enable_prof]) 1299 1300dnl Indicate whether adjacent virtual memory mappings automatically coalesce 1301dnl (and fragment on demand). 1302if test "x${maps_coalesce}" = "x1" ; then 1303 AC_DEFINE([JEMALLOC_MAPS_COALESCE], [ ]) 1304fi 1305 1306dnl Indicate whether to retain memory (rather than using munmap()) by default. 1307if test "x$default_retain" = "x1" ; then 1308 AC_DEFINE([JEMALLOC_RETAIN], [ ]) 1309fi 1310 1311dnl Enable allocation from DSS if supported by the OS. 1312have_dss="1" 1313dnl Check whether the BSD/SUSv1 sbrk() exists. If not, disable DSS support. 1314AC_CHECK_FUNC([sbrk], [have_sbrk="1"], [have_sbrk="0"]) 1315if test "x$have_sbrk" = "x1" ; then 1316 if test "x$sbrk_deprecated" = "x1" ; then 1317 AC_MSG_RESULT([Disabling dss allocation because sbrk is deprecated]) 1318 have_dss="0" 1319 fi 1320else 1321 have_dss="0" 1322fi 1323 1324if test "x$have_dss" = "x1" ; then 1325 AC_DEFINE([JEMALLOC_DSS], [ ]) 1326fi 1327 1328dnl Support the junk/zero filling option by default. 1329AC_ARG_ENABLE([fill], 1330 [AS_HELP_STRING([--disable-fill], [Disable support for junk/zero filling])], 1331[if test "x$enable_fill" = "xno" ; then 1332 enable_fill="0" 1333else 1334 enable_fill="1" 1335fi 1336], 1337[enable_fill="1"] 1338) 1339if test "x$enable_fill" = "x1" ; then 1340 AC_DEFINE([JEMALLOC_FILL], [ ]) 1341fi 1342AC_SUBST([enable_fill]) 1343 1344dnl Disable utrace(2)-based tracing by default. 1345AC_ARG_ENABLE([utrace], 1346 [AS_HELP_STRING([--enable-utrace], [Enable utrace(2)-based tracing])], 1347[if test "x$enable_utrace" = "xno" ; then 1348 enable_utrace="0" 1349else 1350 enable_utrace="1" 1351fi 1352], 1353[enable_utrace="0"] 1354) 1355JE_COMPILABLE([utrace(2)], [ 1356#include <sys/types.h> 1357#include <sys/param.h> 1358#include <sys/time.h> 1359#include <sys/uio.h> 1360#include <sys/ktrace.h> 1361], [ 1362 utrace((void *)0, 0); 1363], [je_cv_utrace]) 1364if test "x${je_cv_utrace}" = "xno" ; then 1365 enable_utrace="0" 1366fi 1367if test "x$enable_utrace" = "x1" ; then 1368 AC_DEFINE([JEMALLOC_UTRACE], [ ]) 1369fi 1370AC_SUBST([enable_utrace]) 1371 1372dnl Do not support the xmalloc option by default. 1373AC_ARG_ENABLE([xmalloc], 1374 [AS_HELP_STRING([--enable-xmalloc], [Support xmalloc option])], 1375[if test "x$enable_xmalloc" = "xno" ; then 1376 enable_xmalloc="0" 1377else 1378 enable_xmalloc="1" 1379fi 1380], 1381[enable_xmalloc="0"] 1382) 1383if test "x$enable_xmalloc" = "x1" ; then 1384 AC_DEFINE([JEMALLOC_XMALLOC], [ ]) 1385fi 1386AC_SUBST([enable_xmalloc]) 1387 1388dnl Support cache-oblivious allocation alignment by default. 1389AC_ARG_ENABLE([cache-oblivious], 1390 [AS_HELP_STRING([--disable-cache-oblivious], 1391 [Disable support for cache-oblivious allocation alignment])], 1392[if test "x$enable_cache_oblivious" = "xno" ; then 1393 enable_cache_oblivious="0" 1394else 1395 enable_cache_oblivious="1" 1396fi 1397], 1398[enable_cache_oblivious="1"] 1399) 1400if test "x$enable_cache_oblivious" = "x1" ; then 1401 AC_DEFINE([JEMALLOC_CACHE_OBLIVIOUS], [ ]) 1402fi 1403AC_SUBST([enable_cache_oblivious]) 1404 1405dnl Do not log by default. 1406AC_ARG_ENABLE([log], 1407 [AS_HELP_STRING([--enable-log], [Support debug logging])], 1408[if test "x$enable_log" = "xno" ; then 1409 enable_log="0" 1410else 1411 enable_log="1" 1412fi 1413], 1414[enable_log="0"] 1415) 1416if test "x$enable_log" = "x1" ; then 1417 AC_DEFINE([JEMALLOC_LOG], [ ]) 1418fi 1419AC_SUBST([enable_log]) 1420 1421dnl Do not use readlinkat by default 1422AC_ARG_ENABLE([readlinkat], 1423 [AS_HELP_STRING([--enable-readlinkat], [Use readlinkat over readlink])], 1424[if test "x$enable_readlinkat" = "xno" ; then 1425 enable_readlinkat="0" 1426else 1427 enable_readlinkat="1" 1428fi 1429], 1430[enable_readlinkat="0"] 1431) 1432if test "x$enable_readlinkat" = "x1" ; then 1433 AC_DEFINE([JEMALLOC_READLINKAT], [ ]) 1434fi 1435AC_SUBST([enable_readlinkat]) 1436 1437dnl Avoid extra safety checks by default 1438AC_ARG_ENABLE([opt-safety-checks], 1439 [AS_HELP_STRING([--enable-opt-safety-checks], 1440 [Perform certain low-overhead checks, even in opt mode])], 1441[if test "x$enable_opt_safety_checks" = "xno" ; then 1442 enable_opt_safety_checks="0" 1443else 1444 enable_opt_safety_checks="1" 1445fi 1446], 1447[enable_opt_safety_checks="0"] 1448) 1449if test "x$enable_opt_safety_checks" = "x1" ; then 1450 AC_DEFINE([JEMALLOC_OPT_SAFETY_CHECKS], [ ]) 1451fi 1452AC_SUBST([enable_opt_safety_checks]) 1453 1454JE_COMPILABLE([a program using __builtin_unreachable], [ 1455void foo (void) { 1456 __builtin_unreachable(); 1457} 1458], [ 1459 { 1460 foo(); 1461 } 1462], [je_cv_gcc_builtin_unreachable]) 1463if test "x${je_cv_gcc_builtin_unreachable}" = "xyes" ; then 1464 AC_DEFINE([JEMALLOC_INTERNAL_UNREACHABLE], [__builtin_unreachable]) 1465else 1466 AC_DEFINE([JEMALLOC_INTERNAL_UNREACHABLE], [abort]) 1467fi 1468 1469dnl ============================================================================ 1470dnl Check for __builtin_ffsl(), then ffsl(3), and fail if neither are found. 1471dnl One of those two functions should (theoretically) exist on all platforms 1472dnl that jemalloc currently has a chance of functioning on without modification. 1473dnl We additionally assume ffs[ll]() or __builtin_ffs[ll]() are defined if 1474dnl ffsl() or __builtin_ffsl() are defined, respectively. 1475JE_COMPILABLE([a program using __builtin_ffsl], [ 1476#include <stdio.h> 1477#include <strings.h> 1478#include <string.h> 1479], [ 1480 { 1481 int rv = __builtin_ffsl(0x08); 1482 printf("%d\n", rv); 1483 } 1484], [je_cv_gcc_builtin_ffsl]) 1485if test "x${je_cv_gcc_builtin_ffsl}" = "xyes" ; then 1486 AC_DEFINE([JEMALLOC_INTERNAL_FFSLL], [__builtin_ffsll]) 1487 AC_DEFINE([JEMALLOC_INTERNAL_FFSL], [__builtin_ffsl]) 1488 AC_DEFINE([JEMALLOC_INTERNAL_FFS], [__builtin_ffs]) 1489else 1490 JE_COMPILABLE([a program using ffsl], [ 1491 #include <stdio.h> 1492 #include <strings.h> 1493 #include <string.h> 1494 ], [ 1495 { 1496 int rv = ffsl(0x08); 1497 printf("%d\n", rv); 1498 } 1499 ], [je_cv_function_ffsl]) 1500 if test "x${je_cv_function_ffsl}" = "xyes" ; then 1501 AC_DEFINE([JEMALLOC_INTERNAL_FFSLL], [ffsll]) 1502 AC_DEFINE([JEMALLOC_INTERNAL_FFSL], [ffsl]) 1503 AC_DEFINE([JEMALLOC_INTERNAL_FFS], [ffs]) 1504 else 1505 AC_MSG_ERROR([Cannot build without ffsl(3) or __builtin_ffsl()]) 1506 fi 1507fi 1508 1509JE_COMPILABLE([a program using __builtin_popcountl], [ 1510#include <stdio.h> 1511#include <strings.h> 1512#include <string.h> 1513], [ 1514 { 1515 int rv = __builtin_popcountl(0x08); 1516 printf("%d\n", rv); 1517 } 1518], [je_cv_gcc_builtin_popcountl]) 1519if test "x${je_cv_gcc_builtin_popcountl}" = "xyes" ; then 1520 AC_DEFINE([JEMALLOC_INTERNAL_POPCOUNT], [__builtin_popcount]) 1521 AC_DEFINE([JEMALLOC_INTERNAL_POPCOUNTL], [__builtin_popcountl]) 1522fi 1523 1524AC_ARG_WITH([lg_quantum], 1525 [AS_HELP_STRING([--with-lg-quantum=<lg-quantum>], 1526 [Base 2 log of minimum allocation alignment])], 1527 [LG_QUANTA="$with_lg_quantum"], 1528 [LG_QUANTA="3 4"]) 1529if test "x$with_lg_quantum" != "x" ; then 1530 AC_DEFINE_UNQUOTED([LG_QUANTUM], [$with_lg_quantum]) 1531fi 1532 1533AC_ARG_WITH([lg_page], 1534 [AS_HELP_STRING([--with-lg-page=<lg-page>], [Base 2 log of system page size])], 1535 [LG_PAGE="$with_lg_page"], [LG_PAGE="detect"]) 1536if test "x$LG_PAGE" = "xdetect"; then 1537 AC_CACHE_CHECK([LG_PAGE], 1538 [je_cv_lg_page], 1539 AC_RUN_IFELSE([AC_LANG_PROGRAM( 1540[[ 1541#include <strings.h> 1542#ifdef _WIN32 1543#include <windows.h> 1544#else 1545#include <unistd.h> 1546#endif 1547#include <stdio.h> 1548]], 1549[[ 1550 int result; 1551 FILE *f; 1552 1553#ifdef _WIN32 1554 SYSTEM_INFO si; 1555 GetSystemInfo(&si); 1556 result = si.dwPageSize; 1557#else 1558 result = sysconf(_SC_PAGESIZE); 1559#endif 1560 if (result == -1) { 1561 return 1; 1562 } 1563 result = JEMALLOC_INTERNAL_FFSL(result) - 1; 1564 1565 f = fopen("conftest.out", "w"); 1566 if (f == NULL) { 1567 return 1; 1568 } 1569 fprintf(f, "%d", result); 1570 fclose(f); 1571 1572 return 0; 1573]])], 1574 [je_cv_lg_page=`cat conftest.out`], 1575 [je_cv_lg_page=undefined], 1576 [je_cv_lg_page=12])) 1577fi 1578if test "x${je_cv_lg_page}" != "x" ; then 1579 LG_PAGE="${je_cv_lg_page}" 1580fi 1581if test "x${LG_PAGE}" != "xundefined" ; then 1582 AC_DEFINE_UNQUOTED([LG_PAGE], [$LG_PAGE]) 1583else 1584 AC_MSG_ERROR([cannot determine value for LG_PAGE]) 1585fi 1586 1587AC_ARG_WITH([lg_hugepage], 1588 [AS_HELP_STRING([--with-lg-hugepage=<lg-hugepage>], 1589 [Base 2 log of system huge page size])], 1590 [je_cv_lg_hugepage="${with_lg_hugepage}"], 1591 [je_cv_lg_hugepage=""]) 1592if test "x${je_cv_lg_hugepage}" = "x" ; then 1593 dnl Look in /proc/meminfo (Linux-specific) for information on the default huge 1594 dnl page size, if any. The relevant line looks like: 1595 dnl 1596 dnl Hugepagesize: 2048 kB 1597 if test -e "/proc/meminfo" ; then 1598 hpsk=[`cat /proc/meminfo 2>/dev/null | \ 1599 grep -e '^Hugepagesize:[[:space:]]\+[0-9]\+[[:space:]]kB$' | \ 1600 awk '{print $2}'`] 1601 if test "x${hpsk}" != "x" ; then 1602 je_cv_lg_hugepage=10 1603 while test "${hpsk}" -gt 1 ; do 1604 hpsk="$((hpsk / 2))" 1605 je_cv_lg_hugepage="$((je_cv_lg_hugepage + 1))" 1606 done 1607 fi 1608 fi 1609 1610 dnl Set default if unable to automatically configure. 1611 if test "x${je_cv_lg_hugepage}" = "x" ; then 1612 je_cv_lg_hugepage=21 1613 fi 1614fi 1615if test "x${LG_PAGE}" != "xundefined" -a \ 1616 "${je_cv_lg_hugepage}" -lt "${LG_PAGE}" ; then 1617 AC_MSG_ERROR([Huge page size (2^${je_cv_lg_hugepage}) must be at least page size (2^${LG_PAGE})]) 1618fi 1619AC_DEFINE_UNQUOTED([LG_HUGEPAGE], [${je_cv_lg_hugepage}]) 1620 1621dnl ============================================================================ 1622dnl Enable libdl by default. 1623AC_ARG_ENABLE([libdl], 1624 [AS_HELP_STRING([--disable-libdl], 1625 [Do not use libdl])], 1626[if test "x$enable_libdl" = "xno" ; then 1627 enable_libdl="0" 1628else 1629 enable_libdl="1" 1630fi 1631], 1632[enable_libdl="1"] 1633) 1634AC_SUBST([libdl]) 1635 1636dnl ============================================================================ 1637dnl Configure pthreads. 1638 1639if test "x$abi" != "xpecoff" ; then 1640 AC_DEFINE([JEMALLOC_HAVE_PTHREAD], [ ]) 1641 AC_CHECK_HEADERS([pthread.h], , [AC_MSG_ERROR([pthread.h is missing])]) 1642 dnl Some systems may embed pthreads functionality in libc; check for libpthread 1643 dnl first, but try libc too before failing. 1644 AC_CHECK_LIB([pthread], [pthread_create], [JE_APPEND_VS(LIBS, -pthread)], 1645 [AC_SEARCH_LIBS([pthread_create], , , 1646 AC_MSG_ERROR([libpthread is missing]))]) 1647 wrap_syms="${wrap_syms} pthread_create" 1648 have_pthread="1" 1649 1650dnl Check if we have dlsym support. 1651 if test "x$enable_libdl" = "x1" ; then 1652 have_dlsym="1" 1653 AC_CHECK_HEADERS([dlfcn.h], 1654 AC_CHECK_FUNC([dlsym], [], 1655 [AC_CHECK_LIB([dl], [dlsym], [LIBS="$LIBS -ldl"], [have_dlsym="0"])]), 1656 [have_dlsym="0"]) 1657 if test "x$have_dlsym" = "x1" ; then 1658 AC_DEFINE([JEMALLOC_HAVE_DLSYM], [ ]) 1659 fi 1660 else 1661 have_dlsym="0" 1662 fi 1663 1664 JE_COMPILABLE([pthread_atfork(3)], [ 1665#include <pthread.h> 1666], [ 1667 pthread_atfork((void *)0, (void *)0, (void *)0); 1668], [je_cv_pthread_atfork]) 1669 if test "x${je_cv_pthread_atfork}" = "xyes" ; then 1670 AC_DEFINE([JEMALLOC_HAVE_PTHREAD_ATFORK], [ ]) 1671 fi 1672 dnl Check if pthread_setname_np is available with the expected API. 1673 JE_COMPILABLE([pthread_setname_np(3)], [ 1674#include <pthread.h> 1675], [ 1676 pthread_setname_np(pthread_self(), "setname_test"); 1677], [je_cv_pthread_setname_np]) 1678 if test "x${je_cv_pthread_setname_np}" = "xyes" ; then 1679 AC_DEFINE([JEMALLOC_HAVE_PTHREAD_SETNAME_NP], [ ]) 1680 fi 1681fi 1682 1683JE_APPEND_VS(CPPFLAGS, -D_REENTRANT) 1684 1685dnl Check whether clock_gettime(2) is in libc or librt. 1686AC_SEARCH_LIBS([clock_gettime], [rt]) 1687 1688dnl Cray wrapper compiler often adds `-lrt` when using `-static`. Check with 1689dnl `-dynamic` as well in case a user tries to dynamically link in jemalloc 1690if test "x$je_cv_cray_prgenv_wrapper" = "xyes" ; then 1691 if test "$ac_cv_search_clock_gettime" != "-lrt"; then 1692 JE_CFLAGS_SAVE() 1693 1694 unset ac_cv_search_clock_gettime 1695 JE_CFLAGS_ADD([-dynamic]) 1696 AC_SEARCH_LIBS([clock_gettime], [rt]) 1697 1698 JE_CFLAGS_RESTORE() 1699 fi 1700fi 1701 1702dnl check for CLOCK_MONOTONIC_COARSE (Linux-specific). 1703JE_COMPILABLE([clock_gettime(CLOCK_MONOTONIC_COARSE, ...)], [ 1704#include <time.h> 1705], [ 1706 struct timespec ts; 1707 1708 clock_gettime(CLOCK_MONOTONIC_COARSE, &ts); 1709], [je_cv_clock_monotonic_coarse]) 1710if test "x${je_cv_clock_monotonic_coarse}" = "xyes" ; then 1711 AC_DEFINE([JEMALLOC_HAVE_CLOCK_MONOTONIC_COARSE]) 1712fi 1713 1714dnl check for CLOCK_MONOTONIC. 1715JE_COMPILABLE([clock_gettime(CLOCK_MONOTONIC, ...)], [ 1716#include <unistd.h> 1717#include <time.h> 1718], [ 1719 struct timespec ts; 1720 1721 clock_gettime(CLOCK_MONOTONIC, &ts); 1722#if !defined(_POSIX_MONOTONIC_CLOCK) || _POSIX_MONOTONIC_CLOCK < 0 1723# error _POSIX_MONOTONIC_CLOCK missing/invalid 1724#endif 1725], [je_cv_clock_monotonic]) 1726if test "x${je_cv_clock_monotonic}" = "xyes" ; then 1727 AC_DEFINE([JEMALLOC_HAVE_CLOCK_MONOTONIC]) 1728fi 1729 1730dnl Check for mach_absolute_time(). 1731JE_COMPILABLE([mach_absolute_time()], [ 1732#include <mach/mach_time.h> 1733], [ 1734 mach_absolute_time(); 1735], [je_cv_mach_absolute_time]) 1736if test "x${je_cv_mach_absolute_time}" = "xyes" ; then 1737 AC_DEFINE([JEMALLOC_HAVE_MACH_ABSOLUTE_TIME]) 1738fi 1739 1740dnl Use syscall(2) (if available) by default. 1741AC_ARG_ENABLE([syscall], 1742 [AS_HELP_STRING([--disable-syscall], [Disable use of syscall(2)])], 1743[if test "x$enable_syscall" = "xno" ; then 1744 enable_syscall="0" 1745else 1746 enable_syscall="1" 1747fi 1748], 1749[enable_syscall="1"] 1750) 1751if test "x$enable_syscall" = "x1" ; then 1752 dnl Check if syscall(2) is usable. Treat warnings as errors, so that e.g. OS 1753 dnl X 10.12's deprecation warning prevents use. 1754 JE_CFLAGS_SAVE() 1755 JE_CFLAGS_ADD([-Werror]) 1756 JE_COMPILABLE([syscall(2)], [ 1757#include <sys/syscall.h> 1758#include <unistd.h> 1759], [ 1760 syscall(SYS_write, 2, "hello", 5); 1761], 1762 [je_cv_syscall]) 1763 JE_CFLAGS_RESTORE() 1764 if test "x$je_cv_syscall" = "xyes" ; then 1765 AC_DEFINE([JEMALLOC_USE_SYSCALL], [ ]) 1766 fi 1767fi 1768 1769dnl Check if the GNU-specific secure_getenv function exists. 1770AC_CHECK_FUNC([secure_getenv], 1771 [have_secure_getenv="1"], 1772 [have_secure_getenv="0"] 1773 ) 1774if test "x$have_secure_getenv" = "x1" ; then 1775 AC_DEFINE([JEMALLOC_HAVE_SECURE_GETENV], [ ]) 1776fi 1777 1778dnl Check if the GNU-specific sched_getcpu function exists. 1779AC_CHECK_FUNC([sched_getcpu], 1780 [have_sched_getcpu="1"], 1781 [have_sched_getcpu="0"] 1782 ) 1783if test "x$have_sched_getcpu" = "x1" ; then 1784 AC_DEFINE([JEMALLOC_HAVE_SCHED_GETCPU], [ ]) 1785fi 1786 1787dnl Check if the GNU-specific sched_setaffinity function exists. 1788AC_CHECK_FUNC([sched_setaffinity], 1789 [have_sched_setaffinity="1"], 1790 [have_sched_setaffinity="0"] 1791 ) 1792if test "x$have_sched_setaffinity" = "x1" ; then 1793 AC_DEFINE([JEMALLOC_HAVE_SCHED_SETAFFINITY], [ ]) 1794fi 1795 1796dnl Check if the Solaris/BSD issetugid function exists. 1797AC_CHECK_FUNC([issetugid], 1798 [have_issetugid="1"], 1799 [have_issetugid="0"] 1800 ) 1801if test "x$have_issetugid" = "x1" ; then 1802 AC_DEFINE([JEMALLOC_HAVE_ISSETUGID], [ ]) 1803fi 1804 1805dnl Check whether the BSD-specific _malloc_thread_cleanup() exists. If so, use 1806dnl it rather than pthreads TSD cleanup functions to support cleanup during 1807dnl thread exit, in order to avoid pthreads library recursion during 1808dnl bootstrapping. 1809AC_CHECK_FUNC([_malloc_thread_cleanup], 1810 [have__malloc_thread_cleanup="1"], 1811 [have__malloc_thread_cleanup="0"] 1812 ) 1813if test "x$have__malloc_thread_cleanup" = "x1" ; then 1814 AC_DEFINE([JEMALLOC_MALLOC_THREAD_CLEANUP], [ ]) 1815 wrap_syms="${wrap_syms} _malloc_thread_cleanup" 1816 force_tls="1" 1817fi 1818 1819dnl Check whether the BSD-specific _pthread_mutex_init_calloc_cb() exists. If 1820dnl so, mutex initialization causes allocation, and we need to implement this 1821dnl callback function in order to prevent recursive allocation. 1822AC_CHECK_FUNC([_pthread_mutex_init_calloc_cb], 1823 [have__pthread_mutex_init_calloc_cb="1"], 1824 [have__pthread_mutex_init_calloc_cb="0"] 1825 ) 1826if test "x$have__pthread_mutex_init_calloc_cb" = "x1" ; then 1827 AC_DEFINE([JEMALLOC_MUTEX_INIT_CB]) 1828 wrap_syms="${wrap_syms} _malloc_prefork _malloc_postfork" 1829fi 1830 1831dnl Disable lazy locking by default. 1832AC_ARG_ENABLE([lazy_lock], 1833 [AS_HELP_STRING([--enable-lazy-lock], 1834 [Enable lazy locking (only lock when multi-threaded)])], 1835[if test "x$enable_lazy_lock" = "xno" ; then 1836 enable_lazy_lock="0" 1837else 1838 enable_lazy_lock="1" 1839fi 1840], 1841[enable_lazy_lock=""] 1842) 1843if test "x${enable_lazy_lock}" = "x" ; then 1844 if test "x${force_lazy_lock}" = "x1" ; then 1845 AC_MSG_RESULT([Forcing lazy-lock to avoid allocator/threading bootstrap issues]) 1846 enable_lazy_lock="1" 1847 else 1848 enable_lazy_lock="0" 1849 fi 1850fi 1851if test "x${enable_lazy_lock}" = "x1" -a "x${abi}" = "xpecoff" ; then 1852 AC_MSG_RESULT([Forcing no lazy-lock because thread creation monitoring is unimplemented]) 1853 enable_lazy_lock="0" 1854fi 1855if test "x$enable_lazy_lock" = "x1" ; then 1856 if test "x$have_dlsym" = "x1" ; then 1857 AC_DEFINE([JEMALLOC_LAZY_LOCK], [ ]) 1858 else 1859 AC_MSG_ERROR([Missing dlsym support: lazy-lock cannot be enabled.]) 1860 fi 1861fi 1862AC_SUBST([enable_lazy_lock]) 1863 1864dnl Automatically configure TLS. 1865if test "x${force_tls}" = "x1" ; then 1866 enable_tls="1" 1867elif test "x${force_tls}" = "x0" ; then 1868 enable_tls="0" 1869else 1870 enable_tls="1" 1871fi 1872if test "x${enable_tls}" = "x1" ; then 1873AC_MSG_CHECKING([for TLS]) 1874AC_COMPILE_IFELSE([AC_LANG_PROGRAM( 1875[[ 1876 __thread int x; 1877]], [[ 1878 x = 42; 1879 1880 return 0; 1881]])], 1882 AC_MSG_RESULT([yes]), 1883 AC_MSG_RESULT([no]) 1884 enable_tls="0") 1885else 1886 enable_tls="0" 1887fi 1888AC_SUBST([enable_tls]) 1889if test "x${enable_tls}" = "x1" ; then 1890 AC_DEFINE_UNQUOTED([JEMALLOC_TLS], [ ]) 1891fi 1892 1893dnl ============================================================================ 1894dnl Check for C11 atomics. 1895 1896JE_COMPILABLE([C11 atomics], [ 1897#include <stdint.h> 1898#if (__STDC_VERSION__ >= 201112L) && !defined(__STDC_NO_ATOMICS__) 1899#include <stdatomic.h> 1900#else 1901#error Atomics not available 1902#endif 1903], [ 1904 uint64_t *p = (uint64_t *)0; 1905 uint64_t x = 1; 1906 volatile atomic_uint_least64_t *a = (volatile atomic_uint_least64_t *)p; 1907 uint64_t r = atomic_fetch_add(a, x) + x; 1908 return r == 0; 1909], [je_cv_c11_atomics]) 1910if test "x${je_cv_c11_atomics}" = "xyes" ; then 1911 AC_DEFINE([JEMALLOC_C11_ATOMICS]) 1912fi 1913 1914dnl ============================================================================ 1915dnl Check for GCC-style __atomic atomics. 1916 1917JE_COMPILABLE([GCC __atomic atomics], [ 1918], [ 1919 int x = 0; 1920 int val = 1; 1921 int y = __atomic_fetch_add(&x, val, __ATOMIC_RELAXED); 1922 int after_add = x; 1923 return after_add == 1; 1924], [je_cv_gcc_atomic_atomics]) 1925if test "x${je_cv_gcc_atomic_atomics}" = "xyes" ; then 1926 AC_DEFINE([JEMALLOC_GCC_ATOMIC_ATOMICS]) 1927 1928 dnl check for 8-bit atomic support 1929 JE_COMPILABLE([GCC 8-bit __atomic atomics], [ 1930 ], [ 1931 unsigned char x = 0; 1932 int val = 1; 1933 int y = __atomic_fetch_add(&x, val, __ATOMIC_RELAXED); 1934 int after_add = (int)x; 1935 return after_add == 1; 1936 ], [je_cv_gcc_u8_atomic_atomics]) 1937 if test "x${je_cv_gcc_u8_atomic_atomics}" = "xyes" ; then 1938 AC_DEFINE([JEMALLOC_GCC_U8_ATOMIC_ATOMICS]) 1939 fi 1940fi 1941 1942dnl ============================================================================ 1943dnl Check for GCC-style __sync atomics. 1944 1945JE_COMPILABLE([GCC __sync atomics], [ 1946], [ 1947 int x = 0; 1948 int before_add = __sync_fetch_and_add(&x, 1); 1949 int after_add = x; 1950 return (before_add == 0) && (after_add == 1); 1951], [je_cv_gcc_sync_atomics]) 1952if test "x${je_cv_gcc_sync_atomics}" = "xyes" ; then 1953 AC_DEFINE([JEMALLOC_GCC_SYNC_ATOMICS]) 1954 1955 dnl check for 8-bit atomic support 1956 JE_COMPILABLE([GCC 8-bit __sync atomics], [ 1957 ], [ 1958 unsigned char x = 0; 1959 int before_add = __sync_fetch_and_add(&x, 1); 1960 int after_add = (int)x; 1961 return (before_add == 0) && (after_add == 1); 1962 ], [je_cv_gcc_u8_sync_atomics]) 1963 if test "x${je_cv_gcc_u8_sync_atomics}" = "xyes" ; then 1964 AC_DEFINE([JEMALLOC_GCC_U8_SYNC_ATOMICS]) 1965 fi 1966fi 1967 1968dnl ============================================================================ 1969dnl Check for atomic(3) operations as provided on Darwin. 1970dnl We need this not for the atomic operations (which are provided above), but 1971dnl rather for the OS_unfair_lock type it exposes. 1972 1973JE_COMPILABLE([Darwin OSAtomic*()], [ 1974#include <libkern/OSAtomic.h> 1975#include <inttypes.h> 1976], [ 1977 { 1978 int32_t x32 = 0; 1979 volatile int32_t *x32p = &x32; 1980 OSAtomicAdd32(1, x32p); 1981 } 1982 { 1983 int64_t x64 = 0; 1984 volatile int64_t *x64p = &x64; 1985 OSAtomicAdd64(1, x64p); 1986 } 1987], [je_cv_osatomic]) 1988if test "x${je_cv_osatomic}" = "xyes" ; then 1989 AC_DEFINE([JEMALLOC_OSATOMIC], [ ]) 1990fi 1991 1992dnl ============================================================================ 1993dnl Check for madvise(2). 1994 1995JE_COMPILABLE([madvise(2)], [ 1996#include <sys/mman.h> 1997], [ 1998 madvise((void *)0, 0, 0); 1999], [je_cv_madvise]) 2000if test "x${je_cv_madvise}" = "xyes" ; then 2001 AC_DEFINE([JEMALLOC_HAVE_MADVISE], [ ]) 2002 2003 dnl Check for madvise(..., MADV_FREE). 2004 JE_COMPILABLE([madvise(..., MADV_FREE)], [ 2005#include <sys/mman.h> 2006], [ 2007 madvise((void *)0, 0, MADV_FREE); 2008], [je_cv_madv_free]) 2009 if test "x${je_cv_madv_free}" = "xyes" ; then 2010 AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ]) 2011 elif test "x${je_cv_madvise}" = "xyes" ; then 2012 case "${host_cpu}" in i686|x86_64) 2013 case "${host}" in *-*-linux*) 2014 AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ]) 2015 AC_DEFINE([JEMALLOC_DEFINE_MADVISE_FREE], [ ]) 2016 ;; 2017 esac 2018 ;; 2019 esac 2020 fi 2021 2022 dnl Check for madvise(..., MADV_DONTNEED). 2023 JE_COMPILABLE([madvise(..., MADV_DONTNEED)], [ 2024#include <sys/mman.h> 2025], [ 2026 madvise((void *)0, 0, MADV_DONTNEED); 2027], [je_cv_madv_dontneed]) 2028 if test "x${je_cv_madv_dontneed}" = "xyes" ; then 2029 AC_DEFINE([JEMALLOC_PURGE_MADVISE_DONTNEED], [ ]) 2030 fi 2031 2032 dnl Check for madvise(..., MADV_DO[NT]DUMP). 2033 JE_COMPILABLE([madvise(..., MADV_DO[[NT]]DUMP)], [ 2034#include <sys/mman.h> 2035], [ 2036 madvise((void *)0, 0, MADV_DONTDUMP); 2037 madvise((void *)0, 0, MADV_DODUMP); 2038], [je_cv_madv_dontdump]) 2039 if test "x${je_cv_madv_dontdump}" = "xyes" ; then 2040 AC_DEFINE([JEMALLOC_MADVISE_DONTDUMP], [ ]) 2041 fi 2042 2043 dnl Check for madvise(..., MADV_[NO]HUGEPAGE). 2044 JE_COMPILABLE([madvise(..., MADV_[[NO]]HUGEPAGE)], [ 2045#include <sys/mman.h> 2046], [ 2047 madvise((void *)0, 0, MADV_HUGEPAGE); 2048 madvise((void *)0, 0, MADV_NOHUGEPAGE); 2049], [je_cv_thp]) 2050case "${host_cpu}" in 2051 arm*) 2052 ;; 2053 *) 2054 if test "x${je_cv_thp}" = "xyes" ; then 2055 AC_DEFINE([JEMALLOC_HAVE_MADVISE_HUGE], [ ]) 2056 fi 2057 ;; 2058esac 2059fi 2060 2061dnl ============================================================================ 2062dnl Check for __builtin_clz() and __builtin_clzl(). 2063 2064AC_CACHE_CHECK([for __builtin_clz], 2065 [je_cv_builtin_clz], 2066 [AC_LINK_IFELSE([AC_LANG_PROGRAM([], 2067 [ 2068 { 2069 unsigned x = 0; 2070 int y = __builtin_clz(x); 2071 } 2072 { 2073 unsigned long x = 0; 2074 int y = __builtin_clzl(x); 2075 } 2076 ])], 2077 [je_cv_builtin_clz=yes], 2078 [je_cv_builtin_clz=no])]) 2079 2080if test "x${je_cv_builtin_clz}" = "xyes" ; then 2081 AC_DEFINE([JEMALLOC_HAVE_BUILTIN_CLZ], [ ]) 2082fi 2083 2084dnl ============================================================================ 2085dnl Check for os_unfair_lock operations as provided on Darwin. 2086 2087JE_COMPILABLE([Darwin os_unfair_lock_*()], [ 2088#include <os/lock.h> 2089#include <AvailabilityMacros.h> 2090], [ 2091 #if MAC_OS_X_VERSION_MIN_REQUIRED < 101200 2092 #error "os_unfair_lock is not supported" 2093 #else 2094 os_unfair_lock lock = OS_UNFAIR_LOCK_INIT; 2095 os_unfair_lock_lock(&lock); 2096 os_unfair_lock_unlock(&lock); 2097 #endif 2098], [je_cv_os_unfair_lock]) 2099if test "x${je_cv_os_unfair_lock}" = "xyes" ; then 2100 AC_DEFINE([JEMALLOC_OS_UNFAIR_LOCK], [ ]) 2101fi 2102 2103dnl ============================================================================ 2104dnl Darwin-related configuration. 2105 2106AC_ARG_ENABLE([zone-allocator], 2107 [AS_HELP_STRING([--disable-zone-allocator], 2108 [Disable zone allocator for Darwin])], 2109[if test "x$enable_zone_allocator" = "xno" ; then 2110 enable_zone_allocator="0" 2111else 2112 enable_zone_allocator="1" 2113fi 2114], 2115[if test "x${abi}" = "xmacho"; then 2116 enable_zone_allocator="1" 2117fi 2118] 2119) 2120AC_SUBST([enable_zone_allocator]) 2121 2122if test "x${enable_zone_allocator}" = "x1" ; then 2123 if test "x${abi}" != "xmacho"; then 2124 AC_MSG_ERROR([--enable-zone-allocator is only supported on Darwin]) 2125 fi 2126 AC_DEFINE([JEMALLOC_ZONE], [ ]) 2127fi 2128 2129dnl ============================================================================ 2130dnl Use initial-exec TLS by default. 2131AC_ARG_ENABLE([initial-exec-tls], 2132 [AS_HELP_STRING([--disable-initial-exec-tls], 2133 [Disable the initial-exec tls model])], 2134[if test "x$enable_initial_exec_tls" = "xno" ; then 2135 enable_initial_exec_tls="0" 2136else 2137 enable_initial_exec_tls="1" 2138fi 2139], 2140[enable_initial_exec_tls="1"] 2141) 2142AC_SUBST([enable_initial_exec_tls]) 2143 2144if test "x${je_cv_tls_model}" = "xyes" -a \ 2145 "x${enable_initial_exec_tls}" = "x1" ; then 2146 AC_DEFINE([JEMALLOC_TLS_MODEL], 2147 [__attribute__((tls_model("initial-exec")))]) 2148else 2149 AC_DEFINE([JEMALLOC_TLS_MODEL], [ ]) 2150fi 2151 2152dnl ============================================================================ 2153dnl Enable background threads if possible. 2154 2155if test "x${have_pthread}" = "x1" -a "x${je_cv_os_unfair_lock}" != "xyes" ; then 2156 AC_DEFINE([JEMALLOC_BACKGROUND_THREAD]) 2157fi 2158 2159dnl ============================================================================ 2160dnl Check for glibc malloc hooks 2161 2162JE_COMPILABLE([glibc malloc hook], [ 2163#include <stddef.h> 2164 2165extern void (* __free_hook)(void *ptr); 2166extern void *(* __malloc_hook)(size_t size); 2167extern void *(* __realloc_hook)(void *ptr, size_t size); 2168], [ 2169 void *ptr = 0L; 2170 if (__malloc_hook) ptr = __malloc_hook(1); 2171 if (__realloc_hook) ptr = __realloc_hook(ptr, 2); 2172 if (__free_hook && ptr) __free_hook(ptr); 2173], [je_cv_glibc_malloc_hook]) 2174if test "x${je_cv_glibc_malloc_hook}" = "xyes" ; then 2175 if test "x${JEMALLOC_PREFIX}" = "x" ; then 2176 AC_DEFINE([JEMALLOC_GLIBC_MALLOC_HOOK], [ ]) 2177 wrap_syms="${wrap_syms} __free_hook __malloc_hook __realloc_hook" 2178 fi 2179fi 2180 2181JE_COMPILABLE([glibc memalign hook], [ 2182#include <stddef.h> 2183 2184extern void *(* __memalign_hook)(size_t alignment, size_t size); 2185], [ 2186 void *ptr = 0L; 2187 if (__memalign_hook) ptr = __memalign_hook(16, 7); 2188], [je_cv_glibc_memalign_hook]) 2189if test "x${je_cv_glibc_memalign_hook}" = "xyes" ; then 2190 if test "x${JEMALLOC_PREFIX}" = "x" ; then 2191 AC_DEFINE([JEMALLOC_GLIBC_MEMALIGN_HOOK], [ ]) 2192 wrap_syms="${wrap_syms} __memalign_hook" 2193 fi 2194fi 2195 2196JE_COMPILABLE([pthreads adaptive mutexes], [ 2197#include <pthread.h> 2198], [ 2199 pthread_mutexattr_t attr; 2200 pthread_mutexattr_init(&attr); 2201 pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ADAPTIVE_NP); 2202 pthread_mutexattr_destroy(&attr); 2203], [je_cv_pthread_mutex_adaptive_np]) 2204if test "x${je_cv_pthread_mutex_adaptive_np}" = "xyes" ; then 2205 AC_DEFINE([JEMALLOC_HAVE_PTHREAD_MUTEX_ADAPTIVE_NP], [ ]) 2206fi 2207 2208JE_CFLAGS_SAVE() 2209JE_CFLAGS_ADD([-D_GNU_SOURCE]) 2210JE_CFLAGS_ADD([-Werror]) 2211JE_CFLAGS_ADD([-herror_on_warning]) 2212JE_COMPILABLE([strerror_r returns char with gnu source], [ 2213#include <errno.h> 2214#include <stdio.h> 2215#include <stdlib.h> 2216#include <string.h> 2217], [ 2218 char *buffer = (char *) malloc(100); 2219 char *error = strerror_r(EINVAL, buffer, 100); 2220 printf("%s\n", error); 2221], [je_cv_strerror_r_returns_char_with_gnu_source]) 2222JE_CFLAGS_RESTORE() 2223if test "x${je_cv_strerror_r_returns_char_with_gnu_source}" = "xyes" ; then 2224 AC_DEFINE([JEMALLOC_STRERROR_R_RETURNS_CHAR_WITH_GNU_SOURCE], [ ]) 2225fi 2226 2227dnl ============================================================================ 2228dnl Check for typedefs, structures, and compiler characteristics. 2229AC_HEADER_STDBOOL 2230 2231dnl ============================================================================ 2232dnl Define commands that generate output files. 2233 2234AC_CONFIG_COMMANDS([include/jemalloc/internal/public_symbols.txt], [ 2235 f="${objroot}include/jemalloc/internal/public_symbols.txt" 2236 mkdir -p "${objroot}include/jemalloc/internal" 2237 cp /dev/null "${f}" 2238 for nm in `echo ${mangling_map} |tr ',' ' '` ; do 2239 n=`echo ${nm} |tr ':' ' ' |awk '{print $[]1}'` 2240 m=`echo ${nm} |tr ':' ' ' |awk '{print $[]2}'` 2241 echo "${n}:${m}" >> "${f}" 2242 dnl Remove name from public_syms so that it isn't redefined later. 2243 public_syms=`for sym in ${public_syms}; do echo "${sym}"; done |grep -v "^${n}\$" |tr '\n' ' '` 2244 done 2245 for sym in ${public_syms} ; do 2246 n="${sym}" 2247 m="${JEMALLOC_PREFIX}${sym}" 2248 echo "${n}:${m}" >> "${f}" 2249 done 2250], [ 2251 srcdir="${srcdir}" 2252 objroot="${objroot}" 2253 mangling_map="${mangling_map}" 2254 public_syms="${public_syms}" 2255 JEMALLOC_PREFIX="${JEMALLOC_PREFIX}" 2256]) 2257AC_CONFIG_COMMANDS([include/jemalloc/internal/private_symbols.awk], [ 2258 f="${objroot}include/jemalloc/internal/private_symbols.awk" 2259 mkdir -p "${objroot}include/jemalloc/internal" 2260 export_syms=`for sym in ${public_syms}; do echo "${JEMALLOC_PREFIX}${sym}"; done; for sym in ${wrap_syms}; do echo "${sym}"; done;` 2261 "${srcdir}/include/jemalloc/internal/private_symbols.sh" "${SYM_PREFIX}" ${export_syms} > "${objroot}include/jemalloc/internal/private_symbols.awk" 2262], [ 2263 srcdir="${srcdir}" 2264 objroot="${objroot}" 2265 public_syms="${public_syms}" 2266 wrap_syms="${wrap_syms}" 2267 SYM_PREFIX="${SYM_PREFIX}" 2268 JEMALLOC_PREFIX="${JEMALLOC_PREFIX}" 2269]) 2270AC_CONFIG_COMMANDS([include/jemalloc/internal/private_symbols_jet.awk], [ 2271 f="${objroot}include/jemalloc/internal/private_symbols_jet.awk" 2272 mkdir -p "${objroot}include/jemalloc/internal" 2273 export_syms=`for sym in ${public_syms}; do echo "jet_${sym}"; done; for sym in ${wrap_syms}; do echo "${sym}"; done;` 2274 "${srcdir}/include/jemalloc/internal/private_symbols.sh" "${SYM_PREFIX}" ${export_syms} > "${objroot}include/jemalloc/internal/private_symbols_jet.awk" 2275], [ 2276 srcdir="${srcdir}" 2277 objroot="${objroot}" 2278 public_syms="${public_syms}" 2279 wrap_syms="${wrap_syms}" 2280 SYM_PREFIX="${SYM_PREFIX}" 2281]) 2282AC_CONFIG_COMMANDS([include/jemalloc/internal/public_namespace.h], [ 2283 mkdir -p "${objroot}include/jemalloc/internal" 2284 "${srcdir}/include/jemalloc/internal/public_namespace.sh" "${objroot}include/jemalloc/internal/public_symbols.txt" > "${objroot}include/jemalloc/internal/public_namespace.h" 2285], [ 2286 srcdir="${srcdir}" 2287 objroot="${objroot}" 2288]) 2289AC_CONFIG_COMMANDS([include/jemalloc/internal/public_unnamespace.h], [ 2290 mkdir -p "${objroot}include/jemalloc/internal" 2291 "${srcdir}/include/jemalloc/internal/public_unnamespace.sh" "${objroot}include/jemalloc/internal/public_symbols.txt" > "${objroot}include/jemalloc/internal/public_unnamespace.h" 2292], [ 2293 srcdir="${srcdir}" 2294 objroot="${objroot}" 2295]) 2296AC_CONFIG_COMMANDS([include/jemalloc/jemalloc_protos_jet.h], [ 2297 mkdir -p "${objroot}include/jemalloc" 2298 cat "${srcdir}/include/jemalloc/jemalloc_protos.h.in" | sed -e 's/@je_@/jet_/g' > "${objroot}include/jemalloc/jemalloc_protos_jet.h" 2299], [ 2300 srcdir="${srcdir}" 2301 objroot="${objroot}" 2302]) 2303AC_CONFIG_COMMANDS([include/jemalloc/jemalloc_rename.h], [ 2304 mkdir -p "${objroot}include/jemalloc" 2305 "${srcdir}/include/jemalloc/jemalloc_rename.sh" "${objroot}include/jemalloc/internal/public_symbols.txt" > "${objroot}include/jemalloc/jemalloc_rename.h" 2306], [ 2307 srcdir="${srcdir}" 2308 objroot="${objroot}" 2309]) 2310AC_CONFIG_COMMANDS([include/jemalloc/jemalloc_mangle.h], [ 2311 mkdir -p "${objroot}include/jemalloc" 2312 "${srcdir}/include/jemalloc/jemalloc_mangle.sh" "${objroot}include/jemalloc/internal/public_symbols.txt" je_ > "${objroot}include/jemalloc/jemalloc_mangle.h" 2313], [ 2314 srcdir="${srcdir}" 2315 objroot="${objroot}" 2316]) 2317AC_CONFIG_COMMANDS([include/jemalloc/jemalloc_mangle_jet.h], [ 2318 mkdir -p "${objroot}include/jemalloc" 2319 "${srcdir}/include/jemalloc/jemalloc_mangle.sh" "${objroot}include/jemalloc/internal/public_symbols.txt" jet_ > "${objroot}include/jemalloc/jemalloc_mangle_jet.h" 2320], [ 2321 srcdir="${srcdir}" 2322 objroot="${objroot}" 2323]) 2324AC_CONFIG_COMMANDS([include/jemalloc/jemalloc.h], [ 2325 mkdir -p "${objroot}include/jemalloc" 2326 "${srcdir}/include/jemalloc/jemalloc.sh" "${objroot}" > "${objroot}include/jemalloc/jemalloc${install_suffix}.h" 2327], [ 2328 srcdir="${srcdir}" 2329 objroot="${objroot}" 2330 install_suffix="${install_suffix}" 2331]) 2332 2333dnl Process .in files. 2334AC_SUBST([cfghdrs_in]) 2335AC_SUBST([cfghdrs_out]) 2336AC_CONFIG_HEADERS([$cfghdrs_tup]) 2337 2338dnl ============================================================================ 2339dnl Generate outputs. 2340 2341AC_CONFIG_FILES([$cfgoutputs_tup config.stamp bin/jemalloc-config bin/jemalloc.sh bin/jeprof]) 2342AC_SUBST([cfgoutputs_in]) 2343AC_SUBST([cfgoutputs_out]) 2344AC_OUTPUT 2345 2346dnl ============================================================================ 2347dnl Print out the results of configuration. 2348AC_MSG_RESULT([===============================================================================]) 2349AC_MSG_RESULT([jemalloc version : ${jemalloc_version}]) 2350AC_MSG_RESULT([library revision : ${rev}]) 2351AC_MSG_RESULT([]) 2352AC_MSG_RESULT([CONFIG : ${CONFIG}]) 2353AC_MSG_RESULT([CC : ${CC}]) 2354AC_MSG_RESULT([CONFIGURE_CFLAGS : ${CONFIGURE_CFLAGS}]) 2355AC_MSG_RESULT([SPECIFIED_CFLAGS : ${SPECIFIED_CFLAGS}]) 2356AC_MSG_RESULT([EXTRA_CFLAGS : ${EXTRA_CFLAGS}]) 2357AC_MSG_RESULT([CPPFLAGS : ${CPPFLAGS}]) 2358AC_MSG_RESULT([CXX : ${CXX}]) 2359AC_MSG_RESULT([CONFIGURE_CXXFLAGS : ${CONFIGURE_CXXFLAGS}]) 2360AC_MSG_RESULT([SPECIFIED_CXXFLAGS : ${SPECIFIED_CXXFLAGS}]) 2361AC_MSG_RESULT([EXTRA_CXXFLAGS : ${EXTRA_CXXFLAGS}]) 2362AC_MSG_RESULT([LDFLAGS : ${LDFLAGS}]) 2363AC_MSG_RESULT([EXTRA_LDFLAGS : ${EXTRA_LDFLAGS}]) 2364AC_MSG_RESULT([DSO_LDFLAGS : ${DSO_LDFLAGS}]) 2365AC_MSG_RESULT([LIBS : ${LIBS}]) 2366AC_MSG_RESULT([RPATH_EXTRA : ${RPATH_EXTRA}]) 2367AC_MSG_RESULT([]) 2368AC_MSG_RESULT([XSLTPROC : ${XSLTPROC}]) 2369AC_MSG_RESULT([XSLROOT : ${XSLROOT}]) 2370AC_MSG_RESULT([]) 2371AC_MSG_RESULT([PREFIX : ${PREFIX}]) 2372AC_MSG_RESULT([BINDIR : ${BINDIR}]) 2373AC_MSG_RESULT([DATADIR : ${DATADIR}]) 2374AC_MSG_RESULT([INCLUDEDIR : ${INCLUDEDIR}]) 2375AC_MSG_RESULT([LIBDIR : ${LIBDIR}]) 2376AC_MSG_RESULT([MANDIR : ${MANDIR}]) 2377AC_MSG_RESULT([]) 2378AC_MSG_RESULT([srcroot : ${srcroot}]) 2379AC_MSG_RESULT([abs_srcroot : ${abs_srcroot}]) 2380AC_MSG_RESULT([objroot : ${objroot}]) 2381AC_MSG_RESULT([abs_objroot : ${abs_objroot}]) 2382AC_MSG_RESULT([]) 2383AC_MSG_RESULT([JEMALLOC_PREFIX : ${JEMALLOC_PREFIX}]) 2384AC_MSG_RESULT([JEMALLOC_PRIVATE_NAMESPACE]) 2385AC_MSG_RESULT([ : ${JEMALLOC_PRIVATE_NAMESPACE}]) 2386AC_MSG_RESULT([install_suffix : ${install_suffix}]) 2387AC_MSG_RESULT([malloc_conf : ${config_malloc_conf}]) 2388AC_MSG_RESULT([documentation : ${enable_doc}]) 2389AC_MSG_RESULT([shared libs : ${enable_shared}]) 2390AC_MSG_RESULT([static libs : ${enable_static}]) 2391AC_MSG_RESULT([autogen : ${enable_autogen}]) 2392AC_MSG_RESULT([debug : ${enable_debug}]) 2393AC_MSG_RESULT([stats : ${enable_stats}]) 2394AC_MSG_RESULT([experimetal_smallocx : ${enable_experimental_smallocx}]) 2395AC_MSG_RESULT([prof : ${enable_prof}]) 2396AC_MSG_RESULT([prof-libunwind : ${enable_prof_libunwind}]) 2397AC_MSG_RESULT([prof-libgcc : ${enable_prof_libgcc}]) 2398AC_MSG_RESULT([prof-gcc : ${enable_prof_gcc}]) 2399AC_MSG_RESULT([fill : ${enable_fill}]) 2400AC_MSG_RESULT([utrace : ${enable_utrace}]) 2401AC_MSG_RESULT([xmalloc : ${enable_xmalloc}]) 2402AC_MSG_RESULT([log : ${enable_log}]) 2403AC_MSG_RESULT([lazy_lock : ${enable_lazy_lock}]) 2404AC_MSG_RESULT([cache-oblivious : ${enable_cache_oblivious}]) 2405AC_MSG_RESULT([cxx : ${enable_cxx}]) 2406AC_MSG_RESULT([===============================================================================]) 2407