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