[SVN-Commit] r1025 - in trunk: mail/thunderbird/files
www/firefox-nightly/files www/firefox/files www/libxul/files
www/seamonkey/files
svn-freebsd-gecko at chruetertee.ch
svn-freebsd-gecko at chruetertee.ch
Sat Sep 22 09:45:22 UTC 2012
Author: jbeich
Date: Sat Sep 22 09:45:15 2012
New Revision: 1025
Log:
sync with bug 788955
Modified:
trunk/mail/thunderbird/files/patch-bug788955
trunk/www/firefox-nightly/files/patch-bug788955
trunk/www/firefox/files/patch-bug788955
trunk/www/libxul/files/patch-bug788955
trunk/www/seamonkey/files/patch-bug788955
Modified: trunk/mail/thunderbird/files/patch-bug788955
==============================================================================
--- trunk/mail/thunderbird/files/patch-bug788955 Sat Sep 22 09:45:05 2012 (r1024)
+++ trunk/mail/thunderbird/files/patch-bug788955 Sat Sep 22 09:45:15 2012 (r1025)
@@ -1,16 +1,31 @@
diff --git Makefile.in Makefile.in
-index e341462..26d19ad 100644
+index e341462..f75bd55 100644
--- mozilla/Makefile.in
+++ mozilla/Makefile.in
-@@ -47,7 +47,7 @@ endif
-
+@@ -48,8 +48,10 @@ endif
ifdef MOZ_MEMORY
tier_base_dirs += memory/mozjemalloc
--ifdef MOZ_JEMALLOC
-+ifeq (1_,$(MOZ_JEMALLOC)_$(MOZ_NATIVE_JEMALLOC))
+ ifdef MOZ_JEMALLOC
++ifndef MOZ_NATIVE_JEMALLOC
tier_base_dirs += memory/jemalloc
endif
++endif
tier_base_dirs += memory/build
+ endif
+ ifndef MOZ_NATIVE_ZLIB
+diff --git allmakefiles.sh allmakefiles.sh
+index 6a9be4b..544beff 100755
+--- mozilla/allmakefiles.sh
++++ mozilla/allmakefiles.sh
+@@ -59,7 +59,7 @@ if [ ! "$LIBXUL_SDK" ]; then
+ mozglue/Makefile
+ mozglue/build/Makefile
+ "
+- if [ "$MOZ_JEMALLOC" ]; then
++ if [ "$MOZ_JEMALLOC" -a ! "$MOZ_NATIVE_JEMALLOC" ]; then
+ add_makefiles "
+ memory/jemalloc/Makefile
+ "
--- mozilla/config/autoconf.mk.in
+++ mozilla/config/autoconf.mk.in
@@ -74,6 +74,7 @@ MOZ_JSDEBUGGER = @MOZ_JSDEBUGGER@
@@ -22,10 +37,10 @@
MOZ_ENABLE_PROFILER_SPS = @MOZ_ENABLE_PROFILER_SPS@
MOZ_JPROF = @MOZ_JPROF@
diff --git configure.in configure.in
-index 4070d8c..3b39473 100644
+index cfcdbc0..ee9a299 100644
--- mozilla/configure.in
+++ mozilla/configure.in
-@@ -3670,21 +3670,22 @@ fi
+@@ -3730,21 +3730,22 @@ fi
dnl Check for the existence of various allocation headers/functions
@@ -57,45 +72,100 @@
dnl See if compiler supports some gcc-style attributes
AC_CACHE_CHECK(for __attribute__((always_inline)),
-@@ -6902,7 +6903,21 @@ if test -z "$MOZ_MEMORY"; then
- AC_MSG_WARN([When not building jemalloc, you need to set WIN32_REDIST_DIR to the path to the Visual C++ Redist (usually VCINSTALLDIR\redist\x86\Microsoft.VC80.CRT, for VC++ v8) if you intend to distribute your build.])
- fi
- ;;
-+ *-freebsd*)
-+ MOZ_JEMALLOC=1
-+ ;;
- esac
-+
+@@ -6960,6 +6961,18 @@ else
+ fi
+
+ if test -z "$MOZ_MEMORY"; then
+ if test -n "$MOZ_JEMALLOC"; then
-+ AC_CHECK_FUNCS(mallctl nallocm,
-+ [MOZ_NATIVE_JEMALLOC=1 MOZ_MEMORY=1],
-+ [MOZ_NATIVE_JEMALLOC= MOZ_MEMORY=])
++ MOZ_NATIVE_JEMALLOC=1
++ AC_CHECK_FUNCS(mallctl nallocm,,
++ [MOZ_NATIVE_JEMALLOC=
++ break])
++ if test -n "$MOZ_NATIVE_JEMALLOC"; then
++ MOZ_MEMORY=1
++ AC_DEFINE(MOZ_MEMORY)
++ AC_DEFINE(MOZ_JEMALLOC)
++ AC_DEFINE(MOZ_NATIVE_JEMALLOC)
++ fi
+ fi
-+ if test -n "$MOZ_NATIVE_JEMALLOC"; then
-+ AC_DEFINE(MOZ_NATIVE_JEMALLOC)
-+ AC_DEFINE(MOZ_MEMORY)
-+ AC_DEFINE(MOZ_JEMALLOC)
-+ fi
- else
- dnl Don't try to run compiler tests on Windows
- if test "$OS_ARCH" = "WINNT"; then
-@@ -6988,6 +7003,7 @@ else
- ;;
- esac
+ case "${target}" in
+ *-mingw*)
+ if test -z "$WIN32_REDIST_DIR" -a -z "$MOZ_DEBUG"; then
+@@ -7054,6 +7067,7 @@ else
fi # MOZ_MEMORY
-+AC_SUBST(MOZ_NATIVE_JEMALLOC)
AC_SUBST(MOZ_MEMORY)
AC_SUBST(MOZ_JEMALLOC)
++AC_SUBST(MOZ_NATIVE_JEMALLOC)
AC_SUBST(MOZ_GLUE_LDFLAGS)
-@@ -8754,7 +8770,7 @@ fi
+ AC_SUBST(MOZ_GLUE_PROGRAM_LDFLAGS)
+ AC_SUBST(WIN32_CRT_LIBS)
+@@ -8819,10 +8833,27 @@ fi
# Run jemalloc configure script
-if test "$MOZ_JEMALLOC" -a "$MOZ_MEMORY"; then
+if test -z "$MOZ_NATIVE_JEMALLOC" -a "$MOZ_JEMALLOC" -a "$MOZ_MEMORY" ; then
ac_configure_args="$_SUBDIR_CONFIG_ARGS --build=$build --host=$target --enable-stats --with-jemalloc-prefix=je_"
- if test "$OS_ARCH" = "Linux"; then
- MANGLE="malloc calloc valloc free realloc memalign posix_memalign malloc_usable_size"
+- if test "$OS_ARCH" = "Linux"; then
+- MANGLE="malloc calloc valloc free realloc memalign posix_memalign malloc_usable_size"
++ case "$OS_ARCH" in
++ Linux)
++ MANGLE="malloc calloc valloc free realloc memalign posix_memalign malloc_usable_size"
++ ;;
++ DragonFly|NetBSD|OpenBSD)
++ MANGLE="malloc calloc valloc free realloc posix_memalign"
++ ;;
++ FreeBSD)
++ # common
++ MANGLE="malloc calloc valloc free realloc posix_memalign malloc_usable_size"
++ # old jemalloc
++ MANGLE="$MANGLE reallocf _malloc_message _malloc_options"
++ # jemalloc 3.0.0
++ MANGLE="$MANGLE aligned_alloc malloc_message malloc_conf"
++ MANGLE="$MANGLE malloc_stats_print mallctl mallctlnametomib mallctlbymib"
++ MANGLE="$MANGLE allocm rallocm sallocm dallocm nallocm"
++ ;;
++ esac
++ if test -n "$MANGLE"; then
+ MANGLED=
+ JEMALLOC_WRAPPER=
+ if test -n "$_WRAP_MALLOC"; then
+diff --git js/src/configure.in js/src/configure.in
+index 846482c..4022506 100644
+--- mozilla/js/src/configure.in
++++ mozilla/js/src/configure.in
+@@ -3094,21 +3094,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)),
diff --git memory/build/Makefile.in memory/build/Makefile.in
index dca0f48..af93ee0 100644
--- mozilla/memory/build/Makefile.in
@@ -110,28 +180,67 @@
else
SHARED_LIBRARY_LIBS += $(call EXPAND_LIBNAME_PATH,jemalloc,$(DEPTH)/memory/mozjemalloc)
endif
+diff --git memory/build/extraMallocFuncs.c memory/build/extraMallocFuncs.c
+index 9d87629..76a2981 100644
+--- mozilla/memory/build/extraMallocFuncs.c
++++ mozilla/memory/build/extraMallocFuncs.c
+@@ -94,7 +94,19 @@ wrap(wcsdup)(const wchar_t *src)
+ #endif
+
+ #ifdef MOZ_JEMALLOC
++#if defined(MALLOC_H) && defined(MOZ_NATIVE_JEMALLOC)
++#include MALLOC_H
++#endif
++
++#if defined(MOZ_NATIVE_JEMALLOC) || defined(__FreeBSD__)
++#define je_malloc_conf malloc_conf
++#define je_malloc_message malloc_message
++#endif
++
+ /* Override some jemalloc defaults */
++#if defined(MOZ_NATIVE_JEMALLOC)
++MOZ_EXTERNAL_VIS
++#endif
+ const char *je_malloc_conf = "narenas:1,lg_chunk:20";
+
+ #ifdef ANDROID
diff --git memory/build/mozjemalloc_compat.c memory/build/mozjemalloc_compat.c
-index 10a845a..57245f6 100644
+index 10a845a..798c299 100644
--- mozilla/memory/build/mozjemalloc_compat.c
+++ mozilla/memory/build/mozjemalloc_compat.c
-@@ -5,7 +5,15 @@
+@@ -5,7 +5,17 @@
#include "mozilla/Types.h"
#include "jemalloc_types.h"
-+#if defined(MALLOC_H)
-+#include MALLOC_H /* for mallctl */
++#if defined(MALLOC_H) && defined(MOZ_NATIVE_JEMALLOC)
++#include MALLOC_H
+#endif
+
-+#if defined(MOZ_NATIVE_JEMALLOC)
++#if defined(MOZ_NATIVE_JEMALLOC) || defined(__FreeBSD__)
+#define je_mallctl mallctl
-+#else
++#endif
++
++#if !defined(MOZ_NATIVE_JEMALLOC)
extern int je_mallctl(const char*, void*, size_t*, void*, size_t);
+#endif
MOZ_EXPORT_API (void)
jemalloc_stats(jemalloc_stats_t *stats)
+diff --git memory/jemalloc/src/src/mutex.c memory/jemalloc/src/src/mutex.c
+index 37a843e..55e18c2 100644
+--- mozilla/memory/jemalloc/src/src/mutex.c
++++ mozilla/memory/jemalloc/src/src/mutex.c
+@@ -64,7 +64,7 @@ pthread_create(pthread_t *__restrict thread,
+ /******************************************************************************/
+
+ #ifdef JEMALLOC_MUTEX_INIT_CB
+-int _pthread_mutex_init_calloc_cb(pthread_mutex_t *mutex,
++JEMALLOC_EXPORT int _pthread_mutex_init_calloc_cb(pthread_mutex_t *mutex,
+ void *(calloc_cb)(size_t, size_t));
+ #endif
+
diff --git memory/mozalloc/mozalloc.cpp memory/mozalloc/mozalloc.cpp
-index 5b61050b..16bba36 100644
+index 5b61050b..5b3399a 100644
--- mozilla/memory/mozalloc/mozalloc.cpp
+++ mozilla/memory/mozalloc/mozalloc.cpp
@@ -12,16 +12,13 @@
@@ -158,48 +267,59 @@
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(MOZ_MEMORY) || defined(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);
diff --git memory/mozjemalloc/jemalloc.h memory/mozjemalloc/jemalloc.h
-index f0e0878..8f78123 100644
+index f0e0878..e74fb4d 100644
--- mozilla/memory/mozjemalloc/jemalloc.h
+++ mozilla/memory/mozjemalloc/jemalloc.h
-@@ -32,8 +32,8 @@
+@@ -32,23 +32,29 @@
#ifndef _JEMALLOC_H_
#define _JEMALLOC_H_
-#if defined(MOZ_MEMORY_DARWIN)
-#include <malloc/malloc.h>
-+#if defined(MALLOC_H)
-+#include MALLOC_H /* for malloc_good_size and nallocm */
++#if defined(MALLOC_H) \
++ && (defined(MOZ_NATIVE_JEMALLOC) || defined(MOZ_MEMORY_DARWIN))
++#include MALLOC_H
#endif
#include "jemalloc_types.h"
-@@ -51,7 +51,9 @@ void jemalloc_stats(jemalloc_stats_t *stats);
- #if defined(MOZ_MEMORY_LINUX)
++#if defined(MOZ_NATIVE_JEMALLOC) || defined(__FreeBSD__)
++#define je_nallocm nallocm
++#endif
++
+ #ifdef __cplusplus
+ extern "C" {
+ #endif
+
+-#if defined(MOZ_MEMORY_LINUX)
++#if defined(MOZ_NATIVE_JEMALLOC) \
++ || defined(MOZ_MEMORY_LINUX) || defined(MOZ_MEMORY_BSD)
__attribute__((weak))
#endif
--#if defined(MOZ_JEMALLOC)
-+#if defined(MOZ_NATIVE_JEMALLOC)
-+#define je_nallocm nallocm
-+#elif defined(MOZ_JEMALLOC)
- int je_nallocm(size_t *rsize, size_t size, int flags);
- #else
- size_t je_malloc_good_size(size_t size);
-diff --git toolkit/library/Makefile.in toolkit/library/Makefile.in
-index 7dbbbc6..0b06ad0 100644
---- mozilla/toolkit/library/Makefile.in
-+++ mozilla/toolkit/library/Makefile.in
-@@ -346,6 +346,10 @@ EXTRA_DSO_LDOPTS += \
- $(SQLITE_LIBS) \
- $(NULL)
+ void jemalloc_stats(jemalloc_stats_t *stats);
-+ifdef MOZ_NATIVE_JEMALLOC
-+EXTRA_DSO_LDOPTS += $(call EXPAND_LIBNAME_PATH,memory,$(DIST)/lib)
-+endif
-+
- ifdef MOZ_NATIVE_JPEG
- EXTRA_DSO_LDOPTS += $(MOZ_JPEG_LIBS)
+ /* Computes the usable size in advance. */
+-#if !defined(MOZ_MEMORY_DARWIN)
+-#if defined(MOZ_MEMORY_LINUX)
++#if !defined(MOZ_NATIVE_JEMALLOC) && !defined(MOZ_MEMORY_DARWIN)
++#if defined(MOZ_MEMORY_LINUX) || defined(MOZ_MEMORY_BSD)
+ __attribute__((weak))
+ #endif
+ #if defined(MOZ_JEMALLOC)
+diff --git mozglue/build/Makefile.in mozglue/build/Makefile.in
+index c333647..15ba505 100644
+--- mozilla/mozglue/build/Makefile.in
++++ mozilla/mozglue/build/Makefile.in
+@@ -23,7 +23,7 @@ FORCE_STATIC_LIB = 1
endif
+
+ # Keep jemalloc separated when mozglue is statically linked
+-ifeq (1_1,$(MOZ_MEMORY)_$(FORCE_SHARED_LIB))
++ifeq (1_1,$(MOZ_MEMORY)_$(or $(MOZ_NATIVE_JEMALLOC),$(FORCE_SHARED_LIB)))
+ SHARED_LIBRARY_LIBS = $(call EXPAND_LIBNAME_PATH,memory,$(DEPTH)/memory/build)
+ else
+ # Temporary, until bug 662814 lands
Modified: trunk/www/firefox-nightly/files/patch-bug788955
==============================================================================
--- trunk/www/firefox-nightly/files/patch-bug788955 Sat Sep 22 09:45:05 2012 (r1024)
+++ trunk/www/firefox-nightly/files/patch-bug788955 Sat Sep 22 09:45:15 2012 (r1025)
@@ -1,21 +1,36 @@
diff --git Makefile.in Makefile.in
-index e341462..26d19ad 100644
+index e341462..f75bd55 100644
--- Makefile.in
+++ Makefile.in
-@@ -47,7 +47,7 @@ endif
-
+@@ -48,8 +48,10 @@ endif
ifdef MOZ_MEMORY
tier_base_dirs += memory/mozjemalloc
--ifdef MOZ_JEMALLOC
-+ifeq (1_,$(MOZ_JEMALLOC)_$(MOZ_NATIVE_JEMALLOC))
+ ifdef MOZ_JEMALLOC
++ifndef MOZ_NATIVE_JEMALLOC
tier_base_dirs += memory/jemalloc
endif
++endif
tier_base_dirs += memory/build
+ endif
+ ifndef MOZ_NATIVE_ZLIB
+diff --git allmakefiles.sh allmakefiles.sh
+index 6a9be4b..544beff 100755
+--- allmakefiles.sh
++++ allmakefiles.sh
+@@ -59,7 +59,7 @@ if [ ! "$LIBXUL_SDK" ]; then
+ mozglue/Makefile
+ mozglue/build/Makefile
+ "
+- if [ "$MOZ_JEMALLOC" ]; then
++ if [ "$MOZ_JEMALLOC" -a ! "$MOZ_NATIVE_JEMALLOC" ]; then
+ add_makefiles "
+ memory/jemalloc/Makefile
+ "
diff --git configure.in configure.in
-index 4070d8c..3b39473 100644
+index cfcdbc0..ee9a299 100644
--- configure.in
+++ configure.in
-@@ -3670,21 +3670,22 @@ fi
+@@ -3730,21 +3730,22 @@ fi
dnl Check for the existence of various allocation headers/functions
@@ -47,45 +62,100 @@
dnl See if compiler supports some gcc-style attributes
AC_CACHE_CHECK(for __attribute__((always_inline)),
-@@ -6902,7 +6903,21 @@ if test -z "$MOZ_MEMORY"; then
- AC_MSG_WARN([When not building jemalloc, you need to set WIN32_REDIST_DIR to the path to the Visual C++ Redist (usually VCINSTALLDIR\redist\x86\Microsoft.VC80.CRT, for VC++ v8) if you intend to distribute your build.])
- fi
- ;;
-+ *-freebsd*)
-+ MOZ_JEMALLOC=1
-+ ;;
- esac
-+
+@@ -6960,6 +6961,18 @@ else
+ fi
+
+ if test -z "$MOZ_MEMORY"; then
+ if test -n "$MOZ_JEMALLOC"; then
-+ AC_CHECK_FUNCS(mallctl nallocm,
-+ [MOZ_NATIVE_JEMALLOC=1 MOZ_MEMORY=1],
-+ [MOZ_NATIVE_JEMALLOC= MOZ_MEMORY=])
++ MOZ_NATIVE_JEMALLOC=1
++ AC_CHECK_FUNCS(mallctl nallocm,,
++ [MOZ_NATIVE_JEMALLOC=
++ break])
++ if test -n "$MOZ_NATIVE_JEMALLOC"; then
++ MOZ_MEMORY=1
++ AC_DEFINE(MOZ_MEMORY)
++ AC_DEFINE(MOZ_JEMALLOC)
++ AC_DEFINE(MOZ_NATIVE_JEMALLOC)
++ fi
+ fi
-+ if test -n "$MOZ_NATIVE_JEMALLOC"; then
-+ AC_DEFINE(MOZ_NATIVE_JEMALLOC)
-+ AC_DEFINE(MOZ_MEMORY)
-+ AC_DEFINE(MOZ_JEMALLOC)
-+ fi
- else
- dnl Don't try to run compiler tests on Windows
- if test "$OS_ARCH" = "WINNT"; then
-@@ -6988,6 +7003,7 @@ else
- ;;
- esac
+ case "${target}" in
+ *-mingw*)
+ if test -z "$WIN32_REDIST_DIR" -a -z "$MOZ_DEBUG"; then
+@@ -7054,6 +7067,7 @@ else
fi # MOZ_MEMORY
-+AC_SUBST(MOZ_NATIVE_JEMALLOC)
AC_SUBST(MOZ_MEMORY)
AC_SUBST(MOZ_JEMALLOC)
++AC_SUBST(MOZ_NATIVE_JEMALLOC)
AC_SUBST(MOZ_GLUE_LDFLAGS)
-@@ -8754,7 +8770,7 @@ fi
+ AC_SUBST(MOZ_GLUE_PROGRAM_LDFLAGS)
+ AC_SUBST(WIN32_CRT_LIBS)
+@@ -8819,10 +8833,27 @@ fi
# Run jemalloc configure script
-if test "$MOZ_JEMALLOC" -a "$MOZ_MEMORY"; then
+if test -z "$MOZ_NATIVE_JEMALLOC" -a "$MOZ_JEMALLOC" -a "$MOZ_MEMORY" ; then
ac_configure_args="$_SUBDIR_CONFIG_ARGS --build=$build --host=$target --enable-stats --with-jemalloc-prefix=je_"
- if test "$OS_ARCH" = "Linux"; then
- MANGLE="malloc calloc valloc free realloc memalign posix_memalign malloc_usable_size"
+- if test "$OS_ARCH" = "Linux"; then
+- MANGLE="malloc calloc valloc free realloc memalign posix_memalign malloc_usable_size"
++ case "$OS_ARCH" in
++ Linux)
++ MANGLE="malloc calloc valloc free realloc memalign posix_memalign malloc_usable_size"
++ ;;
++ DragonFly|NetBSD|OpenBSD)
++ MANGLE="malloc calloc valloc free realloc posix_memalign"
++ ;;
++ FreeBSD)
++ # common
++ MANGLE="malloc calloc valloc free realloc posix_memalign malloc_usable_size"
++ # old jemalloc
++ MANGLE="$MANGLE reallocf _malloc_message _malloc_options"
++ # jemalloc 3.0.0
++ MANGLE="$MANGLE aligned_alloc malloc_message malloc_conf"
++ MANGLE="$MANGLE malloc_stats_print mallctl mallctlnametomib mallctlbymib"
++ MANGLE="$MANGLE allocm rallocm sallocm dallocm nallocm"
++ ;;
++ esac
++ if test -n "$MANGLE"; then
+ MANGLED=
+ JEMALLOC_WRAPPER=
+ if test -n "$_WRAP_MALLOC"; then
+diff --git js/src/configure.in js/src/configure.in
+index 846482c..4022506 100644
+--- js/src/configure.in
++++ js/src/configure.in
+@@ -3094,21 +3094,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)),
diff --git memory/build/Makefile.in memory/build/Makefile.in
index dca0f48..af93ee0 100644
--- memory/build/Makefile.in
@@ -100,28 +170,67 @@
else
SHARED_LIBRARY_LIBS += $(call EXPAND_LIBNAME_PATH,jemalloc,$(DEPTH)/memory/mozjemalloc)
endif
+diff --git memory/build/extraMallocFuncs.c memory/build/extraMallocFuncs.c
+index 9d87629..76a2981 100644
+--- memory/build/extraMallocFuncs.c
++++ memory/build/extraMallocFuncs.c
+@@ -94,7 +94,19 @@ wrap(wcsdup)(const wchar_t *src)
+ #endif
+
+ #ifdef MOZ_JEMALLOC
++#if defined(MALLOC_H) && defined(MOZ_NATIVE_JEMALLOC)
++#include MALLOC_H
++#endif
++
++#if defined(MOZ_NATIVE_JEMALLOC) || defined(__FreeBSD__)
++#define je_malloc_conf malloc_conf
++#define je_malloc_message malloc_message
++#endif
++
+ /* Override some jemalloc defaults */
++#if defined(MOZ_NATIVE_JEMALLOC)
++MOZ_EXTERNAL_VIS
++#endif
+ const char *je_malloc_conf = "narenas:1,lg_chunk:20";
+
+ #ifdef ANDROID
diff --git memory/build/mozjemalloc_compat.c memory/build/mozjemalloc_compat.c
-index 10a845a..57245f6 100644
+index 10a845a..798c299 100644
--- memory/build/mozjemalloc_compat.c
+++ memory/build/mozjemalloc_compat.c
-@@ -5,7 +5,15 @@
+@@ -5,7 +5,17 @@
#include "mozilla/Types.h"
#include "jemalloc_types.h"
-+#if defined(MALLOC_H)
-+#include MALLOC_H /* for mallctl */
++#if defined(MALLOC_H) && defined(MOZ_NATIVE_JEMALLOC)
++#include MALLOC_H
+#endif
+
-+#if defined(MOZ_NATIVE_JEMALLOC)
++#if defined(MOZ_NATIVE_JEMALLOC) || defined(__FreeBSD__)
+#define je_mallctl mallctl
-+#else
++#endif
++
++#if !defined(MOZ_NATIVE_JEMALLOC)
extern int je_mallctl(const char*, void*, size_t*, void*, size_t);
+#endif
MOZ_EXPORT_API (void)
jemalloc_stats(jemalloc_stats_t *stats)
+diff --git memory/jemalloc/src/src/mutex.c memory/jemalloc/src/src/mutex.c
+index 37a843e..55e18c2 100644
+--- memory/jemalloc/src/src/mutex.c
++++ memory/jemalloc/src/src/mutex.c
+@@ -64,7 +64,7 @@ pthread_create(pthread_t *__restrict thread,
+ /******************************************************************************/
+
+ #ifdef JEMALLOC_MUTEX_INIT_CB
+-int _pthread_mutex_init_calloc_cb(pthread_mutex_t *mutex,
++JEMALLOC_EXPORT int _pthread_mutex_init_calloc_cb(pthread_mutex_t *mutex,
+ void *(calloc_cb)(size_t, size_t));
+ #endif
+
diff --git memory/mozalloc/mozalloc.cpp memory/mozalloc/mozalloc.cpp
-index 5b61050b..16bba36 100644
+index 5b61050b..5b3399a 100644
--- memory/mozalloc/mozalloc.cpp
+++ memory/mozalloc/mozalloc.cpp
@@ -12,16 +12,13 @@
@@ -148,48 +257,59 @@
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(MOZ_MEMORY) || defined(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);
diff --git memory/mozjemalloc/jemalloc.h memory/mozjemalloc/jemalloc.h
-index f0e0878..8f78123 100644
+index f0e0878..e74fb4d 100644
--- memory/mozjemalloc/jemalloc.h
+++ memory/mozjemalloc/jemalloc.h
-@@ -32,8 +32,8 @@
+@@ -32,23 +32,29 @@
#ifndef _JEMALLOC_H_
#define _JEMALLOC_H_
-#if defined(MOZ_MEMORY_DARWIN)
-#include <malloc/malloc.h>
-+#if defined(MALLOC_H)
-+#include MALLOC_H /* for malloc_good_size and nallocm */
++#if defined(MALLOC_H) \
++ && (defined(MOZ_NATIVE_JEMALLOC) || defined(MOZ_MEMORY_DARWIN))
++#include MALLOC_H
#endif
#include "jemalloc_types.h"
-@@ -51,7 +51,9 @@ void jemalloc_stats(jemalloc_stats_t *stats);
- #if defined(MOZ_MEMORY_LINUX)
++#if defined(MOZ_NATIVE_JEMALLOC) || defined(__FreeBSD__)
++#define je_nallocm nallocm
++#endif
++
+ #ifdef __cplusplus
+ extern "C" {
+ #endif
+
+-#if defined(MOZ_MEMORY_LINUX)
++#if defined(MOZ_NATIVE_JEMALLOC) \
++ || defined(MOZ_MEMORY_LINUX) || defined(MOZ_MEMORY_BSD)
__attribute__((weak))
#endif
--#if defined(MOZ_JEMALLOC)
-+#if defined(MOZ_NATIVE_JEMALLOC)
-+#define je_nallocm nallocm
-+#elif defined(MOZ_JEMALLOC)
- int je_nallocm(size_t *rsize, size_t size, int flags);
- #else
- size_t je_malloc_good_size(size_t size);
-diff --git toolkit/library/Makefile.in toolkit/library/Makefile.in
-index 7dbbbc6..0b06ad0 100644
---- toolkit/library/Makefile.in
-+++ toolkit/library/Makefile.in
-@@ -346,6 +346,10 @@ EXTRA_DSO_LDOPTS += \
- $(SQLITE_LIBS) \
- $(NULL)
+ void jemalloc_stats(jemalloc_stats_t *stats);
-+ifdef MOZ_NATIVE_JEMALLOC
-+EXTRA_DSO_LDOPTS += $(call EXPAND_LIBNAME_PATH,memory,$(DIST)/lib)
-+endif
-+
- ifdef MOZ_NATIVE_JPEG
- EXTRA_DSO_LDOPTS += $(MOZ_JPEG_LIBS)
+ /* Computes the usable size in advance. */
+-#if !defined(MOZ_MEMORY_DARWIN)
+-#if defined(MOZ_MEMORY_LINUX)
++#if !defined(MOZ_NATIVE_JEMALLOC) && !defined(MOZ_MEMORY_DARWIN)
++#if defined(MOZ_MEMORY_LINUX) || defined(MOZ_MEMORY_BSD)
+ __attribute__((weak))
+ #endif
+ #if defined(MOZ_JEMALLOC)
+diff --git mozglue/build/Makefile.in mozglue/build/Makefile.in
+index c333647..15ba505 100644
+--- mozglue/build/Makefile.in
++++ mozglue/build/Makefile.in
+@@ -23,7 +23,7 @@ FORCE_STATIC_LIB = 1
endif
+
+ # Keep jemalloc separated when mozglue is statically linked
+-ifeq (1_1,$(MOZ_MEMORY)_$(FORCE_SHARED_LIB))
++ifeq (1_1,$(MOZ_MEMORY)_$(or $(MOZ_NATIVE_JEMALLOC),$(FORCE_SHARED_LIB)))
+ SHARED_LIBRARY_LIBS = $(call EXPAND_LIBNAME_PATH,memory,$(DEPTH)/memory/build)
+ else
+ # Temporary, until bug 662814 lands
Modified: trunk/www/firefox/files/patch-bug788955
==============================================================================
--- trunk/www/firefox/files/patch-bug788955 Sat Sep 22 09:45:05 2012 (r1024)
+++ trunk/www/firefox/files/patch-bug788955 Sat Sep 22 09:45:15 2012 (r1025)
@@ -1,16 +1,31 @@
diff --git Makefile.in Makefile.in
-index e341462..26d19ad 100644
+index e341462..f75bd55 100644
--- Makefile.in
+++ Makefile.in
-@@ -47,7 +47,7 @@ endif
-
+@@ -48,8 +48,10 @@ endif
ifdef MOZ_MEMORY
tier_base_dirs += memory/mozjemalloc
--ifdef MOZ_JEMALLOC
-+ifeq (1_,$(MOZ_JEMALLOC)_$(MOZ_NATIVE_JEMALLOC))
+ ifdef MOZ_JEMALLOC
++ifndef MOZ_NATIVE_JEMALLOC
tier_base_dirs += memory/jemalloc
endif
++endif
tier_base_dirs += memory/build
+ endif
+ ifndef MOZ_NATIVE_ZLIB
+diff --git allmakefiles.sh allmakefiles.sh
+index 6a9be4b..544beff 100755
+--- allmakefiles.sh
++++ allmakefiles.sh
+@@ -59,7 +59,7 @@ if [ ! "$LIBXUL_SDK" ]; then
+ mozglue/Makefile
+ mozglue/build/Makefile
+ "
+- if [ "$MOZ_JEMALLOC" ]; then
++ if [ "$MOZ_JEMALLOC" -a ! "$MOZ_NATIVE_JEMALLOC" ]; then
+ add_makefiles "
+ memory/jemalloc/Makefile
+ "
--- config/autoconf.mk.in
+++ config/autoconf.mk.in
@@ -74,6 +74,7 @@ MOZ_JSDEBUGGER = @MOZ_JSDEBUGGER@
@@ -22,10 +37,10 @@
MOZ_ENABLE_PROFILER_SPS = @MOZ_ENABLE_PROFILER_SPS@
MOZ_JPROF = @MOZ_JPROF@
diff --git configure.in configure.in
-index 4070d8c..3b39473 100644
+index cfcdbc0..ee9a299 100644
--- configure.in
+++ configure.in
-@@ -3670,21 +3670,22 @@ fi
+@@ -3730,21 +3730,22 @@ fi
dnl Check for the existence of various allocation headers/functions
@@ -57,45 +72,100 @@
dnl See if compiler supports some gcc-style attributes
AC_CACHE_CHECK(for __attribute__((always_inline)),
-@@ -6902,7 +6903,21 @@ if test -z "$MOZ_MEMORY"; then
- AC_MSG_WARN([When not building jemalloc, you need to set WIN32_REDIST_DIR to the path to the Visual C++ Redist (usually VCINSTALLDIR\redist\x86\Microsoft.VC80.CRT, for VC++ v8) if you intend to distribute your build.])
- fi
- ;;
-+ *-freebsd*)
-+ MOZ_JEMALLOC=1
-+ ;;
- esac
-+
+@@ -6960,6 +6961,18 @@ else
+ fi
+
+ if test -z "$MOZ_MEMORY"; then
+ if test -n "$MOZ_JEMALLOC"; then
-+ AC_CHECK_FUNCS(mallctl nallocm,
-+ [MOZ_NATIVE_JEMALLOC=1 MOZ_MEMORY=1],
-+ [MOZ_NATIVE_JEMALLOC= MOZ_MEMORY=])
++ MOZ_NATIVE_JEMALLOC=1
++ AC_CHECK_FUNCS(mallctl nallocm,,
++ [MOZ_NATIVE_JEMALLOC=
++ break])
++ if test -n "$MOZ_NATIVE_JEMALLOC"; then
++ MOZ_MEMORY=1
++ AC_DEFINE(MOZ_MEMORY)
++ AC_DEFINE(MOZ_JEMALLOC)
++ AC_DEFINE(MOZ_NATIVE_JEMALLOC)
++ fi
+ fi
-+ if test -n "$MOZ_NATIVE_JEMALLOC"; then
-+ AC_DEFINE(MOZ_NATIVE_JEMALLOC)
-+ AC_DEFINE(MOZ_MEMORY)
-+ AC_DEFINE(MOZ_JEMALLOC)
-+ fi
- else
- dnl Don't try to run compiler tests on Windows
- if test "$OS_ARCH" = "WINNT"; then
-@@ -6988,6 +7003,7 @@ else
- ;;
- esac
+ case "${target}" in
+ *-mingw*)
+ if test -z "$WIN32_REDIST_DIR" -a -z "$MOZ_DEBUG"; then
+@@ -7054,6 +7067,7 @@ else
fi # MOZ_MEMORY
-+AC_SUBST(MOZ_NATIVE_JEMALLOC)
AC_SUBST(MOZ_MEMORY)
AC_SUBST(MOZ_JEMALLOC)
++AC_SUBST(MOZ_NATIVE_JEMALLOC)
AC_SUBST(MOZ_GLUE_LDFLAGS)
-@@ -8754,7 +8770,7 @@ fi
+ AC_SUBST(MOZ_GLUE_PROGRAM_LDFLAGS)
+ AC_SUBST(WIN32_CRT_LIBS)
+@@ -8819,10 +8833,27 @@ fi
# Run jemalloc configure script
-if test "$MOZ_JEMALLOC" -a "$MOZ_MEMORY"; then
+if test -z "$MOZ_NATIVE_JEMALLOC" -a "$MOZ_JEMALLOC" -a "$MOZ_MEMORY" ; then
ac_configure_args="$_SUBDIR_CONFIG_ARGS --build=$build --host=$target --enable-stats --with-jemalloc-prefix=je_"
- if test "$OS_ARCH" = "Linux"; then
- MANGLE="malloc calloc valloc free realloc memalign posix_memalign malloc_usable_size"
+- if test "$OS_ARCH" = "Linux"; then
+- MANGLE="malloc calloc valloc free realloc memalign posix_memalign malloc_usable_size"
++ case "$OS_ARCH" in
++ Linux)
++ MANGLE="malloc calloc valloc free realloc memalign posix_memalign malloc_usable_size"
++ ;;
++ DragonFly|NetBSD|OpenBSD)
++ MANGLE="malloc calloc valloc free realloc posix_memalign"
++ ;;
++ FreeBSD)
++ # common
++ MANGLE="malloc calloc valloc free realloc posix_memalign malloc_usable_size"
++ # old jemalloc
++ MANGLE="$MANGLE reallocf _malloc_message _malloc_options"
++ # jemalloc 3.0.0
++ MANGLE="$MANGLE aligned_alloc malloc_message malloc_conf"
++ MANGLE="$MANGLE malloc_stats_print mallctl mallctlnametomib mallctlbymib"
++ MANGLE="$MANGLE allocm rallocm sallocm dallocm nallocm"
++ ;;
++ esac
++ if test -n "$MANGLE"; then
+ MANGLED=
+ JEMALLOC_WRAPPER=
+ if test -n "$_WRAP_MALLOC"; then
+diff --git js/src/configure.in js/src/configure.in
+index 846482c..4022506 100644
+--- js/src/configure.in
++++ js/src/configure.in
+@@ -3094,21 +3094,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)),
diff --git memory/build/Makefile.in memory/build/Makefile.in
index dca0f48..af93ee0 100644
--- memory/build/Makefile.in
@@ -110,28 +180,67 @@
else
SHARED_LIBRARY_LIBS += $(call EXPAND_LIBNAME_PATH,jemalloc,$(DEPTH)/memory/mozjemalloc)
endif
+diff --git memory/build/extraMallocFuncs.c memory/build/extraMallocFuncs.c
+index 9d87629..76a2981 100644
+--- memory/build/extraMallocFuncs.c
++++ memory/build/extraMallocFuncs.c
+@@ -94,7 +94,19 @@ wrap(wcsdup)(const wchar_t *src)
+ #endif
+
+ #ifdef MOZ_JEMALLOC
++#if defined(MALLOC_H) && defined(MOZ_NATIVE_JEMALLOC)
++#include MALLOC_H
++#endif
++
++#if defined(MOZ_NATIVE_JEMALLOC) || defined(__FreeBSD__)
++#define je_malloc_conf malloc_conf
++#define je_malloc_message malloc_message
++#endif
++
+ /* Override some jemalloc defaults */
++#if defined(MOZ_NATIVE_JEMALLOC)
++MOZ_EXTERNAL_VIS
++#endif
+ const char *je_malloc_conf = "narenas:1,lg_chunk:20";
+
+ #ifdef ANDROID
diff --git memory/build/mozjemalloc_compat.c memory/build/mozjemalloc_compat.c
-index 10a845a..57245f6 100644
+index 10a845a..798c299 100644
--- memory/build/mozjemalloc_compat.c
+++ memory/build/mozjemalloc_compat.c
-@@ -5,7 +5,15 @@
+@@ -5,7 +5,17 @@
#include "mozilla/Types.h"
#include "jemalloc_types.h"
-+#if defined(MALLOC_H)
-+#include MALLOC_H /* for mallctl */
++#if defined(MALLOC_H) && defined(MOZ_NATIVE_JEMALLOC)
++#include MALLOC_H
+#endif
+
-+#if defined(MOZ_NATIVE_JEMALLOC)
++#if defined(MOZ_NATIVE_JEMALLOC) || defined(__FreeBSD__)
+#define je_mallctl mallctl
-+#else
++#endif
++
++#if !defined(MOZ_NATIVE_JEMALLOC)
extern int je_mallctl(const char*, void*, size_t*, void*, size_t);
+#endif
MOZ_EXPORT_API (void)
jemalloc_stats(jemalloc_stats_t *stats)
+diff --git memory/jemalloc/src/src/mutex.c memory/jemalloc/src/src/mutex.c
+index 37a843e..55e18c2 100644
+--- memory/jemalloc/src/src/mutex.c
++++ memory/jemalloc/src/src/mutex.c
+@@ -64,7 +64,7 @@ pthread_create(pthread_t *__restrict thread,
+ /******************************************************************************/
+
+ #ifdef JEMALLOC_MUTEX_INIT_CB
+-int _pthread_mutex_init_calloc_cb(pthread_mutex_t *mutex,
++JEMALLOC_EXPORT int _pthread_mutex_init_calloc_cb(pthread_mutex_t *mutex,
+ void *(calloc_cb)(size_t, size_t));
+ #endif
+
diff --git memory/mozalloc/mozalloc.cpp memory/mozalloc/mozalloc.cpp
-index 5b61050b..16bba36 100644
+index 5b61050b..5b3399a 100644
--- memory/mozalloc/mozalloc.cpp
+++ memory/mozalloc/mozalloc.cpp
@@ -12,16 +12,13 @@
@@ -158,48 +267,59 @@
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(MOZ_MEMORY) || defined(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);
diff --git memory/mozjemalloc/jemalloc.h memory/mozjemalloc/jemalloc.h
-index f0e0878..8f78123 100644
+index f0e0878..e74fb4d 100644
--- memory/mozjemalloc/jemalloc.h
+++ memory/mozjemalloc/jemalloc.h
-@@ -32,8 +32,8 @@
+@@ -32,23 +32,29 @@
#ifndef _JEMALLOC_H_
#define _JEMALLOC_H_
-#if defined(MOZ_MEMORY_DARWIN)
-#include <malloc/malloc.h>
-+#if defined(MALLOC_H)
-+#include MALLOC_H /* for malloc_good_size and nallocm */
++#if defined(MALLOC_H) \
++ && (defined(MOZ_NATIVE_JEMALLOC) || defined(MOZ_MEMORY_DARWIN))
++#include MALLOC_H
#endif
#include "jemalloc_types.h"
-@@ -51,7 +51,9 @@ void jemalloc_stats(jemalloc_stats_t *stats);
- #if defined(MOZ_MEMORY_LINUX)
++#if defined(MOZ_NATIVE_JEMALLOC) || defined(__FreeBSD__)
++#define je_nallocm nallocm
++#endif
++
+ #ifdef __cplusplus
+ extern "C" {
+ #endif
+
+-#if defined(MOZ_MEMORY_LINUX)
++#if defined(MOZ_NATIVE_JEMALLOC) \
++ || defined(MOZ_MEMORY_LINUX) || defined(MOZ_MEMORY_BSD)
__attribute__((weak))
#endif
--#if defined(MOZ_JEMALLOC)
-+#if defined(MOZ_NATIVE_JEMALLOC)
-+#define je_nallocm nallocm
-+#elif defined(MOZ_JEMALLOC)
- int je_nallocm(size_t *rsize, size_t size, int flags);
- #else
- size_t je_malloc_good_size(size_t size);
-diff --git toolkit/library/Makefile.in toolkit/library/Makefile.in
-index 7dbbbc6..0b06ad0 100644
---- toolkit/library/Makefile.in
-+++ toolkit/library/Makefile.in
-@@ -346,6 +346,10 @@ EXTRA_DSO_LDOPTS += \
- $(SQLITE_LIBS) \
- $(NULL)
+ void jemalloc_stats(jemalloc_stats_t *stats);
-+ifdef MOZ_NATIVE_JEMALLOC
-+EXTRA_DSO_LDOPTS += $(call EXPAND_LIBNAME_PATH,memory,$(DIST)/lib)
-+endif
-+
- ifdef MOZ_NATIVE_JPEG
- EXTRA_DSO_LDOPTS += $(MOZ_JPEG_LIBS)
+ /* Computes the usable size in advance. */
+-#if !defined(MOZ_MEMORY_DARWIN)
+-#if defined(MOZ_MEMORY_LINUX)
++#if !defined(MOZ_NATIVE_JEMALLOC) && !defined(MOZ_MEMORY_DARWIN)
++#if defined(MOZ_MEMORY_LINUX) || defined(MOZ_MEMORY_BSD)
+ __attribute__((weak))
+ #endif
+ #if defined(MOZ_JEMALLOC)
+diff --git mozglue/build/Makefile.in mozglue/build/Makefile.in
+index c333647..15ba505 100644
+--- mozglue/build/Makefile.in
++++ mozglue/build/Makefile.in
+@@ -23,7 +23,7 @@ FORCE_STATIC_LIB = 1
endif
+
+ # Keep jemalloc separated when mozglue is statically linked
+-ifeq (1_1,$(MOZ_MEMORY)_$(FORCE_SHARED_LIB))
++ifeq (1_1,$(MOZ_MEMORY)_$(or $(MOZ_NATIVE_JEMALLOC),$(FORCE_SHARED_LIB)))
+ SHARED_LIBRARY_LIBS = $(call EXPAND_LIBNAME_PATH,memory,$(DEPTH)/memory/build)
+ else
+ # Temporary, until bug 662814 lands
Modified: trunk/www/libxul/files/patch-bug788955
==============================================================================
--- trunk/www/libxul/files/patch-bug788955 Sat Sep 22 09:45:05 2012 (r1024)
+++ trunk/www/libxul/files/patch-bug788955 Sat Sep 22 09:45:15 2012 (r1025)
@@ -1,16 +1,31 @@
diff --git Makefile.in Makefile.in
-index e341462..26d19ad 100644
+index e341462..f75bd55 100644
--- Makefile.in
+++ Makefile.in
-@@ -47,7 +47,7 @@ endif
-
+@@ -48,8 +48,10 @@ endif
ifdef MOZ_MEMORY
tier_base_dirs += memory/mozjemalloc
--ifdef MOZ_JEMALLOC
-+ifeq (1_,$(MOZ_JEMALLOC)_$(MOZ_NATIVE_JEMALLOC))
+ ifdef MOZ_JEMALLOC
++ifndef MOZ_NATIVE_JEMALLOC
tier_base_dirs += memory/jemalloc
endif
++endif
tier_base_dirs += memory/build
+ endif
+ ifndef MOZ_NATIVE_ZLIB
+diff --git allmakefiles.sh allmakefiles.sh
+index 6a9be4b..544beff 100755
+--- allmakefiles.sh
++++ allmakefiles.sh
+@@ -59,7 +59,7 @@ if [ ! "$LIBXUL_SDK" ]; then
+ mozglue/Makefile
+ mozglue/build/Makefile
+ "
+- if [ "$MOZ_JEMALLOC" ]; then
++ if [ "$MOZ_JEMALLOC" -a ! "$MOZ_NATIVE_JEMALLOC" ]; then
+ add_makefiles "
+ memory/jemalloc/Makefile
+ "
--- config/autoconf.mk.in
+++ config/autoconf.mk.in
@@ -74,6 +74,7 @@ MOZ_JSDEBUGGER = @MOZ_JSDEBUGGER@
@@ -22,10 +37,10 @@
MOZ_ENABLE_PROFILER_SPS = @MOZ_ENABLE_PROFILER_SPS@
MOZ_JPROF = @MOZ_JPROF@
diff --git configure.in configure.in
-index 4070d8c..3b39473 100644
+index cfcdbc0..ee9a299 100644
--- configure.in
+++ configure.in
-@@ -3670,21 +3670,22 @@ fi
+@@ -3730,21 +3730,22 @@ fi
dnl Check for the existence of various allocation headers/functions
@@ -57,45 +72,100 @@
dnl See if compiler supports some gcc-style attributes
AC_CACHE_CHECK(for __attribute__((always_inline)),
-@@ -6902,7 +6903,21 @@ if test -z "$MOZ_MEMORY"; then
- AC_MSG_WARN([When not building jemalloc, you need to set WIN32_REDIST_DIR to the path to the Visual C++ Redist (usually VCINSTALLDIR\redist\x86\Microsoft.VC80.CRT, for VC++ v8) if you intend to distribute your build.])
- fi
- ;;
-+ *-freebsd*)
-+ MOZ_JEMALLOC=1
-+ ;;
- esac
-+
+@@ -6960,6 +6961,18 @@ else
+ fi
+
+ if test -z "$MOZ_MEMORY"; then
+ if test -n "$MOZ_JEMALLOC"; then
-+ AC_CHECK_FUNCS(mallctl nallocm,
-+ [MOZ_NATIVE_JEMALLOC=1 MOZ_MEMORY=1],
-+ [MOZ_NATIVE_JEMALLOC= MOZ_MEMORY=])
++ MOZ_NATIVE_JEMALLOC=1
++ AC_CHECK_FUNCS(mallctl nallocm,,
++ [MOZ_NATIVE_JEMALLOC=
++ break])
++ if test -n "$MOZ_NATIVE_JEMALLOC"; then
++ MOZ_MEMORY=1
++ AC_DEFINE(MOZ_MEMORY)
++ AC_DEFINE(MOZ_JEMALLOC)
++ AC_DEFINE(MOZ_NATIVE_JEMALLOC)
++ fi
+ fi
-+ if test -n "$MOZ_NATIVE_JEMALLOC"; then
-+ AC_DEFINE(MOZ_NATIVE_JEMALLOC)
-+ AC_DEFINE(MOZ_MEMORY)
-+ AC_DEFINE(MOZ_JEMALLOC)
-+ fi
- else
- dnl Don't try to run compiler tests on Windows
- if test "$OS_ARCH" = "WINNT"; then
-@@ -6988,6 +7003,7 @@ else
- ;;
- esac
+ case "${target}" in
+ *-mingw*)
+ if test -z "$WIN32_REDIST_DIR" -a -z "$MOZ_DEBUG"; then
+@@ -7054,6 +7067,7 @@ else
fi # MOZ_MEMORY
-+AC_SUBST(MOZ_NATIVE_JEMALLOC)
AC_SUBST(MOZ_MEMORY)
AC_SUBST(MOZ_JEMALLOC)
++AC_SUBST(MOZ_NATIVE_JEMALLOC)
AC_SUBST(MOZ_GLUE_LDFLAGS)
-@@ -8754,7 +8770,7 @@ fi
+ AC_SUBST(MOZ_GLUE_PROGRAM_LDFLAGS)
+ AC_SUBST(WIN32_CRT_LIBS)
+@@ -8819,10 +8833,27 @@ fi
# Run jemalloc configure script
-if test "$MOZ_JEMALLOC" -a "$MOZ_MEMORY"; then
+if test -z "$MOZ_NATIVE_JEMALLOC" -a "$MOZ_JEMALLOC" -a "$MOZ_MEMORY" ; then
ac_configure_args="$_SUBDIR_CONFIG_ARGS --build=$build --host=$target --enable-stats --with-jemalloc-prefix=je_"
- if test "$OS_ARCH" = "Linux"; then
- MANGLE="malloc calloc valloc free realloc memalign posix_memalign malloc_usable_size"
+- if test "$OS_ARCH" = "Linux"; then
+- MANGLE="malloc calloc valloc free realloc memalign posix_memalign malloc_usable_size"
++ case "$OS_ARCH" in
++ Linux)
++ MANGLE="malloc calloc valloc free realloc memalign posix_memalign malloc_usable_size"
++ ;;
++ DragonFly|NetBSD|OpenBSD)
++ MANGLE="malloc calloc valloc free realloc posix_memalign"
++ ;;
++ FreeBSD)
++ # common
++ MANGLE="malloc calloc valloc free realloc posix_memalign malloc_usable_size"
++ # old jemalloc
++ MANGLE="$MANGLE reallocf _malloc_message _malloc_options"
++ # jemalloc 3.0.0
++ MANGLE="$MANGLE aligned_alloc malloc_message malloc_conf"
++ MANGLE="$MANGLE malloc_stats_print mallctl mallctlnametomib mallctlbymib"
++ MANGLE="$MANGLE allocm rallocm sallocm dallocm nallocm"
++ ;;
++ esac
++ if test -n "$MANGLE"; then
+ MANGLED=
+ JEMALLOC_WRAPPER=
+ if test -n "$_WRAP_MALLOC"; then
+diff --git js/src/configure.in js/src/configure.in
+index 846482c..4022506 100644
+--- js/src/configure.in
++++ js/src/configure.in
+@@ -3094,21 +3094,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)),
diff --git memory/build/Makefile.in memory/build/Makefile.in
index dca0f48..af93ee0 100644
--- memory/build/Makefile.in
@@ -110,28 +180,67 @@
else
SHARED_LIBRARY_LIBS += $(call EXPAND_LIBNAME_PATH,jemalloc,$(DEPTH)/memory/mozjemalloc)
endif
+diff --git memory/build/extraMallocFuncs.c memory/build/extraMallocFuncs.c
+index 9d87629..76a2981 100644
+--- memory/build/extraMallocFuncs.c
++++ memory/build/extraMallocFuncs.c
+@@ -94,7 +94,19 @@ wrap(wcsdup)(const wchar_t *src)
+ #endif
+
+ #ifdef MOZ_JEMALLOC
++#if defined(MALLOC_H) && defined(MOZ_NATIVE_JEMALLOC)
++#include MALLOC_H
++#endif
++
++#if defined(MOZ_NATIVE_JEMALLOC) || defined(__FreeBSD__)
++#define je_malloc_conf malloc_conf
++#define je_malloc_message malloc_message
++#endif
++
+ /* Override some jemalloc defaults */
++#if defined(MOZ_NATIVE_JEMALLOC)
++MOZ_EXTERNAL_VIS
++#endif
+ const char *je_malloc_conf = "narenas:1,lg_chunk:20";
+
+ #ifdef ANDROID
diff --git memory/build/mozjemalloc_compat.c memory/build/mozjemalloc_compat.c
-index 10a845a..57245f6 100644
+index 10a845a..798c299 100644
--- memory/build/mozjemalloc_compat.c
+++ memory/build/mozjemalloc_compat.c
-@@ -5,7 +5,15 @@
+@@ -5,7 +5,17 @@
#include "mozilla/Types.h"
#include "jemalloc_types.h"
-+#if defined(MALLOC_H)
-+#include MALLOC_H /* for mallctl */
++#if defined(MALLOC_H) && defined(MOZ_NATIVE_JEMALLOC)
++#include MALLOC_H
+#endif
+
-+#if defined(MOZ_NATIVE_JEMALLOC)
++#if defined(MOZ_NATIVE_JEMALLOC) || defined(__FreeBSD__)
+#define je_mallctl mallctl
-+#else
++#endif
++
++#if !defined(MOZ_NATIVE_JEMALLOC)
extern int je_mallctl(const char*, void*, size_t*, void*, size_t);
+#endif
MOZ_EXPORT_API (void)
jemalloc_stats(jemalloc_stats_t *stats)
+diff --git memory/jemalloc/src/src/mutex.c memory/jemalloc/src/src/mutex.c
+index 37a843e..55e18c2 100644
+--- memory/jemalloc/src/src/mutex.c
++++ memory/jemalloc/src/src/mutex.c
+@@ -64,7 +64,7 @@ pthread_create(pthread_t *__restrict thread,
+ /******************************************************************************/
+
+ #ifdef JEMALLOC_MUTEX_INIT_CB
+-int _pthread_mutex_init_calloc_cb(pthread_mutex_t *mutex,
++JEMALLOC_EXPORT int _pthread_mutex_init_calloc_cb(pthread_mutex_t *mutex,
+ void *(calloc_cb)(size_t, size_t));
+ #endif
+
diff --git memory/mozalloc/mozalloc.cpp memory/mozalloc/mozalloc.cpp
-index 5b61050b..16bba36 100644
+index 5b61050b..5b3399a 100644
--- memory/mozalloc/mozalloc.cpp
+++ memory/mozalloc/mozalloc.cpp
@@ -12,16 +12,13 @@
@@ -158,48 +267,59 @@
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(MOZ_MEMORY) || defined(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);
diff --git memory/mozjemalloc/jemalloc.h memory/mozjemalloc/jemalloc.h
-index f0e0878..8f78123 100644
+index f0e0878..e74fb4d 100644
--- memory/mozjemalloc/jemalloc.h
+++ memory/mozjemalloc/jemalloc.h
-@@ -32,8 +32,8 @@
+@@ -32,23 +32,29 @@
#ifndef _JEMALLOC_H_
#define _JEMALLOC_H_
-#if defined(MOZ_MEMORY_DARWIN)
-#include <malloc/malloc.h>
-+#if defined(MALLOC_H)
-+#include MALLOC_H /* for malloc_good_size and nallocm */
++#if defined(MALLOC_H) \
++ && (defined(MOZ_NATIVE_JEMALLOC) || defined(MOZ_MEMORY_DARWIN))
++#include MALLOC_H
#endif
#include "jemalloc_types.h"
-@@ -51,7 +51,9 @@ void jemalloc_stats(jemalloc_stats_t *stats);
- #if defined(MOZ_MEMORY_LINUX)
++#if defined(MOZ_NATIVE_JEMALLOC) || defined(__FreeBSD__)
++#define je_nallocm nallocm
++#endif
++
+ #ifdef __cplusplus
+ extern "C" {
+ #endif
+
+-#if defined(MOZ_MEMORY_LINUX)
++#if defined(MOZ_NATIVE_JEMALLOC) \
++ || defined(MOZ_MEMORY_LINUX) || defined(MOZ_MEMORY_BSD)
__attribute__((weak))
#endif
--#if defined(MOZ_JEMALLOC)
-+#if defined(MOZ_NATIVE_JEMALLOC)
-+#define je_nallocm nallocm
-+#elif defined(MOZ_JEMALLOC)
- int je_nallocm(size_t *rsize, size_t size, int flags);
- #else
- size_t je_malloc_good_size(size_t size);
-diff --git toolkit/library/Makefile.in toolkit/library/Makefile.in
-index 7dbbbc6..0b06ad0 100644
---- toolkit/library/Makefile.in
-+++ toolkit/library/Makefile.in
-@@ -346,6 +346,10 @@ EXTRA_DSO_LDOPTS += \
- $(SQLITE_LIBS) \
- $(NULL)
+ void jemalloc_stats(jemalloc_stats_t *stats);
-+ifdef MOZ_NATIVE_JEMALLOC
-+EXTRA_DSO_LDOPTS += $(call EXPAND_LIBNAME_PATH,memory,$(DIST)/lib)
-+endif
-+
- ifdef MOZ_NATIVE_JPEG
- EXTRA_DSO_LDOPTS += $(MOZ_JPEG_LIBS)
+ /* Computes the usable size in advance. */
+-#if !defined(MOZ_MEMORY_DARWIN)
+-#if defined(MOZ_MEMORY_LINUX)
++#if !defined(MOZ_NATIVE_JEMALLOC) && !defined(MOZ_MEMORY_DARWIN)
++#if defined(MOZ_MEMORY_LINUX) || defined(MOZ_MEMORY_BSD)
+ __attribute__((weak))
+ #endif
+ #if defined(MOZ_JEMALLOC)
+diff --git mozglue/build/Makefile.in mozglue/build/Makefile.in
+index c333647..15ba505 100644
+--- mozglue/build/Makefile.in
++++ mozglue/build/Makefile.in
+@@ -23,7 +23,7 @@ FORCE_STATIC_LIB = 1
endif
+
+ # Keep jemalloc separated when mozglue is statically linked
+-ifeq (1_1,$(MOZ_MEMORY)_$(FORCE_SHARED_LIB))
++ifeq (1_1,$(MOZ_MEMORY)_$(or $(MOZ_NATIVE_JEMALLOC),$(FORCE_SHARED_LIB)))
+ SHARED_LIBRARY_LIBS = $(call EXPAND_LIBNAME_PATH,memory,$(DEPTH)/memory/build)
+ else
+ # Temporary, until bug 662814 lands
Modified: trunk/www/seamonkey/files/patch-bug788955
==============================================================================
--- trunk/www/seamonkey/files/patch-bug788955 Sat Sep 22 09:45:05 2012 (r1024)
+++ trunk/www/seamonkey/files/patch-bug788955 Sat Sep 22 09:45:15 2012 (r1025)
@@ -1,16 +1,31 @@
diff --git Makefile.in Makefile.in
-index e341462..26d19ad 100644
+index e341462..f75bd55 100644
--- mozilla/Makefile.in
+++ mozilla/Makefile.in
-@@ -47,7 +47,7 @@ endif
-
+@@ -48,8 +48,10 @@ endif
ifdef MOZ_MEMORY
tier_base_dirs += memory/mozjemalloc
--ifdef MOZ_JEMALLOC
-+ifeq (1_,$(MOZ_JEMALLOC)_$(MOZ_NATIVE_JEMALLOC))
+ ifdef MOZ_JEMALLOC
++ifndef MOZ_NATIVE_JEMALLOC
tier_base_dirs += memory/jemalloc
endif
++endif
tier_base_dirs += memory/build
+ endif
+ ifndef MOZ_NATIVE_ZLIB
+diff --git allmakefiles.sh allmakefiles.sh
+index 6a9be4b..544beff 100755
+--- mozilla/allmakefiles.sh
++++ mozilla/allmakefiles.sh
+@@ -59,7 +59,7 @@ if [ ! "$LIBXUL_SDK" ]; then
+ mozglue/Makefile
+ mozglue/build/Makefile
+ "
+- if [ "$MOZ_JEMALLOC" ]; then
++ if [ "$MOZ_JEMALLOC" -a ! "$MOZ_NATIVE_JEMALLOC" ]; then
+ add_makefiles "
+ memory/jemalloc/Makefile
+ "
--- mozilla/config/autoconf.mk.in
+++ mozilla/config/autoconf.mk.in
@@ -74,6 +74,7 @@ MOZ_JSDEBUGGER = @MOZ_JSDEBUGGER@
@@ -22,10 +37,10 @@
MOZ_ENABLE_PROFILER_SPS = @MOZ_ENABLE_PROFILER_SPS@
MOZ_JPROF = @MOZ_JPROF@
diff --git configure.in configure.in
-index 4070d8c..3b39473 100644
+index cfcdbc0..ee9a299 100644
--- mozilla/configure.in
+++ mozilla/configure.in
-@@ -3670,21 +3670,22 @@ fi
+@@ -3730,21 +3730,22 @@ fi
dnl Check for the existence of various allocation headers/functions
@@ -57,45 +72,100 @@
dnl See if compiler supports some gcc-style attributes
AC_CACHE_CHECK(for __attribute__((always_inline)),
-@@ -6902,7 +6903,21 @@ if test -z "$MOZ_MEMORY"; then
- AC_MSG_WARN([When not building jemalloc, you need to set WIN32_REDIST_DIR to the path to the Visual C++ Redist (usually VCINSTALLDIR\redist\x86\Microsoft.VC80.CRT, for VC++ v8) if you intend to distribute your build.])
- fi
- ;;
-+ *-freebsd*)
-+ MOZ_JEMALLOC=1
-+ ;;
- esac
-+
+@@ -6960,6 +6961,18 @@ else
+ fi
+
+ if test -z "$MOZ_MEMORY"; then
+ if test -n "$MOZ_JEMALLOC"; then
-+ AC_CHECK_FUNCS(mallctl nallocm,
-+ [MOZ_NATIVE_JEMALLOC=1 MOZ_MEMORY=1],
-+ [MOZ_NATIVE_JEMALLOC= MOZ_MEMORY=])
++ MOZ_NATIVE_JEMALLOC=1
++ AC_CHECK_FUNCS(mallctl nallocm,,
++ [MOZ_NATIVE_JEMALLOC=
++ break])
++ if test -n "$MOZ_NATIVE_JEMALLOC"; then
++ MOZ_MEMORY=1
++ AC_DEFINE(MOZ_MEMORY)
++ AC_DEFINE(MOZ_JEMALLOC)
++ AC_DEFINE(MOZ_NATIVE_JEMALLOC)
++ fi
+ fi
-+ if test -n "$MOZ_NATIVE_JEMALLOC"; then
-+ AC_DEFINE(MOZ_NATIVE_JEMALLOC)
-+ AC_DEFINE(MOZ_MEMORY)
-+ AC_DEFINE(MOZ_JEMALLOC)
-+ fi
- else
- dnl Don't try to run compiler tests on Windows
- if test "$OS_ARCH" = "WINNT"; then
-@@ -6988,6 +7003,7 @@ else
- ;;
- esac
+ case "${target}" in
+ *-mingw*)
+ if test -z "$WIN32_REDIST_DIR" -a -z "$MOZ_DEBUG"; then
+@@ -7054,6 +7067,7 @@ else
fi # MOZ_MEMORY
-+AC_SUBST(MOZ_NATIVE_JEMALLOC)
AC_SUBST(MOZ_MEMORY)
AC_SUBST(MOZ_JEMALLOC)
++AC_SUBST(MOZ_NATIVE_JEMALLOC)
AC_SUBST(MOZ_GLUE_LDFLAGS)
-@@ -8754,7 +8770,7 @@ fi
+ AC_SUBST(MOZ_GLUE_PROGRAM_LDFLAGS)
+ AC_SUBST(WIN32_CRT_LIBS)
+@@ -8819,10 +8833,27 @@ fi
# Run jemalloc configure script
-if test "$MOZ_JEMALLOC" -a "$MOZ_MEMORY"; then
+if test -z "$MOZ_NATIVE_JEMALLOC" -a "$MOZ_JEMALLOC" -a "$MOZ_MEMORY" ; then
ac_configure_args="$_SUBDIR_CONFIG_ARGS --build=$build --host=$target --enable-stats --with-jemalloc-prefix=je_"
- if test "$OS_ARCH" = "Linux"; then
- MANGLE="malloc calloc valloc free realloc memalign posix_memalign malloc_usable_size"
+- if test "$OS_ARCH" = "Linux"; then
+- MANGLE="malloc calloc valloc free realloc memalign posix_memalign malloc_usable_size"
++ case "$OS_ARCH" in
++ Linux)
++ MANGLE="malloc calloc valloc free realloc memalign posix_memalign malloc_usable_size"
++ ;;
++ DragonFly|NetBSD|OpenBSD)
++ MANGLE="malloc calloc valloc free realloc posix_memalign"
++ ;;
++ FreeBSD)
++ # common
++ MANGLE="malloc calloc valloc free realloc posix_memalign malloc_usable_size"
++ # old jemalloc
++ MANGLE="$MANGLE reallocf _malloc_message _malloc_options"
++ # jemalloc 3.0.0
++ MANGLE="$MANGLE aligned_alloc malloc_message malloc_conf"
++ MANGLE="$MANGLE malloc_stats_print mallctl mallctlnametomib mallctlbymib"
++ MANGLE="$MANGLE allocm rallocm sallocm dallocm nallocm"
++ ;;
++ esac
++ if test -n "$MANGLE"; then
+ MANGLED=
+ JEMALLOC_WRAPPER=
+ if test -n "$_WRAP_MALLOC"; then
+diff --git js/src/configure.in js/src/configure.in
+index 846482c..4022506 100644
+--- mozilla/js/src/configure.in
++++ mozilla/js/src/configure.in
+@@ -3094,21 +3094,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)),
diff --git memory/build/Makefile.in memory/build/Makefile.in
index dca0f48..af93ee0 100644
--- mozilla/memory/build/Makefile.in
@@ -110,28 +180,67 @@
else
SHARED_LIBRARY_LIBS += $(call EXPAND_LIBNAME_PATH,jemalloc,$(DEPTH)/memory/mozjemalloc)
endif
+diff --git memory/build/extraMallocFuncs.c memory/build/extraMallocFuncs.c
+index 9d87629..76a2981 100644
+--- mozilla/memory/build/extraMallocFuncs.c
++++ mozilla/memory/build/extraMallocFuncs.c
+@@ -94,7 +94,19 @@ wrap(wcsdup)(const wchar_t *src)
+ #endif
+
+ #ifdef MOZ_JEMALLOC
++#if defined(MALLOC_H) && defined(MOZ_NATIVE_JEMALLOC)
++#include MALLOC_H
++#endif
++
++#if defined(MOZ_NATIVE_JEMALLOC) || defined(__FreeBSD__)
++#define je_malloc_conf malloc_conf
++#define je_malloc_message malloc_message
++#endif
++
+ /* Override some jemalloc defaults */
++#if defined(MOZ_NATIVE_JEMALLOC)
++MOZ_EXTERNAL_VIS
++#endif
+ const char *je_malloc_conf = "narenas:1,lg_chunk:20";
+
+ #ifdef ANDROID
diff --git memory/build/mozjemalloc_compat.c memory/build/mozjemalloc_compat.c
-index 10a845a..57245f6 100644
+index 10a845a..798c299 100644
--- mozilla/memory/build/mozjemalloc_compat.c
+++ mozilla/memory/build/mozjemalloc_compat.c
-@@ -5,7 +5,15 @@
+@@ -5,7 +5,17 @@
#include "mozilla/Types.h"
#include "jemalloc_types.h"
-+#if defined(MALLOC_H)
-+#include MALLOC_H /* for mallctl */
++#if defined(MALLOC_H) && defined(MOZ_NATIVE_JEMALLOC)
++#include MALLOC_H
+#endif
+
-+#if defined(MOZ_NATIVE_JEMALLOC)
++#if defined(MOZ_NATIVE_JEMALLOC) || defined(__FreeBSD__)
+#define je_mallctl mallctl
-+#else
++#endif
++
++#if !defined(MOZ_NATIVE_JEMALLOC)
extern int je_mallctl(const char*, void*, size_t*, void*, size_t);
+#endif
MOZ_EXPORT_API (void)
jemalloc_stats(jemalloc_stats_t *stats)
+diff --git memory/jemalloc/src/src/mutex.c memory/jemalloc/src/src/mutex.c
+index 37a843e..55e18c2 100644
+--- mozilla/memory/jemalloc/src/src/mutex.c
++++ mozilla/memory/jemalloc/src/src/mutex.c
+@@ -64,7 +64,7 @@ pthread_create(pthread_t *__restrict thread,
+ /******************************************************************************/
+
+ #ifdef JEMALLOC_MUTEX_INIT_CB
+-int _pthread_mutex_init_calloc_cb(pthread_mutex_t *mutex,
++JEMALLOC_EXPORT int _pthread_mutex_init_calloc_cb(pthread_mutex_t *mutex,
+ void *(calloc_cb)(size_t, size_t));
+ #endif
+
diff --git memory/mozalloc/mozalloc.cpp memory/mozalloc/mozalloc.cpp
-index 5b61050b..16bba36 100644
+index 5b61050b..5b3399a 100644
--- mozilla/memory/mozalloc/mozalloc.cpp
+++ mozilla/memory/mozalloc/mozalloc.cpp
@@ -12,16 +12,13 @@
@@ -158,48 +267,59 @@
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(MOZ_MEMORY) || defined(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);
diff --git memory/mozjemalloc/jemalloc.h memory/mozjemalloc/jemalloc.h
-index f0e0878..8f78123 100644
+index f0e0878..e74fb4d 100644
--- mozilla/memory/mozjemalloc/jemalloc.h
+++ mozilla/memory/mozjemalloc/jemalloc.h
-@@ -32,8 +32,8 @@
+@@ -32,23 +32,29 @@
#ifndef _JEMALLOC_H_
#define _JEMALLOC_H_
-#if defined(MOZ_MEMORY_DARWIN)
-#include <malloc/malloc.h>
-+#if defined(MALLOC_H)
-+#include MALLOC_H /* for malloc_good_size and nallocm */
++#if defined(MALLOC_H) \
++ && (defined(MOZ_NATIVE_JEMALLOC) || defined(MOZ_MEMORY_DARWIN))
++#include MALLOC_H
#endif
#include "jemalloc_types.h"
-@@ -51,7 +51,9 @@ void jemalloc_stats(jemalloc_stats_t *stats);
- #if defined(MOZ_MEMORY_LINUX)
++#if defined(MOZ_NATIVE_JEMALLOC) || defined(__FreeBSD__)
++#define je_nallocm nallocm
++#endif
++
+ #ifdef __cplusplus
+ extern "C" {
+ #endif
+
+-#if defined(MOZ_MEMORY_LINUX)
++#if defined(MOZ_NATIVE_JEMALLOC) \
++ || defined(MOZ_MEMORY_LINUX) || defined(MOZ_MEMORY_BSD)
__attribute__((weak))
#endif
--#if defined(MOZ_JEMALLOC)
-+#if defined(MOZ_NATIVE_JEMALLOC)
-+#define je_nallocm nallocm
-+#elif defined(MOZ_JEMALLOC)
- int je_nallocm(size_t *rsize, size_t size, int flags);
- #else
- size_t je_malloc_good_size(size_t size);
-diff --git toolkit/library/Makefile.in toolkit/library/Makefile.in
-index 7dbbbc6..0b06ad0 100644
---- mozilla/toolkit/library/Makefile.in
-+++ mozilla/toolkit/library/Makefile.in
-@@ -346,6 +346,10 @@ EXTRA_DSO_LDOPTS += \
- $(SQLITE_LIBS) \
- $(NULL)
+ void jemalloc_stats(jemalloc_stats_t *stats);
-+ifdef MOZ_NATIVE_JEMALLOC
-+EXTRA_DSO_LDOPTS += $(call EXPAND_LIBNAME_PATH,memory,$(DIST)/lib)
-+endif
-+
- ifdef MOZ_NATIVE_JPEG
- EXTRA_DSO_LDOPTS += $(MOZ_JPEG_LIBS)
+ /* Computes the usable size in advance. */
+-#if !defined(MOZ_MEMORY_DARWIN)
+-#if defined(MOZ_MEMORY_LINUX)
++#if !defined(MOZ_NATIVE_JEMALLOC) && !defined(MOZ_MEMORY_DARWIN)
++#if defined(MOZ_MEMORY_LINUX) || defined(MOZ_MEMORY_BSD)
+ __attribute__((weak))
+ #endif
+ #if defined(MOZ_JEMALLOC)
+diff --git mozglue/build/Makefile.in mozglue/build/Makefile.in
+index c333647..15ba505 100644
+--- mozilla/mozglue/build/Makefile.in
++++ mozilla/mozglue/build/Makefile.in
+@@ -23,7 +23,7 @@ FORCE_STATIC_LIB = 1
endif
+
+ # Keep jemalloc separated when mozglue is statically linked
+-ifeq (1_1,$(MOZ_MEMORY)_$(FORCE_SHARED_LIB))
++ifeq (1_1,$(MOZ_MEMORY)_$(or $(MOZ_NATIVE_JEMALLOC),$(FORCE_SHARED_LIB)))
+ SHARED_LIBRARY_LIBS = $(call EXPAND_LIBNAME_PATH,memory,$(DEPTH)/memory/build)
+ else
+ # Temporary, until bug 662814 lands
More information about the freebsd-gecko
mailing list