This commit is contained in:
Chris Jones 2009-10-02 18:09:39 -05:00
Родитель ad289df5bd 708e2e04ae
Коммит 2151b59798
39 изменённых файлов: 104 добавлений и 1052 удалений

Просмотреть файл

@ -61,10 +61,13 @@ TIERS += base
tier_base_dirs = \
config \
build \
memory \
probes \
$(NULL)
ifdef MOZ_MEMORY
tier_base_dirs += memory/jemalloc
endif
ifdef COMPILE_ENVIRONMENT
include $(topsrcdir)/$(MOZ_BUILD_APP)/build.mk
endif

Просмотреть файл

@ -49,7 +49,6 @@
@BINPATH@/@DLL_PREFIX@plds4@DLL_SUFFIX@
@BINPATH@/@DLL_PREFIX@xpcom@DLL_SUFFIX@
@BINPATH@/@DLL_PREFIX@nspr4@DLL_SUFFIX@
@BINPATH@/@DLL_PREFIX@mozalloc@DLL_SUFFIX@
#ifdef XP_MACOSX
@BINPATH@/XUL
#else

Просмотреть файл

@ -56,9 +56,9 @@ endif
ifdef WINCE
# We need jemalloc built before the shunt
ifdef MOZ_MEMORY
DIRS += wince/tools $(DEPTH)/memory/jemalloc $(DEPTH)/memory/mozalloc wince/shunt
DIRS += wince/tools $(DEPTH)/memory/jemalloc wince/shunt
else
DIRS += wince/tools $(DEPTH)/memory/mozalloc wince/shunt
DIRS += wince/tools wince/shunt
endif
endif

Просмотреть файл

@ -81,8 +81,6 @@ EXPORTS_mozce_shunt += $(topsrcdir)/memory/jemalloc/jemalloc.h
EXTRA_LIBS += $(OBJDIR)/memory/jemalloc/jemalloc.obj
endif
EXTRA_DSO_LDOPTS += $(MOZALLOC_LIB)
DEFFILE = mozce_shunt.def
OS_LIBS += $(call EXPAND_LIBNAME, libcmt)

Просмотреть файл

