Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
96 changed files
with
36,383 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# Makefile for Borland C++ 4.5 on NT | ||
# For Borland 5.0, replace bc45 by bc5. | ||
# If you have the Borland assembler, remove "-DUSE_GENERIC" | ||
# | ||
bc= c:\bc45 | ||
bcbin= $(bc)\bin | ||
bclib= $(bc)\lib | ||
bcinclude= $(bc)\include | ||
|
||
cc= $(bcbin)\bcc32 | ||
rc= $(bcbin)\brc32 | ||
lib= $(bcbin)\tlib | ||
link= $(bcbin)\tlink32 | ||
cflags= -R -v -vi -H -H=gc.csm -I$(bcinclude);cord -L$(bclib) \ | ||
-w-pro -w-aus -w-par -w-ccc -w-rch -a4 -D__STDC__=0 | ||
#defines= -DSILENT | ||
defines= -DSMALL_CONFIG -DSILENT -DALL_INTERIOR_POINTERS -DUSE_GENERIC | ||
|
||
.c.obj: | ||
$(cc) @&&| | ||
$(cdebug) $(cflags) $(cvars) $(defines) -o$* -c $*.c | ||
| | ||
|
||
.cpp.obj: | ||
$(cc) @&&| | ||
$(cdebug) $(cflags) $(cvars) $(defines) -o$* -c $*.cpp | ||
| | ||
|
||
.rc.res: | ||
$(rc) -i$(bcinclude) -r -fo$* $*.rc | ||
|
||
XXXOBJS= XXXalloc.obj XXXreclaim.obj XXXallchblk.obj XXXmisc.obj \ | ||
XXXmach_dep.obj XXXos_dep.obj XXXmark_rts.obj XXXheaders.obj XXXmark.obj \ | ||
XXXobj_map.obj XXXblacklst.obj XXXfinalize.obj XXXnew_hblk.obj \ | ||
XXXdbg_mlc.obj XXXmalloc.obj XXXstubborn.obj XXXdyn_load.obj \ | ||
XXXtypd_mlc.obj XXXptr_chck.obj XXXgc_cpp.obj XXXmallocx.obj | ||
|
||
OBJS= $(XXXOBJS:XXX=) | ||
|
||
all: gctest.exe cord\de.exe test_cpp.exe | ||
|
||
$(OBJS) test.obj: gc_priv.h gc_hdrs.h gc.h gcconfig.h MAKEFILE | ||
|
||
gc.lib: $(OBJS) | ||
-del gc.lib | ||
tlib $* @&&| | ||
$(XXXOBJS:XXX=+) | ||
| | ||
|
||
gctest.exe: test.obj gc.lib | ||
$(cc) @&&| | ||
$(cflags) -W -e$* test.obj gc.lib | ||
| | ||
|
||
cord\de.obj cord\de_win.obj: cord\cord.h cord\private\cord_pos.h cord\de_win.h \ | ||
cord\de_cmds.h | ||
|
||
cord\de.exe: cord\cordbscs.obj cord\cordxtra.obj cord\de.obj cord\de_win.obj \ | ||
cord\de_win.res gc.lib | ||
$(cc) @&&| | ||
$(cflags) -W -e$* cord\cordbscs.obj cord\cordxtra.obj \ | ||
cord\de.obj cord\de_win.obj gc.lib | ||
| | ||
$(rc) cord\de_win.res cord\de.exe | ||
|
||
gc_cpp.obj: gc_cpp.h gc.h | ||
|
||
gc_cpp.cpp: gc_cpp.cc | ||
copy gc_cpp.cc gc_cpp.cpp | ||
|
||
test_cpp.cpp: test_cpp.cc | ||
copy test_cpp.cc test_cpp.cpp | ||
|
||
test_cpp.exe: test_cpp.obj gc_cpp.h gc.h gc.lib | ||
$(cc) @&&| | ||
$(cflags) -W -e$* test_cpp.obj gc.lib | ||
| | ||
|
||
scratch: | ||
-del *.obj *.res *.exe *.csm cord\*.obj cord\*.res cord\*.exe cord\*.csm | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
# | ||
# OS/2 specific Makefile for the EMX environment | ||
# | ||
# You need GNU Make 3.71, gcc 2.5.7, emx 0.8h and GNU fileutils 3.9 | ||
# or similar tools. C++ interface and de.exe weren't tested. | ||
# | ||
# Rename this file "Makefile". | ||
# | ||
|
||
# Primary targets: | ||
# gc.a - builds basic library | ||
# c++ - adds C++ interface to library and include directory | ||
# cords - adds cords (heavyweight strings) to library and include directory | ||
# test - prints porting information, then builds basic version of gc.a, and runs | ||
# some tests of collector and cords. Does not add cords or c++ interface to gc.a | ||
# cord/de.exe - builds dumb editor based on cords. | ||
CC= gcc | ||
CXX=g++ | ||
# Needed only for "make c++", which adds the c++ interface | ||
|
||
CFLAGS= -O -DALL_INTERIOR_POINTERS -DSILENT | ||
# Setjmp_test may yield overly optimistic results when compiled | ||
# without optimization. | ||
# -DSILENT disables statistics printing, and improves performance. | ||
# -DCHECKSUMS reports on erroneously clear dirty bits, and unexpectedly | ||
# altered stubborn objects, at substantial performance cost. | ||
# -DFIND_LEAK causes the collector to assume that all inaccessible | ||
# objects should have been explicitly deallocated, and reports exceptions | ||
# -DSOLARIS_THREADS enables support for Solaris (thr_) threads. | ||
# (Clients should also define SOLARIS_THREADS and then include | ||
# gc.h before performing thr_ or GC_ operations.) | ||
# -DALL_INTERIOR_POINTERS allows all pointers to the interior | ||
# of objects to be recognized. (See gc_private.h for consequences.) | ||
# -DSMALL_CONFIG tries to tune the collector for small heap sizes, | ||
# usually causing it to use less space in such situations. | ||
# Incremental collection no longer works in this case. | ||
# -DDONT_ADD_BYTE_AT_END is meaningful only with | ||
# -DALL_INTERIOR_POINTERS. Normally -DALL_INTERIOR_POINTERS | ||
# causes all objects to be padded so that pointers just past the end of | ||
# an object can be recognized. This can be expensive. (The padding | ||
# is normally more than one byte due to alignment constraints.) | ||
# -DDONT_ADD_BYTE_AT_END disables the padding. | ||
|
||
AR= ar | ||
RANLIB= ar s | ||
|
||
# Redefining srcdir allows object code for the nonPCR version of the collector | ||
# to be generated in different directories | ||
srcdir = . | ||
VPATH = $(srcdir) | ||
|
||
OBJS= alloc.o reclaim.o allchblk.o misc.o mach_dep.o os_dep.o mark_rts.o headers.o mark.o obj_map.o blacklst.o finalize.o new_hblk.o dyn_load.o dbg_mlc.o malloc.o stubborn.o checksums.o typd_mlc.o ptr_chck.o mallocx.o | ||
|
||
CORD_OBJS= cord/cordbscs.o cord/cordxtra.o cord/cordprnt.o | ||
|
||
CORD_INCLUDE_FILES= $(srcdir)/gc.h $(srcdir)/cord/cord.h $(srcdir)/cord/ec.h \ | ||
$(srcdir)/cord/cord_pos.h | ||
|
||
# Libraries needed for curses applications. Only needed for de. | ||
CURSES= -lcurses -ltermlib | ||
|
||
# The following is irrelevant on most systems. But a few | ||
# versions of make otherwise fork the shell specified in | ||
# the SHELL environment variable. | ||
SHELL= bash | ||
|
||
SPECIALCFLAGS = | ||
# Alternative flags to the C compiler for mach_dep.c. | ||
# Mach_dep.c often doesn't like optimization, and it's | ||
# not time-critical anyway. | ||
|
||
all: gc.a gctest.exe | ||
|
||
$(OBJS) test.o: $(srcdir)/gc_priv.h $(srcdir)/gc_hdrs.h $(srcdir)/gc.h \ | ||
$(srcdir)/gcconfig.h $(srcdir)/gc_typed.h | ||
# The dependency on Makefile is needed. Changing | ||
# options such as -DSILENT affects the size of GC_arrays, | ||
# invalidating all .o files that rely on gc_priv.h | ||
|
||
mark.o typd_mlc.o finalize.o: $(srcdir)/gc_mark.h | ||
|
||
gc.a: $(OBJS) | ||
$(AR) ru gc.a $(OBJS) | ||
$(RANLIB) gc.a | ||
|
||
cords: $(CORD_OBJS) cord/cordtest.exe | ||
$(AR) ru gc.a $(CORD_OBJS) | ||
$(RANLIB) gc.a | ||
cp $(srcdir)/cord/cord.h include/cord.h | ||
cp $(srcdir)/cord/ec.h include/ec.h | ||
cp $(srcdir)/cord/cord_pos.h include/cord_pos.h | ||
|
||
gc_cpp.o: $(srcdir)/gc_cpp.cc $(srcdir)/gc_cpp.h | ||
$(CXX) -c -O $(srcdir)/gc_cpp.cc | ||
|
||
c++: gc_cpp.o $(srcdir)/gc_cpp.h | ||
$(AR) ru gc.a gc_cpp.o | ||
$(RANLIB) gc.a | ||
cp $(srcdir)/gc_cpp.h include/gc_cpp.h | ||
|
||
mach_dep.o: $(srcdir)/mach_dep.c | ||
$(CC) -o mach_dep.o -c $(SPECIALCFLAGS) $(srcdir)/mach_dep.c | ||
|
||
mark_rts.o: $(srcdir)/mark_rts.c | ||
$(CC) -o mark_rts.o -c $(CFLAGS) $(srcdir)/mark_rts.c | ||
|
||
cord/cordbscs.o: $(srcdir)/cord/cordbscs.c $(CORD_INCLUDE_FILES) | ||
$(CC) $(CFLAGS) -c $(srcdir)/cord/cordbscs.c -o cord/cordbscs.o | ||
|
||
cord/cordxtra.o: $(srcdir)/cord/cordxtra.c $(CORD_INCLUDE_FILES) | ||
$(CC) $(CFLAGS) -c $(srcdir)/cord/cordxtra.c -o cord/cordxtra.o | ||
|
||
cord/cordprnt.o: $(srcdir)/cord/cordprnt.c $(CORD_INCLUDE_FILES) | ||
$(CC) $(CFLAGS) -c $(srcdir)/cord/cordprnt.c -o cord/cordprnt.o | ||
|
||
cord/cordtest.exe: $(srcdir)/cord/cordtest.c $(CORD_OBJS) gc.a | ||
$(CC) $(CFLAGS) -o cord/cordtest.exe $(srcdir)/cord/cordtest.c $(CORD_OBJS) gc.a | ||
|
||
cord/de.exe: $(srcdir)/cord/de.c $(srcdir)/cord/cordbscs.o $(srcdir)/cord/cordxtra.o gc.a | ||
$(CC) $(CFLAGS) -o cord/de.exe $(srcdir)/cord/de.c $(srcdir)/cord/cordbscs.o $(srcdir)/cord/cordxtra.o gc.a $(CURSES) | ||
|
||
clean: | ||
rm -f gc.a test.o gctest.exe output-local output-diff $(OBJS) \ | ||
setjmp_test mon.out gmon.out a.out core \ | ||
$(CORD_OBJS) cord/cordtest.exe cord/de.exe | ||
-rm -f *~ | ||
|
||
gctest.exe: test.o gc.a | ||
$(CC) $(CFLAGS) -o gctest.exe test.o gc.a | ||
|
||
# If an optimized setjmp_test generates a segmentation fault, | ||
# odds are your compiler is broken. Gctest may still work. | ||
# Try compiling setjmp_t.c unoptimized. | ||
setjmp_test.exe: $(srcdir)/setjmp_t.c $(srcdir)/gc.h | ||
$(CC) $(CFLAGS) -o setjmp_test.exe $(srcdir)/setjmp_t.c | ||
|
||
test: setjmp_test.exe gctest.exe | ||
./setjmp_test | ||
./gctest | ||
make cord/cordtest.exe | ||
cord/cordtest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
/* | ||
MacOS.c | ||
Some routines for the Macintosh OS port of the Hans-J. Boehm, Alan J. Demers | ||
garbage collector. | ||
<Revision History> | ||
11/22/94 pcb StripAddress the temporary memory handle for 24-bit mode. | ||
11/30/94 pcb Tracking all memory usage so we can deallocate it all at once. | ||
02/10/96 pcb Added routine to perform a final collection when | ||
unloading shared library. | ||
by Patrick C. Beard. | ||
*/ | ||
/* Boehm, February 15, 1996 2:55 pm PST */ | ||
|
||
#include <Resources.h> | ||
#include <Memory.h> | ||
#include <LowMem.h> | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
|
||
#include "gc.h" | ||
#include "gc_priv.h" | ||
|
||
// use 'CODE' resource 0 to get exact location of the beginning of global space. | ||
|
||
typedef struct { | ||
unsigned long aboveA5; | ||
unsigned long belowA5; | ||
unsigned long JTSize; | ||
unsigned long JTOffset; | ||
} *CodeZeroPtr, **CodeZeroHandle; | ||
|
||
void* GC_MacGetDataStart() | ||
{ | ||
CodeZeroHandle code0 = (CodeZeroHandle)GetResource('CODE', 0); | ||
if (code0) { | ||
long belowA5Size = (**code0).belowA5; | ||
ReleaseResource((Handle)code0); | ||
return (LMGetCurrentA5() - belowA5Size); | ||
} | ||
fprintf(stderr, "Couldn't load the jump table."); | ||
exit(-1); | ||
return 0; | ||
} | ||
|
||
/* track the use of temporary memory so it can be freed all at once. */ | ||
|
||
typedef struct TemporaryMemoryBlock TemporaryMemoryBlock, **TemporaryMemoryHandle; | ||
|
||
struct TemporaryMemoryBlock { | ||
TemporaryMemoryHandle nextBlock; | ||
char data[]; | ||
}; | ||
|
||
static TemporaryMemoryHandle theTemporaryMemory = NULL; | ||
static Boolean firstTime = true; | ||
|
||
void GC_MacFreeTemporaryMemory(void); | ||
|
||
Ptr GC_MacTemporaryNewPtr(size_t size, Boolean clearMemory) | ||
{ | ||
static Boolean firstTime = true; | ||
OSErr result; | ||
TemporaryMemoryHandle tempMemBlock; | ||
Ptr tempPtr = nil; | ||
|
||
tempMemBlock = (TemporaryMemoryHandle)TempNewHandle(size + sizeof(TemporaryMemoryBlock), &result); | ||
if (tempMemBlock && result == noErr) { | ||
HLockHi((Handle)tempMemBlock); | ||
tempPtr = (**tempMemBlock).data; | ||
if (clearMemory) memset(tempPtr, 0, size); | ||
tempPtr = StripAddress(tempPtr); | ||
|
||
// keep track of the allocated blocks. | ||
(**tempMemBlock).nextBlock = theTemporaryMemory; | ||
theTemporaryMemory = tempMemBlock; | ||
} | ||
|
||
# if !defined(SHARED_LIBRARY_BUILD) | ||
// install an exit routine to clean up the memory used at the end. | ||
if (firstTime) { | ||
atexit(&GC_MacFreeTemporaryMemory); | ||
firstTime = false; | ||
} | ||
# endif | ||
|
||
return tempPtr; | ||
} | ||
|
||
extern word GC_fo_entries; | ||
|
||
static void perform_final_collection() | ||
{ | ||
unsigned i; | ||
word last_fo_entries = 0; | ||
|
||
/* adjust the stack bottom, because CFM calls us from another stack | ||
location. */ | ||
GC_stackbottom = (ptr_t)&i; | ||
|
||
/* try to collect and finalize everything in sight */ | ||
for (i = 0; i < 2 || GC_fo_entries < last_fo_entries; i++) { | ||
last_fo_entries = GC_fo_entries; | ||
GC_gcollect(); | ||
} | ||
} | ||
|
||
|
||
void GC_MacFreeTemporaryMemory() | ||
{ | ||
# if defined(SHARED_LIBRARY_BUILD) | ||
/* if possible, collect all memory, and invoke all finalizers. */ | ||
perform_final_collection(); | ||
# endif | ||
|
||
if (theTemporaryMemory != NULL) { | ||
long totalMemoryUsed = 0; | ||
TemporaryMemoryHandle tempMemBlock = theTemporaryMemory; | ||
while (tempMemBlock != NULL) { | ||
TemporaryMemoryHandle nextBlock = (**tempMemBlock).nextBlock; | ||
totalMemoryUsed += GetHandleSize((Handle)tempMemBlock); | ||
DisposeHandle((Handle)tempMemBlock); | ||
tempMemBlock = nextBlock; | ||
} | ||
theTemporaryMemory = NULL; | ||
|
||
# if !defined(SILENT) && !defined(SHARED_LIBRARY_BUILD) | ||
fprintf(stdout, "[total memory used: %ld bytes.]\n", | ||
totalMemoryUsed); | ||
fprintf(stdout, "[total collections: %ld.]\n", GC_gc_no); | ||
# endif | ||
} | ||
} | ||
|
||
#if __option(far_data) | ||
|
||
void* GC_MacGetDataEnd() | ||
{ | ||
CodeZeroHandle code0 = (CodeZeroHandle)GetResource('CODE', 0); | ||
if (code0) { | ||
long aboveA5Size = (**code0).aboveA5; | ||
ReleaseResource((Handle)code0); | ||
return (LMGetCurrentA5() + aboveA5Size); | ||
} | ||
fprintf(stderr, "Couldn't load the jump table."); | ||
exit(-1); | ||
return 0; | ||
} | ||
|
||
#endif /* __option(far_data) */ |
Oops, something went wrong.