diff --git a/aclocal.m4 b/aclocal.m4 index 90356f99b79..5f306518702 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -33,6 +33,7 @@ builtin(include, build/autoconf/winsdk.m4)dnl builtin(include, build/autoconf/icu.m4)dnl builtin(include, build/autoconf/ffi.m4)dnl builtin(include, build/autoconf/clang-plugin.m4)dnl +builtin(include, build/autoconf/alloc.m4)dnl MOZ_PROG_CHECKMSYS() diff --git a/build/autoconf/alloc.m4 b/build/autoconf/alloc.m4 new file mode 100644 index 00000000000..8234a608d44 --- /dev/null +++ b/build/autoconf/alloc.m4 @@ -0,0 +1,53 @@ +dnl This Source Code Form is subject to the terms of the Mozilla Public +dnl License, v. 2.0. If a copy of the MPL was not distributed with this +dnl file, You can obtain one at http://mozilla.org/MPL/2.0/. + +dnl Check for the existence of various allocation headers/functions +AC_DEFUN([MOZ_CHECK_ALLOCATOR],[ + +MALLOC_HEADERS="malloc.h malloc_np.h malloc/malloc.h sys/malloc.h" +MALLOC_H= + +for file in $MALLOC_HEADERS; do + MOZ_CHECK_HEADER($file, [MALLOC_H=$file]) + if test "$MALLOC_H" != ""; then + AC_DEFINE_UNQUOTED(MALLOC_H, <$MALLOC_H>) + break + fi +done + +MOZ_CHECK_HEADERS(alloca.h) + +AC_CHECK_FUNCS(strndup posix_memalign memalign) + +AC_CHECK_FUNCS(malloc_usable_size) +MALLOC_USABLE_SIZE_CONST_PTR=const +MOZ_CHECK_HEADERS([malloc.h], [ + AC_MSG_CHECKING([whether malloc_usable_size definition can use const argument]) + AC_TRY_COMPILE([#include + #include + size_t malloc_usable_size(const void *ptr);], + [return malloc_usable_size(0);], + AC_MSG_RESULT([yes]), + AC_MSG_RESULT([no]) + MALLOC_USABLE_SIZE_CONST_PTR=) +]) +AC_DEFINE_UNQUOTED([MALLOC_USABLE_SIZE_CONST_PTR],[$MALLOC_USABLE_SIZE_CONST_PTR]) + + +dnl In newer bionic headers, valloc is built but not defined, +dnl so we check more carefully here. +AC_MSG_CHECKING([for valloc in malloc.h]) +AC_EGREP_HEADER(valloc, malloc.h, + AC_DEFINE(HAVE_VALLOC) + AC_MSG_RESULT([yes]), + AC_MSG_RESULT([no])) + +AC_MSG_CHECKING([for valloc in unistd.h]) +AC_EGREP_HEADER(valloc, unistd.h, + AC_DEFINE(HAVE_VALLOC) + AC_MSG_RESULT([yes]), + AC_MSG_RESULT([no])) + + +]) diff --git a/configure.in b/configure.in index 0d541675bd5..988797d6525 100644 --- a/configure.in +++ b/configure.in @@ -3399,51 +3399,7 @@ if test -n "$MOZ_LINKER" -a "$OS_TARGET" = "Android"; then fi fi -dnl Check for the existence of various allocation headers/functions - -MALLOC_HEADERS="malloc.h malloc_np.h malloc/malloc.h sys/malloc.h" -MALLOC_H= - -for file in $MALLOC_HEADERS; do - MOZ_CHECK_HEADER($file, [MALLOC_H=$file]) - if test "$MALLOC_H" != ""; then - AC_DEFINE_UNQUOTED(MALLOC_H, <$MALLOC_H>) - break - fi -done - -MOZ_CHECK_HEADERS(alloca.h) - -AC_CHECK_FUNCS(strndup posix_memalign memalign) - -AC_CHECK_FUNCS(malloc_usable_size) -MALLOC_USABLE_SIZE_CONST_PTR=const -MOZ_CHECK_HEADERS([malloc.h], [ - AC_MSG_CHECKING([whether malloc_usable_size definition can use const argument]) - AC_TRY_COMPILE([#include - #include - size_t malloc_usable_size(const void *ptr);], - [return malloc_usable_size(0);], - AC_MSG_RESULT([yes]), - AC_MSG_RESULT([no]) - MALLOC_USABLE_SIZE_CONST_PTR=) -]) -AC_DEFINE_UNQUOTED([MALLOC_USABLE_SIZE_CONST_PTR],[$MALLOC_USABLE_SIZE_CONST_PTR]) - - -dnl In newer bionic headers, valloc is built but not defined, -dnl so we check more carefully here. -AC_MSG_CHECKING([for valloc in malloc.h]) -AC_EGREP_HEADER(valloc, malloc.h, - AC_DEFINE(HAVE_VALLOC) - AC_MSG_RESULT([yes]), - AC_MSG_RESULT([no])) - -AC_MSG_CHECKING([for valloc in unistd.h]) -AC_EGREP_HEADER(valloc, unistd.h, - AC_DEFINE(HAVE_VALLOC) - AC_MSG_RESULT([yes]), - AC_MSG_RESULT([no])) +MOZ_CHECK_ALLOCATOR dnl See if compiler supports some gcc-style attributes diff --git a/js/src/aclocal.m4 b/js/src/aclocal.m4 index 99c73acc12a..fc36340880f 100644 --- a/js/src/aclocal.m4 +++ b/js/src/aclocal.m4 @@ -32,6 +32,7 @@ builtin(include, ../../build/autoconf/winsdk.m4)dnl builtin(include, ../../build/autoconf/icu.m4)dnl builtin(include, ../../build/autoconf/ffi.m4)dnl builtin(include, ../../build/autoconf/clang-plugin.m4)dnl +builtin(include, ../../build/autoconf/alloc.m4)dnl define([__MOZ_AC_INIT_PREPARE], defn([AC_INIT_PREPARE])) define([AC_INIT_PREPARE], diff --git a/js/src/configure.in b/js/src/configure.in index 9c21772292d..4f72dc31d56 100644 --- a/js/src/configure.in +++ b/js/src/configure.in @@ -3847,18 +3847,9 @@ dnl ======================================================== dnl JavaScript shell dnl ======================================================== -MALLOC_HEADERS="malloc.h malloc_np.h malloc/malloc.h sys/malloc.h" -MALLOC_H= +MOZ_CHECK_ALLOCATOR -for file in $MALLOC_HEADERS; do - MOZ_CHECK_HEADER($file, [MALLOC_H=$file]) - if test "$MALLOC_H" != ""; then - AC_DEFINE_UNQUOTED(MALLOC_H, <$MALLOC_H>) - break - fi -done - -AC_CHECK_FUNCS(setlocale localeconv malloc_size malloc_usable_size) +AC_CHECK_FUNCS(setlocale localeconv) AC_SUBST(MOZILLA_VERSION)