@ -67,27 +67,32 @@ typedef unsigned short wchar_t;
namespace std {
struct nothrow_t {};
extern const nothrow_t nothrow;
struct bad_alloc {};
};
#endif
// grab malloc and free prototypes
#include "jemalloc.h"
// mozalloc.h defines "normal" infallible operator new, but not
// std::nothrow operator new, so we define that below. This is inline
// and exported from the shunt.
// Normal and nothrow versions of operator new, none of which
// actually throw for us. These are both inline and exported
// from the shunt.
inline void *operator new(size_t size) throw() {
return (void*) malloc(size);
}
inline void *operator new(size_t size, const std::nothrow_t&) throw() {
return malloc(size);
return (void*) malloc(size);
}
inline void operator delete(void *ptr) throw() {
free(ptr);
}
inline void *operator new[](size_t size) throw() {
return (void*) malloc(size);
}
inline void *operator new[](size_t size, const std::nothrow_t&) throw() {
return malloc(size);
return (void*) malloc(size);
}
inline void operator delete(void* ptr, const std::nothrow_t&) throw() {
free(ptr);
}
inline void operator delete[](void* ptr, const std::nothrow_t&) throw() {
free(ptr);
inline void operator delete[](void *ptr) throw() {
return free(ptr);
}
// Placement new. Just inline, not exported (which doesn't work for
@ -99,30 +104,6 @@ inline void *operator new[](size_t, void *p) {
return p;
}
// for Gecko, include infallible mozalloc allocators. elsewhere, define
// operator new() normally.
// NB: this include guard needs to be kept in sync with the one in nscore.h
#if defined(_MOZILLA_CONFIG_H_) && !defined(XPCOM_GLUE) && !defined(NS_NO_XPCOM) && !defined(MOZ_NO_MOZALLOC)
# include "mozilla/mozalloc.h"
#else
inline void* operator new(size_t size) throw() {
return malloc(size);
}
inline void* operator new[](size_t size) throw() {
return malloc(size);
}
inline void operator delete(void* ptr) throw() {
free(ptr);
}
inline void operator delete[](void* ptr) throw() {
free(ptr);
}
#endif // if defined(_MOZILLA_CONFIG_H_)
extern "C" {
#endif
@ -135,9 +116,6 @@ extern "C" {
#undef _wcsndup
#undef wcsndup
// _strdup() and _wcsdup() are both infallible, i.e., will never return
// NULL
char * __cdecl
_strdup(const char*);
@ -154,7 +132,7 @@ _wcsndup(const wchar_t *, unsigned int);
} //extern "C"
#endif
#endif // ifdef MOZ_MEMORY
#endif
#define strdup _strdup
#define strndup _strndup

Просмотреть файл

@ -39,8 +39,6 @@
#include "include/mozce_shunt.h"
#include <stdlib.h>
#include "mozilla/mozalloc_macro_wrappers.h" /* infallible malloc */
#ifdef MOZ_MEMORY
// declare the nothrow object
@ -49,7 +47,8 @@ const std::nothrow_t std::nothrow;
char*
_strndup(const char *src, size_t len) {
char* dst = (char*)malloc(len + 1);
strncpy(dst, src, len + 1);
if(dst)
strncpy(dst, src, len + 1);
return dst;
}
@ -63,7 +62,8 @@ _strdup(const char *src) {
wchar_t *
_wcsndup(const wchar_t *src, size_t len) {
wchar_t* dst = (wchar_t*)malloc(sizeof(wchar_t) * (len + 1));
wcsncpy(dst, src, len + 1);
if(dst)
wcsncpy(dst, src, len + 1);
return dst;
}

Просмотреть файл

@ -225,7 +225,6 @@ else
endif
endif
MOZALLOC_LIB = $(call EXPAND_MOZLIBNAME,mozalloc)
# append debug flags
# (these might have been above when processing MOZ_DBGRINFO_MODULES)

Просмотреть файл

@ -1055,9 +1055,9 @@ MOZ_PNG_CFLAGS=
MOZ_PNG_LIBS='$(call EXPAND_LIBNAME_PATH,mozpng,$(DEPTH)/modules/libimg/png)'
MOZ_JS_LIBS='-L$(LIBXUL_DIST)/bin -lmozjs'
DYNAMIC_XPCOM_LIBS='-L$(LIBXUL_DIST)/bin -lxpcom -lxpcom_core -lmozalloc'
DYNAMIC_XPCOM_LIBS='-L$(LIBXUL_DIST)/bin -lxpcom -lxpcom_core'
MOZ_FIX_LINK_PATHS='-Wl,-rpath-link,$(LIBXUL_DIST)/bin -Wl,-rpath-link,$(prefix)/lib'
XPCOM_FROZEN_LDOPTS='-L$(LIBXUL_DIST)/bin -lxpcom -lmozalloc'
XPCOM_FROZEN_LDOPTS='-L$(LIBXUL_DIST)/bin -lxpcom'
LIBXUL_LIBS='$(XPCOM_FROZEN_LDOPTS) -lxul'
XPCOM_GLUE_LDOPTS='$(LIBXUL_DIST)/lib/$(LIB_PREFIX)xpcomglue_s.$(LIB_SUFFIX) $(XPCOM_FROZEN_LDOPTS)'
XPCOM_STANDALONE_GLUE_LDOPTS='$(LIBXUL_DIST)/lib/$(LIB_PREFIX)xpcomglue.$(LIB_SUFFIX)'
@ -2013,11 +2013,11 @@ case "$target" in
DLL_PREFIX=
DOXYGEN=:
DSO_LDOPTS=-SUBSYSTEM:WINDOWSCE
DYNAMIC_XPCOM_LIBS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xpcom_core.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
DYNAMIC_XPCOM_LIBS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xpcom_core.lib'
GARBAGE=
IMPORT_LIB_SUFFIX=lib
LIBS="$LIBS"
LIBXUL_LIBS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xul.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
LIBXUL_LIBS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xul.lib'
LIB_PREFIX=
LIB_SUFFIX=lib
MKCSHLIB='$(LD) -NOLOGO -DLL -OUT:$@ $(DSO_LDOPTS)'
@ -2036,7 +2036,7 @@ case "$target" in
TARGET_NSPR_MDCPUCFG='\"md/_wince.cfg\"'
UNZIP=unzip
XARGS=xargs
XPCOM_FROZEN_LDOPTS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
XPCOM_FROZEN_LDOPTS='$(LIBXUL_DIST)/lib/xpcom.lib'
ZIP=zip
LIBIDL_CFLAGS="-I$MOZ_TOOLS_DIR/include ${GLIB_CFLAGS}"
LIBIDL_LIBS="$MOZ_TOOLS_DIR/lib/libidl-0.6_s.lib $MOZ_TOOLS_DIR/lib/glib-1.2_s.lib"
@ -2095,8 +2095,8 @@ case "$target" in
LIBS="$LIBS -lgdi32 -lwinmm -lwsock32"
MOZ_JS_LIBS='-L$(LIBXUL_DIST)/lib -ljs$(MOZ_BITS)$(VERSION_NUMBER)'
MOZ_FIX_LINK_PATHS=
DYNAMIC_XPCOM_LIBS='-L$(LIBXUL_DIST)/lib -lxpcom -lxpcom_core -lmozalloc'
XPCOM_FROZEN_LDOPTS='-L$(LIBXUL_DIST)/lib -lxpcom -lmozalloc'
DYNAMIC_XPCOM_LIBS='-L$(LIBXUL_DIST)/lib -lxpcom -lxpcom_core'
XPCOM_FROZEN_LDOPTS='-L$(LIBXUL_DIST)/lib -lxpcom'
DLL_PREFIX=
IMPORT_LIB_SUFFIX=dll.a
else
@ -2135,9 +2135,9 @@ case "$target" in
MOZ_OPTIMIZE_FLAGS='-O1'
MOZ_JS_LIBS='$(LIBXUL_DIST)/lib/js$(MOZ_BITS)$(VERSION_NUMBER).lib'
MOZ_FIX_LINK_PATHS=
DYNAMIC_XPCOM_LIBS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xpcom_core.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
XPCOM_FROZEN_LDOPTS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
LIBXUL_LIBS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xul.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
DYNAMIC_XPCOM_LIBS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xpcom_core.lib'
XPCOM_FROZEN_LDOPTS='$(LIBXUL_DIST)/lib/xpcom.lib'
LIBXUL_LIBS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xul.lib'
MOZ_COMPONENT_NSPR_LIBS='$(NSPR_LIBS)'
if test $_MSC_VER -ge 1400; then
LDFLAGS="$LDFLAGS -NXCOMPAT -SAFESEH"
@ -2436,8 +2436,8 @@ case "$target" in
MOZ_DEBUG_FLAGS="-g -fno-inline"
MOZ_OPTIMIZE_FLAGS="-O2"
MOZ_OPTIMIZE_LDFLAGS="-s -Zlinker /EXEPACK:2 -Zlinker /PACKCODE -Zlinker /PACKDATA"
DYNAMIC_XPCOM_LIBS='-L$(LIBXUL_DIST)/lib $(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xpcomcor.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
LIBXUL_LIBS='-L$(LIBXUL_DIST)/lib $(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xul.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
DYNAMIC_XPCOM_LIBS='-L$(LIBXUL_DIST)/lib $(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xpcomcor.lib'
LIBXUL_LIBS='-L$(LIBXUL_DIST)/lib $(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xul.lib'
TARGET_MD_ARCH=os2
_PLATFORM_DEFAULT_TOOLKIT="cairo-os2"
MOZ_ENABLE_POSTSCRIPT=
@ -4122,52 +4122,7 @@ if test "$ac_cv_trouble_comparing_to_zero" = yes ; then
AC_DEFINE(HAVE_CPP_TROUBLE_COMPARING_TO_ZERO)
fi
dnl Check for the existence of various allocation headers/functions
MALLOC_H=
AC_CHECK_HEADER(malloc.h, [MALLOC_H=malloc.h])
if test "$MALLOC_H" = ""; then
AC_CHECK_HEADER(malloc/malloc.h, [MALLOC_H=malloc/malloc.h])
if test "$MALLOC_H" = ""; then
AC_CHECK_HEADER(sys/malloc.h, [MALLOC_H=sys/malloc.h])
fi
fi
if test "$MALLOC_H" != ""; then
AC_DEFINE_UNQUOTED(MALLOC_H, <$MALLOC_H>)
fi
MOZ_ALLOCATING_FUNCS="strndup posix_memalign memalign valloc"
AC_CHECK_FUNCS(strndup posix_memalign memalign valloc)
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)])
AC_CACHE_CHECK(for __attribute__((malloc)),
ac_cv_attribute_malloc,
[AC_TRY_COMPILE([],
[void* f(int) __attribute__((malloc));],
ac_cv_attribute_malloc=yes,
ac_cv_attribute_malloc=no)])
AC_CACHE_CHECK(for __attribute__((warn_unused_result)),
ac_cv_attribute_warn_unused,
[AC_TRY_COMPILE([],
[int f(void) __attribute__((warn_unused_result));],
ac_cv_attribute_warn_unused=yes,
ac_cv_attribute_warn_unused=no)])
AC_CACHE_CHECK(for __attribute__((noreturn)),
ac_cv_attribute_noreturn,
[AC_TRY_COMPILE([],
[void f(void) __attribute__((noreturn));],
ac_cv_attribute_noreturn=yes,
ac_cv_attribute_noreturn=no)])
dnl End of C++ language/feature checks
AC_LANG_C
@ -4203,40 +4158,6 @@ dnl ========================================================
dnl The macros used for command line options
dnl are defined in build/autoconf/altoptions.m4.
dnl If the compiler supports these attributes, define them as
dnl convenience macros.
if test "$ac_cv_attribute_always_inline" = yes ; then
AC_DEFINE(NS_ALWAYS_INLINE, [__attribute__((always_inline))])
else
AC_DEFINE(NS_ALWAYS_INLINE,)
fi
if test "$ac_cv_attribute_malloc" = yes ; then
AC_DEFINE(NS_ATTR_MALLOC, [__attribute__((malloc))])
else
AC_DEFINE(NS_ATTR_MALLOC,)
fi
if test "$ac_cv_attribute_warn_unused" = yes ; then
AC_DEFINE(NS_WARN_UNUSED_RESULT, [__attribute__((warn_unused_result))])
else
AC_DEFINE(NS_WARN_UNUSED_RESULT,)
fi
if test "$ac_cv_attribute_noreturn" = yes ; then
AC_DEFINE(NS_NORETURN, [__attribute__((noreturn))])
else
AC_DEFINE(NS_NORETURN,)
fi
dnl We can't run TRY_COMPILE tests on Windows, so hard-code some
dnl features that Windows actually does support.
if test -n "$SKIP_COMPILER_CHECKS"; then
dnl Windows has malloc.h
AC_DEFINE(MALLOC_H, [<malloc.h>])
AC_DEFINE(HAVE_FORCEINLINE)
fi # SKIP_COMPILER_CHECKS
dnl ========================================================
dnl =
@ -6559,13 +6480,6 @@ if test "$MOZ_MEMORY"; then
AC_MSG_ERROR([--enable-jemalloc not supported on ${target}])
;;
esac
if test "$OS_ARCH" != "Darwin"; then
dnl NB: this must be kept in sync with jemalloc.h
AC_DEFINE(HAVE_JEMALLOC_VALLOC)
AC_DEFINE(HAVE_JEMALLOC_POSIX_MEMALIGN)
AC_DEFINE(HAVE_JEMALLOC_MEMALIGN)
fi
fi
AC_SUBST(MOZ_MEMORY)
AC_SUBST(MOZ_MEMORY_LDFLAGS)

