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