1 dnl This Source Code Form is subject to the terms of the Mozilla Public
2 dnl License, v. 2.0. If a copy of the MPL was not distributed with this
3 dnl file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 dnl Check for the existence of various allocation headers/functions
6 AC_DEFUN([MOZ_CHECK_ALLOCATOR],[
8 MALLOC_HEADERS="malloc.h malloc_np.h malloc/malloc.h sys/malloc.h"
11 for file in $MALLOC_HEADERS; do
12 MOZ_CHECK_HEADER($file, [MALLOC_H=$file])
13 if test "$MALLOC_H" != ""; then
14 AC_DEFINE_UNQUOTED(MALLOC_H, <$MALLOC_H>)
19 AC_CHECK_FUNCS(strndup posix_memalign memalign)
21 AC_CHECK_FUNCS(malloc_usable_size)
22 MALLOC_USABLE_SIZE_CONST_PTR=const
23 if test -n "$HAVE_MALLOC_H"; then
24 AC_MSG_CHECKING([whether malloc_usable_size definition can use const argument])
25 AC_TRY_COMPILE([#include <malloc.h>
27 size_t malloc_usable_size(const void *ptr);],
28 [return malloc_usable_size(0);],
31 MALLOC_USABLE_SIZE_CONST_PTR=)
33 AC_DEFINE_UNQUOTED([MALLOC_USABLE_SIZE_CONST_PTR],[$MALLOC_USABLE_SIZE_CONST_PTR])
36 dnl In newer bionic headers, valloc is built but not defined,
37 dnl so we check more carefully here.
38 AC_MSG_CHECKING([for valloc in malloc.h])
39 AC_EGREP_HEADER(valloc, malloc.h,
40 AC_DEFINE(HAVE_VALLOC)
44 AC_MSG_CHECKING([for valloc in unistd.h])
45 AC_EGREP_HEADER(valloc, unistd.h,
46 AC_DEFINE(HAVE_VALLOC)
50 AC_MSG_CHECKING([for _aligned_malloc in malloc.h])
51 AC_EGREP_HEADER(_aligned_malloc, malloc.h,
52 AC_DEFINE(HAVE_ALIGNED_MALLOC)