Bug 780287 - Don't wrap jemalloc on gonk, r=glandium
authorMichael Wu <mwu@mozilla.com>
Mon, 06 Aug 2012 16:22:26 -0400
changeset 107035 853059c5f3db02bc58d8c0f27368835e62bcde32
parent 107031 870b30638837c578560a5538e1a34e2287ff81a3
child 107036 fa77c8c2a3464037199d9333fa051d89857a6c52
push idunknown
push userunknown
push dateunknown
reviewersglandium
bugs780287
milestone17.0a1
Bug 780287 - Don't wrap jemalloc on gonk, r=glandium
configure.in
memory/build/extraMallocFuncs.c
memory/mozjemalloc/jemalloc.c
--- a/configure.in
+++ b/configure.in
@@ -190,20 +190,20 @@ if test -n "$gonkdir" ; then
     i?86)
         ARCH_DIR=arch-x86
         ;;
     esac
 
     CPPFLAGS="-DANDROID -isystem $gonkdir/bionic/libc/$ARCH_DIR/include -isystem $gonkdir/bionic/libc/include/ -isystem $gonkdir/bionic/libc/kernel/common -isystem $gonkdir/bionic/libc/kernel/$ARCH_DIR -isystem $gonkdir/bionic/libm/include -I$gonkdir/frameworks/base/opengl/include -I$gonkdir/frameworks/base/native/include -I$gonkdir/hardware/libhardware/include -I$gonkdir/hardware/libhardware_legacy/include -I$gonkdir/system -I$gonkdir/system/core/include -isystem $gonkdir/bionic -I$gonkdir/frameworks/base/include -I$gonkdir/external/dbus $CPPFLAGS -I$gonkdir/frameworks/base/services/sensorservice -I$gonkdir/frameworks/base/services/camera"
     CFLAGS="-mandroid -fno-short-enums -fno-exceptions $CFLAGS"
     CXXFLAGS="-mandroid -fno-short-enums -fno-exceptions $CXXFLAGS $STLPORT_CPPFLAGS"
-    LIBS="$LIBS $STLPORT_LIBS"
-
     dnl Add -llog by default, since we use it all over the place.
-    LDFLAGS="-mandroid -L$gonkdir/out/target/product/$GONK_PRODUCT/obj/lib -Wl,-rpath-link=$gonkdir/out/target/product/$GONK_PRODUCT/obj/lib --sysroot=$gonkdir/out/target/product/$GONK_PRODUCT/obj/ -llog $LDFLAGS"
+    LIBS="$LIBS -llog $STLPORT_LIBS"
+
+    LDFLAGS="-mandroid -L$gonkdir/out/target/product/$GONK_PRODUCT/obj/lib -Wl,-rpath-link=$gonkdir/out/target/product/$GONK_PRODUCT/obj/lib --sysroot=$gonkdir/out/target/product/$GONK_PRODUCT/obj/ $LDFLAGS"
 
     dnl prevent cross compile section from using these flags as host flags
     if test -z "$HOST_CPPFLAGS" ; then
         HOST_CPPFLAGS=" "
     fi
     if test -z "$HOST_CFLAGS" ; then
         HOST_CFLAGS=" "
     fi
@@ -6965,17 +6965,21 @@ else
     AC_DEFINE(MOZ_MEMORY_DARWIN)
     ;;
   *-*freebsd*)
     AC_DEFINE(MOZ_MEMORY_BSD)
     ;;
   *-android*|*-linuxandroid*)
     AC_DEFINE(MOZ_MEMORY_LINUX)
     AC_DEFINE(MOZ_MEMORY_ANDROID)
-    _WRAP_MALLOC=1
+    if test -z "$gonkdir"; then
+      _WRAP_MALLOC=1
+    else
+      AC_DEFINE(MOZ_MEMORY_GONK)
+    fi
     MOZ_GLUE_LDFLAGS=
     ;;
   *-*linux*)
     AC_DEFINE(MOZ_MEMORY_LINUX)
     ;;
   *-netbsd*)
     AC_DEFINE(MOZ_MEMORY_BSD)
     ;;
--- a/memory/build/extraMallocFuncs.c
+++ b/memory/build/extraMallocFuncs.c
@@ -1,19 +1,21 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include <string.h>
 #include "mozilla/Types.h"
 
-#ifdef ANDROID
+#ifdef MOZ_WIDGET_ANDROID
 #define wrap(a) __wrap_ ## a
 #elif defined(XP_WIN) || defined(XP_MACOSX)
 #define wrap(a) je_ ## a
+#elif defined(MOZ_WIDGET_GONK)
+#define wrap(a) a
 #endif
 
 #ifdef wrap
 void *wrap(malloc)(size_t);
 void wrap(free)(void *);
 #endif
 
 #ifdef ANDROID
--- a/memory/mozjemalloc/jemalloc.c
+++ b/memory/mozjemalloc/jemalloc.c
@@ -6213,16 +6213,17 @@ malloc_shutdown()
 /******************************************************************************/
 /*
  * Begin malloc(3)-compatible functions.
  */
 
 /*
  * Mangle standard interfaces, in order to avoid linking problems.
  */
+#ifndef MOZ_MEMORY_GONK
 #if defined(MOZ_MEMORY_DARWIN) || defined(MOZ_MEMORY_WINDOWS) || \
     defined(MOZ_MEMORY_ANDROID)
 
 #ifdef MOZ_MEMORY_ANDROID
 /*
  * On Android, we use __wrap_* instead of je_* to accomodate with the
  * linker's --wrap option we use. That option prefixes the function
  * names it is given with __wrap_.
@@ -6236,16 +6237,17 @@ malloc_shutdown()
 #define memalign(a, b)          wrap(memalign)(a, b)
 #define posix_memalign(a, b, c) wrap(posix_memalign)(a, b, c)
 #define valloc(a)               wrap(valloc)(a)
 #define calloc(a, b)            wrap(calloc)(a, b)
 #define realloc(a, b)           wrap(realloc)(a, b)
 #define free(a)                 wrap(free)(a)
 #define malloc_usable_size(a)   wrap(malloc_usable_size)(a)
 #endif
+#endif
 
 /*
  * Even though we compile with MOZ_MEMORY, we may have to dynamically decide
  * not to use jemalloc, as discussed above. However, we call jemalloc
  * functions directly from mozalloc. Since it's pretty dangerous to mix the
  * allocators, we need to call the OSX allocators from the functions below,
  * when osx_use_jemalloc is not (dynamically) set.
  *