Просмотреть файл

@ -41,7 +41,6 @@
* A class that handles loading and evaluation of <script> elements.
*/
#include "jscntxt.h"
#include "nsScriptLoader.h"
#include "nsIDOMCharacterData.h"
#include "nsParserUtils.h"
@ -61,6 +60,7 @@
#include "nsIScriptElement.h"
#include "nsIDOMHTMLScriptElement.h"
#include "nsIDocShell.h"
#include "jscntxt.h"
#include "nsContentUtils.h"
#include "nsUnicharUtils.h"
#include "nsAutoPtr.h"

Просмотреть файл

@ -47,7 +47,6 @@
* see http://developer.mozilla.org/en/docs/XUL
*/
#include "jscntxt.h" // for JSVERSION_HAS_XML
#include "nsXULContentSink.h"
#include "nsCOMPtr.h"
#include "nsForwardReference.h"
@ -80,6 +79,7 @@
#include "nsXULElement.h"
#include "prlog.h"
#include "prmem.h"
#include "jscntxt.h" // for JSVERSION_HAS_XML
#include "nsCRT.h"
#include "nsXULPrototypeDocument.h" // XXXbe temporary

Просмотреть файл

@ -37,13 +37,6 @@
*
* ***** END LICENSE BLOCK ***** */
// JavaScript includes
#include "jsapi.h"
#include "jsprvtd.h" // we are using private JS typedefs...
#include "jscntxt.h"
#include "jsdbgapi.h"
#include "jsnum.h"
#include "nscore.h"
#include "nsDOMClassInfo.h"
#include "nsCRT.h"
@ -69,6 +62,13 @@
#include "nsIRunnable.h"
#include "nsThreadUtils.h"
// JavaScript includes
#include "jsapi.h"
#include "jsprvtd.h" // we are using private JS typedefs...
#include "jscntxt.h"
#include "jsdbgapi.h"
#include "jsnum.h"
// General helper includes
#include "nsGlobalWindow.h"
#include "nsIContent.h"

Просмотреть файл

