head	1.3;
access;
symbols;
locks; strict;
comment	@# @;


1.3
date	2013.02.20.00.52.22;	author svnexp;	state dead;
branches;
next	1.2;

1.2
date	2012.11.20.23.18.40;	author svnexp;	state Exp;
branches;
next	1.1;

1.1
date	2012.10.10.21.13.06;	author flo;	state Exp;
branches;
next	;


desc
@@


1.3
log
@## SVN ## Exported commit - http://svnweb.freebsd.org/changeset/base/312608
## SVN ## CVS IS DEPRECATED: http://wiki.freebsd.org/CvsIsDeprecated
@
text
@diff --git Makefile.in Makefile.in
index e341462..f75bd55 100644
--- Makefile.in
+++ Makefile.in
@@@@ -48,8 +48,10 @@@@ endif
 ifdef MOZ_MEMORY
 tier_base_dirs += memory/mozjemalloc
 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..d2e49e3 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 -z "$MOZ_NATIVE_JEMALLOC" ]; then
     add_makefiles "
       memory/jemalloc/Makefile
     "
diff --git configure.in configure.in
index bb05782..2f32516 100644
--- configure.in
+++ configure.in
@@@@ -3711,21 +3711,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)),
@@@@ -6939,6 +6940,18 @@@@ else
 fi
 
 if test -z "$MOZ_MEMORY"; then
+  if test -n "$MOZ_JEMALLOC"; then
+    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
   case "${target}" in
     *-mingw*)
       if test -z "$WIN32_REDIST_DIR" -a -z "$MOZ_DEBUG"; then
@@@@ -7033,6 +7046,7 @@@@ else
 fi # MOZ_MEMORY
 AC_SUBST(MOZ_MEMORY)
 AC_SUBST(MOZ_JEMALLOC)
+AC_SUBST(MOZ_NATIVE_JEMALLOC)
 AC_SUBST(MOZ_GLUE_LDFLAGS)
 AC_SUBST(MOZ_GLUE_PROGRAM_LDFLAGS)
 AC_SUBST(WIN32_CRT_LIBS)
@@@@ -8820,10 +8834,22 @@@@ 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"
+  case "$OS_ARCH" in
+    Linux|DragonFly|FreeBSD|NetBSD|OpenBSD)
+      MANGLE="malloc calloc valloc free realloc posix_memalign"
+      case "$OS_ARCH" in
+        Linux)
+          MANGLE="$MANGLE memalign malloc_usable_size"
+          ;;
+        FreeBSD)
+          MANGLE="$MANGLE malloc_usable_size"
+          ;;
+      esac
+      ;;
+  esac
+  if test -n "$MANGLE"; then
     MANGLED=
     JEMALLOC_WRAPPER=
     if test -n "$_WRAP_MALLOC"; then
diff --git memory/build/Makefile.in memory/build/Makefile.in
index dca0f48..af93ee0 100644
--- memory/build/Makefile.in
+++ memory/build/Makefile.in
@@@@ -22,7 +22,9 @@@@ CSRCS = extraMallocFuncs.c
 
 ifdef MOZ_JEMALLOC
 CSRCS += mozjemalloc_compat.c
+ifndef MOZ_NATIVE_JEMALLOC
 SHARED_LIBRARY_LIBS += $(call EXPAND_LIBNAME_PATH,jemalloc,$(DEPTH)/memory/jemalloc)
+endif
 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..03c8320 100644
--- memory/build/extraMallocFuncs.c
+++ memory/build/extraMallocFuncs.c
@@@@ -94,8 +94,16 @@@@ wrap(wcsdup)(const wchar_t *src)
 #endif
 
 #ifdef MOZ_JEMALLOC
+
+#undef wrap
+#if defined(MOZ_NATIVE_JEMALLOC)
+#define wrap(a) a
+#else
+#define wrap(a) je_ ## a
+#endif
+
 /* Override some jemalloc defaults */
