1 dnl Process this file with autoconf to produce a configure script.
4 dnl ============================================================================
5 dnl Custom macro definitions.
7 dnl JE_CFLAGS_APPEND(cflag)
8 AC_DEFUN([JE_CFLAGS_APPEND],
10 AC_MSG_CHECKING([whether compiler supports $1])
12 if test "x${CFLAGS}" = "x" ; then
17 AC_RUN_IFELSE([AC_LANG_PROGRAM(
28 dnl JE_COMPILABLE(label, hcode, mcode, rvar)
29 AC_DEFUN([JE_COMPILABLE],
31 AC_MSG_CHECKING([whether $1 is compilable])
32 AC_RUN_IFELSE([AC_LANG_PROGRAM(
41 dnl ============================================================================
44 if test "x${srcroot}" = "x." ; then
50 abs_srcroot="`cd \"${srcdir}\"; pwd`/"
51 AC_SUBST([abs_srcroot])
56 AC_SUBST([abs_objroot])
58 dnl Munge install path variables.
59 if test "x$prefix" = "xNONE" ; then
62 if test "x$exec_prefix" = "xNONE" ; then
67 BINDIR=`eval echo $bindir`
68 BINDIR=`eval echo $BINDIR`
70 INCLUDEDIR=`eval echo $includedir`
71 INCLUDEDIR=`eval echo $INCLUDEDIR`
72 AC_SUBST([INCLUDEDIR])
73 LIBDIR=`eval echo $libdir`
74 LIBDIR=`eval echo $LIBDIR`
76 DATADIR=`eval echo $datadir`
77 DATADIR=`eval echo $DATADIR`
79 MANDIR=`eval echo $mandir`
80 MANDIR=`eval echo $MANDIR`
83 dnl Support for building documentation.
84 AC_PATH_PROG([XSLTPROC], [xsltproc], , [$PATH])
85 AC_ARG_WITH([xslroot],
86 [AS_HELP_STRING([--with-xslroot=<path>], [XSL stylesheet root path])],
87 if test "x$with_xslroot" = "xno" ; then
88 XSLROOT="/usr/share/xml/docbook/stylesheet/docbook-xsl"
90 XSLROOT="${with_xslroot}"
92 XSLROOT="/usr/share/xml/docbook/stylesheet/docbook-xsl"
96 dnl If CFLAGS isn't defined, set CFLAGS to something reasonable. Otherwise,
97 dnl just prevent autoconf from molesting CFLAGS.
100 if test "x$CFLAGS" = "x" ; then
102 if test "x$GCC" = "xyes" ; then
103 JE_CFLAGS_APPEND([-std=gnu99])
104 JE_CFLAGS_APPEND([-Wall])
105 JE_CFLAGS_APPEND([-pipe])
106 JE_CFLAGS_APPEND([-g3])
109 dnl Append EXTRA_CFLAGS to CFLAGS, if defined.
110 if test "x$EXTRA_CFLAGS" != "x" ; then
111 JE_CFLAGS_APPEND([$EXTRA_CFLAGS])
115 AC_CHECK_SIZEOF([void *])
116 if test "x${ac_cv_sizeof_void_p}" = "x8" ; then
118 elif test "x${ac_cv_sizeof_void_p}" = "x4" ; then
121 AC_MSG_ERROR([Unsupported pointer size: ${ac_cv_sizeof_void_p}])
123 AC_DEFINE_UNQUOTED([LG_SIZEOF_PTR], [$LG_SIZEOF_PTR])
125 AC_CHECK_SIZEOF([int])
126 if test "x${ac_cv_sizeof_int}" = "x8" ; then
128 elif test "x${ac_cv_sizeof_int}" = "x4" ; then
131 AC_MSG_ERROR([Unsupported int size: ${ac_cv_sizeof_int}])
133 AC_DEFINE_UNQUOTED([LG_SIZEOF_INT], [$LG_SIZEOF_INT])
135 AC_CHECK_SIZEOF([long])
136 if test "x${ac_cv_sizeof_long}" = "x8" ; then
138 elif test "x${ac_cv_sizeof_long}" = "x4" ; then
141 AC_MSG_ERROR([Unsupported long size: ${ac_cv_sizeof_long}])
143 AC_DEFINE_UNQUOTED([LG_SIZEOF_LONG], [$LG_SIZEOF_LONG])
146 dnl CPU-specific settings.
148 case "${host_cpu}" in
152 JE_COMPILABLE([__asm__], [], [[__asm__ volatile("pause"); return 0;]],
154 if test "x${asm}" = "xyes" ; then
155 CPU_SPINWAIT='__asm__ volatile("pause")'
159 JE_COMPILABLE([__asm__ syntax], [],
160 [[__asm__ volatile("pause"); return 0;]], [asm])
161 if test "x${asm}" = "xyes" ; then
162 CPU_SPINWAIT='__asm__ volatile("pause")'
168 AC_DEFINE_UNQUOTED([CPU_SPINWAIT], [$CPU_SPINWAIT])
170 dnl Platform-specific settings. abi and RPATH can probably be determined
171 dnl programmatically, but doing so is error-prone, which makes it generally
172 dnl not worth the trouble.
174 dnl Define cpp macros in CPPFLAGS, rather than doing AC_DEFINE(macro), since the
175 dnl definitions need to be seen before any headers are included, which is a pain
176 dnl to make happen otherwise.
179 CFLAGS="$CFLAGS -fno-common -no-cpp-precomp"
181 AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE])
187 AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE])
192 CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
194 AC_DEFINE([JEMALLOC_PURGE_MADVISE_DONTNEED])
198 AC_MSG_CHECKING([ABI])
199 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
206 [CFLAGS="$CFLAGS"; abi="elf"],
208 AC_MSG_RESULT([$abi])
209 AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE])
216 dnl Solaris needs this for sigwait().
217 CPPFLAGS="$CPPFLAGS -D_POSIX_PTHREAD_SEMANTICS"
218 LIBS="$LIBS -lposix4 -lsocket -lnsl"
221 AC_MSG_RESULT([Unsupported operating system: ${host}])
229 JE_COMPILABLE([__attribute__ syntax],
230 [static __attribute__((unused)) void foo(void){}],
233 if test "x${attribute}" = "xyes" ; then
234 AC_DEFINE([JEMALLOC_HAVE_ATTR], [ ])
235 if test "x${GCC}" = "xyes" -a "x${abi}" = "xelf"; then
236 JE_CFLAGS_APPEND([-fvisibility=hidden])
240 JE_COMPILABLE([mremap(...MREMAP_FIXED...)], [
242 #include <sys/mman.h>
244 void *p = mremap((void *)0, 0, 0, MREMAP_MAYMOVE|MREMAP_FIXED, (void *)0);
246 if test "x${mremap_fixed}" = "xyes" ; then
247 AC_DEFINE([JEMALLOC_MREMAP_FIXED])
250 dnl Support optional additions to rpath.
252 [AS_HELP_STRING([--with-rpath=<rpath>], [Colon-separated rpath (ELF systems only)])],
253 if test "x$with_rpath" = "xno" ; then
256 RPATH_EXTRA="`echo $with_rpath | tr \":\" \" \"`"
260 AC_SUBST([RPATH_EXTRA])
262 dnl Disable rules that do automatic regeneration of configure output by default.
263 AC_ARG_ENABLE([autogen],
264 [AS_HELP_STRING([--enable-autogen], [Automatically regenerate configure output])],
265 if test "x$enable_autogen" = "xno" ; then
273 AC_SUBST([enable_autogen])
277 AC_PATH_PROG([AR], [ar], , [$PATH])
278 AC_PATH_PROG([LD], [ld], , [$PATH])
279 AC_PATH_PROG([AUTOCONF], [autoconf], , [$PATH])
281 dnl Do not prefix public APIs by default.
282 AC_ARG_WITH([jemalloc_prefix],
283 [AS_HELP_STRING([--with-jemalloc-prefix=<prefix>], [Prefix to prepend to all public APIs])],
284 [JEMALLOC_PREFIX="$with_jemalloc_prefix"],
285 [if test "x$abi" != "xmacho" ; then
288 JEMALLOC_PREFIX="je_"
291 if test "x$JEMALLOC_PREFIX" != "x" ; then
292 JEMALLOC_CPREFIX=`echo ${JEMALLOC_PREFIX} | tr "a-z" "A-Z"`
293 AC_DEFINE_UNQUOTED([JEMALLOC_PREFIX], ["$JEMALLOC_PREFIX"])
294 AC_DEFINE_UNQUOTED([JEMALLOC_CPREFIX], ["$JEMALLOC_CPREFIX"])
295 jemalloc_prefix="$JEMALLOC_PREFIX"
296 jemalloc_cprefix="$JEMALLOC_CPREFIX"
297 AC_SUBST([jemalloc_prefix])
298 AC_SUBST([jemalloc_cprefix])
299 AC_DEFINE_UNQUOTED([JEMALLOC_P(string_that_no_one_should_want_to_use_as_a_jemalloc_API_prefix)], [${JEMALLOC_PREFIX}##string_that_no_one_should_want_to_use_as_a_jemalloc_API_prefix])
302 dnl Do not add suffix to installed files by default.
303 AC_ARG_WITH([install_suffix],
304 [AS_HELP_STRING([--with-install-suffix=<suffix>], [Suffix to append to all installed files])],
305 [INSTALL_SUFFIX="$with_install_suffix"],
308 install_suffix="$INSTALL_SUFFIX"
309 AC_SUBST([install_suffix])
311 cfgoutputs_in="${srcroot}Makefile.in"
312 cfgoutputs_in="${cfgoutputs_in} ${srcroot}doc/html.xsl.in"
313 cfgoutputs_in="${cfgoutputs_in} ${srcroot}doc/manpages.xsl.in"
314 cfgoutputs_in="${cfgoutputs_in} ${srcroot}doc/jemalloc.xml.in"
315 cfgoutputs_in="${cfgoutputs_in} ${srcroot}include/jemalloc/jemalloc.h.in"
316 cfgoutputs_in="${cfgoutputs_in} ${srcroot}include/jemalloc/internal/jemalloc_internal.h.in"
317 cfgoutputs_in="${cfgoutputs_in} ${srcroot}test/jemalloc_test.h.in"
319 cfgoutputs_out="Makefile"
320 cfgoutputs_out="${cfgoutputs_out} doc/html.xsl"
321 cfgoutputs_out="${cfgoutputs_out} doc/manpages.xsl"
322 cfgoutputs_out="${cfgoutputs_out} doc/jemalloc${install_suffix}.xml"
323 cfgoutputs_out="${cfgoutputs_out} include/jemalloc/jemalloc${install_suffix}.h"
324 cfgoutputs_out="${cfgoutputs_out} include/jemalloc/internal/jemalloc_internal.h"
325 cfgoutputs_out="${cfgoutputs_out} test/jemalloc_test.h"
327 cfgoutputs_tup="Makefile"
328 cfgoutputs_tup="${cfgoutputs_tup} doc/html.xsl:doc/html.xsl.in"
329 cfgoutputs_tup="${cfgoutputs_tup} doc/manpages.xsl:doc/manpages.xsl.in"
330 cfgoutputs_tup="${cfgoutputs_tup} doc/jemalloc${install_suffix}.xml:doc/jemalloc.xml.in"
331 cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/jemalloc${install_suffix}.h:include/jemalloc/jemalloc.h.in"
332 cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/internal/jemalloc_internal.h"
333 cfgoutputs_tup="${cfgoutputs_tup} test/jemalloc_test.h:test/jemalloc_test.h.in"
335 cfghdrs_in="${srcroot}include/jemalloc/jemalloc_defs.h.in"
337 cfghdrs_out="include/jemalloc/jemalloc_defs${install_suffix}.h"
339 cfghdrs_tup="include/jemalloc/jemalloc_defs${install_suffix}.h:include/jemalloc/jemalloc_defs.h.in"
341 dnl Do not silence irrelevant compiler warnings by default, since enabling this
342 dnl option incurs a performance penalty.
343 AC_ARG_ENABLE([cc-silence],
344 [AS_HELP_STRING([--enable-cc-silence],
345 [Silence irrelevant compiler warnings])],
346 [if test "x$enable_cc_silence" = "xno" ; then
347 enable_cc_silence="0"
349 enable_cc_silence="1"
352 [enable_cc_silence="0"]
354 if test "x$enable_cc_silence" = "x1" ; then
355 AC_DEFINE([JEMALLOC_CC_SILENCE])
358 dnl Do not compile with debugging by default.
359 AC_ARG_ENABLE([debug],
360 [AS_HELP_STRING([--enable-debug], [Build debugging code])],
361 [if test "x$enable_debug" = "xno" ; then
369 if test "x$enable_debug" = "x1" ; then
370 AC_DEFINE([JEMALLOC_DEBUG], [ ])
371 AC_DEFINE([JEMALLOC_IVSALLOC], [ ])
373 AC_SUBST([enable_debug])
375 dnl Only optimize if not debugging.
376 if test "x$enable_debug" = "x0" -a "x$no_CFLAGS" = "xyes" ; then
377 dnl Make sure that an optimization flag was not specified in EXTRA_CFLAGS.
379 echo "$EXTRA_CFLAGS" | grep "\-O" >/dev/null || optimize="yes"
380 if test "x${optimize}" = "xyes" ; then
381 if test "x$GCC" = "xyes" ; then
382 JE_CFLAGS_APPEND([-O3])
383 JE_CFLAGS_APPEND([-funroll-loops])
385 JE_CFLAGS_APPEND([-O])
390 dnl Do not enable statistics calculation by default.
391 AC_ARG_ENABLE([stats],
392 [AS_HELP_STRING([--enable-stats], [Enable statistics calculation/reporting])],
393 [if test "x$enable_stats" = "xno" ; then
401 if test "x$enable_stats" = "x1" ; then
402 AC_DEFINE([JEMALLOC_STATS], [ ])
404 AC_SUBST([enable_stats])
406 dnl Do not enable profiling by default.
407 AC_ARG_ENABLE([prof],
408 [AS_HELP_STRING([--enable-prof], [Enable allocation profiling])],
409 [if test "x$enable_prof" = "xno" ; then
417 if test "x$enable_prof" = "x1" ; then
420 backtrace_method="N/A"
423 AC_ARG_ENABLE([prof-libunwind],
424 [AS_HELP_STRING([--enable-prof-libunwind], [Use libunwind for backtracing])],
425 [if test "x$enable_prof_libunwind" = "xno" ; then
426 enable_prof_libunwind="0"
428 enable_prof_libunwind="1"
431 [enable_prof_libunwind="0"]
433 AC_ARG_WITH([static_libunwind],
434 [AS_HELP_STRING([--with-static-libunwind=<libunwind.a>],
435 [Path to static libunwind library; use rather than dynamically linking])],
436 if test "x$with_static_libunwind" = "xno" ; then
439 if test ! -f "$with_static_libunwind" ; then
440 AC_MSG_ERROR([Static libunwind not found: $with_static_libunwind])
442 LUNWIND="$with_static_libunwind"
446 if test "x$backtrace_method" = "x" -a "x$enable_prof_libunwind" = "x1" ; then
447 AC_CHECK_HEADERS([libunwind.h], , [enable_prof_libunwind="0"])
448 if test "x$LUNWIND" = "x-lunwind" ; then
449 AC_CHECK_LIB([unwind], [backtrace], [LIBS="$LIBS $LUNWIND"],
450 [enable_prof_libunwind="0"])
452 LIBS="$LIBS $LUNWIND"
454 if test "x${enable_prof_libunwind}" = "x1" ; then
455 backtrace_method="libunwind"
456 AC_DEFINE([JEMALLOC_PROF_LIBUNWIND], [ ])
460 AC_ARG_ENABLE([prof-libgcc],
461 [AS_HELP_STRING([--disable-prof-libgcc],
462 [Do not use libgcc for backtracing])],
463 [if test "x$enable_prof_libgcc" = "xno" ; then
464 enable_prof_libgcc="0"
466 enable_prof_libgcc="1"
469 [enable_prof_libgcc="1"]
471 if test "x$backtrace_method" = "x" -a "x$enable_prof_libgcc" = "x1" \
472 -a "x$GCC" = "xyes" ; then
473 AC_CHECK_HEADERS([unwind.h], , [enable_prof_libgcc="0"])
474 AC_CHECK_LIB([gcc], [_Unwind_Backtrace], [LIBS="$LIBS -lgcc"], [enable_prof_libgcc="0"])
475 dnl The following is conservative, in that it only has entries for CPUs on
476 dnl which jemalloc has been tested.
477 AC_MSG_CHECKING([libgcc-based backtracing reliability on ${host_cpu}])
478 case "${host_cpu}" in
480 AC_MSG_RESULT([unreliable])
481 enable_prof_libgcc="0";
484 AC_MSG_RESULT([reliable])
487 AC_MSG_RESULT([unreliable])
488 enable_prof_libgcc="0";
491 if test "x${enable_prof_libgcc}" = "x1" ; then
492 backtrace_method="libgcc"
493 AC_DEFINE([JEMALLOC_PROF_LIBGCC], [ ])
496 enable_prof_libgcc="0"
499 AC_ARG_ENABLE([prof-gcc],
500 [AS_HELP_STRING([--disable-prof-gcc],
501 [Do not use gcc intrinsics for backtracing])],
502 [if test "x$enable_prof_gcc" = "xno" ; then
508 [enable_prof_gcc="1"]
510 if test "x$backtrace_method" = "x" -a "x$enable_prof_gcc" = "x1" \
511 -a "x$GCC" = "xyes" ; then
512 backtrace_method="gcc intrinsics"
513 AC_DEFINE([JEMALLOC_PROF_GCC], [ ])
518 if test "x$backtrace_method" = "x" ; then
519 backtrace_method="none (disabling profiling)"
522 AC_MSG_CHECKING([configured backtracing method])
523 AC_MSG_RESULT([$backtrace_method])
524 if test "x$enable_prof" = "x1" ; then
526 AC_DEFINE([JEMALLOC_PROF], [ ])
528 AC_SUBST([enable_prof])
530 dnl Enable tiny allocations by default.
531 AC_ARG_ENABLE([tiny],
532 [AS_HELP_STRING([--disable-tiny], [Disable tiny (sub-quantum) allocations])],
533 [if test "x$enable_tiny" = "xno" ; then
541 if test "x$enable_tiny" = "x1" ; then
542 AC_DEFINE([JEMALLOC_TINY], [ ])
544 AC_SUBST([enable_tiny])
546 dnl Enable thread-specific caching by default.
547 AC_ARG_ENABLE([tcache],
548 [AS_HELP_STRING([--disable-tcache], [Disable per thread caches])],
549 [if test "x$enable_tcache" = "xno" ; then
557 if test "x$enable_tcache" = "x1" ; then
558 AC_DEFINE([JEMALLOC_TCACHE], [ ])
560 AC_SUBST([enable_tcache])
562 dnl Do not enable mmap()ped swap files by default.
563 AC_ARG_ENABLE([swap],
564 [AS_HELP_STRING([--enable-swap], [Enable mmap()ped swap files])],
565 [if test "x$enable_swap" = "xno" ; then
573 if test "x$enable_swap" = "x1" ; then
574 AC_DEFINE([JEMALLOC_SWAP], [ ])
576 AC_SUBST([enable_swap])
578 dnl Do not enable allocation from DSS by default.
580 [AS_HELP_STRING([--enable-dss], [Enable allocation from DSS])],
581 [if test "x$enable_dss" = "xno" ; then
589 if test "x$enable_dss" = "x1" ; then
590 AC_DEFINE([JEMALLOC_DSS], [ ])
592 AC_SUBST([enable_dss])
594 dnl Do not support the junk/zero filling option by default.
595 AC_ARG_ENABLE([fill],
596 [AS_HELP_STRING([--enable-fill], [Support junk/zero filling option])],
597 [if test "x$enable_fill" = "xno" ; then
605 if test "x$enable_fill" = "x1" ; then
606 AC_DEFINE([JEMALLOC_FILL], [ ])
608 AC_SUBST([enable_fill])
610 dnl Do not support the xmalloc option by default.
611 AC_ARG_ENABLE([xmalloc],
612 [AS_HELP_STRING([--enable-xmalloc], [Support xmalloc option])],
613 [if test "x$enable_xmalloc" = "xno" ; then
621 if test "x$enable_xmalloc" = "x1" ; then
622 AC_DEFINE([JEMALLOC_XMALLOC], [ ])
624 AC_SUBST([enable_xmalloc])
626 dnl Do not support the SYSV option by default.
627 AC_ARG_ENABLE([sysv],
628 [AS_HELP_STRING([--enable-sysv], [Support SYSV semantics option])],
629 [if test "x$enable_sysv" = "xno" ; then
637 if test "x$enable_sysv" = "x1" ; then
638 AC_DEFINE([JEMALLOC_SYSV], [ ])
640 AC_SUBST([enable_sysv])
642 dnl Do not determine page shift at run time by default.
643 AC_ARG_ENABLE([dynamic_page_shift],
644 [AS_HELP_STRING([--enable-dynamic-page-shift],
645 [Determine page size at run time (don't trust configure result)])],
646 [if test "x$enable_dynamic_page_shift" = "xno" ; then
647 enable_dynamic_page_shift="0"
649 enable_dynamic_page_shift="1"
652 [enable_dynamic_page_shift="0"]
654 if test "x$enable_dynamic_page_shift" = "x1" ; then
655 AC_DEFINE([DYNAMIC_PAGE_SHIFT], [ ])
657 AC_SUBST([enable_dynamic_page_shift])
659 AC_MSG_CHECKING([STATIC_PAGE_SHIFT])
660 AC_RUN_IFELSE([AC_LANG_PROGRAM(
668 result = sysconf(_SC_PAGESIZE);
672 f = fopen("conftest.out", "w");
676 fprintf(f, "%u\n", ffs((int)result) - 1);
681 [STATIC_PAGE_SHIFT=`cat conftest.out`]
682 AC_MSG_RESULT([$STATIC_PAGE_SHIFT])
683 AC_DEFINE_UNQUOTED([STATIC_PAGE_SHIFT], [$STATIC_PAGE_SHIFT]),
684 AC_MSG_RESULT([error]))
686 dnl ============================================================================
687 dnl jemalloc configuration.
690 dnl Set VERSION if source directory has an embedded git repository.
691 if test -d "${srcroot}../.git" ; then
692 git describe --long --abbrev=40 > ${srcroot}VERSION
694 jemalloc_version=`cat ${srcroot}VERSION`
695 jemalloc_version_major=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]1}'`
696 jemalloc_version_minor=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]2}'`
697 jemalloc_version_bugfix=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]3}'`
698 jemalloc_version_nrev=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]4}'`
699 jemalloc_version_gid=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]5}'`
700 AC_SUBST([jemalloc_version])
701 AC_SUBST([jemalloc_version_major])
702 AC_SUBST([jemalloc_version_minor])
703 AC_SUBST([jemalloc_version_bugfix])
704 AC_SUBST([jemalloc_version_nrev])
705 AC_SUBST([jemalloc_version_gid])
707 dnl ============================================================================
708 dnl Configure pthreads.
710 AC_CHECK_HEADERS([pthread.h], , [AC_MSG_ERROR([pthread.h is missing])])
711 AC_CHECK_LIB([pthread], [pthread_create], [LIBS="$LIBS -lpthread"],
712 [AC_MSG_ERROR([libpthread is missing])])
714 CPPFLAGS="$CPPFLAGS -D_REENTRANT"
716 dnl Enable lazy locking by default.
717 AC_ARG_ENABLE([lazy_lock],
718 [AS_HELP_STRING([--disable-lazy-lock],
719 [Disable lazy locking (always lock, even when single-threaded)])],
720 [if test "x$enable_lazy_lock" = "xno" ; then
726 [enable_lazy_lock="1"]
728 if test "x$enable_lazy_lock" = "x1" ; then
729 AC_CHECK_HEADERS([dlfcn.h], , [AC_MSG_ERROR([dlfcn.h is missing])])
730 AC_CHECK_LIB([dl], [dlopen], [LIBS="$LIBS -ldl"],
731 [AC_MSG_ERROR([libdl is missing])])
732 AC_DEFINE([JEMALLOC_LAZY_LOCK], [ ])
734 AC_SUBST([enable_lazy_lock])
737 [AS_HELP_STRING([--disable-tls], [Disable thread-local storage (__thread keyword)])],
738 if test "x$enable_tls" = "xno" ; then
746 if test "x${enable_tls}" = "x1" ; then
747 AC_MSG_CHECKING([for TLS])
748 AC_RUN_IFELSE([AC_LANG_PROGRAM(
756 AC_MSG_RESULT([yes]),
760 AC_SUBST([enable_tls])
761 if test "x${enable_tls}" = "x0" ; then
762 AC_DEFINE_UNQUOTED([NO_TLS], [ ])
765 dnl ============================================================================
766 dnl Check for ffsl(3), and fail if not found. This function exists on all
767 dnl platforms that jemalloc currently has a chance of functioning on without
770 AC_CHECK_FUNC([ffsl], [],
771 [AC_MSG_ERROR([Cannot build without ffsl(3)])])
773 dnl ============================================================================
774 dnl Check for atomic(3) operations as provided on Darwin.
776 JE_COMPILABLE([Darwin OSAtomic*()], [
777 #include <libkern/OSAtomic.h>
778 #include <inttypes.h>
782 volatile int32_t *x32p = &x32;
783 OSAtomicAdd32(1, x32p);
787 volatile int64_t *x64p = &x64;
788 OSAtomicAdd64(1, x64p);
791 if test "x${osatomic}" = "xyes" ; then
792 AC_DEFINE([JEMALLOC_OSATOMIC])
795 dnl ============================================================================
796 dnl Check for spinlock(3) operations as provided on Darwin.
798 JE_COMPILABLE([Darwin OSSpin*()], [
799 #include <libkern/OSAtomic.h>
800 #include <inttypes.h>
803 OSSpinLockLock(&lock);
804 OSSpinLockUnlock(&lock);
806 if test "x${osspin}" = "xyes" ; then
807 AC_DEFINE([JEMALLOC_OSSPIN])
810 dnl ============================================================================
811 dnl Check for allocator-related functions that should be wrapped.
813 AC_CHECK_FUNC([memalign],
814 [AC_DEFINE([JEMALLOC_OVERRIDE_MEMALIGN])])
815 AC_CHECK_FUNC([valloc],
816 [AC_DEFINE([JEMALLOC_OVERRIDE_VALLOC])])
818 dnl ============================================================================
819 dnl Darwin-related configuration.
821 if test "x${abi}" = "xmacho" ; then
822 AC_DEFINE([JEMALLOC_IVSALLOC])
823 AC_DEFINE([JEMALLOC_ZONE])
825 dnl The szone version jumped from 3 to 6 between the OS X 10.5.x and 10.6
826 dnl releases. malloc_zone_t and malloc_introspection_t have new fields in
827 dnl 10.6, which is the only source-level indication of the change.
828 AC_MSG_CHECKING([malloc zone version])
829 AC_TRY_COMPILE([#include <stdlib.h>
830 #include <malloc/malloc.h>], [
831 static malloc_zone_t zone;
832 static struct malloc_introspection_t zone_introspect;
841 zone.zone_name = "jemalloc_zone";
842 zone.batch_malloc = NULL;
843 zone.batch_free = NULL;
844 zone.introspect = &zone_introspect;
846 zone.memalign = NULL;
847 zone.free_definite_size = NULL;
849 zone_introspect.enumerator = NULL;
850 zone_introspect.good_size = NULL;
851 zone_introspect.check = NULL;
852 zone_introspect.print = NULL;
853 zone_introspect.log = NULL;
854 zone_introspect.force_lock = NULL;
855 zone_introspect.force_unlock = NULL;
856 zone_introspect.statistics = NULL;
857 zone_introspect.zone_locked = NULL;
858 ], [AC_DEFINE_UNQUOTED([JEMALLOC_ZONE_VERSION], [6])
860 [AC_DEFINE_UNQUOTED([JEMALLOC_ZONE_VERSION], [3])
864 dnl ============================================================================
865 dnl Check for typedefs, structures, and compiler characteristics.
868 dnl Process .in files.
869 AC_SUBST([cfghdrs_in])
870 AC_SUBST([cfghdrs_out])
871 AC_CONFIG_HEADERS([$cfghdrs_tup])
873 dnl ============================================================================
874 dnl Generate outputs.
875 AC_CONFIG_FILES([$cfgoutputs_tup config.stamp])
876 AC_SUBST([cfgoutputs_in])
877 AC_SUBST([cfgoutputs_out])
880 dnl ============================================================================
881 dnl Print out the results of configuration.
882 AC_MSG_RESULT([===============================================================================])
883 AC_MSG_RESULT([jemalloc version : $jemalloc_version])
885 AC_MSG_RESULT([CC : ${CC}])
886 AC_MSG_RESULT([CPPFLAGS : ${CPPFLAGS}])
887 AC_MSG_RESULT([CFLAGS : ${CFLAGS}])
888 AC_MSG_RESULT([LDFLAGS : ${LDFLAGS}])
889 AC_MSG_RESULT([LIBS : ${LIBS}])
890 AC_MSG_RESULT([RPATH_EXTRA : ${RPATH_EXTRA}])
892 AC_MSG_RESULT([XSLTPROC : ${XSLTPROC}])
893 AC_MSG_RESULT([XSLROOT : ${XSLROOT}])
895 AC_MSG_RESULT([PREFIX : ${PREFIX}])
896 AC_MSG_RESULT([BINDIR : ${BINDIR}])
897 AC_MSG_RESULT([INCLUDEDIR : ${INCLUDEDIR}])
898 AC_MSG_RESULT([LIBDIR : ${LIBDIR}])
899 AC_MSG_RESULT([DATADIR : ${DATADIR}])
900 AC_MSG_RESULT([MANDIR : ${MANDIR}])
902 AC_MSG_RESULT([srcroot : ${srcroot}])
903 AC_MSG_RESULT([abs_srcroot : ${abs_srcroot}])
904 AC_MSG_RESULT([objroot : ${objroot}])
905 AC_MSG_RESULT([abs_objroot : ${abs_objroot}])
907 AC_MSG_RESULT([JEMALLOC_PREFIX : ${JEMALLOC_PREFIX}])
908 AC_MSG_RESULT([install_suffix : ${install_suffix}])
909 AC_MSG_RESULT([autogen : ${enable_autogen}])
910 AC_MSG_RESULT([cc-silence : ${enable_cc_silence}])
911 AC_MSG_RESULT([debug : ${enable_debug}])
912 AC_MSG_RESULT([stats : ${enable_stats}])
913 AC_MSG_RESULT([prof : ${enable_prof}])
914 AC_MSG_RESULT([prof-libunwind : ${enable_prof_libunwind}])
915 AC_MSG_RESULT([prof-libgcc : ${enable_prof_libgcc}])
916 AC_MSG_RESULT([prof-gcc : ${enable_prof_gcc}])
917 AC_MSG_RESULT([tiny : ${enable_tiny}])
918 AC_MSG_RESULT([tcache : ${enable_tcache}])
919 AC_MSG_RESULT([fill : ${enable_fill}])
920 AC_MSG_RESULT([xmalloc : ${enable_xmalloc}])
921 AC_MSG_RESULT([sysv : ${enable_sysv}])
922 AC_MSG_RESULT([swap : ${enable_swap}])
923 AC_MSG_RESULT([dss : ${enable_dss}])
924 AC_MSG_RESULT([dynamic_page_shift : ${enable_dynamic_page_shift}])
925 AC_MSG_RESULT([lazy_lock : ${enable_lazy_lock}])
926 AC_MSG_RESULT([tls : ${enable_tls}])
927 AC_MSG_RESULT([===============================================================================])