@ -37,7 +37,6 @@
*
* ***** END LICENSE BLOCK ***** */
#include "jscntxt.h"
#include "nsJSEnvironment.h"
#include "nsIScriptGlobalObject.h"
#include "nsIScriptObjectPrincipal.h"
@ -77,6 +76,7 @@
#include "nsITimer.h"
#include "nsIAtom.h"
#include "nsContentUtils.h"
#include "jscntxt.h"
#include "nsEventDispatcher.h"
#include "nsIContent.h"
#include "nsCycleCollector.h"

Просмотреть файл

@ -37,8 +37,6 @@
*
* ***** END LICENSE BLOCK ***** */
#include "jscntxt.h"
#include "nsDOMThreadService.h"
// Interfaces
@ -62,6 +60,7 @@
#include "nsPIDOMWindow.h"
// Other includes
#include "jscntxt.h"
#include "nsAutoLock.h"
#include "nsAutoPtr.h"
#include "nsContentUtils.h"

Просмотреть файл

@ -39,9 +39,6 @@
#include "npapi.h"
#include "jsapi.h"
#include "jscntxt.h"
#include "nsISupports.h"
#ifdef MOZ_ACTIVEX_PLUGIN_XPCONNECT
@ -61,6 +58,8 @@
#include "nsIScriptContext.h"
#include "nsIURI.h"
#include "nsIJSContextStack.h"
#include "jsapi.h"
#include "jscntxt.h"
#include "nsIScriptSecurityManager.h"
#endif

Просмотреть файл

@ -52,7 +52,6 @@ CPPSRCS = jsctypes-test.cpp
EXTRA_DSO_LDOPTS += \
$(XPCOM_STANDALONE_GLUE_LDOPTS) \
$(MOZALLOC_LIB) \
$(NSPR_LIBS) \
$(NULL)

Просмотреть файл

@ -37,10 +37,10 @@
*
* ***** END LICENSE BLOCK ***** */
#include "jsd_xpc.h"
#include "jsdbgapi.h"
#include "jscntxt.h"
#include "jsfun.h"
#include "jsd_xpc.h"
#include "nsIXPConnect.h"
#include "nsIGenericFactory.h"

Просмотреть файл

@ -225,7 +225,6 @@ else
endif
endif
MOZALLOC_LIB = $(call EXPAND_MOZLIBNAME,mozalloc)
# append debug flags
# (these might have been above when processing MOZ_DBGRINFO_MODULES)

Просмотреть файл