-const char *je_malloc_conf = "narenas:1,lg_chunk:20";
+MOZ_EXPORT_DATA(const char *) wrap(malloc_conf) = "narenas:1,lg_chunk:20";
 
 #ifdef ANDROID
 #include <android/log.h>
diff --git memory/build/mozjemalloc_compat.c memory/build/mozjemalloc_compat.c
index 10a845a..94ad96e 100644
--- memory/build/mozjemalloc_compat.c
+++ memory/build/mozjemalloc_compat.c
@@@@ -5,14 +5,21 @@@@
 #include "mozilla/Types.h"
 #include "jemalloc_types.h"
 
-extern int je_mallctl(const char*, void*, size_t*, void*, size_t);
+#if defined(MOZ_NATIVE_JEMALLOC)
+#define wrap(a) a
+#else
+#define wrap(a) je_ ## a
+#endif
 
-MOZ_EXPORT_API (void)
+extern MOZ_IMPORT_API(int)
+wrap(mallctl)(const char*, void*, size_t*, void*, size_t);
+
+MOZ_EXPORT_API(void)
 jemalloc_stats(jemalloc_stats_t *stats)
 {
   size_t size = sizeof(stats->mapped);
-  je_mallctl("stats.mapped", &stats->mapped, &size, NULL, 0);
-  je_mallctl("stats.allocated", &stats->allocated, &size, NULL, 0);
+  wrap(mallctl)("stats.mapped", &stats->mapped, &size, NULL, 0);
+  wrap(mallctl)("stats.allocated", &stats->allocated, &size, NULL, 0);
   stats->committed = -1;
   stats->dirty = -1;
 }
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..5b3399a 100644
--- memory/mozalloc/mozalloc.cpp
+++ memory/mozalloc/mozalloc.cpp
@@@@ -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);
diff --git memory/mozjemalloc/jemalloc.h memory/mozjemalloc/jemalloc.h
index f0e0878..2486e83 100644
--- memory/mozjemalloc/jemalloc.h
+++ memory/mozjemalloc/jemalloc.h
@@@@ -37,22 +37,29 @@@@
 #endif
 #include "jemalloc_types.h"
 
+#if defined(MOZ_NATIVE_JEMALLOC)
+#define wrap(a) a
+#else
+#define wrap(a) je_ ## a
+#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
 void	jemalloc_stats(jemalloc_stats_t *stats);
 
 /* Computes the usable size in advance. */
 #if !defined(MOZ_MEMORY_DARWIN)
-#if defined(MOZ_MEMORY_LINUX)
+#if defined(MOZ_MEMORY_LINUX) || defined(MOZ_MEMORY_BSD)
 __attribute__((weak))
 #endif
 #if defined(MOZ_JEMALLOC)
-int je_nallocm(size_t *rsize, size_t size, int flags);
+MOZ_IMPORT_API(int) wrap(nallocm)(size_t *rsize, size_t size, int flags);
 #else
 size_t je_malloc_good_size(size_t size);
 #endif
