Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1 | dnl Process this file with autoconf to produce a configure script. |
| 2 | AC_INIT([Makefile.in]) |
| 3 | |
Jason Evans | f3340ca | 2009-06-30 16:17:05 -0700 | [diff] [blame] | 4 | dnl ============================================================================ |
| 5 | dnl Custom macro definitions. |
| 6 | |
| 7 | dnl JE_CFLAGS_APPEND(cflag) |
| 8 | AC_DEFUN([JE_CFLAGS_APPEND], |
| 9 | [ |
| 10 | AC_MSG_CHECKING([whether compiler supports $1]) |
| 11 | TCFLAGS="${CFLAGS}" |
| 12 | if test "x${CFLAGS}" = "x" ; then |
| 13 | CFLAGS="$1" |
| 14 | else |
| 15 | CFLAGS="${CFLAGS} $1" |
| 16 | fi |
Jason Evans | 6684cac | 2012-03-05 12:15:36 -0800 | [diff] [blame] | 17 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM( |
Jason Evans | f3340ca | 2009-06-30 16:17:05 -0700 | [diff] [blame] | 18 | [[ |
| 19 | ]], [[ |
| 20 | return 0; |
| 21 | ]])], |
| 22 | AC_MSG_RESULT([yes]), |
| 23 | AC_MSG_RESULT([no]) |
| 24 | [CFLAGS="${TCFLAGS}"] |
| 25 | ) |
| 26 | ]) |
| 27 | |
| 28 | dnl JE_COMPILABLE(label, hcode, mcode, rvar) |
Jason Evans | 4c2faa8 | 2012-03-13 11:09:23 -0700 | [diff] [blame] | 29 | dnl |
Jason Evans | f3e139a | 2012-03-19 09:54:20 -0700 | [diff] [blame] | 30 | dnl Use AC_LINK_IFELSE() rather than AC_COMPILE_IFELSE() so that linker errors |
Jason Evans | 4c2faa8 | 2012-03-13 11:09:23 -0700 | [diff] [blame] | 31 | dnl cause failure. |
Jason Evans | f3340ca | 2009-06-30 16:17:05 -0700 | [diff] [blame] | 32 | AC_DEFUN([JE_COMPILABLE], |
| 33 | [ |
Jason Evans | 6684cac | 2012-03-05 12:15:36 -0800 | [diff] [blame] | 34 | AC_CACHE_CHECK([whether $1 is compilable], |
| 35 | [$4], |
Jason Evans | f3e139a | 2012-03-19 09:54:20 -0700 | [diff] [blame] | 36 | [AC_LINK_IFELSE([AC_LANG_PROGRAM([$2], |
| 37 | [$3])], |
| 38 | [$4=yes], |
| 39 | [$4=no])]) |
Jason Evans | f3340ca | 2009-06-30 16:17:05 -0700 | [diff] [blame] | 40 | ]) |
| 41 | |
| 42 | dnl ============================================================================ |
| 43 | |
Jason Evans | f576c63 | 2011-11-01 22:27:41 -0700 | [diff] [blame] | 44 | dnl Library revision. |
| 45 | rev=1 |
| 46 | AC_SUBST([rev]) |
| 47 | |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 48 | srcroot=$srcdir |
| 49 | if test "x${srcroot}" = "x." ; then |
| 50 | srcroot="" |
| 51 | else |
| 52 | srcroot="${srcroot}/" |
| 53 | fi |
| 54 | AC_SUBST([srcroot]) |
| 55 | abs_srcroot="`cd \"${srcdir}\"; pwd`/" |
| 56 | AC_SUBST([abs_srcroot]) |
| 57 | |
| 58 | objroot="" |
| 59 | AC_SUBST([objroot]) |
| 60 | abs_objroot="`pwd`/" |
| 61 | AC_SUBST([abs_objroot]) |
| 62 | |
| 63 | dnl Munge install path variables. |
| 64 | if test "x$prefix" = "xNONE" ; then |
| 65 | prefix="/usr/local" |
| 66 | fi |
| 67 | if test "x$exec_prefix" = "xNONE" ; then |
| 68 | exec_prefix=$prefix |
| 69 | fi |
| 70 | PREFIX=$prefix |
| 71 | AC_SUBST([PREFIX]) |
| 72 | BINDIR=`eval echo $bindir` |
| 73 | BINDIR=`eval echo $BINDIR` |
| 74 | AC_SUBST([BINDIR]) |
| 75 | INCLUDEDIR=`eval echo $includedir` |
| 76 | INCLUDEDIR=`eval echo $INCLUDEDIR` |
| 77 | AC_SUBST([INCLUDEDIR]) |
| 78 | LIBDIR=`eval echo $libdir` |
| 79 | LIBDIR=`eval echo $LIBDIR` |
| 80 | AC_SUBST([LIBDIR]) |
| 81 | DATADIR=`eval echo $datadir` |
| 82 | DATADIR=`eval echo $DATADIR` |
| 83 | AC_SUBST([DATADIR]) |
| 84 | MANDIR=`eval echo $mandir` |
| 85 | MANDIR=`eval echo $MANDIR` |
| 86 | AC_SUBST([MANDIR]) |
| 87 | |
Jason Evans | aee7fd2 | 2010-11-24 22:00:02 -0800 | [diff] [blame] | 88 | dnl Support for building documentation. |
Jason Evans | 7329a4f | 2013-01-22 10:53:29 -0800 | [diff] [blame] | 89 | AC_PATH_PROG([XSLTPROC], [xsltproc], [false], [$PATH]) |
Jason Evans | 7091b41 | 2012-03-19 09:36:44 -0700 | [diff] [blame] | 90 | if test -d "/usr/share/xml/docbook/stylesheet/docbook-xsl" ; then |
| 91 | DEFAULT_XSLROOT="/usr/share/xml/docbook/stylesheet/docbook-xsl" |
| 92 | elif test -d "/usr/share/sgml/docbook/xsl-stylesheets" ; then |
| 93 | DEFAULT_XSLROOT="/usr/share/sgml/docbook/xsl-stylesheets" |
| 94 | else |
| 95 | dnl Documentation building will fail if this default gets used. |
| 96 | DEFAULT_XSLROOT="" |
| 97 | fi |
Jason Evans | aee7fd2 | 2010-11-24 22:00:02 -0800 | [diff] [blame] | 98 | AC_ARG_WITH([xslroot], |
Jason Evans | 7091b41 | 2012-03-19 09:36:44 -0700 | [diff] [blame] | 99 | [AS_HELP_STRING([--with-xslroot=<path>], [XSL stylesheet root path])], [ |
Jason Evans | aee7fd2 | 2010-11-24 22:00:02 -0800 | [diff] [blame] | 100 | if test "x$with_xslroot" = "xno" ; then |
Jason Evans | 7091b41 | 2012-03-19 09:36:44 -0700 | [diff] [blame] | 101 | XSLROOT="${DEFAULT_XSLROOT}" |
Jason Evans | aee7fd2 | 2010-11-24 22:00:02 -0800 | [diff] [blame] | 102 | else |
| 103 | XSLROOT="${with_xslroot}" |
Jason Evans | 7091b41 | 2012-03-19 09:36:44 -0700 | [diff] [blame] | 104 | fi |
| 105 | ], |
| 106 | XSLROOT="${DEFAULT_XSLROOT}" |
Jason Evans | aee7fd2 | 2010-11-24 22:00:02 -0800 | [diff] [blame] | 107 | ) |
| 108 | AC_SUBST([XSLROOT]) |
| 109 | |
Jason Evans | f3340ca | 2009-06-30 16:17:05 -0700 | [diff] [blame] | 110 | dnl If CFLAGS isn't defined, set CFLAGS to something reasonable. Otherwise, |
| 111 | dnl just prevent autoconf from molesting CFLAGS. |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 112 | CFLAGS=$CFLAGS |
| 113 | AC_PROG_CC |
Mike Hommey | fd97b1d | 2012-04-30 12:38:31 +0200 | [diff] [blame] | 114 | if test "x$GCC" != "xyes" ; then |
| 115 | AC_CACHE_CHECK([whether compiler is MSVC], |
| 116 | [je_cv_msvc], |
| 117 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], |
| 118 | [ |
| 119 | #ifndef _MSC_VER |
| 120 | int fail[-1]; |
| 121 | #endif |
| 122 | ])], |
| 123 | [je_cv_msvc=yes], |
| 124 | [je_cv_msvc=no])]) |
| 125 | fi |
| 126 | |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 127 | if test "x$CFLAGS" = "x" ; then |
| 128 | no_CFLAGS="yes" |
Jason Evans | cfeccd3 | 2010-03-03 15:48:20 -0800 | [diff] [blame] | 129 | if test "x$GCC" = "xyes" ; then |
| 130 | JE_CFLAGS_APPEND([-std=gnu99]) |
| 131 | JE_CFLAGS_APPEND([-Wall]) |
| 132 | JE_CFLAGS_APPEND([-pipe]) |
| 133 | JE_CFLAGS_APPEND([-g3]) |
Mike Hommey | fd97b1d | 2012-04-30 12:38:31 +0200 | [diff] [blame] | 134 | elif test "x$je_cv_msvc" = "xyes" ; then |
| 135 | CC="$CC -nologo" |
| 136 | JE_CFLAGS_APPEND([-Zi]) |
| 137 | JE_CFLAGS_APPEND([-MT]) |
| 138 | JE_CFLAGS_APPEND([-W3]) |
| 139 | CPPFLAGS="$CPPFLAGS -I${srcroot}/include/msvc_compat" |
Jason Evans | cfeccd3 | 2010-03-03 15:48:20 -0800 | [diff] [blame] | 140 | fi |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 141 | fi |
| 142 | dnl Append EXTRA_CFLAGS to CFLAGS, if defined. |
| 143 | if test "x$EXTRA_CFLAGS" != "x" ; then |
Jason Evans | f3340ca | 2009-06-30 16:17:05 -0700 | [diff] [blame] | 144 | JE_CFLAGS_APPEND([$EXTRA_CFLAGS]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 145 | fi |
| 146 | AC_PROG_CPP |
| 147 | |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 148 | AC_CHECK_SIZEOF([void *]) |
| 149 | if test "x${ac_cv_sizeof_void_p}" = "x8" ; then |
Jason Evans | 94ad2b5 | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 150 | LG_SIZEOF_PTR=3 |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 151 | elif test "x${ac_cv_sizeof_void_p}" = "x4" ; then |
Jason Evans | 94ad2b5 | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 152 | LG_SIZEOF_PTR=2 |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 153 | else |
| 154 | AC_MSG_ERROR([Unsupported pointer size: ${ac_cv_sizeof_void_p}]) |
| 155 | fi |
Jason Evans | 94ad2b5 | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 156 | AC_DEFINE_UNQUOTED([LG_SIZEOF_PTR], [$LG_SIZEOF_PTR]) |
| 157 | |
| 158 | AC_CHECK_SIZEOF([int]) |
| 159 | if test "x${ac_cv_sizeof_int}" = "x8" ; then |
| 160 | LG_SIZEOF_INT=3 |
| 161 | elif test "x${ac_cv_sizeof_int}" = "x4" ; then |
| 162 | LG_SIZEOF_INT=2 |
| 163 | else |
| 164 | AC_MSG_ERROR([Unsupported int size: ${ac_cv_sizeof_int}]) |
| 165 | fi |
| 166 | AC_DEFINE_UNQUOTED([LG_SIZEOF_INT], [$LG_SIZEOF_INT]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 167 | |
Jason Evans | 84c8eef | 2011-03-16 10:30:13 -0700 | [diff] [blame] | 168 | AC_CHECK_SIZEOF([long]) |
| 169 | if test "x${ac_cv_sizeof_long}" = "x8" ; then |
| 170 | LG_SIZEOF_LONG=3 |
| 171 | elif test "x${ac_cv_sizeof_long}" = "x4" ; then |
| 172 | LG_SIZEOF_LONG=2 |
| 173 | else |
| 174 | AC_MSG_ERROR([Unsupported long size: ${ac_cv_sizeof_long}]) |
| 175 | fi |
| 176 | AC_DEFINE_UNQUOTED([LG_SIZEOF_LONG], [$LG_SIZEOF_LONG]) |
| 177 | |
Jason Evans | d81e4bd | 2012-03-06 14:57:45 -0800 | [diff] [blame] | 178 | AC_CHECK_SIZEOF([intmax_t]) |
| 179 | if test "x${ac_cv_sizeof_intmax_t}" = "x16" ; then |
| 180 | LG_SIZEOF_INTMAX_T=4 |
| 181 | elif test "x${ac_cv_sizeof_intmax_t}" = "x8" ; then |
| 182 | LG_SIZEOF_INTMAX_T=3 |
| 183 | elif test "x${ac_cv_sizeof_intmax_t}" = "x4" ; then |
| 184 | LG_SIZEOF_INTMAX_T=2 |
| 185 | else |
Mike Hommey | 14103d3 | 2012-04-20 08:38:39 +0200 | [diff] [blame] | 186 | AC_MSG_ERROR([Unsupported intmax_t size: ${ac_cv_sizeof_intmax_t}]) |
Jason Evans | d81e4bd | 2012-03-06 14:57:45 -0800 | [diff] [blame] | 187 | fi |
| 188 | AC_DEFINE_UNQUOTED([LG_SIZEOF_INTMAX_T], [$LG_SIZEOF_INTMAX_T]) |
| 189 | |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 190 | AC_CANONICAL_HOST |
| 191 | dnl CPU-specific settings. |
| 192 | CPU_SPINWAIT="" |
| 193 | case "${host_cpu}" in |
| 194 | i[[345]]86) |
| 195 | ;; |
| 196 | i686) |
Jason Evans | f3340ca | 2009-06-30 16:17:05 -0700 | [diff] [blame] | 197 | JE_COMPILABLE([__asm__], [], [[__asm__ volatile("pause"); return 0;]], |
Jason Evans | 6684cac | 2012-03-05 12:15:36 -0800 | [diff] [blame] | 198 | [je_cv_asm]) |
| 199 | if test "x${je_cv_asm}" = "xyes" ; then |
Jason Evans | f3340ca | 2009-06-30 16:17:05 -0700 | [diff] [blame] | 200 | CPU_SPINWAIT='__asm__ volatile("pause")' |
| 201 | fi |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 202 | ;; |
| 203 | x86_64) |
Jason Evans | f3340ca | 2009-06-30 16:17:05 -0700 | [diff] [blame] | 204 | JE_COMPILABLE([__asm__ syntax], [], |
Jason Evans | 6684cac | 2012-03-05 12:15:36 -0800 | [diff] [blame] | 205 | [[__asm__ volatile("pause"); return 0;]], [je_cv_asm]) |
| 206 | if test "x${je_cv_asm}" = "xyes" ; then |
Jason Evans | f3340ca | 2009-06-30 16:17:05 -0700 | [diff] [blame] | 207 | CPU_SPINWAIT='__asm__ volatile("pause")' |
| 208 | fi |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 209 | ;; |
| 210 | *) |
| 211 | ;; |
| 212 | esac |
| 213 | AC_DEFINE_UNQUOTED([CPU_SPINWAIT], [$CPU_SPINWAIT]) |
| 214 | |
Antony Dovgal | 2bd3cbc | 2011-10-13 09:33:33 +0400 | [diff] [blame] | 215 | LD_PRELOAD_VAR="LD_PRELOAD" |
Jason Evans | f576c63 | 2011-11-01 22:27:41 -0700 | [diff] [blame] | 216 | so="so" |
Mike Hommey | fd97b1d | 2012-04-30 12:38:31 +0200 | [diff] [blame] | 217 | importlib="${so}" |
Mike Hommey | 7cdea39 | 2012-04-30 12:38:27 +0200 | [diff] [blame] | 218 | o="$ac_objext" |
Mike Hommey | 5bee66d | 2012-04-16 16:30:24 +0200 | [diff] [blame] | 219 | a="a" |
Mike Hommey | 7cdea39 | 2012-04-30 12:38:27 +0200 | [diff] [blame] | 220 | exe="$ac_exeext" |
Mike Hommey | a19e87f | 2012-04-21 21:27:46 -0700 | [diff] [blame] | 221 | libprefix="lib" |
Mike Hommey | fa08da7 | 2012-04-16 16:30:25 +0200 | [diff] [blame] | 222 | DSO_LDFLAGS='-shared -Wl,-soname,$(@F)' |
| 223 | RPATH='-Wl,-rpath,$(1)' |
Mike Hommey | 7cdea39 | 2012-04-30 12:38:27 +0200 | [diff] [blame] | 224 | SOREV="${so}.${rev}" |
Mike Hommey | 188da7c | 2012-04-18 18:29:41 +0200 | [diff] [blame] | 225 | PIC_CFLAGS='-fPIC -DPIC' |
Mike Hommey | fd97b1d | 2012-04-30 12:38:31 +0200 | [diff] [blame] | 226 | CTARGET='-o $@' |
| 227 | LDTARGET='-o $@' |
| 228 | EXTRA_LDFLAGS= |
Jason Evans | 80ddf49 | 2013-08-20 11:48:19 +0100 | [diff] [blame] | 229 | ARFLAGS='crus' |
| 230 | AROUT=' $@' |
Mike Hommey | 79c4bca | 2012-05-02 21:30:51 +0200 | [diff] [blame] | 231 | CC_MM=1 |
Jason Evans | 7372b15 | 2012-02-10 20:22:09 -0800 | [diff] [blame] | 232 | |
Jory A. Pratt | ad505e0 | 2013-08-11 09:44:59 -0500 | [diff] [blame] | 233 | AN_MAKEVAR([AR], [AC_PROG_AR]) |
| 234 | AN_PROGRAM([ar], [AC_PROG_AR]) |
| 235 | AC_DEFUN([AC_PROG_AR], [AC_CHECK_TOOL(AR, ar, :)]) |
| 236 | AC_PROG_AR |
| 237 | |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 238 | dnl Platform-specific settings. abi and RPATH can probably be determined |
| 239 | dnl programmatically, but doing so is error-prone, which makes it generally |
| 240 | dnl not worth the trouble. |
| 241 | dnl |
| 242 | dnl Define cpp macros in CPPFLAGS, rather than doing AC_DEFINE(macro), since the |
| 243 | dnl definitions need to be seen before any headers are included, which is a pain |
| 244 | dnl to make happen otherwise. |
Jason Evans | 59ae276 | 2012-04-16 17:52:27 -0700 | [diff] [blame] | 245 | default_munmap="1" |
Jason Evans | 247d124 | 2012-10-09 16:20:10 -0700 | [diff] [blame] | 246 | JEMALLOC_USABLE_SIZE_CONST="const" |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 247 | case "${host}" in |
| 248 | *-*-darwin*) |
Mike Hommey | a6770a7 | 2012-05-03 14:12:49 +0200 | [diff] [blame] | 249 | CFLAGS="$CFLAGS" |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 250 | abi="macho" |
Jason Evans | e24c7af | 2012-03-19 10:21:17 -0700 | [diff] [blame] | 251 | AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 252 | RPATH="" |
Antony Dovgal | 2bd3cbc | 2011-10-13 09:33:33 +0400 | [diff] [blame] | 253 | LD_PRELOAD_VAR="DYLD_INSERT_LIBRARIES" |
Jason Evans | f576c63 | 2011-11-01 22:27:41 -0700 | [diff] [blame] | 254 | so="dylib" |
Mike Hommey | fd97b1d | 2012-04-30 12:38:31 +0200 | [diff] [blame] | 255 | importlib="${so}" |
Jason Evans | b80581d | 2012-03-23 16:17:43 -0700 | [diff] [blame] | 256 | force_tls="0" |
Mike Hommey | fa08da7 | 2012-04-16 16:30:25 +0200 | [diff] [blame] | 257 | DSO_LDFLAGS='-shared -Wl,-dylib_install_name,$(@F)' |
Mike Hommey | 7cdea39 | 2012-04-30 12:38:27 +0200 | [diff] [blame] | 258 | SOREV="${rev}.${so}" |
Jason Evans | 6668853 | 2013-12-03 21:49:36 -0800 | [diff] [blame] | 259 | sbrk_deprecated="1" |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 260 | ;; |
| 261 | *-*-freebsd*) |
| 262 | CFLAGS="$CFLAGS" |
| 263 | abi="elf" |
Jason Evans | e24c7af | 2012-03-19 10:21:17 -0700 | [diff] [blame] | 264 | AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ]) |
Jason Evans | fd4fcef | 2012-03-23 17:40:58 -0700 | [diff] [blame] | 265 | force_lazy_lock="1" |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 266 | ;; |
| 267 | *-*-linux*) |
| 268 | CFLAGS="$CFLAGS" |
| 269 | CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE" |
| 270 | abi="elf" |
Garrett Cooper | 13e4e24 | 2012-12-02 17:58:40 -0800 | [diff] [blame] | 271 | AC_DEFINE([JEMALLOC_HAS_ALLOCA_H]) |
Jason Evans | e24c7af | 2012-03-19 10:21:17 -0700 | [diff] [blame] | 272 | AC_DEFINE([JEMALLOC_PURGE_MADVISE_DONTNEED], [ ]) |
Jason Evans | 02b2312 | 2012-04-05 11:06:23 -0700 | [diff] [blame] | 273 | AC_DEFINE([JEMALLOC_THREADED_INIT], [ ]) |
Jason Evans | 247d124 | 2012-10-09 16:20:10 -0700 | [diff] [blame] | 274 | JEMALLOC_USABLE_SIZE_CONST="" |
Jason Evans | 59ae276 | 2012-04-16 17:52:27 -0700 | [diff] [blame] | 275 | default_munmap="0" |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 276 | ;; |
| 277 | *-*-netbsd*) |
| 278 | AC_MSG_CHECKING([ABI]) |
| 279 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM( |
| 280 | [[#ifdef __ELF__ |
| 281 | /* ELF */ |
| 282 | #else |
| 283 | #error aout |
| 284 | #endif |
| 285 | ]])], |
| 286 | [CFLAGS="$CFLAGS"; abi="elf"], |
| 287 | [abi="aout"]) |
| 288 | AC_MSG_RESULT([$abi]) |
Jason Evans | e24c7af | 2012-03-19 10:21:17 -0700 | [diff] [blame] | 289 | AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 290 | ;; |
| 291 | *-*-solaris2*) |
| 292 | CFLAGS="$CFLAGS" |
| 293 | abi="elf" |
Mike Hommey | fa08da7 | 2012-04-16 16:30:25 +0200 | [diff] [blame] | 294 | RPATH='-Wl,-R,$(1)' |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 295 | dnl Solaris needs this for sigwait(). |
| 296 | CPPFLAGS="$CPPFLAGS -D_POSIX_PTHREAD_SEMANTICS" |
| 297 | LIBS="$LIBS -lposix4 -lsocket -lnsl" |
| 298 | ;; |
Antony Dovgal | 2bd3cbc | 2011-10-13 09:33:33 +0400 | [diff] [blame] | 299 | *-ibm-aix*) |
| 300 | if "$LG_SIZEOF_PTR" = "8"; then |
| 301 | dnl 64bit AIX |
| 302 | LD_PRELOAD_VAR="LDR_PRELOAD64" |
| 303 | else |
| 304 | dnl 32bit AIX |
| 305 | LD_PRELOAD_VAR="LDR_PRELOAD" |
| 306 | fi |
| 307 | abi="xcoff" |
Antony Dovgal | 2bd3cbc | 2011-10-13 09:33:33 +0400 | [diff] [blame] | 308 | ;; |
Mike Hommey | a19e87f | 2012-04-21 21:27:46 -0700 | [diff] [blame] | 309 | *-*-mingw*) |
| 310 | abi="pecoff" |
| 311 | force_tls="0" |
| 312 | RPATH="" |
| 313 | so="dll" |
Mike Hommey | fd97b1d | 2012-04-30 12:38:31 +0200 | [diff] [blame] | 314 | if test "x$je_cv_msvc" = "xyes" ; then |
| 315 | importlib="lib" |
| 316 | DSO_LDFLAGS="-LD" |
| 317 | EXTRA_LDFLAGS="-link -DEBUG" |
| 318 | CTARGET='-Fo$@' |
| 319 | LDTARGET='-Fe$@' |
Jory A. Pratt | ad505e0 | 2013-08-11 09:44:59 -0500 | [diff] [blame] | 320 | AR='lib' |
| 321 | ARFLAGS='-nologo -out:' |
Jason Evans | 80ddf49 | 2013-08-20 11:48:19 +0100 | [diff] [blame] | 322 | AROUT='$@' |
Mike Hommey | 79c4bca | 2012-05-02 21:30:51 +0200 | [diff] [blame] | 323 | CC_MM= |
Mike Hommey | fd97b1d | 2012-04-30 12:38:31 +0200 | [diff] [blame] | 324 | else |
| 325 | importlib="${so}" |
| 326 | DSO_LDFLAGS="-shared" |
| 327 | fi |
Mike Hommey | a19e87f | 2012-04-21 21:27:46 -0700 | [diff] [blame] | 328 | a="lib" |
| 329 | libprefix="" |
Mike Hommey | 7cdea39 | 2012-04-30 12:38:27 +0200 | [diff] [blame] | 330 | SOREV="${so}" |
Mike Hommey | a19e87f | 2012-04-21 21:27:46 -0700 | [diff] [blame] | 331 | PIC_CFLAGS="" |
| 332 | ;; |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 333 | *) |
| 334 | AC_MSG_RESULT([Unsupported operating system: ${host}]) |
| 335 | abi="elf" |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 336 | ;; |
| 337 | esac |
Jason Evans | 247d124 | 2012-10-09 16:20:10 -0700 | [diff] [blame] | 338 | AC_DEFINE_UNQUOTED([JEMALLOC_USABLE_SIZE_CONST], [$JEMALLOC_USABLE_SIZE_CONST]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 339 | AC_SUBST([abi]) |
| 340 | AC_SUBST([RPATH]) |
Antony Dovgal | 2bd3cbc | 2011-10-13 09:33:33 +0400 | [diff] [blame] | 341 | AC_SUBST([LD_PRELOAD_VAR]) |
Jason Evans | f576c63 | 2011-11-01 22:27:41 -0700 | [diff] [blame] | 342 | AC_SUBST([so]) |
Mike Hommey | fd97b1d | 2012-04-30 12:38:31 +0200 | [diff] [blame] | 343 | AC_SUBST([importlib]) |
Mike Hommey | 5bee66d | 2012-04-16 16:30:24 +0200 | [diff] [blame] | 344 | AC_SUBST([o]) |
| 345 | AC_SUBST([a]) |
| 346 | AC_SUBST([exe]) |
Mike Hommey | a19e87f | 2012-04-21 21:27:46 -0700 | [diff] [blame] | 347 | AC_SUBST([libprefix]) |
Mike Hommey | fa08da7 | 2012-04-16 16:30:25 +0200 | [diff] [blame] | 348 | AC_SUBST([DSO_LDFLAGS]) |
Mike Hommey | fd97b1d | 2012-04-30 12:38:31 +0200 | [diff] [blame] | 349 | AC_SUBST([EXTRA_LDFLAGS]) |
Mike Hommey | 85221d5 | 2012-04-18 18:29:40 +0200 | [diff] [blame] | 350 | AC_SUBST([SOREV]) |
Mike Hommey | 188da7c | 2012-04-18 18:29:41 +0200 | [diff] [blame] | 351 | AC_SUBST([PIC_CFLAGS]) |
Mike Hommey | fd97b1d | 2012-04-30 12:38:31 +0200 | [diff] [blame] | 352 | AC_SUBST([CTARGET]) |
| 353 | AC_SUBST([LDTARGET]) |
| 354 | AC_SUBST([MKLIB]) |
Jason Evans | 80ddf49 | 2013-08-20 11:48:19 +0100 | [diff] [blame] | 355 | AC_SUBST([ARFLAGS]) |
| 356 | AC_SUBST([AROUT]) |
Mike Hommey | 79c4bca | 2012-05-02 21:30:51 +0200 | [diff] [blame] | 357 | AC_SUBST([CC_MM]) |
Mike Hommey | fd97b1d | 2012-04-30 12:38:31 +0200 | [diff] [blame] | 358 | |
Jason Evans | fa5d245 | 2011-03-15 10:25:59 -0700 | [diff] [blame] | 359 | JE_COMPILABLE([__attribute__ syntax], |
| 360 | [static __attribute__((unused)) void foo(void){}], |
| 361 | [], |
Jason Evans | 6684cac | 2012-03-05 12:15:36 -0800 | [diff] [blame] | 362 | [je_cv_attribute]) |
| 363 | if test "x${je_cv_attribute}" = "xyes" ; then |
Jason Evans | fa5d245 | 2011-03-15 10:25:59 -0700 | [diff] [blame] | 364 | AC_DEFINE([JEMALLOC_HAVE_ATTR], [ ]) |
| 365 | if test "x${GCC}" = "xyes" -a "x${abi}" = "xelf"; then |
| 366 | JE_CFLAGS_APPEND([-fvisibility=hidden]) |
| 367 | fi |
| 368 | fi |
Jason Evans | 3cc1f1a | 2012-04-03 22:30:05 -0700 | [diff] [blame] | 369 | dnl Check for tls_model attribute support (clang 3.0 still lacks support). |
| 370 | SAVED_CFLAGS="${CFLAGS}" |
| 371 | JE_CFLAGS_APPEND([-Werror]) |
| 372 | JE_COMPILABLE([tls_model attribute], [], |
| 373 | [static __thread int |
| 374 | __attribute__((tls_model("initial-exec"))) foo; |
| 375 | foo = 0;], |
| 376 | [je_cv_tls_model]) |
| 377 | CFLAGS="${SAVED_CFLAGS}" |
| 378 | if test "x${je_cv_tls_model}" = "xyes" ; then |
| 379 | AC_DEFINE([JEMALLOC_TLS_MODEL], |
| 380 | [__attribute__((tls_model("initial-exec")))]) |
| 381 | else |
| 382 | AC_DEFINE([JEMALLOC_TLS_MODEL], [ ]) |
| 383 | fi |
Jason Evans | fa5d245 | 2011-03-15 10:25:59 -0700 | [diff] [blame] | 384 | |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 385 | dnl Support optional additions to rpath. |
| 386 | AC_ARG_WITH([rpath], |
Jason Evans | 90895cf | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 387 | [AS_HELP_STRING([--with-rpath=<rpath>], [Colon-separated rpath (ELF systems only)])], |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 388 | if test "x$with_rpath" = "xno" ; then |
| 389 | RPATH_EXTRA= |
| 390 | else |
| 391 | RPATH_EXTRA="`echo $with_rpath | tr \":\" \" \"`" |
| 392 | fi, |
| 393 | RPATH_EXTRA= |
| 394 | ) |
| 395 | AC_SUBST([RPATH_EXTRA]) |
| 396 | |
| 397 | dnl Disable rules that do automatic regeneration of configure output by default. |
| 398 | AC_ARG_ENABLE([autogen], |
Jason Evans | 78d815c | 2010-01-17 14:06:20 -0800 | [diff] [blame] | 399 | [AS_HELP_STRING([--enable-autogen], [Automatically regenerate configure output])], |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 400 | if test "x$enable_autogen" = "xno" ; then |
| 401 | enable_autogen="0" |
| 402 | else |
| 403 | enable_autogen="1" |
| 404 | fi |
| 405 | , |
| 406 | enable_autogen="0" |
| 407 | ) |
| 408 | AC_SUBST([enable_autogen]) |
| 409 | |
| 410 | AC_PROG_INSTALL |
| 411 | AC_PROG_RANLIB |
Jason Evans | 7329a4f | 2013-01-22 10:53:29 -0800 | [diff] [blame] | 412 | AC_PATH_PROG([LD], [ld], [false], [$PATH]) |
| 413 | AC_PATH_PROG([AUTOCONF], [autoconf], [false], [$PATH]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 414 | |
Jason Evans | 0a0bbf6 | 2012-03-13 12:55:21 -0700 | [diff] [blame] | 415 | public_syms="malloc_conf malloc_message malloc calloc posix_memalign aligned_alloc realloc free malloc_usable_size malloc_stats_print mallctl mallctlnametomib mallctlbymib" |
Jason Evans | 7e77eaf | 2012-03-02 17:47:37 -0800 | [diff] [blame] | 416 | |
| 417 | dnl Check for allocator-related functions that should be wrapped. |
| 418 | AC_CHECK_FUNC([memalign], |
Jason Evans | e24c7af | 2012-03-19 10:21:17 -0700 | [diff] [blame] | 419 | [AC_DEFINE([JEMALLOC_OVERRIDE_MEMALIGN], [ ]) |
Jason Evans | 7e77eaf | 2012-03-02 17:47:37 -0800 | [diff] [blame] | 420 | public_syms="${public_syms} memalign"]) |
| 421 | AC_CHECK_FUNC([valloc], |
Jason Evans | e24c7af | 2012-03-19 10:21:17 -0700 | [diff] [blame] | 422 | [AC_DEFINE([JEMALLOC_OVERRIDE_VALLOC], [ ]) |
Jason Evans | 7e77eaf | 2012-03-02 17:47:37 -0800 | [diff] [blame] | 423 | public_syms="${public_syms} valloc"]) |
| 424 | |
| 425 | dnl Support the experimental API by default. |
| 426 | AC_ARG_ENABLE([experimental], |
| 427 | [AS_HELP_STRING([--disable-experimental], |
| 428 | [Disable support for the experimental API])], |
| 429 | [if test "x$enable_experimental" = "xno" ; then |
| 430 | enable_experimental="0" |
| 431 | else |
| 432 | enable_experimental="1" |
| 433 | fi |
| 434 | ], |
| 435 | [enable_experimental="1"] |
| 436 | ) |
| 437 | if test "x$enable_experimental" = "x1" ; then |
| 438 | AC_DEFINE([JEMALLOC_EXPERIMENTAL], [ ]) |
| 439 | public_syms="${public_syms} allocm dallocm nallocm rallocm sallocm" |
| 440 | fi |
| 441 | AC_SUBST([enable_experimental]) |
| 442 | |
Jason Evans | 748dfac | 2013-12-06 18:27:33 -0800 | [diff] [blame] | 443 | dnl Do not compute test code coverage by default. |
| 444 | GCOV_FLAGS= |
| 445 | AC_ARG_ENABLE([code-coverage], |
| 446 | [AS_HELP_STRING([--enable-code-coverage], |
| 447 | [Enable code coverage])], |
| 448 | [if test "x$enable_code_coverage" = "xno" ; then |
| 449 | enable_code_coverage="0" |
| 450 | else |
| 451 | enable_code_coverage="1" |
| 452 | fi |
| 453 | ], |
| 454 | [enable_code_coverage="0"] |
| 455 | ) |
| 456 | if test "x$enable_code_coverage" = "x1" ; then |
| 457 | deoptimize="no" |
| 458 | echo "$CFLAGS $EXTRA_CFLAGS" | grep '\-O' >/dev/null || deoptimize="yes" |
| 459 | if test "x${deoptimize}" = "xyes" ; then |
| 460 | JE_CFLAGS_APPEND([-O0]) |
| 461 | fi |
| 462 | JE_CFLAGS_APPEND([-fprofile-arcs -ftest-coverage]) |
| 463 | EXTRA_LDFLAGS="$EXTRA_LDFLAGS -fprofile-arcs -ftest-coverage" |
| 464 | AC_DEFINE([JEMALLOC_CODE_COVERAGE], [ ]) |
| 465 | fi |
| 466 | AC_SUBST([enable_code_coverage]) |
| 467 | |
Jason Evans | 0a5489e | 2012-03-01 17:19:20 -0800 | [diff] [blame] | 468 | dnl Perform no name mangling by default. |
| 469 | AC_ARG_WITH([mangling], |
| 470 | [AS_HELP_STRING([--with-mangling=<map>], [Mangle symbols in <map>])], |
| 471 | [mangling_map="$with_mangling"], [mangling_map=""]) |
| 472 | for nm in `echo ${mangling_map} |tr ',' ' '` ; do |
Jason Evans | 08fc3b2 | 2012-03-12 15:07:53 -0700 | [diff] [blame] | 473 | k="`echo ${nm} |tr ':' ' ' |awk '{print $1}'`" |
| 474 | n="je_${k}" |
Jason Evans | 0a5489e | 2012-03-01 17:19:20 -0800 | [diff] [blame] | 475 | m=`echo ${nm} |tr ':' ' ' |awk '{print $2}'` |
| 476 | AC_DEFINE_UNQUOTED([${n}], [${m}]) |
Jason Evans | 08fc3b2 | 2012-03-12 15:07:53 -0700 | [diff] [blame] | 477 | dnl Remove key from public_syms so that it isn't redefined later. |
| 478 | public_syms=`for sym in ${public_syms}; do echo "${sym}"; done |grep -v "^${k}\$" |tr '\n' ' '` |
Jason Evans | 0a5489e | 2012-03-01 17:19:20 -0800 | [diff] [blame] | 479 | done |
| 480 | |
Jason Evans | 90895cf | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 481 | dnl Do not prefix public APIs by default. |
| 482 | AC_ARG_WITH([jemalloc_prefix], |
| 483 | [AS_HELP_STRING([--with-jemalloc-prefix=<prefix>], [Prefix to prepend to all public APIs])], |
Jason Evans | b0fd501 | 2010-01-17 01:49:20 -0800 | [diff] [blame] | 484 | [JEMALLOC_PREFIX="$with_jemalloc_prefix"], |
Mike Hommey | 7cdea39 | 2012-04-30 12:38:27 +0200 | [diff] [blame] | 485 | [if test "x$abi" != "xmacho" -a "x$abi" != "xpecoff"; then |
Jason Evans | 2dbecf1 | 2010-09-05 10:35:13 -0700 | [diff] [blame] | 486 | JEMALLOC_PREFIX="" |
| 487 | else |
| 488 | JEMALLOC_PREFIX="je_" |
| 489 | fi] |
Jason Evans | 90895cf | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 490 | ) |
| 491 | if test "x$JEMALLOC_PREFIX" != "x" ; then |
Jason Evans | e733970 | 2010-10-23 18:37:06 -0700 | [diff] [blame] | 492 | JEMALLOC_CPREFIX=`echo ${JEMALLOC_PREFIX} | tr "a-z" "A-Z"` |
| 493 | AC_DEFINE_UNQUOTED([JEMALLOC_PREFIX], ["$JEMALLOC_PREFIX"]) |
| 494 | AC_DEFINE_UNQUOTED([JEMALLOC_CPREFIX], ["$JEMALLOC_CPREFIX"]) |
Jason Evans | 90895cf | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 495 | fi |
Jason Evans | 0a5489e | 2012-03-01 17:19:20 -0800 | [diff] [blame] | 496 | dnl Generate macros to rename public symbols. All public symbols are prefixed |
| 497 | dnl with je_ in the source code, so these macro definitions are needed even if |
| 498 | dnl --with-jemalloc-prefix wasn't specified. |
Jason Evans | 7e77eaf | 2012-03-02 17:47:37 -0800 | [diff] [blame] | 499 | for stem in ${public_syms}; do |
Jason Evans | 0a5489e | 2012-03-01 17:19:20 -0800 | [diff] [blame] | 500 | n="je_${stem}" |
| 501 | m="${JEMALLOC_PREFIX}${stem}" |
| 502 | AC_DEFINE_UNQUOTED([${n}], [${m}]) |
| 503 | done |
Jason Evans | 90895cf | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 504 | |
Mike Hommey | 9906660 | 2012-11-19 10:55:26 +0100 | [diff] [blame] | 505 | AC_ARG_WITH([export], |
| 506 | [AS_HELP_STRING([--without-export], [disable exporting jemalloc public APIs])], |
| 507 | [if test "x$with_export" = "xno"; then |
Jason Evans | 2625c89 | 2013-01-22 16:46:27 -0800 | [diff] [blame] | 508 | AC_DEFINE([JEMALLOC_EXPORT],[]) |
Mike Hommey | 9906660 | 2012-11-19 10:55:26 +0100 | [diff] [blame] | 509 | fi] |
| 510 | ) |
| 511 | |
Jason Evans | 86abd0d | 2013-11-30 15:25:42 -0800 | [diff] [blame] | 512 | dnl Mangle library-private APIs. |
Jason Evans | 746e77a | 2011-07-30 16:40:52 -0700 | [diff] [blame] | 513 | AC_ARG_WITH([private_namespace], |
| 514 | [AS_HELP_STRING([--with-private-namespace=<prefix>], [Prefix to prepend to all library-private APIs])], |
Jason Evans | 86abd0d | 2013-11-30 15:25:42 -0800 | [diff] [blame] | 515 | [JEMALLOC_PRIVATE_NAMESPACE="${with_private_namespace}je_"], |
| 516 | [JEMALLOC_PRIVATE_NAMESPACE="je_"] |
Jason Evans | 746e77a | 2011-07-30 16:40:52 -0700 | [diff] [blame] | 517 | ) |
Jason Evans | 86abd0d | 2013-11-30 15:25:42 -0800 | [diff] [blame] | 518 | AC_DEFINE_UNQUOTED([JEMALLOC_PRIVATE_NAMESPACE], [$JEMALLOC_PRIVATE_NAMESPACE]) |
| 519 | private_namespace="$JEMALLOC_PRIVATE_NAMESPACE" |
| 520 | AC_SUBST([private_namespace]) |
Jason Evans | 746e77a | 2011-07-30 16:40:52 -0700 | [diff] [blame] | 521 | |
Jason Evans | b0fd501 | 2010-01-17 01:49:20 -0800 | [diff] [blame] | 522 | dnl Do not add suffix to installed files by default. |
| 523 | AC_ARG_WITH([install_suffix], |
| 524 | [AS_HELP_STRING([--with-install-suffix=<suffix>], [Suffix to append to all installed files])], |
| 525 | [INSTALL_SUFFIX="$with_install_suffix"], |
| 526 | [INSTALL_SUFFIX=] |
| 527 | ) |
| 528 | install_suffix="$INSTALL_SUFFIX" |
| 529 | AC_SUBST([install_suffix]) |
| 530 | |
Jason Evans | 86abd0d | 2013-11-30 15:25:42 -0800 | [diff] [blame] | 531 | dnl Substitute @je_@ in jemalloc_protos.h.in, primarily to make generation of |
| 532 | dnl jemalloc_protos_jet.h easy. |
| 533 | je_="je_" |
| 534 | AC_SUBST([je_]) |
| 535 | |
Jason Evans | aee7fd2 | 2010-11-24 22:00:02 -0800 | [diff] [blame] | 536 | cfgoutputs_in="${srcroot}Makefile.in" |
| 537 | cfgoutputs_in="${cfgoutputs_in} ${srcroot}doc/html.xsl.in" |
| 538 | cfgoutputs_in="${cfgoutputs_in} ${srcroot}doc/manpages.xsl.in" |
| 539 | cfgoutputs_in="${cfgoutputs_in} ${srcroot}doc/jemalloc.xml.in" |
Jason Evans | 86abd0d | 2013-11-30 15:25:42 -0800 | [diff] [blame] | 540 | cfgoutputs_in="${cfgoutputs_in} ${srcroot}include/jemalloc/jemalloc_macros.h.in" |
| 541 | cfgoutputs_in="${cfgoutputs_in} ${srcroot}include/jemalloc/jemalloc_protos.h.in" |
| 542 | cfgoutputs_in="${cfgoutputs_in} ${srcroot}include/jemalloc/jemalloc_mangle.h.in" |
Jason Evans | 0656ec0 | 2010-04-07 23:37:35 -0700 | [diff] [blame] | 543 | cfgoutputs_in="${cfgoutputs_in} ${srcroot}include/jemalloc/internal/jemalloc_internal.h.in" |
Jason Evans | 86abd0d | 2013-11-30 15:25:42 -0800 | [diff] [blame] | 544 | cfgoutputs_in="${cfgoutputs_in} ${srcroot}test/test.sh.in" |
| 545 | cfgoutputs_in="${cfgoutputs_in} ${srcroot}test/include/test/jemalloc_test.h.in" |
Jason Evans | b0fd501 | 2010-01-17 01:49:20 -0800 | [diff] [blame] | 546 | |
Jason Evans | aee7fd2 | 2010-11-24 22:00:02 -0800 | [diff] [blame] | 547 | cfgoutputs_out="Makefile" |
| 548 | cfgoutputs_out="${cfgoutputs_out} doc/html.xsl" |
| 549 | cfgoutputs_out="${cfgoutputs_out} doc/manpages.xsl" |
Jason Evans | 86abd0d | 2013-11-30 15:25:42 -0800 | [diff] [blame] | 550 | cfgoutputs_out="${cfgoutputs_out} doc/jemalloc.xml" |
| 551 | cfgoutputs_out="${cfgoutputs_out} include/jemalloc/jemalloc_macros.h" |
| 552 | cfgoutputs_out="${cfgoutputs_out} include/jemalloc/jemalloc_protos.h" |
| 553 | cfgoutputs_out="${cfgoutputs_out} include/jemalloc/jemalloc_mangle.h" |
Jason Evans | 376b152 | 2010-02-11 14:45:59 -0800 | [diff] [blame] | 554 | cfgoutputs_out="${cfgoutputs_out} include/jemalloc/internal/jemalloc_internal.h" |
Jason Evans | 86abd0d | 2013-11-30 15:25:42 -0800 | [diff] [blame] | 555 | cfgoutputs_out="${cfgoutputs_out} test/test.sh" |
| 556 | cfgoutputs_out="${cfgoutputs_out} test/include/test/jemalloc_test.h" |
Jason Evans | b0fd501 | 2010-01-17 01:49:20 -0800 | [diff] [blame] | 557 | |
Jason Evans | aee7fd2 | 2010-11-24 22:00:02 -0800 | [diff] [blame] | 558 | cfgoutputs_tup="Makefile" |
| 559 | cfgoutputs_tup="${cfgoutputs_tup} doc/html.xsl:doc/html.xsl.in" |
| 560 | cfgoutputs_tup="${cfgoutputs_tup} doc/manpages.xsl:doc/manpages.xsl.in" |
Jason Evans | 86abd0d | 2013-11-30 15:25:42 -0800 | [diff] [blame] | 561 | cfgoutputs_tup="${cfgoutputs_tup} doc/jemalloc.xml:doc/jemalloc.xml.in" |
| 562 | cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/jemalloc_macros.h:include/jemalloc/jemalloc_macros.h.in" |
| 563 | cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/jemalloc_protos.h:include/jemalloc/jemalloc_protos.h.in" |
| 564 | cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/jemalloc_mangle.h:include/jemalloc/jemalloc_mangle.h.in" |
Jason Evans | 376b152 | 2010-02-11 14:45:59 -0800 | [diff] [blame] | 565 | cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/internal/jemalloc_internal.h" |
Jason Evans | 86abd0d | 2013-11-30 15:25:42 -0800 | [diff] [blame] | 566 | cfgoutputs_tup="${cfgoutputs_tup} test/test.sh:test/test.sh.in" |
| 567 | cfgoutputs_tup="${cfgoutputs_tup} test/include/test/jemalloc_test.h:test/include/test/jemalloc_test.h.in" |
Jason Evans | b0fd501 | 2010-01-17 01:49:20 -0800 | [diff] [blame] | 568 | |
Jason Evans | 0656ec0 | 2010-04-07 23:37:35 -0700 | [diff] [blame] | 569 | cfghdrs_in="${srcroot}include/jemalloc/jemalloc_defs.h.in" |
Jason Evans | 86abd0d | 2013-11-30 15:25:42 -0800 | [diff] [blame] | 570 | cfghdrs_in="${cfghdrs_in} ${srcroot}include/jemalloc/internal/jemalloc_internal_defs.h.in" |
| 571 | cfghdrs_in="${cfghdrs_in} ${srcroot}include/jemalloc/internal/private_namespace.sh" |
| 572 | cfghdrs_in="${cfghdrs_in} ${srcroot}include/jemalloc/internal/private_unnamespace.sh" |
| 573 | cfghdrs_in="${cfghdrs_in} ${srcroot}include/jemalloc/internal/public_namespace.sh" |
| 574 | cfghdrs_in="${cfghdrs_in} ${srcroot}include/jemalloc/internal/public_unnamespace.sh" |
Jason Evans | b172610 | 2012-02-28 16:50:47 -0800 | [diff] [blame] | 575 | cfghdrs_in="${cfghdrs_in} ${srcroot}include/jemalloc/internal/size_classes.sh" |
Jason Evans | dc1bed6 | 2013-12-05 21:43:46 -0800 | [diff] [blame] | 576 | cfghdrs_in="${cfghdrs_in} ${srcroot}include/jemalloc/jemalloc.sh" |
Jason Evans | b0fd501 | 2010-01-17 01:49:20 -0800 | [diff] [blame] | 577 | |
Jason Evans | 86abd0d | 2013-11-30 15:25:42 -0800 | [diff] [blame] | 578 | cfghdrs_out="include/jemalloc/jemalloc_defs.h" |
| 579 | cfghdrs_out="${cfghdrs_out} include/jemalloc/jemalloc${install_suffix}.h" |
| 580 | cfghdrs_out="${cfghdrs_out} include/jemalloc/jemalloc_protos_jet.h" |
| 581 | cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/jemalloc_internal_defs.h" |
| 582 | cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/private_namespace.h" |
| 583 | cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/private_unnamespace.h" |
| 584 | cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/public_namespace.h" |
| 585 | cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/public_unnamespace.h" |
Jason Evans | b172610 | 2012-02-28 16:50:47 -0800 | [diff] [blame] | 586 | cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/size_classes.h" |
Jason Evans | b0fd501 | 2010-01-17 01:49:20 -0800 | [diff] [blame] | 587 | |
Jason Evans | 86abd0d | 2013-11-30 15:25:42 -0800 | [diff] [blame] | 588 | cfghdrs_tup="include/jemalloc/jemalloc_defs.h:include/jemalloc/jemalloc_defs.h.in" |
| 589 | cfghdrs_tup="${cfghdrs_tup} include/jemalloc/internal/jemalloc_internal_defs.h:${srcroot}include/jemalloc/internal/jemalloc_internal_defs.h.in" |
Jason Evans | b0fd501 | 2010-01-17 01:49:20 -0800 | [diff] [blame] | 590 | |
Jason Evans | 355b438 | 2010-09-20 19:20:48 -0700 | [diff] [blame] | 591 | dnl Do not silence irrelevant compiler warnings by default, since enabling this |
| 592 | dnl option incurs a performance penalty. |
| 593 | AC_ARG_ENABLE([cc-silence], |
| 594 | [AS_HELP_STRING([--enable-cc-silence], |
| 595 | [Silence irrelevant compiler warnings])], |
| 596 | [if test "x$enable_cc_silence" = "xno" ; then |
| 597 | enable_cc_silence="0" |
| 598 | else |
| 599 | enable_cc_silence="1" |
| 600 | fi |
| 601 | ], |
| 602 | [enable_cc_silence="0"] |
| 603 | ) |
| 604 | if test "x$enable_cc_silence" = "x1" ; then |
Jason Evans | e24c7af | 2012-03-19 10:21:17 -0700 | [diff] [blame] | 605 | AC_DEFINE([JEMALLOC_CC_SILENCE], [ ]) |
Jason Evans | 355b438 | 2010-09-20 19:20:48 -0700 | [diff] [blame] | 606 | fi |
| 607 | |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 608 | dnl Do not compile with debugging by default. |
| 609 | AC_ARG_ENABLE([debug], |
Mike Hommey | 5135e34 | 2012-12-06 22:16:26 +0100 | [diff] [blame] | 610 | [AS_HELP_STRING([--enable-debug], [Build debugging code (implies --enable-ivsalloc)])], |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 611 | [if test "x$enable_debug" = "xno" ; then |
| 612 | enable_debug="0" |
| 613 | else |
| 614 | enable_debug="1" |
| 615 | fi |
| 616 | ], |
| 617 | [enable_debug="0"] |
| 618 | ) |
| 619 | if test "x$enable_debug" = "x1" ; then |
| 620 | AC_DEFINE([JEMALLOC_DEBUG], [ ]) |
Mike Hommey | 5135e34 | 2012-12-06 22:16:26 +0100 | [diff] [blame] | 621 | enable_ivsalloc="1" |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 622 | fi |
| 623 | AC_SUBST([enable_debug]) |
| 624 | |
Mike Hommey | 5135e34 | 2012-12-06 22:16:26 +0100 | [diff] [blame] | 625 | dnl Do not validate pointers by default. |
| 626 | AC_ARG_ENABLE([ivsalloc], |
| 627 | [AS_HELP_STRING([--enable-ivsalloc], [Validate pointers passed through the public API])], |
| 628 | [if test "x$enable_ivsalloc" = "xno" ; then |
| 629 | enable_ivsalloc="0" |
| 630 | else |
| 631 | enable_ivsalloc="1" |
| 632 | fi |
| 633 | ], |
| 634 | [enable_ivsalloc="0"] |
| 635 | ) |
| 636 | if test "x$enable_ivsalloc" = "x1" ; then |
| 637 | AC_DEFINE([JEMALLOC_IVSALLOC], [ ]) |
| 638 | fi |
| 639 | |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 640 | dnl Only optimize if not debugging. |
| 641 | if test "x$enable_debug" = "x0" -a "x$no_CFLAGS" = "xyes" ; then |
| 642 | dnl Make sure that an optimization flag was not specified in EXTRA_CFLAGS. |
Jason Evans | f3340ca | 2009-06-30 16:17:05 -0700 | [diff] [blame] | 643 | optimize="no" |
Jason Evans | 748dfac | 2013-12-06 18:27:33 -0800 | [diff] [blame] | 644 | echo "$CFLAGS $EXTRA_CFLAGS" | grep '\-O' >/dev/null || optimize="yes" |
Jason Evans | f3340ca | 2009-06-30 16:17:05 -0700 | [diff] [blame] | 645 | if test "x${optimize}" = "xyes" ; then |
| 646 | if test "x$GCC" = "xyes" ; then |
| 647 | JE_CFLAGS_APPEND([-O3]) |
| 648 | JE_CFLAGS_APPEND([-funroll-loops]) |
Mike Hommey | fd97b1d | 2012-04-30 12:38:31 +0200 | [diff] [blame] | 649 | elif test "x$je_cv_msvc" = "xyes" ; then |
| 650 | JE_CFLAGS_APPEND([-O2]) |
Jason Evans | f3340ca | 2009-06-30 16:17:05 -0700 | [diff] [blame] | 651 | else |
| 652 | JE_CFLAGS_APPEND([-O]) |
| 653 | fi |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 654 | fi |
| 655 | fi |
| 656 | |
Jason Evans | d073a32 | 2012-02-28 20:41:16 -0800 | [diff] [blame] | 657 | dnl Enable statistics calculation by default. |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 658 | AC_ARG_ENABLE([stats], |
Jason Evans | 777c191 | 2012-02-28 20:49:22 -0800 | [diff] [blame] | 659 | [AS_HELP_STRING([--disable-stats], |
| 660 | [Disable statistics calculation/reporting])], |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 661 | [if test "x$enable_stats" = "xno" ; then |
| 662 | enable_stats="0" |
| 663 | else |
| 664 | enable_stats="1" |
| 665 | fi |
| 666 | ], |
Jason Evans | d073a32 | 2012-02-28 20:41:16 -0800 | [diff] [blame] | 667 | [enable_stats="1"] |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 668 | ) |
| 669 | if test "x$enable_stats" = "x1" ; then |
| 670 | AC_DEFINE([JEMALLOC_STATS], [ ]) |
| 671 | fi |
| 672 | AC_SUBST([enable_stats]) |
| 673 | |
Jason Evans | 6109fe0 | 2010-02-10 10:37:56 -0800 | [diff] [blame] | 674 | dnl Do not enable profiling by default. |
| 675 | AC_ARG_ENABLE([prof], |
| 676 | [AS_HELP_STRING([--enable-prof], [Enable allocation profiling])], |
| 677 | [if test "x$enable_prof" = "xno" ; then |
| 678 | enable_prof="0" |
| 679 | else |
| 680 | enable_prof="1" |
| 681 | fi |
| 682 | ], |
| 683 | [enable_prof="0"] |
| 684 | ) |
Jason Evans | 77f350b | 2011-03-15 22:23:12 -0700 | [diff] [blame] | 685 | if test "x$enable_prof" = "x1" ; then |
| 686 | backtrace_method="" |
Jason Evans | b27805b | 2010-02-10 18:15:53 -0800 | [diff] [blame] | 687 | else |
Jason Evans | 77f350b | 2011-03-15 22:23:12 -0700 | [diff] [blame] | 688 | backtrace_method="N/A" |
Jason Evans | b27805b | 2010-02-10 18:15:53 -0800 | [diff] [blame] | 689 | fi |
Jason Evans | 77f350b | 2011-03-15 22:23:12 -0700 | [diff] [blame] | 690 | |
Jason Evans | 6109fe0 | 2010-02-10 10:37:56 -0800 | [diff] [blame] | 691 | AC_ARG_ENABLE([prof-libunwind], |
| 692 | [AS_HELP_STRING([--enable-prof-libunwind], [Use libunwind for backtracing])], |
| 693 | [if test "x$enable_prof_libunwind" = "xno" ; then |
| 694 | enable_prof_libunwind="0" |
| 695 | else |
| 696 | enable_prof_libunwind="1" |
| 697 | fi |
| 698 | ], |
| 699 | [enable_prof_libunwind="0"] |
| 700 | ) |
Jason Evans | ca6bd4f | 2010-03-02 14:12:58 -0800 | [diff] [blame] | 701 | AC_ARG_WITH([static_libunwind], |
| 702 | [AS_HELP_STRING([--with-static-libunwind=<libunwind.a>], |
| 703 | [Path to static libunwind library; use rather than dynamically linking])], |
| 704 | if test "x$with_static_libunwind" = "xno" ; then |
| 705 | LUNWIND="-lunwind" |
| 706 | else |
| 707 | if test ! -f "$with_static_libunwind" ; then |
| 708 | AC_MSG_ERROR([Static libunwind not found: $with_static_libunwind]) |
| 709 | fi |
| 710 | LUNWIND="$with_static_libunwind" |
| 711 | fi, |
| 712 | LUNWIND="-lunwind" |
| 713 | ) |
Jason Evans | 77f350b | 2011-03-15 22:23:12 -0700 | [diff] [blame] | 714 | if test "x$backtrace_method" = "x" -a "x$enable_prof_libunwind" = "x1" ; then |
| 715 | AC_CHECK_HEADERS([libunwind.h], , [enable_prof_libunwind="0"]) |
| 716 | if test "x$LUNWIND" = "x-lunwind" ; then |
| 717 | AC_CHECK_LIB([unwind], [backtrace], [LIBS="$LIBS $LUNWIND"], |
| 718 | [enable_prof_libunwind="0"]) |
| 719 | else |
| 720 | LIBS="$LIBS $LUNWIND" |
| 721 | fi |
| 722 | if test "x${enable_prof_libunwind}" = "x1" ; then |
| 723 | backtrace_method="libunwind" |
| 724 | AC_DEFINE([JEMALLOC_PROF_LIBUNWIND], [ ]) |
| 725 | fi |
| 726 | fi |
| 727 | |
| 728 | AC_ARG_ENABLE([prof-libgcc], |
| 729 | [AS_HELP_STRING([--disable-prof-libgcc], |
| 730 | [Do not use libgcc for backtracing])], |
| 731 | [if test "x$enable_prof_libgcc" = "xno" ; then |
| 732 | enable_prof_libgcc="0" |
| 733 | else |
| 734 | enable_prof_libgcc="1" |
| 735 | fi |
| 736 | ], |
| 737 | [enable_prof_libgcc="1"] |
| 738 | ) |
| 739 | if test "x$backtrace_method" = "x" -a "x$enable_prof_libgcc" = "x1" \ |
| 740 | -a "x$GCC" = "xyes" ; then |
| 741 | AC_CHECK_HEADERS([unwind.h], , [enable_prof_libgcc="0"]) |
| 742 | AC_CHECK_LIB([gcc], [_Unwind_Backtrace], [LIBS="$LIBS -lgcc"], [enable_prof_libgcc="0"]) |
| 743 | dnl The following is conservative, in that it only has entries for CPUs on |
| 744 | dnl which jemalloc has been tested. |
| 745 | AC_MSG_CHECKING([libgcc-based backtracing reliability on ${host_cpu}]) |
| 746 | case "${host_cpu}" in |
| 747 | i[[3456]]86) |
| 748 | AC_MSG_RESULT([unreliable]) |
| 749 | enable_prof_libgcc="0"; |
| 750 | ;; |
| 751 | x86_64) |
| 752 | AC_MSG_RESULT([reliable]) |
| 753 | ;; |
| 754 | *) |
| 755 | AC_MSG_RESULT([unreliable]) |
| 756 | enable_prof_libgcc="0"; |
| 757 | ;; |
| 758 | esac |
| 759 | if test "x${enable_prof_libgcc}" = "x1" ; then |
| 760 | backtrace_method="libgcc" |
| 761 | AC_DEFINE([JEMALLOC_PROF_LIBGCC], [ ]) |
| 762 | fi |
| 763 | else |
| 764 | enable_prof_libgcc="0" |
| 765 | fi |
| 766 | |
| 767 | AC_ARG_ENABLE([prof-gcc], |
| 768 | [AS_HELP_STRING([--disable-prof-gcc], |
| 769 | [Do not use gcc intrinsics for backtracing])], |
| 770 | [if test "x$enable_prof_gcc" = "xno" ; then |
| 771 | enable_prof_gcc="0" |
| 772 | else |
| 773 | enable_prof_gcc="1" |
| 774 | fi |
| 775 | ], |
| 776 | [enable_prof_gcc="1"] |
| 777 | ) |
| 778 | if test "x$backtrace_method" = "x" -a "x$enable_prof_gcc" = "x1" \ |
| 779 | -a "x$GCC" = "xyes" ; then |
| 780 | backtrace_method="gcc intrinsics" |
| 781 | AC_DEFINE([JEMALLOC_PROF_GCC], [ ]) |
| 782 | else |
| 783 | enable_prof_gcc="0" |
| 784 | fi |
| 785 | |
| 786 | if test "x$backtrace_method" = "x" ; then |
| 787 | backtrace_method="none (disabling profiling)" |
| 788 | enable_prof="0" |
| 789 | fi |
| 790 | AC_MSG_CHECKING([configured backtracing method]) |
| 791 | AC_MSG_RESULT([$backtrace_method]) |
Jason Evans | 2dbecf1 | 2010-09-05 10:35:13 -0700 | [diff] [blame] | 792 | if test "x$enable_prof" = "x1" ; then |
Jason Evans | 6716aa8 | 2012-04-23 13:04:55 -0700 | [diff] [blame] | 793 | if test "x${force_tls}" = "x0" ; then |
| 794 | AC_MSG_ERROR([Heap profiling requires TLS]); |
| 795 | fi |
| 796 | force_tls="1" |
Jason Evans | d37d5ad | 2013-12-05 23:01:50 -0800 | [diff] [blame] | 797 | |
| 798 | if test "x$abi" != "xpecoff"; then |
| 799 | dnl Heap profiling uses the log(3) function. |
| 800 | LIBS="$LIBS -lm" |
| 801 | fi |
| 802 | |
Jason Evans | 2dbecf1 | 2010-09-05 10:35:13 -0700 | [diff] [blame] | 803 | AC_DEFINE([JEMALLOC_PROF], [ ]) |
Jason Evans | 2dbecf1 | 2010-09-05 10:35:13 -0700 | [diff] [blame] | 804 | fi |
| 805 | AC_SUBST([enable_prof]) |
Jason Evans | 2dbecf1 | 2010-09-05 10:35:13 -0700 | [diff] [blame] | 806 | |
Jason Evans | 84cbbcb | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 807 | dnl Enable thread-specific caching by default. |
| 808 | AC_ARG_ENABLE([tcache], |
| 809 | [AS_HELP_STRING([--disable-tcache], [Disable per thread caches])], |
| 810 | [if test "x$enable_tcache" = "xno" ; then |
| 811 | enable_tcache="0" |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 812 | else |
Jason Evans | 84cbbcb | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 813 | enable_tcache="1" |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 814 | fi |
| 815 | ], |
Jason Evans | 84cbbcb | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 816 | [enable_tcache="1"] |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 817 | ) |
Jason Evans | 2dbecf1 | 2010-09-05 10:35:13 -0700 | [diff] [blame] | 818 | if test "x$enable_tcache" = "x1" ; then |
| 819 | AC_DEFINE([JEMALLOC_TCACHE], [ ]) |
| 820 | fi |
| 821 | AC_SUBST([enable_tcache]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 822 | |
Jason Evans | 2e671ff | 2012-05-09 16:12:00 -0700 | [diff] [blame] | 823 | dnl Disable mremap() for huge realloc() by default. |
| 824 | AC_ARG_ENABLE([mremap], |
| 825 | [AS_HELP_STRING([--enable-mremap], [Enable mremap(2) for huge realloc()])], |
| 826 | [if test "x$enable_mremap" = "xno" ; then |
| 827 | enable_mremap="0" |
| 828 | else |
| 829 | enable_mremap="1" |
| 830 | fi |
| 831 | ], |
| 832 | [enable_mremap="0"] |
| 833 | ) |
| 834 | if test "x$enable_mremap" = "x1" ; then |
| 835 | JE_COMPILABLE([mremap(...MREMAP_FIXED...)], [ |
Jason Evans | a4f124f | 2013-12-08 22:28:27 -0800 | [diff] [blame^] | 836 | #define _GNU_SOURCE |
Jason Evans | 2e671ff | 2012-05-09 16:12:00 -0700 | [diff] [blame] | 837 | #include <sys/mman.h> |
| 838 | ], [ |
| 839 | void *p = mremap((void *)0, 0, 0, MREMAP_MAYMOVE|MREMAP_FIXED, (void *)0); |
| 840 | ], [je_cv_mremap_fixed]) |
| 841 | if test "x${je_cv_mremap_fixed}" = "xno" ; then |
| 842 | enable_mremap="0" |
| 843 | fi |
| 844 | fi |
| 845 | if test "x$enable_mremap" = "x1" ; then |
| 846 | AC_DEFINE([JEMALLOC_MREMAP], [ ]) |
| 847 | fi |
| 848 | AC_SUBST([enable_mremap]) |
| 849 | |
Jason Evans | 59ae276 | 2012-04-16 17:52:27 -0700 | [diff] [blame] | 850 | dnl Enable VM deallocation via munmap() by default. |
| 851 | AC_ARG_ENABLE([munmap], |
| 852 | [AS_HELP_STRING([--disable-munmap], [Disable VM deallocation via munmap(2)])], |
| 853 | [if test "x$enable_munmap" = "xno" ; then |
| 854 | enable_munmap="0" |
| 855 | else |
| 856 | enable_munmap="1" |
| 857 | fi |
| 858 | ], |
| 859 | [enable_munmap="${default_munmap}"] |
| 860 | ) |
| 861 | if test "x$enable_munmap" = "x1" ; then |
| 862 | AC_DEFINE([JEMALLOC_MUNMAP], [ ]) |
| 863 | fi |
| 864 | AC_SUBST([enable_munmap]) |
| 865 | |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 866 | dnl Do not enable allocation from DSS by default. |
| 867 | AC_ARG_ENABLE([dss], |
| 868 | [AS_HELP_STRING([--enable-dss], [Enable allocation from DSS])], |
| 869 | [if test "x$enable_dss" = "xno" ; then |
| 870 | enable_dss="0" |
| 871 | else |
| 872 | enable_dss="1" |
| 873 | fi |
| 874 | ], |
| 875 | [enable_dss="0"] |
| 876 | ) |
Mike Hommey | 83c324a | 2012-04-12 10:13:03 +0200 | [diff] [blame] | 877 | dnl Check whether the BSD/SUSv1 sbrk() exists. If not, disable DSS support. |
| 878 | AC_CHECK_FUNC([sbrk], [have_sbrk="1"], [have_sbrk="0"]) |
| 879 | if test "x$have_sbrk" = "x1" ; then |
Jason Evans | 6668853 | 2013-12-03 21:49:36 -0800 | [diff] [blame] | 880 | if test "x$sbrk_deprecated" == "x1" ; then |
| 881 | AC_MSG_RESULT([Disabling dss allocation because sbrk is deprecated]) |
| 882 | enable_dss="0" |
| 883 | else |
| 884 | AC_DEFINE([JEMALLOC_HAVE_SBRK], [ ]) |
| 885 | fi |
Mike Hommey | 83c324a | 2012-04-12 10:13:03 +0200 | [diff] [blame] | 886 | else |
| 887 | enable_dss="0" |
| 888 | fi |
| 889 | |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 890 | if test "x$enable_dss" = "x1" ; then |
| 891 | AC_DEFINE([JEMALLOC_DSS], [ ]) |
| 892 | fi |
| 893 | AC_SUBST([enable_dss]) |
| 894 | |
Jason Evans | 777c191 | 2012-02-28 20:49:22 -0800 | [diff] [blame] | 895 | dnl Support the junk/zero filling option by default. |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 896 | AC_ARG_ENABLE([fill], |
Jason Evans | 122449b | 2012-04-06 00:35:09 -0700 | [diff] [blame] | 897 | [AS_HELP_STRING([--disable-fill], |
| 898 | [Disable support for junk/zero filling, quarantine, and redzones])], |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 899 | [if test "x$enable_fill" = "xno" ; then |
| 900 | enable_fill="0" |
| 901 | else |
| 902 | enable_fill="1" |
| 903 | fi |
| 904 | ], |
Jason Evans | 777c191 | 2012-02-28 20:49:22 -0800 | [diff] [blame] | 905 | [enable_fill="1"] |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 906 | ) |
| 907 | if test "x$enable_fill" = "x1" ; then |
| 908 | AC_DEFINE([JEMALLOC_FILL], [ ]) |
| 909 | fi |
| 910 | AC_SUBST([enable_fill]) |
| 911 | |
Jason Evans | b147611 | 2012-04-05 13:36:17 -0700 | [diff] [blame] | 912 | dnl Disable utrace(2)-based tracing by default. |
| 913 | AC_ARG_ENABLE([utrace], |
| 914 | [AS_HELP_STRING([--enable-utrace], [Enable utrace(2)-based tracing])], |
| 915 | [if test "x$enable_utrace" = "xno" ; then |
| 916 | enable_utrace="0" |
| 917 | else |
| 918 | enable_utrace="1" |
| 919 | fi |
| 920 | ], |
| 921 | [enable_utrace="0"] |
| 922 | ) |
| 923 | JE_COMPILABLE([utrace(2)], [ |
| 924 | #include <sys/types.h> |
| 925 | #include <sys/param.h> |
| 926 | #include <sys/time.h> |
| 927 | #include <sys/uio.h> |
| 928 | #include <sys/ktrace.h> |
| 929 | ], [ |
| 930 | utrace((void *)0, 0); |
| 931 | ], [je_cv_utrace]) |
| 932 | if test "x${je_cv_utrace}" = "xno" ; then |
| 933 | enable_utrace="0" |
| 934 | fi |
| 935 | if test "x$enable_utrace" = "x1" ; then |
| 936 | AC_DEFINE([JEMALLOC_UTRACE], [ ]) |
| 937 | fi |
| 938 | AC_SUBST([enable_utrace]) |
| 939 | |
Jason Evans | 122449b | 2012-04-06 00:35:09 -0700 | [diff] [blame] | 940 | dnl Support Valgrind by default. |
| 941 | AC_ARG_ENABLE([valgrind], |
| 942 | [AS_HELP_STRING([--disable-valgrind], [Disable support for Valgrind])], |
| 943 | [if test "x$enable_valgrind" = "xno" ; then |
| 944 | enable_valgrind="0" |
| 945 | else |
| 946 | enable_valgrind="1" |
| 947 | fi |
| 948 | ], |
| 949 | [enable_valgrind="1"] |
| 950 | ) |
| 951 | if test "x$enable_valgrind" = "x1" ; then |
| 952 | JE_COMPILABLE([valgrind], [ |
| 953 | #include <valgrind/valgrind.h> |
| 954 | #include <valgrind/memcheck.h> |
| 955 | |
Mike Hommey | 7bfecf4 | 2012-04-30 15:15:15 +0200 | [diff] [blame] | 956 | #if !defined(VALGRIND_RESIZEINPLACE_BLOCK) |
Jason Evans | 122449b | 2012-04-06 00:35:09 -0700 | [diff] [blame] | 957 | # error "Incompatible Valgrind version" |
| 958 | #endif |
| 959 | ], [], [je_cv_valgrind]) |
| 960 | if test "x${je_cv_valgrind}" = "xno" ; then |
| 961 | enable_valgrind="0" |
| 962 | fi |
| 963 | if test "x$enable_valgrind" = "x1" ; then |
| 964 | AC_DEFINE([JEMALLOC_VALGRIND], [ ]) |
| 965 | fi |
| 966 | fi |
| 967 | AC_SUBST([enable_valgrind]) |
| 968 | |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 969 | dnl Do not support the xmalloc option by default. |
| 970 | AC_ARG_ENABLE([xmalloc], |
| 971 | [AS_HELP_STRING([--enable-xmalloc], [Support xmalloc option])], |
| 972 | [if test "x$enable_xmalloc" = "xno" ; then |
| 973 | enable_xmalloc="0" |
| 974 | else |
| 975 | enable_xmalloc="1" |
| 976 | fi |
| 977 | ], |
| 978 | [enable_xmalloc="0"] |
| 979 | ) |
| 980 | if test "x$enable_xmalloc" = "x1" ; then |
| 981 | AC_DEFINE([JEMALLOC_XMALLOC], [ ]) |
| 982 | fi |
| 983 | AC_SUBST([enable_xmalloc]) |
| 984 | |
Jason Evans | 6684cac | 2012-03-05 12:15:36 -0800 | [diff] [blame] | 985 | AC_CACHE_CHECK([STATIC_PAGE_SHIFT], |
| 986 | [je_cv_static_page_shift], |
| 987 | AC_RUN_IFELSE([AC_LANG_PROGRAM( |
Mike Hommey | a19e87f | 2012-04-21 21:27:46 -0700 | [diff] [blame] | 988 | [[ |
Mike Hommey | fd97b1d | 2012-04-30 12:38:31 +0200 | [diff] [blame] | 989 | #include <strings.h> |
Mike Hommey | a19e87f | 2012-04-21 21:27:46 -0700 | [diff] [blame] | 990 | #ifdef _WIN32 |
| 991 | #include <windows.h> |
| 992 | #else |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 993 | #include <unistd.h> |
Mike Hommey | a19e87f | 2012-04-21 21:27:46 -0700 | [diff] [blame] | 994 | #endif |
| 995 | #include <stdio.h> |
Jason Evans | 6684cac | 2012-03-05 12:15:36 -0800 | [diff] [blame] | 996 | ]], |
| 997 | [[ |
Garrett Cooper | 72c1e59 | 2012-12-02 17:57:28 -0800 | [diff] [blame] | 998 | int result; |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 999 | FILE *f; |
| 1000 | |
Mike Hommey | a19e87f | 2012-04-21 21:27:46 -0700 | [diff] [blame] | 1001 | #ifdef _WIN32 |
| 1002 | SYSTEM_INFO si; |
| 1003 | GetSystemInfo(&si); |
| 1004 | result = si.dwPageSize; |
| 1005 | #else |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1006 | result = sysconf(_SC_PAGESIZE); |
Mike Hommey | a19e87f | 2012-04-21 21:27:46 -0700 | [diff] [blame] | 1007 | #endif |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1008 | if (result == -1) { |
| 1009 | return 1; |
| 1010 | } |
Mike Hommey | a19e87f | 2012-04-21 21:27:46 -0700 | [diff] [blame] | 1011 | result = ffsl(result) - 1; |
| 1012 | |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1013 | f = fopen("conftest.out", "w"); |
| 1014 | if (f == NULL) { |
| 1015 | return 1; |
| 1016 | } |
Garrett Cooper | 72c1e59 | 2012-12-02 17:57:28 -0800 | [diff] [blame] | 1017 | fprintf(f, "%d\n", result); |
Jason Evans | 3cc1f1a | 2012-04-03 22:30:05 -0700 | [diff] [blame] | 1018 | fclose(f); |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1019 | |
| 1020 | return 0; |
| 1021 | ]])], |
Jason Evans | 6684cac | 2012-03-05 12:15:36 -0800 | [diff] [blame] | 1022 | [je_cv_static_page_shift=`cat conftest.out`], |
| 1023 | [je_cv_static_page_shift=undefined])) |
| 1024 | |
| 1025 | if test "x$je_cv_static_page_shift" != "xundefined"; then |
| 1026 | AC_DEFINE_UNQUOTED([STATIC_PAGE_SHIFT], [$je_cv_static_page_shift]) |
| 1027 | else |
| 1028 | AC_MSG_ERROR([cannot determine value for STATIC_PAGE_SHIFT]) |
| 1029 | fi |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1030 | |
| 1031 | dnl ============================================================================ |
| 1032 | dnl jemalloc configuration. |
| 1033 | dnl |
Jason Evans | a40bc7a | 2010-03-02 13:01:16 -0800 | [diff] [blame] | 1034 | |
| 1035 | dnl Set VERSION if source directory has an embedded git repository. |
Jason Evans | 955851f | 2011-03-31 22:38:51 -0700 | [diff] [blame] | 1036 | if test -d "${srcroot}.git" ; then |
Jason Evans | 79d660d | 2010-09-17 17:38:24 -0700 | [diff] [blame] | 1037 | git describe --long --abbrev=40 > ${srcroot}VERSION |
Jason Evans | a40bc7a | 2010-03-02 13:01:16 -0800 | [diff] [blame] | 1038 | fi |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1039 | jemalloc_version=`cat ${srcroot}VERSION` |
Jason Evans | a40bc7a | 2010-03-02 13:01:16 -0800 | [diff] [blame] | 1040 | jemalloc_version_major=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]1}'` |
| 1041 | jemalloc_version_minor=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]2}'` |
| 1042 | jemalloc_version_bugfix=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]3}'` |
| 1043 | jemalloc_version_nrev=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]4}'` |
| 1044 | jemalloc_version_gid=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]5}'` |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1045 | AC_SUBST([jemalloc_version]) |
Jason Evans | a40bc7a | 2010-03-02 13:01:16 -0800 | [diff] [blame] | 1046 | AC_SUBST([jemalloc_version_major]) |
| 1047 | AC_SUBST([jemalloc_version_minor]) |
| 1048 | AC_SUBST([jemalloc_version_bugfix]) |
| 1049 | AC_SUBST([jemalloc_version_nrev]) |
| 1050 | AC_SUBST([jemalloc_version_gid]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1051 | |
| 1052 | dnl ============================================================================ |
| 1053 | dnl Configure pthreads. |
| 1054 | |
Mike Hommey | a19e87f | 2012-04-21 21:27:46 -0700 | [diff] [blame] | 1055 | if test "x$abi" != "xpecoff" ; then |
| 1056 | AC_CHECK_HEADERS([pthread.h], , [AC_MSG_ERROR([pthread.h is missing])]) |
| 1057 | dnl Some systems may embed pthreads functionality in libc; check for libpthread |
| 1058 | dnl first, but try libc too before failing. |
| 1059 | AC_CHECK_LIB([pthread], [pthread_create], [LIBS="$LIBS -lpthread"], |
| 1060 | [AC_SEARCH_LIBS([pthread_create], , , |
| 1061 | AC_MSG_ERROR([libpthread is missing]))]) |
| 1062 | fi |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1063 | |
| 1064 | CPPFLAGS="$CPPFLAGS -D_REENTRANT" |
| 1065 | |
Jason Evans | cd9a134 | 2012-03-21 18:33:03 -0700 | [diff] [blame] | 1066 | dnl Check whether the BSD-specific _malloc_thread_cleanup() exists. If so, use |
| 1067 | dnl it rather than pthreads TSD cleanup functions to support cleanup during |
| 1068 | dnl thread exit, in order to avoid pthreads library recursion during |
| 1069 | dnl bootstrapping. |
Jason Evans | cd9a134 | 2012-03-21 18:33:03 -0700 | [diff] [blame] | 1070 | AC_CHECK_FUNC([_malloc_thread_cleanup], |
| 1071 | [have__malloc_thread_cleanup="1"], |
| 1072 | [have__malloc_thread_cleanup="0"] |
| 1073 | ) |
| 1074 | if test "x$have__malloc_thread_cleanup" = "x1" ; then |
| 1075 | AC_DEFINE([JEMALLOC_MALLOC_THREAD_CLEANUP], [ ]) |
| 1076 | force_tls="1" |
| 1077 | fi |
| 1078 | |
Jason Evans | 41b6afb | 2012-02-02 22:04:57 -0800 | [diff] [blame] | 1079 | dnl Check whether the BSD-specific _pthread_mutex_init_calloc_cb() exists. If |
| 1080 | dnl so, mutex initialization causes allocation, and we need to implement this |
| 1081 | dnl callback function in order to prevent recursive allocation. |
| 1082 | AC_CHECK_FUNC([_pthread_mutex_init_calloc_cb], |
| 1083 | [have__pthread_mutex_init_calloc_cb="1"], |
| 1084 | [have__pthread_mutex_init_calloc_cb="0"] |
| 1085 | ) |
| 1086 | if test "x$have__pthread_mutex_init_calloc_cb" = "x1" ; then |
| 1087 | AC_DEFINE([JEMALLOC_MUTEX_INIT_CB]) |
| 1088 | fi |
| 1089 | |
Jason Evans | 0fee70d | 2012-02-13 12:36:11 -0800 | [diff] [blame] | 1090 | dnl Disable lazy locking by default. |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1091 | AC_ARG_ENABLE([lazy_lock], |
Jason Evans | 0fee70d | 2012-02-13 12:36:11 -0800 | [diff] [blame] | 1092 | [AS_HELP_STRING([--enable-lazy-lock], |
| 1093 | [Enable lazy locking (only lock when multi-threaded)])], |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1094 | [if test "x$enable_lazy_lock" = "xno" ; then |
| 1095 | enable_lazy_lock="0" |
| 1096 | else |
| 1097 | enable_lazy_lock="1" |
| 1098 | fi |
| 1099 | ], |
Jason Evans | 0fee70d | 2012-02-13 12:36:11 -0800 | [diff] [blame] | 1100 | [enable_lazy_lock="0"] |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1101 | ) |
Jason Evans | fd4fcef | 2012-03-23 17:40:58 -0700 | [diff] [blame] | 1102 | if test "x$enable_lazy_lock" = "x0" -a "x${force_lazy_lock}" = "x1" ; then |
| 1103 | AC_MSG_RESULT([Forcing lazy-lock to avoid allocator/threading bootstrap issues]) |
| 1104 | enable_lazy_lock="1" |
| 1105 | fi |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1106 | if test "x$enable_lazy_lock" = "x1" ; then |
Mike Hommey | a19e87f | 2012-04-21 21:27:46 -0700 | [diff] [blame] | 1107 | if test "x$abi" != "xpecoff" ; then |
| 1108 | AC_CHECK_HEADERS([dlfcn.h], , [AC_MSG_ERROR([dlfcn.h is missing])]) |
| 1109 | AC_CHECK_FUNC([dlsym], [], |
| 1110 | [AC_CHECK_LIB([dl], [dlsym], [LIBS="$LIBS -ldl"], |
| 1111 | [AC_MSG_ERROR([libdl is missing])]) |
| 1112 | ]) |
| 1113 | fi |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1114 | AC_DEFINE([JEMALLOC_LAZY_LOCK], [ ]) |
| 1115 | fi |
| 1116 | AC_SUBST([enable_lazy_lock]) |
| 1117 | |
Jason Evans | 78d815c | 2010-01-17 14:06:20 -0800 | [diff] [blame] | 1118 | AC_ARG_ENABLE([tls], |
| 1119 | [AS_HELP_STRING([--disable-tls], [Disable thread-local storage (__thread keyword)])], |
| 1120 | if test "x$enable_tls" = "xno" ; then |
| 1121 | enable_tls="0" |
| 1122 | else |
| 1123 | enable_tls="1" |
| 1124 | fi |
| 1125 | , |
| 1126 | enable_tls="1" |
| 1127 | ) |
Jason Evans | cd9a134 | 2012-03-21 18:33:03 -0700 | [diff] [blame] | 1128 | if test "x${enable_tls}" = "x0" -a "x${force_tls}" = "x1" ; then |
| 1129 | AC_MSG_RESULT([Forcing TLS to avoid allocator/threading bootstrap issues]) |
| 1130 | enable_tls="1" |
| 1131 | fi |
Jason Evans | b80581d | 2012-03-23 16:17:43 -0700 | [diff] [blame] | 1132 | if test "x${enable_tls}" = "x1" -a "x${force_tls}" = "x0" ; then |
| 1133 | AC_MSG_RESULT([Forcing no TLS to avoid allocator/threading bootstrap issues]) |
| 1134 | enable_tls="0" |
| 1135 | fi |
Jason Evans | 78d815c | 2010-01-17 14:06:20 -0800 | [diff] [blame] | 1136 | if test "x${enable_tls}" = "x1" ; then |
| 1137 | AC_MSG_CHECKING([for TLS]) |
Jason Evans | 6684cac | 2012-03-05 12:15:36 -0800 | [diff] [blame] | 1138 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM( |
Jason Evans | 78d815c | 2010-01-17 14:06:20 -0800 | [diff] [blame] | 1139 | [[ |
| 1140 | __thread int x; |
| 1141 | ]], [[ |
| 1142 | x = 42; |
| 1143 | |
| 1144 | return 0; |
| 1145 | ]])], |
| 1146 | AC_MSG_RESULT([yes]), |
| 1147 | AC_MSG_RESULT([no]) |
| 1148 | enable_tls="0") |
| 1149 | fi |
Jason Evans | b267d0f | 2010-08-13 15:42:29 -0700 | [diff] [blame] | 1150 | AC_SUBST([enable_tls]) |
Jason Evans | e24c7af | 2012-03-19 10:21:17 -0700 | [diff] [blame] | 1151 | if test "x${enable_tls}" = "x1" ; then |
| 1152 | AC_DEFINE_UNQUOTED([JEMALLOC_TLS], [ ]) |
Jason Evans | cd9a134 | 2012-03-21 18:33:03 -0700 | [diff] [blame] | 1153 | elif test "x${force_tls}" = "x1" ; then |
| 1154 | AC_MSG_ERROR([Failed to configure TLS, which is mandatory for correct function]) |
Jason Evans | 78d815c | 2010-01-17 14:06:20 -0800 | [diff] [blame] | 1155 | fi |
| 1156 | |
Jason Evans | 2dbecf1 | 2010-09-05 10:35:13 -0700 | [diff] [blame] | 1157 | dnl ============================================================================ |
Jason Evans | 84c8eef | 2011-03-16 10:30:13 -0700 | [diff] [blame] | 1158 | dnl Check for ffsl(3), and fail if not found. This function exists on all |
| 1159 | dnl platforms that jemalloc currently has a chance of functioning on without |
| 1160 | dnl modification. |
Jason Evans | 4c2faa8 | 2012-03-13 11:09:23 -0700 | [diff] [blame] | 1161 | JE_COMPILABLE([a program using ffsl], [ |
Garrett Cooper | 72c1e59 | 2012-12-02 17:57:28 -0800 | [diff] [blame] | 1162 | #include <stdio.h> |
Jason Evans | 382132e | 2012-04-04 15:25:43 -0700 | [diff] [blame] | 1163 | #include <strings.h> |
Jason Evans | 4c2faa8 | 2012-03-13 11:09:23 -0700 | [diff] [blame] | 1164 | #include <string.h> |
| 1165 | ], [ |
| 1166 | { |
| 1167 | int rv = ffsl(0x08); |
Garrett Cooper | 72c1e59 | 2012-12-02 17:57:28 -0800 | [diff] [blame] | 1168 | printf("%d\n", rv); |
Jason Evans | 4c2faa8 | 2012-03-13 11:09:23 -0700 | [diff] [blame] | 1169 | } |
| 1170 | ], [je_cv_function_ffsl]) |
Jason Evans | 6684cac | 2012-03-05 12:15:36 -0800 | [diff] [blame] | 1171 | if test "x${je_cv_function_ffsl}" != "xyes" ; then |
| 1172 | AC_MSG_ERROR([Cannot build without ffsl(3)]) |
| 1173 | fi |
Jason Evans | 84c8eef | 2011-03-16 10:30:13 -0700 | [diff] [blame] | 1174 | |
| 1175 | dnl ============================================================================ |
Jason Evans | b57d3ec | 2012-04-17 13:17:54 -0700 | [diff] [blame] | 1176 | dnl Check for atomic(9) operations as provided on FreeBSD. |
| 1177 | |
| 1178 | JE_COMPILABLE([atomic(9)], [ |
| 1179 | #include <sys/types.h> |
| 1180 | #include <machine/atomic.h> |
| 1181 | #include <inttypes.h> |
| 1182 | ], [ |
| 1183 | { |
| 1184 | uint32_t x32 = 0; |
| 1185 | volatile uint32_t *x32p = &x32; |
| 1186 | atomic_fetchadd_32(x32p, 1); |
| 1187 | } |
| 1188 | { |
| 1189 | unsigned long xlong = 0; |
| 1190 | volatile unsigned long *xlongp = &xlong; |
| 1191 | atomic_fetchadd_long(xlongp, 1); |
| 1192 | } |
| 1193 | ], [je_cv_atomic9]) |
| 1194 | if test "x${je_cv_atomic9}" = "xyes" ; then |
| 1195 | AC_DEFINE([JEMALLOC_ATOMIC9]) |
| 1196 | fi |
| 1197 | |
| 1198 | dnl ============================================================================ |
Jason Evans | 763baa6 | 2011-03-18 19:10:31 -0700 | [diff] [blame] | 1199 | dnl Check for atomic(3) operations as provided on Darwin. |
| 1200 | |
| 1201 | JE_COMPILABLE([Darwin OSAtomic*()], [ |
| 1202 | #include <libkern/OSAtomic.h> |
| 1203 | #include <inttypes.h> |
| 1204 | ], [ |
| 1205 | { |
| 1206 | int32_t x32 = 0; |
| 1207 | volatile int32_t *x32p = &x32; |
| 1208 | OSAtomicAdd32(1, x32p); |
| 1209 | } |
| 1210 | { |
| 1211 | int64_t x64 = 0; |
| 1212 | volatile int64_t *x64p = &x64; |
| 1213 | OSAtomicAdd64(1, x64p); |
| 1214 | } |
Jason Evans | 6684cac | 2012-03-05 12:15:36 -0800 | [diff] [blame] | 1215 | ], [je_cv_osatomic]) |
| 1216 | if test "x${je_cv_osatomic}" = "xyes" ; then |
Jason Evans | e24c7af | 2012-03-19 10:21:17 -0700 | [diff] [blame] | 1217 | AC_DEFINE([JEMALLOC_OSATOMIC], [ ]) |
Jason Evans | 763baa6 | 2011-03-18 19:10:31 -0700 | [diff] [blame] | 1218 | fi |
| 1219 | |
| 1220 | dnl ============================================================================ |
Mike Hommey | c1e567b | 2012-03-26 17:03:41 +0200 | [diff] [blame] | 1221 | dnl Check whether __sync_{add,sub}_and_fetch() are available despite |
| 1222 | dnl __GCC_HAVE_SYNC_COMPARE_AND_SWAP_n macros being undefined. |
| 1223 | |
| 1224 | AC_DEFUN([JE_SYNC_COMPARE_AND_SWAP_CHECK],[ |
| 1225 | AC_CACHE_CHECK([whether to force $1-bit __sync_{add,sub}_and_fetch()], |
| 1226 | [je_cv_sync_compare_and_swap_$2], |
Mike Hommey | 2cfe6d6 | 2012-03-27 15:03:07 +0200 | [diff] [blame] | 1227 | [AC_LINK_IFELSE([AC_LANG_PROGRAM([ |
| 1228 | #include <stdint.h> |
| 1229 | ], |
| 1230 | [ |
| 1231 | #ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_$2 |
| 1232 | { |
| 1233 | uint$1_t x$1 = 0; |
| 1234 | __sync_add_and_fetch(&x$1, 42); |
| 1235 | __sync_sub_and_fetch(&x$1, 1); |
| 1236 | } |
| 1237 | #else |
| 1238 | #error __GCC_HAVE_SYNC_COMPARE_AND_SWAP_$2 is defined, no need to force |
| 1239 | #endif |
| 1240 | ])], |
Mike Hommey | c1e567b | 2012-03-26 17:03:41 +0200 | [diff] [blame] | 1241 | [je_cv_sync_compare_and_swap_$2=yes], |
| 1242 | [je_cv_sync_compare_and_swap_$2=no])]) |
| 1243 | |
| 1244 | if test "x${je_cv_sync_compare_and_swap_$2}" = "xyes" ; then |
| 1245 | AC_DEFINE([JE_FORCE_SYNC_COMPARE_AND_SWAP_$2], [ ]) |
| 1246 | fi |
| 1247 | ]) |
| 1248 | |
Jason Evans | b57d3ec | 2012-04-17 13:17:54 -0700 | [diff] [blame] | 1249 | if test "x${je_cv_atomic9}" != "xyes" -a "x${je_cv_osatomic}" != "xyes" ; then |
Mike Hommey | c1e567b | 2012-03-26 17:03:41 +0200 | [diff] [blame] | 1250 | JE_SYNC_COMPARE_AND_SWAP_CHECK(32, 4) |
| 1251 | JE_SYNC_COMPARE_AND_SWAP_CHECK(64, 8) |
| 1252 | fi |
| 1253 | |
| 1254 | dnl ============================================================================ |
Jason Evans | 893a0ed | 2011-03-18 19:30:18 -0700 | [diff] [blame] | 1255 | dnl Check for spinlock(3) operations as provided on Darwin. |
| 1256 | |
| 1257 | JE_COMPILABLE([Darwin OSSpin*()], [ |
| 1258 | #include <libkern/OSAtomic.h> |
| 1259 | #include <inttypes.h> |
| 1260 | ], [ |
| 1261 | OSSpinLock lock = 0; |
| 1262 | OSSpinLockLock(&lock); |
| 1263 | OSSpinLockUnlock(&lock); |
Jason Evans | 6684cac | 2012-03-05 12:15:36 -0800 | [diff] [blame] | 1264 | ], [je_cv_osspin]) |
| 1265 | if test "x${je_cv_osspin}" = "xyes" ; then |
Jason Evans | e24c7af | 2012-03-19 10:21:17 -0700 | [diff] [blame] | 1266 | AC_DEFINE([JEMALLOC_OSSPIN], [ ]) |
Jason Evans | 893a0ed | 2011-03-18 19:30:18 -0700 | [diff] [blame] | 1267 | fi |
| 1268 | |
| 1269 | dnl ============================================================================ |
Jason Evans | 2dbecf1 | 2010-09-05 10:35:13 -0700 | [diff] [blame] | 1270 | dnl Darwin-related configuration. |
Jason Evans | 78d815c | 2010-01-17 14:06:20 -0800 | [diff] [blame] | 1271 | |
Mike Hommey | d0357f7 | 2012-11-26 18:52:41 +0100 | [diff] [blame] | 1272 | AC_ARG_ENABLE([zone-allocator], |
| 1273 | [AS_HELP_STRING([--disable-zone-allocator], |
| 1274 | [Disable zone allocator for Darwin])], |
| 1275 | [if test "x$enable_zone_allocator" = "xno" ; then |
| 1276 | enable_zone_allocator="0" |
| 1277 | else |
| 1278 | enable_zone_allocator="1" |
| 1279 | fi |
| 1280 | ], |
| 1281 | [if test "x${abi}" = "xmacho"; then |
| 1282 | enable_zone_allocator="1" |
| 1283 | fi |
| 1284 | ] |
| 1285 | ) |
| 1286 | AC_SUBST([enable_zone_allocator]) |
| 1287 | |
| 1288 | if test "x${enable_zone_allocator}" = "x1" ; then |
| 1289 | if test "x${abi}" != "xmacho"; then |
| 1290 | AC_MSG_ERROR([--enable-zone-allocator is only supported on Darwin]) |
| 1291 | fi |
Jason Evans | e24c7af | 2012-03-19 10:21:17 -0700 | [diff] [blame] | 1292 | AC_DEFINE([JEMALLOC_IVSALLOC], [ ]) |
| 1293 | AC_DEFINE([JEMALLOC_ZONE], [ ]) |
Jason Evans | 6109fe0 | 2010-02-10 10:37:56 -0800 | [diff] [blame] | 1294 | |
Jason Evans | 2dbecf1 | 2010-09-05 10:35:13 -0700 | [diff] [blame] | 1295 | dnl The szone version jumped from 3 to 6 between the OS X 10.5.x and 10.6 |
| 1296 | dnl releases. malloc_zone_t and malloc_introspection_t have new fields in |
| 1297 | dnl 10.6, which is the only source-level indication of the change. |
| 1298 | AC_MSG_CHECKING([malloc zone version]) |
Mike Hommey | 154829d | 2012-03-20 18:01:38 +0100 | [diff] [blame] | 1299 | AC_DEFUN([JE_ZONE_PROGRAM], |
| 1300 | [AC_LANG_PROGRAM( |
| 1301 | [#include <malloc/malloc.h>], |
| 1302 | [static foo[[sizeof($1) $2 sizeof(void *) * $3 ? 1 : -1]]] |
| 1303 | )]) |
Jason Evans | 2dbecf1 | 2010-09-05 10:35:13 -0700 | [diff] [blame] | 1304 | |
Mike Hommey | 154829d | 2012-03-20 18:01:38 +0100 | [diff] [blame] | 1305 | AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,14)],[JEMALLOC_ZONE_VERSION=3],[ |
| 1306 | AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,15)],[JEMALLOC_ZONE_VERSION=5],[ |
| 1307 | AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,16)],[ |
| 1308 | AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_introspection_t,==,9)],[JEMALLOC_ZONE_VERSION=6],[ |
| 1309 | AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_introspection_t,==,13)],[JEMALLOC_ZONE_VERSION=7],[JEMALLOC_ZONE_VERSION=] |
| 1310 | )])],[ |
| 1311 | AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,17)],[JEMALLOC_ZONE_VERSION=8],[ |
| 1312 | AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,>,17)],[JEMALLOC_ZONE_VERSION=9],[JEMALLOC_ZONE_VERSION=] |
| 1313 | )])])])]) |
| 1314 | if test "x${JEMALLOC_ZONE_VERSION}" = "x"; then |
| 1315 | AC_MSG_RESULT([unsupported]) |
| 1316 | AC_MSG_ERROR([Unsupported malloc zone version]) |
| 1317 | fi |
| 1318 | if test "${JEMALLOC_ZONE_VERSION}" = 9; then |
| 1319 | JEMALLOC_ZONE_VERSION=8 |
| 1320 | AC_MSG_RESULT([> 8]) |
| 1321 | else |
| 1322 | AC_MSG_RESULT([$JEMALLOC_ZONE_VERSION]) |
| 1323 | fi |
| 1324 | AC_DEFINE_UNQUOTED(JEMALLOC_ZONE_VERSION, [$JEMALLOC_ZONE_VERSION]) |
Jason Evans | b27805b | 2010-02-10 18:15:53 -0800 | [diff] [blame] | 1325 | fi |
| 1326 | |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1327 | dnl ============================================================================ |
| 1328 | dnl Check for typedefs, structures, and compiler characteristics. |
| 1329 | AC_HEADER_STDBOOL |
| 1330 | |
Jason Evans | 748dfac | 2013-12-06 18:27:33 -0800 | [diff] [blame] | 1331 | dnl ============================================================================ |
| 1332 | dnl Define commands that generate output files. |
| 1333 | |
Jason Evans | 86abd0d | 2013-11-30 15:25:42 -0800 | [diff] [blame] | 1334 | AC_CONFIG_COMMANDS([include/jemalloc/internal/private_namespace.h], [ |
| 1335 | mkdir -p "${objroot}include/jemalloc/internal" |
| 1336 | "${srcdir}/include/jemalloc/internal/private_namespace.sh" "${srcdir}/include/jemalloc/internal/private_symbols.txt" > "${objroot}include/jemalloc/internal/private_namespace.h" |
| 1337 | ]) |
| 1338 | AC_CONFIG_COMMANDS([include/jemalloc/internal/private_unnamespace.h], [ |
| 1339 | mkdir -p "${objroot}include/jemalloc/internal" |
| 1340 | "${srcdir}/include/jemalloc/internal/private_unnamespace.sh" "${srcdir}/include/jemalloc/internal/private_symbols.txt" > "${objroot}include/jemalloc/internal/private_unnamespace.h" |
| 1341 | ]) |
| 1342 | AC_CONFIG_COMMANDS([include/jemalloc/internal/public_namespace.h], [ |
| 1343 | mkdir -p "${objroot}include/jemalloc/internal" |
| 1344 | "${srcdir}/include/jemalloc/internal/public_namespace.sh" "${srcdir}/include/jemalloc/internal/public_symbols.txt" > "${objroot}include/jemalloc/internal/public_namespace.h" |
| 1345 | ]) |
| 1346 | AC_CONFIG_COMMANDS([include/jemalloc/internal/public_unnamespace.h], [ |
| 1347 | mkdir -p "${objroot}include/jemalloc/internal" |
| 1348 | "${srcdir}/include/jemalloc/internal/public_unnamespace.sh" "${srcdir}/include/jemalloc/internal/public_symbols.txt" > "${objroot}include/jemalloc/internal/public_unnamespace.h" |
| 1349 | ]) |
Jason Evans | b172610 | 2012-02-28 16:50:47 -0800 | [diff] [blame] | 1350 | AC_CONFIG_COMMANDS([include/jemalloc/internal/size_classes.h], [ |
Jason Evans | 86abd0d | 2013-11-30 15:25:42 -0800 | [diff] [blame] | 1351 | mkdir -p "${objroot}include/jemalloc/internal" |
Jason Evans | b172610 | 2012-02-28 16:50:47 -0800 | [diff] [blame] | 1352 | "${srcdir}/include/jemalloc/internal/size_classes.sh" > "${objroot}include/jemalloc/internal/size_classes.h" |
| 1353 | ]) |
Jason Evans | 86abd0d | 2013-11-30 15:25:42 -0800 | [diff] [blame] | 1354 | AC_CONFIG_COMMANDS([include/jemalloc/jemalloc_protos_jet.h], [ |
| 1355 | mkdir -p "${objroot}include/jemalloc" |
| 1356 | cat "${srcdir}/include/jemalloc/jemalloc_protos.h.in" | sed -e 's/@je_@/jet_/g' > "${objroot}include/jemalloc/jemalloc_protos_jet.h" |
| 1357 | ]) |
| 1358 | AC_CONFIG_COMMANDS([include/jemalloc/jemalloc.h], [ |
| 1359 | mkdir -p "${objroot}include/jemalloc" |
| 1360 | "${srcdir}/include/jemalloc/jemalloc.sh" "${objroot}" > "${objroot}include/jemalloc/jemalloc${install_suffix}.h" |
| 1361 | ]) |
Jason Evans | b172610 | 2012-02-28 16:50:47 -0800 | [diff] [blame] | 1362 | |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1363 | dnl Process .in files. |
Jason Evans | b0fd501 | 2010-01-17 01:49:20 -0800 | [diff] [blame] | 1364 | AC_SUBST([cfghdrs_in]) |
| 1365 | AC_SUBST([cfghdrs_out]) |
Jason Evans | 0656ec0 | 2010-04-07 23:37:35 -0700 | [diff] [blame] | 1366 | AC_CONFIG_HEADERS([$cfghdrs_tup]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1367 | |
| 1368 | dnl ============================================================================ |
| 1369 | dnl Generate outputs. |
Jason Evans | 748dfac | 2013-12-06 18:27:33 -0800 | [diff] [blame] | 1370 | |
Antony Dovgal | 2bd3cbc | 2011-10-13 09:33:33 +0400 | [diff] [blame] | 1371 | AC_CONFIG_FILES([$cfgoutputs_tup config.stamp bin/jemalloc.sh]) |
Jason Evans | b0fd501 | 2010-01-17 01:49:20 -0800 | [diff] [blame] | 1372 | AC_SUBST([cfgoutputs_in]) |
| 1373 | AC_SUBST([cfgoutputs_out]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1374 | AC_OUTPUT |
| 1375 | |
| 1376 | dnl ============================================================================ |
| 1377 | dnl Print out the results of configuration. |
| 1378 | AC_MSG_RESULT([===============================================================================]) |
Jason Evans | f576c63 | 2011-11-01 22:27:41 -0700 | [diff] [blame] | 1379 | AC_MSG_RESULT([jemalloc version : ${jemalloc_version}]) |
| 1380 | AC_MSG_RESULT([library revision : ${rev}]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1381 | AC_MSG_RESULT([]) |
| 1382 | AC_MSG_RESULT([CC : ${CC}]) |
| 1383 | AC_MSG_RESULT([CPPFLAGS : ${CPPFLAGS}]) |
| 1384 | AC_MSG_RESULT([CFLAGS : ${CFLAGS}]) |
| 1385 | AC_MSG_RESULT([LDFLAGS : ${LDFLAGS}]) |
Jason Evans | 748dfac | 2013-12-06 18:27:33 -0800 | [diff] [blame] | 1386 | AC_MSG_RESULT([EXTRA_LDFLAGS : ${EXTRA_LDFLAGS}]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1387 | AC_MSG_RESULT([LIBS : ${LIBS}]) |
| 1388 | AC_MSG_RESULT([RPATH_EXTRA : ${RPATH_EXTRA}]) |
| 1389 | AC_MSG_RESULT([]) |
Jason Evans | aee7fd2 | 2010-11-24 22:00:02 -0800 | [diff] [blame] | 1390 | AC_MSG_RESULT([XSLTPROC : ${XSLTPROC}]) |
| 1391 | AC_MSG_RESULT([XSLROOT : ${XSLROOT}]) |
| 1392 | AC_MSG_RESULT([]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1393 | AC_MSG_RESULT([PREFIX : ${PREFIX}]) |
| 1394 | AC_MSG_RESULT([BINDIR : ${BINDIR}]) |
Jason Evans | 662a017 | 2009-07-01 19:24:31 -0700 | [diff] [blame] | 1395 | AC_MSG_RESULT([INCLUDEDIR : ${INCLUDEDIR}]) |
| 1396 | AC_MSG_RESULT([LIBDIR : ${LIBDIR}]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1397 | AC_MSG_RESULT([DATADIR : ${DATADIR}]) |
| 1398 | AC_MSG_RESULT([MANDIR : ${MANDIR}]) |
| 1399 | AC_MSG_RESULT([]) |
| 1400 | AC_MSG_RESULT([srcroot : ${srcroot}]) |
| 1401 | AC_MSG_RESULT([abs_srcroot : ${abs_srcroot}]) |
| 1402 | AC_MSG_RESULT([objroot : ${objroot}]) |
| 1403 | AC_MSG_RESULT([abs_objroot : ${abs_objroot}]) |
| 1404 | AC_MSG_RESULT([]) |
Jason Evans | 90895cf | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 1405 | AC_MSG_RESULT([JEMALLOC_PREFIX : ${JEMALLOC_PREFIX}]) |
Jason Evans | 746e77a | 2011-07-30 16:40:52 -0700 | [diff] [blame] | 1406 | AC_MSG_RESULT([JEMALLOC_PRIVATE_NAMESPACE]) |
| 1407 | AC_MSG_RESULT([ : ${JEMALLOC_PRIVATE_NAMESPACE}]) |
Jason Evans | b0fd501 | 2010-01-17 01:49:20 -0800 | [diff] [blame] | 1408 | AC_MSG_RESULT([install_suffix : ${install_suffix}]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1409 | AC_MSG_RESULT([autogen : ${enable_autogen}]) |
Jason Evans | 7e77eaf | 2012-03-02 17:47:37 -0800 | [diff] [blame] | 1410 | AC_MSG_RESULT([experimental : ${enable_experimental}]) |
Jason Evans | 355b438 | 2010-09-20 19:20:48 -0700 | [diff] [blame] | 1411 | AC_MSG_RESULT([cc-silence : ${enable_cc_silence}]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1412 | AC_MSG_RESULT([debug : ${enable_debug}]) |
Jason Evans | 748dfac | 2013-12-06 18:27:33 -0800 | [diff] [blame] | 1413 | AC_MSG_RESULT([code-coverage : ${enable_code_coverage}]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1414 | AC_MSG_RESULT([stats : ${enable_stats}]) |
Jason Evans | 6109fe0 | 2010-02-10 10:37:56 -0800 | [diff] [blame] | 1415 | AC_MSG_RESULT([prof : ${enable_prof}]) |
| 1416 | AC_MSG_RESULT([prof-libunwind : ${enable_prof_libunwind}]) |
Jason Evans | 77f350b | 2011-03-15 22:23:12 -0700 | [diff] [blame] | 1417 | AC_MSG_RESULT([prof-libgcc : ${enable_prof_libgcc}]) |
| 1418 | AC_MSG_RESULT([prof-gcc : ${enable_prof_gcc}]) |
Jason Evans | 84cbbcb | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 1419 | AC_MSG_RESULT([tcache : ${enable_tcache}]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1420 | AC_MSG_RESULT([fill : ${enable_fill}]) |
Jason Evans | b147611 | 2012-04-05 13:36:17 -0700 | [diff] [blame] | 1421 | AC_MSG_RESULT([utrace : ${enable_utrace}]) |
Jason Evans | 122449b | 2012-04-06 00:35:09 -0700 | [diff] [blame] | 1422 | AC_MSG_RESULT([valgrind : ${enable_valgrind}]) |
| 1423 | AC_MSG_RESULT([xmalloc : ${enable_xmalloc}]) |
Jason Evans | 2e671ff | 2012-05-09 16:12:00 -0700 | [diff] [blame] | 1424 | AC_MSG_RESULT([mremap : ${enable_mremap}]) |
Jason Evans | 59ae276 | 2012-04-16 17:52:27 -0700 | [diff] [blame] | 1425 | AC_MSG_RESULT([munmap : ${enable_munmap}]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1426 | AC_MSG_RESULT([dss : ${enable_dss}]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1427 | AC_MSG_RESULT([lazy_lock : ${enable_lazy_lock}]) |
Jason Evans | 2dbecf1 | 2010-09-05 10:35:13 -0700 | [diff] [blame] | 1428 | AC_MSG_RESULT([tls : ${enable_tls}]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1429 | AC_MSG_RESULT([===============================================================================]) |