@ -46,10 +46,6 @@
/* XPConnect JavaScript interactive shell. */
#include <stdio.h>
#include "jsapi.h"
#include "jscntxt.h"
#include "jsdbgapi.h"
#include "jsprf.h"
#include "nsXULAppAPI.h"
#include "nsServiceManagerUtils.h"
#include "nsComponentManagerUtils.h"
@ -68,6 +64,9 @@
#include "nsILocalFile.h"
#include "nsDirectoryServiceDefs.h"
#include "nsAppDirectoryServiceDefs.h"
#include "jsapi.h"
#include "jsdbgapi.h"
#include "jsprf.h"
#include "nscore.h"
#include "nsArrayEnumerator.h"
#include "nsCOMArray.h"
@ -530,6 +529,9 @@ DumpXPC(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
return JS_TRUE;
}
/* XXX needed only by GC() */
#include "jscntxt.h"
static JSBool
GC(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{

Просмотреть файл

@ -34,8 +34,8 @@
*
* ***** END LICENSE BLOCK ***** */
#include "xpcprivate.h"
#include "xpcJSWeakReference.h"
#include "xpcprivate.h"
xpcJSWeakReference::xpcJSWeakReference()
{

Просмотреть файл

@ -50,14 +50,6 @@
#include <stdlib.h>
#include <stdarg.h>
#include <math.h>
#include "jsapi.h"
#include "jsdhash.h"
#include "jsprf.h"
#include "prprf.h"
#include "jsinterp.h"
#include "jscntxt.h"
#include "jsdbgapi.h"
#include "jsgc.h"
#include "nscore.h"
#include "nsXPCOM.h"
#include "nsAutoPtr.h"
@ -82,6 +74,14 @@
#include "nsIModule.h"
#include "nsAutoLock.h"
#include "nsXPTCUtils.h"
#include "jsapi.h"
#include "jsdhash.h"
#include "jsprf.h"
#include "prprf.h"
#include "jsinterp.h"
#include "jscntxt.h"
#include "jsdbgapi.h"
#include "jsgc.h"
#include "xptinfo.h"
#include "xpcforwards.h"
#include "xpclog.h"

Просмотреть файл

@ -1,52 +0,0 @@
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is the Mozilla platform.
#
# The Initial Developer of the Original Code is
# the Mozilla Foundation <http://www.mozilla.org/>.
# Portions created by the Initial Developer are Copyright (C) 2009
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
DIRS =
ifdef MOZ_MEMORY
DIRS += jemalloc
endif
DIRS += mozalloc
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -1,64 +0,0 @@
#
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is
# Mozilla Foundation
# Portions created by the Initial Developer are Copyright (C) 2008
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Ted Mielczarek <ted.mielczarek@gmail.com>
#
# Alternatively, the contents of this file may be used under the terms of
# either of the GNU General Public License Version 2 or later (the "GPL"),
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
VISIBILITY_FLAGS=
MODULE = mozalloc
LIBRARY_NAME = mozalloc
FORCE_SHARED_LIB= 1
DIST_INSTALL = 1
# The wince shunt relies on this library
export NO_SHUNT = 1
EXPORTS_NAMESPACES = mozilla
EXPORTS_mozilla = mozalloc.h mozalloc_macro_wrappers.h mozalloc_oom.h
CPPSRCS = \
mozalloc.cpp \
mozalloc_oom.cpp \
$(NULL)
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -1,209 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* vim: sw=4 ts=4 et :
*/
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Mozilla Foundation
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Chris Jones <jones.chris.g@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include <errno.h>
#include <new> // for std::bad_alloc
#include <string.h>
#if defined(MALLOC_H)
# include MALLOC_H // for memalign, valloc where available
#endif // if defined(MALLOC_H)
#include <stddef.h> // for size_t
#include <stdlib.h> // for malloc, free
// Make sure that "malloc" et al. resolve to their libc variants.
#define MOZALLOC_DONT_DEFINE_MACRO_WRAPPERS
#include "mozilla/mozalloc.h"
#include "mozilla/mozalloc_oom.h" // for mozalloc_handle_oom
#if defined(__GNUC__) && (__GNUC__ > 2)
#define LIKELY(x) (__builtin_expect(!!(x), 1))
#define UNLIKELY(x) (__builtin_expect(!!(x), 0))
#else
#define LIKELY(x) (x)
#define UNLIKELY(x) (x)
#endif
void*
moz_xmalloc(size_t size)
{
void* ptr = malloc(size);
if (UNLIKELY(!ptr)) {
mozalloc_handle_oom();
return moz_xmalloc(size);
}
return ptr;
}
void*
moz_malloc(size_t size)
{
return malloc(size);
}
void*
moz_xcalloc(size_t nmemb, size_t size)
{
void* ptr = calloc(nmemb, size);
if (UNLIKELY(!ptr)) {
mozalloc_handle_oom();
return moz_xcalloc(nmemb, size);
}
return ptr;
}
void*
moz_calloc(size_t nmemb, size_t size)
{
return calloc(nmemb, size);
}
void*
moz_xrealloc(void* ptr, size_t size)
{
void* newptr = realloc(ptr, size);
if (UNLIKELY(!newptr)) {
mozalloc_handle_oom();
return moz_xrealloc(ptr, size);
}
return newptr;
}
void*
moz_realloc(void* ptr, size_t size)
{
return realloc(ptr, size);
}
char*
moz_xstrdup(const char* str)
{
char* dup = strdup(str);
if (UNLIKELY(!dup)) {
mozalloc_handle_oom();
return moz_xstrdup(str);
}
return dup;
}
char*
moz_strdup(const char* str)
{
return strdup(str);
}
#if defined(HAVE_STRNDUP)
char*
moz_xstrndup(const char* str, size_t strsize)
{
char* dup = strndup(str, strsize);
if (UNLIKELY(!dup)) {
mozalloc_handle_oom();
return moz_xstrndup(str, strsize);
}
return dup;
}
char*
moz_strndup(const char* str, size_t strsize)
{
return strndup(str, strsize);
}
#endif // if defined(HAVE_STRNDUP)
#if defined(HAVE_POSIX_MEMALIGN)
int
moz_xposix_memalign(void **ptr, size_t alignment, size_t size)
{
int err = posix_memalign(ptr, alignment, size);
if (UNLIKELY(err && ENOMEM == err)) {
mozalloc_handle_oom();
return moz_xposix_memalign(ptr, alignment, size);
}
// else: (0 == err) or (EINVAL == err)
return err;
}
int
moz_posix_memalign(void **ptr, size_t alignment, size_t size)
{
return posix_memalign(ptr, alignment, size);
}
#endif // if defined(HAVE_POSIX_MEMALIGN)
#if defined(HAVE_MEMALIGN)
void*
moz_xmemalign(size_t boundary, size_t size)
{
void* ptr = memalign(boundary, size);
if (UNLIKELY(!ptr && EINVAL != errno)) {
mozalloc_handle_oom();
return moz_xmemalign(boundary, size);
}
// non-NULL ptr or errno == EINVAL
return ptr;
}
void*
moz_memalign(size_t boundary, size_t size)
{
return memalign(boundary, size);
}
#endif // if defined(HAVE_MEMALIGN)
#if defined(HAVE_VALLOC)
void*
moz_xvalloc(size_t size)
{
void* ptr = valloc(size);
if (UNLIKELY(!ptr)) {
mozalloc_handle_oom();
return moz_xvalloc(size);
}
return ptr;
}
void*
moz_valloc(size_t size)
{
return valloc(size);
}
#endif // if defined(HAVE_VALLOC)
namespace mozilla {
const fallible_t fallible = fallible_t();
} // namespace mozilla

Просмотреть файл

@ -1,279 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* vim: sw=4 ts=4 et :
*/
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Mozilla Foundation
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Chris Jones <jones.chris.g@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef mozilla_mozalloc_h
#define mozilla_mozalloc_h
/*
* https://bugzilla.mozilla.org/show_bug.cgi?id=427099
*/
/*
* NB: this header depends on the symbols malloc(), free(), and
* std::bad_alloc. But because this header is used in situations
* where malloc/free have different visibility, we rely on code
* including this header to provide the declarations of malloc/free.
* I.e., we don't #include <stdlib.h> or <new> on purpose.
*/
#if defined(XP_WIN) || (defined(XP_OS2) && defined(__declspec))
# define MOZALLOC_EXPORT __declspec(dllexport)
#elif defined(HAVE_VISIBILITY_ATTRIBUTE)
/* Make sure symbols are still exported even if we're wrapped in a
* |visibility push(hidden)| blanket. */
# define MOZALLOC_EXPORT __attribute__ ((visibility ("default")))
#else
# define MOZALLOC_EXPORT
#endif
#if defined(NS_ALWAYS_INLINE)
# define MOZALLOC_INLINE NS_ALWAYS_INLINE inline
#elif defined(HAVE_FORCEINLINE)
# define MOZALLOC_INLINE __forceinline
#else
# define MOZALLOC_INLINE inline
#endif
#if defined(__cplusplus)
extern "C" {
#endif /* ifdef __cplusplus */
/*
* If we don't have these system functions, but do have jemalloc
* replacements, go ahead and declare them independently of jemalloc.
* Trying to #include the jemalloc header causes redeclaration of some
* system functions with different visibility.
*/
/* FIXME/cjones: make something like the following work with jemalloc */
#if 0
#if !defined(HAVE_POSIX_MEMALIGN) && defined(HAVE_JEMALLOC_POSIX_MEMALIGN)
MOZALLOC_IMPORT int posix_memalign(void **, size_t, size_t)
NS_WARN_UNUSED_RESULT;
#endif
#endif
/*
* Each pair of declarations below is analogous to a "standard"
* allocation function, except that the out-of-memory handling is made
* explicit. The |moz_x| versions will never return a NULL pointer;
* if memory is exhausted, they abort. The |moz_| versions may return
* NULL pointers if memory is exhausted: their return value must be
* checked.
*
* All these allocation functions are *guaranteed* to return a pointer
* to memory allocated in such a way that that memory can be freed by
* passing that pointer to whatever function the symbol |free()|
* resolves to at link time.
*/
MOZALLOC_EXPORT void* moz_xmalloc(size_t size)
NS_ATTR_MALLOC NS_WARN_UNUSED_RESULT;
MOZALLOC_EXPORT
void* moz_malloc(size_t size)
NS_ATTR_MALLOC NS_WARN_UNUSED_RESULT;
MOZALLOC_EXPORT void* moz_xcalloc(size_t nmemb, size_t size)
NS_ATTR_MALLOC NS_WARN_UNUSED_RESULT;
MOZALLOC_EXPORT void* moz_calloc(size_t nmemb, size_t size)
NS_ATTR_MALLOC NS_WARN_UNUSED_RESULT;
MOZALLOC_EXPORT void* moz_xrealloc(void* ptr, size_t size)
NS_ATTR_MALLOC NS_WARN_UNUSED_RESULT;
MOZALLOC_EXPORT void* moz_realloc(void* ptr, size_t size)
NS_ATTR_MALLOC NS_WARN_UNUSED_RESULT;
MOZALLOC_EXPORT char* moz_xstrdup(const char* str)
NS_ATTR_MALLOC NS_WARN_UNUSED_RESULT;
MOZALLOC_EXPORT char* moz_strdup(const char* str)
NS_ATTR_MALLOC NS_WARN_UNUSED_RESULT;
#if defined(HAVE_STRNDUP)
MOZALLOC_EXPORT char* moz_xstrndup(const char* str, size_t strsize)
NS_ATTR_MALLOC NS_WARN_UNUSED_RESULT;
MOZALLOC_EXPORT char* moz_strndup(const char* str, size_t strsize)
NS_ATTR_MALLOC NS_WARN_UNUSED_RESULT;
#endif /* if defined(HAVE_STRNDUP) */
#if defined(HAVE_POSIX_MEMALIGN)
MOZALLOC_EXPORT int moz_xposix_memalign(void **ptr, size_t alignment, size_t size)
NS_WARN_UNUSED_RESULT;
MOZALLOC_EXPORT int moz_posix_memalign(void **ptr, size_t alignment, size_t size)
NS_WARN_UNUSED_RESULT;
#endif /* if defined(HAVE_POSIX_MEMALIGN) */
#if defined(HAVE_MEMALIGN)
MOZALLOC_EXPORT void* moz_xmemalign(size_t boundary, size_t size)
NS_ATTR_MALLOC NS_WARN_UNUSED_RESULT;
MOZALLOC_EXPORT void* moz_memalign(size_t boundary, size_t size)
NS_ATTR_MALLOC NS_WARN_UNUSED_RESULT;
#endif /* if defined(HAVE_MEMALIGN) */
#if defined(HAVE_VALLOC)
MOZALLOC_EXPORT void* moz_xvalloc(size_t size)
NS_ATTR_MALLOC NS_WARN_UNUSED_RESULT;
MOZALLOC_EXPORT void* moz_valloc(size_t size)
NS_ATTR_MALLOC NS_WARN_UNUSED_RESULT;
#endif /* if defined(HAVE_VALLOC) */
#ifdef __cplusplus
} /* extern "C" */
#endif /* ifdef __cplusplus */
#ifdef __cplusplus
/*
* We implement the default operators new/delete as part of
* libmozalloc, replacing their definitions in libstdc++. The
* operator new* definitions in libmozalloc will never return a NULL
* pointer.
*
* Each operator new immediately below returns a pointer to memory
* that can be delete'd by any of
*
* (1) the matching infallible operator delete immediately below
* (2) the matching "fallible" operator delete further below
* (3) the matching system |operator delete(void*, std::nothrow)|
* (4) the matching system |operator delete(void*) throw(std::bad_alloc)|
*
* NB: these are declared |throw(std::bad_alloc)|, though they will never
* throw that exception. This declaration is consistent with the rule
* that |::operator new() throw(std::bad_alloc)| will never return NULL.
*/
MOZALLOC_INLINE
void* operator new(size_t size) throw(std::bad_alloc)
{
return moz_xmalloc(size);
}
MOZALLOC_INLINE
void* operator new[](size_t size) throw(std::bad_alloc)
{
return moz_xmalloc(size);
}
MOZALLOC_INLINE
void operator delete(void* ptr) throw()
{
return free(ptr);
}
MOZALLOC_INLINE
void operator delete[](void* ptr) throw()
{
return free(ptr);
}
/*
* We also add a new allocator variant: "fallible operator new."
* Unlike libmozalloc's implementations of the standard nofail
* allocators, this allocator is allowed to return NULL. It can be used
* as follows
*
* Foo* f = new (mozilla::fallible) Foo(...);
*
* operator delete(fallible) is defined for completeness only.
*
* Each operator new below returns a pointer to memory that can be
* delete'd by any of
*
* (1) the matching "fallible" operator delete below
* (2) the matching infallible operator delete above
* (3) the matching system |operator delete(void*, std::nothrow)|
* (4) the matching system |operator delete(void*) throw(std::bad_alloc)|
*/
namespace mozilla {
struct MOZALLOC_EXPORT fallible_t { };
} /* namespace mozilla */
MOZALLOC_INLINE
void* operator new(size_t size, const mozilla::fallible_t&) throw()
{
return malloc(size);
}
MOZALLOC_INLINE
void* operator new[](size_t size, const mozilla::fallible_t&) throw()
{
return malloc(size);
}
MOZALLOC_INLINE
void operator delete(void* ptr, const mozilla::fallible_t&) throw()
{
free(ptr);
}
MOZALLOC_INLINE
void operator delete[](void* ptr, const mozilla::fallible_t&) throw()
{
free(ptr);
}
#endif /* ifdef __cplusplus */
#endif /* ifndef mozilla_mozalloc_h */

Просмотреть файл

@ -1,77 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* vim: sw=4 ts=4 et :
*/
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Mozilla Foundation
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Chris Jones <jones.chris.g@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef mozilla_mozalloc_macro_wrappers_h
#define mozilla_mozalloc_macro_wrappers_h
/*
* Make libc "allocating functions" never fail (return NULL).
*
* FIXME: use infallible allocators by default after
* http://bugzilla.mozilla.org/show_bug.cgi?id=507249
* lands.
*/
#define malloc(_) moz_malloc(_)
#define calloc(_, __) moz_calloc(_, __)
#define realloc(_, __) moz_realloc(_, __)
#define strdup(_) moz_strdup(_)
#if defined(HAVE_STRNDUP)
#define strndup(_, __) moz_strndup(_, __)
#endif
#if defined(HAVE_POSIX_MEMALIGN)
#define posix_memalign(_, __, ___) moz_posix_memalign(_, __, ___)
#endif
#if defined(HAVE_MEMALIGN)
#define memalign(_, __) moz_memalign(_, __)
#endif
#if defined(HAVE_VALLOC)
#define valloc(_) moz_valloc(_)
#endif
#endif /* ifndef mozilla_mozalloc_macro_wrappers_h */

Просмотреть файл

@ -1,85 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* vim: sw=4 ts=4 et :
*/
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Mozilla Foundation
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Chris Jones <jones.chris.g@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include <stdlib.h> // for abort()
#if defined(_WIN32)
# include <signal.h> // for raise
#elif defined(XP_UNIX)
# include <unistd.h> // for _exit
#endif
#include "mozilla/mozalloc_oom.h"
static int gDummyCounter;
void
mozalloc_handle_oom()
{
// NB: this is handle_oom() stage 1, which simply aborts on OOM.
// we might proceed to a stage 2 in which an attempt is made to
// reclaim memory
// XXX/cjones: most of this function was copied from
// xpcom/base/nsDebugImpl.cpp:Abort(), except that we assume on
// UNIX-like platforms can directly abort() rather than need to go
// through PR_Abort(). we don't want this code to rely on NSPR.
#if defined(_WIN32)
# if !defined(WINCE)
//This should exit us
raise(SIGABRT);
# endif
//If we are ignored exit this way..
_exit(3);
#elif defined(XP_UNIX) || defined(XP_OS2) || defined(XP_BEOS)
abort();
#else
# warning not attempting to abort() on this platform
#endif
// Still haven't aborted? Try dereferencing null.
// (Written this way to lessen the likelihood of it being optimized away.)
gDummyCounter += *((int*) 0); // TODO annotation saying we know
// this is crazy
// Still haven't aborted? Try _exit().
_exit(127);
}

Просмотреть файл

@ -1,70 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* vim: sw=4 ts=4 et :
*/
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Mozilla Foundation
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Chris Jones <jones.chris.g@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef mozilla_mozalloc_oom_h
#define mozilla_mozalloc_oom_h
#if defined(XP_WIN) || (defined(XP_OS2) && defined(__declspec))
# define MOZALLOC_EXPORT __declspec(dllexport)
#elif defined(HAVE_VISIBILITY_ATTRIBUTE)
/* Make sure symbols are still exported even if we're wrapped in a
* |visibility push(hidden)| blanket. */
# define MOZALLOC_EXPORT __attribute__ ((visibility ("default")))
#else
# define MOZALLOC_EXPORT
#endif
/**
* Called when memory is critically low. Returns iff it was able to
* remedy the critical memory situation; if not, it will abort().
*
* We have to re-#define MOZALLOC_EXPORT because this header can be
* used indepedently of mozalloc.h.
*/
MOZALLOC_EXPORT void mozalloc_handle_oom();
/* TODO: functions to query system memory usage and register
* critical-memory handlers. */
#endif /* ifndef mozilla_mozalloc_oom_h */

Просмотреть файл

@ -36,9 +36,6 @@
*
* ***** END LICENSE BLOCK ***** */
// FIXME(bug 332648): Give me a real API please!
#include "jscntxt.h"
#include "nsJSNPRuntime.h"
#include "nsNPAPIPlugin.h"
#include "nsNPAPIPluginInstance.h"
@ -53,6 +50,9 @@
#include "prmem.h"
#include "nsIContent.h"
// FIXME(bug 332648): Give me a real API please!
#include "jscntxt.h"
// Hash of JSObject wrappers that wraps JSObjects as NPObjects. There
// will be one wrapper per JSObject per plugin instance, i.e. if two
// plugins access the JSObject x, two wrappers for x will be

Просмотреть файл

@ -39,9 +39,6 @@
#include "prtypes.h"
#include "prmem.h"
#include "prclist.h"
#include "jscntxt.h"
#include "nsAutoLock.h"
#include "nsNPAPIPlugin.h"
#include "nsNPAPIPluginInstance.h"
@ -68,6 +65,8 @@
#include "nsDOMJSUtils.h"
#include "nsIPrincipal.h"
#include "jscntxt.h"
#include "nsIXPConnect.h"
#include "nsIObserverService.h"

Просмотреть файл

@ -61,8 +61,6 @@ CPPSRCS = \
LOCAL_INCLUDES = -I$(srcdir)
DEFINES += -DXPCOM_GLUE
# plugins should always be shared, even in the "static" build
FORCE_SHARED_LIB = 1

Просмотреть файл

@ -42,8 +42,6 @@ VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
DEFINES += -DMOZ_NO_MOZALLOC
EXTRA_PP_COMPONENTS = \
FastStartup.js \
$(NULL)

Просмотреть файл

@ -342,6 +342,10 @@ nsGTKRemoteService::HandleCommand(char* aCommand, nsIDOMWindow* aWindow,
command.Trim(" ", PR_TRUE, PR_TRUE);
ToLowerCase(command);
#ifdef DEBUG_bsmedberg
printf("Processing xremote command: %s\n", command.get());
#endif
if (!command.EqualsLiteral("ping")) {
nsCAutoString desktopStartupID;
nsDependentCString cmd(aCommand);
@ -389,6 +393,13 @@ nsGTKRemoteService::HandleCommandLine(char* aBuffer, nsIDOMWindow* aWindow,
PRInt32 argc = TO_LITTLE_ENDIAN32(*reinterpret_cast<PRInt32*>(aBuffer));
char *wd = aBuffer + ((argc + 1) * sizeof(PRInt32));
#ifdef DEBUG_bsmedberg
printf("Receiving command line:\n"
" wd:\t%s\n"
" argc:\t%i\n",
wd, argc);
#endif
nsCOMPtr<nsILocalFile> lf;
rv = NS_NewNativeLocalFile(nsDependentCString(wd), PR_TRUE,
getter_AddRefs(lf));
@ -411,6 +422,9 @@ nsGTKRemoteService::HandleCommandLine(char* aBuffer, nsIDOMWindow* aWindow,
cmd, ' ',
&desktopStartupID);
}
#ifdef DEBUG_bsmedberg
printf(" argv[%i]:\t%s\n", i, argv[i]);
#endif
}
rv = cmdline->Init(argc, argv, lf, nsICommandLine::STATE_REMOTE_AUTO);
@ -511,6 +525,10 @@ nsGTKRemoteService::HandlePropertyChange(GtkWidget *aWidget,
(we only care
about the first ) */
#ifdef DEBUG_bsmedberg
printf("Handling command: %s\n", data);
#endif
// Failed to get property off the window?
if (result != Success)
return FALSE;

Просмотреть файл

@ -180,7 +180,7 @@ endif
DEFINES += -DIMPL_XREAPI
EXTRA_DSO_LDOPTS += $(NSPR_LIBS) $(MOZALLOC_LIB)
EXTRA_DSO_LDOPTS += $(NSPR_LIBS)
ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
CXXFLAGS += $(TK_CFLAGS)

Просмотреть файл

@ -51,8 +51,6 @@ LIBRARY_NAME = xremote_client_s
FORCE_STATIC_LIB = 1
DEFINES += -DXPCOM_GLUE
ifdef MOZ_ENABLE_PHOTON
CPPSRCS += PhRemoteClient.cpp
else

Просмотреть файл

@ -264,7 +264,7 @@ NS_Alloc(PRSize size)
if (size > PR_INT32_MAX)
return nsnull;
void* result = moz_malloc(size);
void* result = PR_Malloc(size);
if (! result) {
// Request an asynchronous flush
sGlobalMemory.FlushMemory(NS_LITERAL_STRING("alloc-failure").get(), PR_FALSE);
@ -278,7 +278,7 @@ NS_Realloc(void* ptr, PRSize size)
if (size > PR_INT32_MAX)
return nsnull;
void* result = moz_realloc(ptr, size);
void* result = PR_Realloc(ptr, size);
if (! result && size != 0) {
// Request an asynchronous flush
sGlobalMemory.FlushMemory(NS_LITERAL_STRING("alloc-failure").get(), PR_FALSE);
@ -289,7 +289,7 @@ NS_Realloc(void* ptr, PRSize size)
XPCOM_API(void)
NS_Free(void* ptr)
{
free(ptr);
PR_Free(ptr);
}
nsresult

Просмотреть файл

@ -45,16 +45,6 @@
#include "xpcom-config.h"
#endif
/* Definitions of functions and operators that allocate memory. */
#if !defined(XPCOM_GLUE) && !defined(NS_NO_XPCOM) && !defined(MOZ_NO_MOZALLOC)
# if defined(__cplusplus)
# include <new> /* to give mozalloc std::bad_alloc */
# endif
# include <stdlib.h> /* to give mozalloc malloc/free decls */
# include "mozilla/mozalloc.h"
# include "mozilla/mozalloc_macro_wrappers.h"
#endif
/**
* Incorporate the core NSPR data types which XPCOM uses.
*/

Просмотреть файл

@ -149,10 +149,7 @@ DEFINES += \
-DEXPORT_XPT_API \
-DEXPORT_XPTC_API
EXTRA_DSO_LDOPTS += \
$(MOZALLOC_LIB) \
$(NSPR_LIBS) \
$(NULL)
EXTRA_DSO_LDOPTS += $(NSPR_LIBS)
ifdef TARGET_XPCOM_ABI
DEFINES += -DTARGET_XPCOM_ABI=\"$(TARGET_XPCOM_ABI)\"

Просмотреть файл

@ -58,6 +58,12 @@ class UTF8traits
static PRBool is6byte(char c) { return (c & 0xFE) == 0xFC; }
};
#ifdef __GNUC__
#define NS_ALWAYS_INLINE __attribute__((always_inline))
#else
#define NS_ALWAYS_INLINE
#endif
/**
* Extract the next UCS-4 character from the buffer and return it. The
* pointer passed in is advanced to the start of the next character in the

Просмотреть файл

@ -78,7 +78,6 @@ DEPENDENT_LIBS_LIST += \
$(LIB_PREFIX)nspr4$(DLL_SUFFIX) \
$(LIB_PREFIX)plc4$(DLL_SUFFIX) \
$(LIB_PREFIX)plds4$(DLL_SUFFIX) \
$(LIB_PREFIX)mozalloc$(DLL_SUFFIX) \
$(NULL)
ifdef MOZ_ENABLE_LIBXUL
@ -116,13 +115,9 @@ EXTRA_DSO_LIBS = xpcom_core
DEPENDENT_LIBS_LIST += $(LIB_PREFIX)xpcom_core$(DLL_SUFFIX)
endif
endif #ifdef MOZ_ENABLE_LIBXUL
endif
EXTRA_DSO_LDOPTS += \
$(EXTRA_DSO_LIBS) \
$(NSPR_LIBS) \
$(MOZALLOC_LIB) \
$(NULL)
EXTRA_DSO_LDOPTS += $(EXTRA_DSO_LIBS) $(NSPR_LIBS)
include $(topsrcdir)/config/rules.mk