@@@@ -62,11 +69,11 @@@@ static inline size_t je_malloc_usable_size_in_advance(size_t size) {
 #if defined(MOZ_MEMORY_DARWIN)
   return malloc_good_size(size);
 #elif defined(MOZ_JEMALLOC)
-  if (je_nallocm) {
+  if (wrap(nallocm)) {
     size_t ret;
     if (size == 0)
       size = 1;
-    if (!je_nallocm(&ret, size, 0))
+    if (!wrap(nallocm)(&ret, size, 0))
       return ret;
   }
   return size;
@@@@ -113,4 +120,6 @@@@ void    jemalloc_purge_freed_pages();
 } /* extern "C" */
 #endif
 
+#undef wrap
+
 #endif /* _JEMALLOC_H_ */
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
@


1.2
log
@## SVN ##
## SVN ## Exported commit - http://svnweb.freebsd.org/changeset/base/ 307606
## SVN ## CVS IS DEPRECATED: http://wiki.freebsd.org/CvsIsDeprecated
## SVN ##
## SVN ## ------------------------------------------------------------------------
## SVN ## r307606 | flo | 2012-11-20 23:01:15 +0000 (Tue, 20 Nov 2012) | 14 lines
## SVN ##
## SVN ## - Update firefox and thunderbird to 17.0
## SVN ## - Update seamonkey to 2.14
## SVN ## - Update ESR ports and libxul to 10.0.11
## SVN ## - support more h264 codecs when using GSTREAMER with YouTube
## SVN ## - Unbreak firefox-esr, thunderbird-esr and libxul on head >= 1000024 [1]
## SVN ## - Buildsystem is not python 3 aware, use python up to 2.7 [2]
## SVN ##
## SVN ## PR:		ports/173679 [1]
## SVN ## Submitted by:	swills [1], demon [2]
## SVN ## In collaboration with:	Jan Beich <jbeich@@tormail.org>
## SVN ## Security:	d23119df-335d-11e2-b64c-c8600054b392
## SVN ## Approved by:	portmgr (beat)
## SVN ## Feature safe:	yes
## SVN ##
## SVN ## ------------------------------------------------------------------------
## SVN ##
@
text
@@


1.1
log
@SVN rev 305684 on 2012-10-10 21:13:06Z by flo

- Update firefox-esr, thunderbird-esr, linux-firefox and linux-thunderbird to 10.0.8
- Update firefox and thunderbird to 16.0
- Update seamonkey to 2.13
- Update all -i18n ports respectively
- switch firefox 16.0 and seamonkey 2.13 to ALSA by default for better
  latency during pause and seeking with HTML5 video
- remove fedisableexcept() hacks, obsolete since FreeBSD 4.0
- support system hunspell dictionaries [1]
- unbreak -esr ports with clang3.2 [2]
- unbreak nss build when CC contains full path [3]
- remove GNOME option grouping [4]
- integrate enigmail into thunderbird/seamonkey as an option [5]
- remove mail/enigmail* [6]
- enable ENIGMAIL, LIGHTNING and GIO options by default
- add more reporters in about:memory: page-faults-hard, page-faults-soft,
  resident, vsize
- use bundled jemalloc 3.0.0 on FreeBSD < 10.0 for gecko 16.0,
  only heap-allocated reporter works in about:memory (see bug 762445)
- use lrintf() instead of slow C cast in bundled libopus
- use libjpeg-turbo's faster color conversion if available during build
- record startup time for telemetry
- use -z origin instead of hardcoding path to gecko runtime
- fail early if incompatible libxul version is installed (in USE_GECKO)
- *miscellaneous cleanups and fixups*

PR:		ports/171534 [1]
PR:		ports/171566 [2]
PR:		ports/172164 [3]
PR:		ports/172201 [4]
Discussed with:	ale, beat, Jan Beich [5]
Approved by:	ale [6]
In collaboration with:	Jan Beich <jbeich@@tormail.org>
Security:	6e5a9afd-12d3-11e2-b47d-c8600054b392
Feature safe:	yes
Approved by:	portmgr (beat)
@
text
@a28 10
--- config/autoconf.mk.in
+++ config/autoconf.mk.in
@@@@ -74,6 +74,7 @@@@ MOZ_JSDEBUGGER  = @@MOZ_JSDEBUGGER@@
 MOZ_IPDL_TESTS 	= @@MOZ_IPDL_TESTS@@
 MOZ_MEMORY      = @@MOZ_MEMORY@@
 MOZ_JEMALLOC    = @@MOZ_JEMALLOC@@
+MOZ_NATIVE_JEMALLOC    = @@MOZ_NATIVE_JEMALLOC@@
 MOZ_PROFILING   = @@MOZ_PROFILING@@
 MOZ_ENABLE_PROFILER_SPS = @@MOZ_ENABLE_PROFILER_SPS@@
 MOZ_JPROF       = @@MOZ_JPROF@@
@

