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