Bug 788955 - Check for malloc_usable_size() and malloc_np.h via autoconf. r=glandium

This commit is contained in:
Jan Beich 2012-10-17 16:39:15 +02:00
parent ca351406a3
commit 5291459067
4 changed files with 14 additions and 15 deletions

View File

@ -481,6 +481,7 @@ MacTCP.h
MacTypes.h
MacWindows.h
malloc.h
malloc_np.h
map
mapicode.h
mapidefs.h

View File

@ -3768,21 +3768,22 @@ 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=
MOZ_CHECK_HEADER(malloc.h, [MALLOC_H=malloc.h])
if test "$MALLOC_H" = ""; then
MOZ_CHECK_HEADER(malloc/malloc.h, [MALLOC_H=malloc/malloc.h])
if test "$MALLOC_H" = ""; then
MOZ_CHECK_HEADER(sys/malloc.h, [MALLOC_H=sys/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
fi
if test "$MALLOC_H" != ""; then
AC_DEFINE_UNQUOTED(MALLOC_H, <$MALLOC_H>)
fi
done
MOZ_ALLOCATING_FUNCS="strndup posix_memalign memalign valloc"
AC_CHECK_FUNCS(strndup posix_memalign memalign valloc)
AC_CHECK_FUNCS(malloc_usable_size)
dnl See if compiler supports some gcc-style attributes
AC_CACHE_CHECK(for __attribute__((always_inline)),

View File

@ -481,6 +481,7 @@ MacTCP.h
MacTypes.h
MacWindows.h
malloc.h
malloc_np.h
map
mapicode.h
mapidefs.h

View File

@ -12,16 +12,13 @@
#include <sys/types.h>
#if defined(MALLOC_H)
# include MALLOC_H // for memalign, valloc where available
# include MALLOC_H // for memalign, valloc, malloc_size, malloc_usable_size
#endif // if defined(MALLOC_H)
#include <stddef.h> // for size_t
#include <stdlib.h> // for malloc, free
#if defined(XP_UNIX)
# include <unistd.h> // for valloc on *BSD
#endif //if defined(XP_UNIX)
#if defined(__FreeBSD__)
# include <malloc_np.h> // for malloc_usable_size
#endif // if defined(__FreeBSD__)
#if defined(XP_WIN) || (defined(XP_OS2) && defined(__declspec))
# define MOZALLOC_EXPORT __declspec(dllexport)
@ -213,8 +210,7 @@ moz_malloc_usable_size(void *ptr)
#if defined(XP_MACOSX)
return malloc_size(ptr);
#elif defined(MOZ_MEMORY) || (defined(XP_LINUX) && !defined(ANDROID)) || defined(__FreeBSD__)
// Android bionic libc doesn't have malloc_usable_size.
#elif defined(HAVE_MALLOC_USABLE_SIZE) || defined(MOZ_MEMORY)
return malloc_usable_size(ptr);
#elif defined(XP_WIN)
return _msize(ptr);