alloc.m4 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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/.
  4. dnl Check for the existence of various allocation headers/functions
  5. AC_DEFUN([MOZ_CHECK_ALLOCATOR],[
  6. MALLOC_HEADERS="malloc.h malloc_np.h malloc/malloc.h sys/malloc.h"
  7. MALLOC_H=
  8. for file in $MALLOC_HEADERS; do
  9. MOZ_CHECK_HEADER($file, [MALLOC_H=$file])
  10. if test "$MALLOC_H" != ""; then
  11. AC_DEFINE_UNQUOTED(MALLOC_H, <$MALLOC_H>)
  12. break
  13. fi
  14. done
  15. AC_CHECK_FUNCS(strndup posix_memalign memalign)
  16. AC_CHECK_FUNCS(malloc_usable_size)
  17. MALLOC_USABLE_SIZE_CONST_PTR=const
  18. if test -n "$HAVE_MALLOC_H"; then
  19. AC_MSG_CHECKING([whether malloc_usable_size definition can use const argument])
  20. AC_TRY_COMPILE([#include <malloc.h>
  21. #include <stddef.h>
  22. size_t malloc_usable_size(const void *ptr);],
  23. [return malloc_usable_size(0);],
  24. AC_MSG_RESULT([yes]),
  25. AC_MSG_RESULT([no])
  26. MALLOC_USABLE_SIZE_CONST_PTR=)
  27. fi
  28. AC_DEFINE_UNQUOTED([MALLOC_USABLE_SIZE_CONST_PTR],[$MALLOC_USABLE_SIZE_CONST_PTR])
  29. dnl In newer bionic headers, valloc is built but not defined,
  30. dnl so we check more carefully here.
  31. AC_MSG_CHECKING([for valloc in malloc.h])
  32. AC_EGREP_HEADER(valloc, malloc.h,
  33. AC_DEFINE(HAVE_VALLOC)
  34. AC_MSG_RESULT([yes]),
  35. AC_MSG_RESULT([no]))
  36. AC_MSG_CHECKING([for valloc in unistd.h])
  37. AC_EGREP_HEADER(valloc, unistd.h,
  38. AC_DEFINE(HAVE_VALLOC)
  39. AC_MSG_RESULT([yes]),
  40. AC_MSG_RESULT([no]))
  41. ])