Bug 1104651 - Make valloc optional, r=glandium
authorMichael Wu <mwu@mozilla.com>
Tue, 16 Dec 2014 20:34:56 -0500
changeset 248167 a5e74ea5a1594dab03f3d06e28e065f6de65abdd
parent 248166 164949cf7a7940c98dd6614185ba8918d67ebb09
child 248168 997e003830a88482783058a746e790730fdde1c6
push id698
push userjlund@mozilla.com
push dateMon, 23 Mar 2015 22:08:11 +0000
treeherdermozilla-release@b0c0ae7b02a3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium
bugs1104651
milestone37.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1104651 - Make valloc optional, r=glandium
config/check_vanilla_allocations.py
configure.in
js/src/jsutil.cpp
--- a/config/check_vanilla_allocations.py
+++ b/config/check_vanilla_allocations.py
@@ -86,20 +86,20 @@ def main():
     alloc_fns = [
         # Matches |operator new(unsigned T)|, where |T| is |int| or |long|.
         r'operator new\(unsigned',
 
         # Matches |operator new[](unsigned T)|, where |T| is |int| or |long|.
         r'operator new\[\]\(unsigned',
 
         r'memalign',
-        # These two aren't available on all Linux configurations.
+        # These three aren't available on all Linux configurations.
         #r'posix_memalign',
         #r'aligned_alloc',
-        r'valloc',
+        #r'valloc',
     ]
 
     if args.aggressive:
         alloc_fns += [
             r'malloc',
             r'calloc',
             r'realloc',
             r'free',
--- a/configure.in
+++ b/configure.in
@@ -3388,20 +3388,34 @@ 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
 
-AC_CHECK_FUNCS(strndup posix_memalign memalign valloc)
+AC_CHECK_FUNCS(strndup posix_memalign memalign)
 
 AC_CHECK_FUNCS(malloc_usable_size)
 
+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]))
+
 dnl See if compiler supports some gcc-style attributes
 
 AC_CACHE_CHECK(for __attribute__((always_inline)),
                ac_cv_attribute_always_inline,
                [AC_TRY_COMPILE([inline void f(void) __attribute__((always_inline));],
                                [],
                                ac_cv_attribute_always_inline=yes,
                                ac_cv_attribute_always_inline=no)])
--- a/js/src/jsutil.cpp
+++ b/js/src/jsutil.cpp
@@ -50,31 +50,32 @@ namespace js {
 // This function calls all the vanilla heap allocation functions.  It is never
 // called, and exists purely to help config/check_vanilla_allocations.py.  See
 // that script for more details.
 extern void
 AllTheNonBasicVanillaNewAllocations()
 {
     // posix_memalign and aligned_alloc aren't available on all Linux
     // configurations.
+    // valloc was deprecated in Android 5.0
     //char *q;
     //posix_memalign((void**)&q, 16, 16);
 
     intptr_t p =
         intptr_t(malloc(16)) +
         intptr_t(calloc(1, 16)) +
         intptr_t(realloc(nullptr, 16)) +
         intptr_t(new char) +
         intptr_t(new char) +
         intptr_t(new char) +
         intptr_t(new char[16]) +
         intptr_t(memalign(16, 16)) +
         //intptr_t(q) +
         //intptr_t(aligned_alloc(16, 16)) +
-        intptr_t(valloc(4096)) +
+        //intptr_t(valloc(4096)) +
         intptr_t(strdup("dummy"));
 
     printf("%u\n", uint32_t(p));  // make sure |p| is not optimized away
 
     free((int*)p);      // this would crash if ever actually called
 
     MOZ_CRASH();
 }