add js to tree

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@3693 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Brian West
2006-12-18 15:53:47 +00:00
parent 855c7b9a77
commit fff98f6316
1137 changed files with 386873 additions and 0 deletions

View File

@@ -0,0 +1 @@
Makefile

View File

@@ -0,0 +1,10 @@
/.cvsignore/1.2/Sat May 12 06:22:03 2001//
/Makefile.in/1.13/Wed Jun 1 14:28:27 2005//
/macgc.c/3.5/Sun Apr 25 15:00:36 2004//
/os2gc.c/3.6/Sun Apr 25 15:00:36 2004//
/prgcapi.c/3.6/Sun Apr 25 15:00:36 2004//
/prmsgc.c/3.10/Mon Nov 7 22:39:00 2005//
/unixgc.c/3.6/Sun Apr 25 15:00:36 2004//
/win16gc.c/3.5/Sun Apr 25 15:00:36 2004//
/win32gc.c/3.5/Sun Apr 25 15:00:36 2004//
D

View File

@@ -0,0 +1 @@
mozilla/nsprpub/lib/msgc/src

View File

@@ -0,0 +1 @@
:pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot

View File

@@ -0,0 +1,103 @@
#
# ***** 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 Netscape Portable Runtime (NSPR).
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 1998-2000
# 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 *****
#! gmake
MOD_DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(MOD_DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/config.mk
INCLUDES = -I$(dist_includedir) -I../include
CSRCS = prgcapi.c prmsgc.c
ifeq ($(OS_ARCH),WINNT)
CSRCS += win32gc.c
else
ifeq ($(OS_ARCH),OS2)
CSRCS += os2gc.c
else
CSRCS += unixgc.c
endif
endif
NSPR_VERSION = $(MOD_MAJOR_VERSION)
EXTRA_LIBS = $(LIBNSPR)
ifdef RESOLVE_LINK_SYMBOLS
EXTRA_LIBS += $(OS_LIBS)
endif
ifeq ($(OS_ARCH), WINNT)
ifdef NS_USE_GCC
DLLBASE=-Wl,--image-base -Wl,0x30000000
else
DLLBASE=-BASE:0x30000000
endif # GCC
#RES=$(OBJDIR)/ds.res
#RESNAME=$(MOD_DEPTH)/pr/src/nspr.rc
#OS_LIBS = user32.lib
endif # WINNT
LIBRARY_NAME = msgc
LIBRARY_VERSION = $(MOD_MAJOR_VERSION)
RELEASE_LIBS = $(TARGETS)
include $(topsrcdir)/config/rules.mk
#
# The Client build wants the shared libraries in $(dist_bindir),
# so we also install them there.
#
export:: $(TARGETS)
$(INSTALL) -m 444 $(TARGETS) $(dist_libdir)
ifdef SHARED_LIBRARY
$(INSTALL) -m 444 $(SHARED_LIBRARY) $(dist_bindir)
endif
ifeq ($(MOZ_BITS),16)
$(INSTALL) -m 444 $(TARGETS) $(MOZ_DIST)/lib
$(INSTALL) -m 444 $(TARGETS) $(MOZ_DIST)/bin
endif

View File

@@ -0,0 +1,75 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** 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 Netscape Portable Runtime (NSPR).
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998-2000
* 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 ***** */
#include "primpl.h"
#include "MacMemAllocator.h"
void _MD_InitGC() {}
void *_MD_GrowGCHeap(size_t *sizep)
{
void *heapPtr = NULL;
size_t heapSize = *sizep;
// In previous versions of this code we tried to allocate GC heaps from the application
// heap. In the 4.0 application, we try to keep our app heap allications to a minimum
// and instead go through our own memory allocation routines.
heapPtr = malloc(heapSize);
if (heapPtr == NULL) {
FreeMemoryStats stats;
memtotal(heapSize, &stats); // How much can we allcoate?
if (stats.maxBlockSize < heapSize)
heapSize = stats.maxBlockSize;
heapPtr = malloc(heapSize);
if (heapPtr == NULL) // Now we're hurting
heapSize = 0;
}
*sizep = heapSize;
return heapPtr;
}
void _MD_FreeGCSegment(void *base, int32 /* len */)
{
free(base);
}

View File

@@ -0,0 +1,83 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** 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 Netscape Portable Runtime (NSPR).
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998-2000
* 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 ***** */
/*
* GC related routines
*
*/
#include "prlog.h"
#include <stdlib.h>
/* Leave a bit of room for any malloc header bytes... */
#define MAX_SEGMENT_SIZE (65536L - 4096L)
/************************************************************************/
/*
** Machine dependent GC Heap management routines:
** _MD_GrowGCHeap
*/
/************************************************************************/
void _MD_InitGC() {}
void *_MD_GrowGCHeap(PRUint32 *sizep)
{
void *addr;
if ( *sizep > MAX_SEGMENT_SIZE )
{
*sizep = MAX_SEGMENT_SIZE;
}
addr = malloc((size_t)*sizep);
return addr;
}
PRBool _MD_ExtendGCHeap(char *base, PRInt32 oldSize, PRInt32 newSize) {
/* Not sure about this. Todd? */
return PR_FALSE;
}
void _MD_FreeGCSegment(void *base, PRInt32 len)
{
if (base)
{
free(base);
}
}

View File

@@ -0,0 +1,351 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** 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 Netscape Portable Runtime (NSPR).
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998-2000
* 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 ***** */
#include <stdarg.h>
#include <string.h>
#include <stdio.h>
#include "prenv.h"
#include "prmem.h"
#include "prmon.h"
#include "prlog.h"
#include "prthread.h"
#if defined(XP_MAC)
#include "pprthred.h"
#else
#include "private/pprthred.h"
#endif
#include "gcint.h"
/*
** Generic GC implementation independent code for the NSPR GC
*/
RootFinder *_pr_rootFinders;
CollectorType *_pr_collectorTypes;
/* GC State information */
GCInfo _pr_gcData;
GCBeginGCHook *_pr_beginGCHook;
void *_pr_beginGCHookArg;
GCBeginGCHook *_pr_endGCHook;
void *_pr_endGCHookArg;
GCBeginFinalizeHook *_pr_beginFinalizeHook;
void *_pr_beginFinalizeHookArg;
GCBeginFinalizeHook *_pr_endFinalizeHook;
void *_pr_endFinalizeHookArg;
FILE *_pr_dump_file;
int _pr_do_a_dump;
GCLockHook *_pr_GCLockHook;
extern PRLogModuleInfo *_pr_msgc_lm;
/************************************************************************/
static PRStatus PR_CALLBACK
pr_ScanOneThread(PRThread* t, void** addr, PRUword count, void* closure)
{
#if defined(XP_MAC)
#pragma unused (t, closure)
#endif
_pr_gcData.processRootBlock(addr, count);
return PR_SUCCESS;
}
/*
** Scan all of the threads C stack's and registers, looking for "root"
** pointers into the GC heap. These are the objects that the GC cannot
** move and are considered "live" by the GC. Caller has stopped all of
** the threads from running.
*/
static void PR_CALLBACK ScanThreads(void *arg)
{
PR_ScanStackPointers(pr_ScanOneThread, arg);
}
/************************************************************************/
PR_IMPLEMENT(GCInfo *) PR_GetGCInfo(void)
{
return &_pr_gcData;
}
PR_IMPLEMENT(PRInt32) PR_RegisterType(GCType *t)
{
CollectorType *ct, *ect;
int rv = -1;
LOCK_GC();
ct = &_pr_collectorTypes[0];
ect = &_pr_collectorTypes[FREE_MEMORY_TYPEIX];
for (; ct < ect; ct++) {
if (ct->flags == 0) {
ct->gctype = *t;
ct->flags = _GC_TYPE_BUSY;
if (0 != ct->gctype.finalize) {
ct->flags |= _GC_TYPE_FINAL;
}
if (0 != ct->gctype.getWeakLinkOffset) {
ct->flags |= _GC_TYPE_WEAK;
}
rv = ct - &_pr_collectorTypes[0];
break;
}
}
UNLOCK_GC();
return rv;
}
PR_IMPLEMENT(PRStatus) PR_RegisterRootFinder(
GCRootFinder f, char *name, void *arg)
{
RootFinder *rf = PR_NEWZAP(RootFinder);
if (rf) {
rf->func = f;
rf->name = name;
rf->arg = arg;
LOCK_GC();
rf->next = _pr_rootFinders;
_pr_rootFinders = rf;
UNLOCK_GC();
return PR_SUCCESS;
}
return PR_FAILURE;
}
PR_IMPLEMENT(int) PR_RegisterGCLockHook(GCLockHookFunc* f, void *arg)
{
GCLockHook *rf = 0;
rf = (GCLockHook*) calloc(1, sizeof(GCLockHook));
if (rf) {
rf->func = f;
rf->arg = arg;
LOCK_GC();
/* first dummy node */
if (! _pr_GCLockHook) {
_pr_GCLockHook = (GCLockHook*) calloc(1, sizeof(GCLockHook));
_pr_GCLockHook->next = _pr_GCLockHook;
_pr_GCLockHook->prev = _pr_GCLockHook;
}
rf->next = _pr_GCLockHook;
rf->prev = _pr_GCLockHook->prev;
_pr_GCLockHook->prev->next = rf;
_pr_GCLockHook->prev = rf;
UNLOCK_GC();
return 0;
}
return -1;
}
/*
PR_IMPLEMENT(void) PR_SetGCLockHook(GCLockHook *hook, void *arg)
{
LOCK_GC();
_pr_GCLockHook = hook;
_pr_GCLockHookArg2 = arg;
UNLOCK_GC();
}
PR_IMPLEMENT(void) PR_GetGCLockHook(GCLockHook **hook, void **arg)
{
LOCK_GC();
*hook = _pr_GCLockHook;
*arg = _pr_GCLockHookArg2;
UNLOCK_GC();
}
*/
PR_IMPLEMENT(void) PR_SetBeginGCHook(GCBeginGCHook *hook, void *arg)
{
LOCK_GC();
_pr_beginGCHook = hook;
_pr_beginGCHookArg = arg;
UNLOCK_GC();
}
PR_IMPLEMENT(void) PR_GetBeginGCHook(GCBeginGCHook **hook, void **arg)
{
LOCK_GC();
*hook = _pr_beginGCHook;
*arg = _pr_beginGCHookArg;
UNLOCK_GC();
}
PR_IMPLEMENT(void) PR_SetEndGCHook(GCEndGCHook *hook, void *arg)
{
LOCK_GC();
_pr_endGCHook = hook;
_pr_endGCHookArg = arg;
UNLOCK_GC();
}
PR_IMPLEMENT(void) PR_GetEndGCHook(GCEndGCHook **hook, void **arg)
{
LOCK_GC();
*hook = _pr_endGCHook;
*arg = _pr_endGCHookArg;
UNLOCK_GC();
}
PR_IMPLEMENT(void) PR_SetBeginFinalizeHook(GCBeginFinalizeHook *hook, void *arg)
{
LOCK_GC();
_pr_beginFinalizeHook = hook;
_pr_beginFinalizeHookArg = arg;
UNLOCK_GC();
}
PR_IMPLEMENT(void) PR_GetBeginFinalizeHook(GCBeginFinalizeHook **hook,
void **arg)
{
LOCK_GC();
*hook = _pr_beginFinalizeHook;
*arg = _pr_beginFinalizeHookArg;
UNLOCK_GC();
}
PR_IMPLEMENT(void) PR_SetEndFinalizeHook(GCEndFinalizeHook *hook, void *arg)
{
LOCK_GC();
_pr_endFinalizeHook = hook;
_pr_endFinalizeHookArg = arg;
UNLOCK_GC();
}
PR_IMPLEMENT(void) PR_GetEndFinalizeHook(GCEndFinalizeHook **hook, void **arg)
{
LOCK_GC();
*hook = _pr_endFinalizeHook;
*arg = _pr_endFinalizeHookArg;
UNLOCK_GC();
}
#ifdef DEBUG
#include "prprf.h"
#if defined(WIN16)
static FILE *tracefile = 0;
#endif
PR_IMPLEMENT(void) GCTrace(char *fmt, ...)
{
va_list ap;
char buf[400];
va_start(ap, fmt);
PR_vsnprintf(buf, sizeof(buf), fmt, ap);
va_end(ap);
#if defined(WIN16)
if ( tracefile == 0 )
{
tracefile = fopen( "xxxGCtr", "w" );
}
fprintf(tracefile, "%s\n", buf );
fflush(tracefile);
#else
PR_LOG(_pr_msgc_lm, PR_LOG_ALWAYS, ("%s", buf));
#endif
}
#endif
void _PR_InitGC(PRWord flags)
{
static char firstTime = 1;
if (!firstTime) return;
firstTime = 0;
_MD_InitGC();
if (flags == 0) {
char *ev = PR_GetEnv("GCLOG");
if (ev && ev[0]) {
flags = atoi(ev);
}
}
_pr_gcData.flags = flags;
_pr_gcData.lock = PR_NewMonitor();
_pr_collectorTypes = (CollectorType*) PR_CALLOC(256 * sizeof(CollectorType));
PR_RegisterRootFinder(ScanThreads, "scan threads", 0);
PR_RegisterRootFinder(_PR_ScanFinalQueue, "scan final queue", 0);
}
extern void pr_FinalizeOnExit(void);
#ifdef DEBUG
#ifdef GC_STATS
PR_PUBLIC_API(void) PR_PrintGCAllocStats(void);
#endif
#endif
PR_IMPLEMENT(void)
PR_ShutdownGC(PRBool finalizeOnExit)
{
/* first finalize all the objects in the heap */
if (finalizeOnExit) {
pr_FinalizeOnExit();
}
#ifdef DEBUG
#ifdef GC_STATS
PR_PrintGCAllocStats();
#endif /* GC_STATS */
#endif /* DEBUG */
/* then the chance for any future allocations */
/* finally delete the gc heap */
/* write me */
}
/******************************************************************************/

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,155 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** 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 Netscape Portable Runtime (NSPR).
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998-2000
* 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 ***** */
#include "prlock.h"
#include "prlog.h"
#include "prmem.h"
#include "gcint.h"
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/mman.h>
#define _PR_GC_VMBASE 0x40000000
#if defined(SOLARIS)
#define _MD_MMAP_FLAGS MAP_SHARED
#elif defined(RELIANTUNIX)
#define _MD_MMAP_FLAGS MAP_PRIVATE|MAP_FIXED
#else
#define _MD_MMAP_FLAGS MAP_PRIVATE
#endif
static PRInt32 zero_fd = -1;
static PRLock *zero_fd_lock = NULL;
void _MD_InitGC(void)
{
#ifdef DEBUG
/*
* Disable using mmap(2) if NSPR_NO_MMAP is set
*/
if (getenv("NSPR_NO_MMAP")) {
zero_fd = -2;
return;
}
#endif
zero_fd = open("/dev/zero",O_RDWR , 0);
zero_fd_lock = PR_NewLock();
}
/* This static variable is used by _MD_GrowGCHeap and _MD_ExtendGCHeap */
static void *lastaddr = (void*) _PR_GC_VMBASE;
void *_MD_GrowGCHeap(PRUint32 *sizep)
{
void *addr;
PRUint32 size;
size = *sizep;
PR_Lock(zero_fd_lock);
if (zero_fd < 0) {
goto mmap_loses;
}
/* Extend the mapping */
addr = mmap(lastaddr, size, PROT_READ|PROT_WRITE|PROT_EXEC,
_MD_MMAP_FLAGS,
zero_fd, 0);
if (addr == (void*)-1) {
zero_fd = -1;
goto mmap_loses;
}
lastaddr = ((char*)addr + size);
#ifdef DEBUG
PR_LOG(_pr_msgc_lm, PR_LOG_WARNING,
("GC: heap extends from %08x to %08x\n",
_PR_GC_VMBASE,
_PR_GC_VMBASE + (char*)lastaddr - (char*)_PR_GC_VMBASE));
#endif
PR_Unlock(zero_fd_lock);
return addr;
mmap_loses:
PR_Unlock(zero_fd_lock);
return PR_MALLOC(size);
}
/* XXX - This is disabled. MAP_FIXED just does not work. */
#if 0
PRBool _MD_ExtendGCHeap(char *base, PRInt32 oldSize, PRInt32 newSize) {
PRBool rv = PR_FALSE;
void* addr;
PRInt32 allocSize = newSize - oldSize;
PR_Lock(zero_fd_lock);
addr = mmap(base + oldSize, allocSize, PROT_READ|PROT_WRITE|PROT_EXEC,
_MD_MMAP_FLAGS | MAP_FIXED, zero_fd, 0);
if (addr == (void*)-1) {
goto loser;
}
if (addr != (void*) (base + oldSize)) {
munmap(base + oldSize, allocSize);
goto loser;
}
lastaddr = ((char*)base + newSize);
PR_LOG(_pr_msgc_lm, PR_LOG_ALWAYS,
("GC: heap now extends from %p to %p",
base, base + newSize));
rv = PR_TRUE;
loser:
PR_Unlock(zero_fd_lock);
return rv;
}
#else
PRBool _MD_ExtendGCHeap(char *base, PRInt32 oldSize, PRInt32 newSize) {
return PR_FALSE;
}
#endif
void _MD_FreeGCSegment(void *base, PRInt32 len)
{
if (zero_fd < 0) {
PR_DELETE(base);
} else {
(void) munmap(base, len);
}
}

View File

@@ -0,0 +1,77 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** 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 Netscape Portable Runtime (NSPR).
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998-2000
* 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 ***** */
#if defined(WIN16)
#include <windows.h>
#endif
#include "prtypes.h"
#include <stdlib.h>
#define MAX_SEGMENT_SIZE (65536l - 4096l)
/************************************************************************/
/*
** Machine dependent GC Heap management routines:
** _MD_GrowGCHeap
*/
/************************************************************************/
void _MD_InitGC(void) {}
extern void *
_MD_GrowGCHeap(PRUint32 *sizep)
{
void *addr;
if( *sizep > MAX_SEGMENT_SIZE ) {
*sizep = MAX_SEGMENT_SIZE;
}
addr = malloc((size_t)*sizep);
return addr;
}
HINSTANCE _pr_hInstance;
int CALLBACK LibMain( HINSTANCE hInst, WORD wDataSeg,
WORD cbHeapSize, LPSTR lpszCmdLine )
{
_pr_hInstance = hInst;
return TRUE;
}

View File

@@ -0,0 +1,129 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** 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 Netscape Portable Runtime (NSPR).
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998-2000
* 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 ***** */
/*
* GC related routines
*
*/
#include <windows.h>
#include "prlog.h"
extern PRLogModuleInfo* _pr_msgc_lm;
#define GC_VMBASE 0x40000000
#define GC_VMLIMIT 0x00FFFFFF
/************************************************************************/
/*
** Machine dependent GC Heap management routines:
** _MD_GrowGCHeap
*/
/************************************************************************/
void *baseaddr = (void*) GC_VMBASE;
void *lastaddr = (void*) GC_VMBASE;
void _MD_InitGC() {}
void *_MD_GrowGCHeap(PRUint32 *sizep)
{
void *addr;
size_t size;
/* Reserve a block of memory for the GC */
if( lastaddr == baseaddr ) {
addr = VirtualAlloc( (void *)GC_VMBASE, GC_VMLIMIT, MEM_RESERVE, PAGE_READWRITE );
/*
** If the GC_VMBASE address is already mapped, then let the OS choose a
** base address that is available...
*/
if (addr == NULL) {
addr = VirtualAlloc( NULL, GC_VMLIMIT, MEM_RESERVE, PAGE_READWRITE );
baseaddr = lastaddr = addr;
if (addr == NULL) {
PR_LOG(_pr_msgc_lm, PR_LOG_ALWAYS, ("GC: unable to allocate heap: LastError=%ld",
GetLastError()));
return 0;
}
}
}
size = *sizep;
/* Extend the mapping */
addr = VirtualAlloc( lastaddr, size, MEM_COMMIT, PAGE_READWRITE );
if (addr == NULL) {
return 0;
}
lastaddr = ((char*)addr + size);
PR_LOG(_pr_msgc_lm, PR_LOG_ALWAYS,
("GC: heap extends from %08x to %08x",
baseaddr, (long)baseaddr + (char*)lastaddr - (char*)baseaddr));
return addr;
}
PRBool _MD_ExtendGCHeap(char *base, PRInt32 oldSize, PRInt32 newSize) {
void* addr;
addr = VirtualAlloc( base + oldSize, newSize - oldSize,
MEM_COMMIT, PAGE_READWRITE );
if (NULL == addr) {
PR_LOG(_pr_msgc_lm, PR_LOG_ALWAYS, ("GC: unable to extend heap: LastError=%ld",
GetLastError()));
return PR_FALSE;
}
if (base + oldSize != (char*)addr) {
PR_LOG(_pr_msgc_lm, PR_LOG_ALWAYS, ("GC: segment extension returned %x instead of %x",
addr, base + oldSize));
VirtualFree(addr, newSize - oldSize, MEM_DECOMMIT);
return PR_FALSE;
}
lastaddr = base + newSize;
PR_LOG(_pr_msgc_lm, PR_LOG_ALWAYS,
("GC: heap now extends from %p to %p",
base, base + newSize));
return PR_TRUE;
}
void _MD_FreeGCSegment(void *base, PRInt32 len)
{
(void)VirtualFree(base, 0, MEM_RELEASE);
}