summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2013-07-10 13:35:23 +0200
committerIvan Maidanski <ivmai@mail.ru>2013-07-10 13:42:36 +0200
commit5f52b60915bc7effa5d68ea7da8c29584806e9ce (patch)
treea7f8cc02c2df345588664b6c591b301875a10ce9
parent065a811dec7bd88a7170ea08e7189403cce9ed23 (diff)
Expand tabs to spaces in rarely used (ancient) files
* extra/AmigaOS.c: Expand tabs to spaces. * extra/MacOS.c: Likewise. * extra/Mac_files/dataend.c: Likewise. * extra/Mac_files/datastart.c: Likewise. * extra/symbian.cpp: Likewise. * cord/cordxtra.c: Likewise.
-rw-r--r--cord/cordxtra.c46
-rw-r--r--extra/AmigaOS.c536
-rw-r--r--extra/MacOS.c130
-rw-r--r--extra/Mac_files/dataend.c6
-rw-r--r--extra/Mac_files/datastart.c6
-rw-r--r--extra/symbian.cpp74
6 files changed, 399 insertions, 399 deletions
diff --git a/cord/cordxtra.c b/cord/cordxtra.c
index b00a482..fbf8163 100644
--- a/cord/cordxtra.c
+++ b/cord/cordxtra.c
@@ -135,8 +135,8 @@ int CORD_batched_fill_proc(const char * s, void * client_data)
return(0);
}
-/* Fill buf with len characters starting at i. */
-/* Assumes len characters are available. */
+/* Fill buf with len characters starting at i. */
+/* Assumes len characters are available. */
void CORD_fill_buf(CORD x, size_t i, size_t len, char * buf)
{
CORD_fill_data fd;
@@ -362,12 +362,12 @@ size_t CORD_rchr(CORD x, size_t i, int c)
}
}
-/* Find the first occurrence of s in x at position start or later. */
+/* Find the first occurrence of s in x at position start or later. */
/* This uses an asymptotically poor algorithm, which should typically */
/* perform acceptably. We compare the first few characters directly, */
-/* and call CORD_ncmp whenever there is a partial match. */
+/* and call CORD_ncmp whenever there is a partial match. */
/* This has the advantage that we allocate very little, or not at all. */
-/* It's very fast if there are few close misses. */
+/* It's very fast if there are few close misses. */
size_t CORD_str(CORD x, size_t start, CORD s)
{
CORD_pos xpos;
@@ -375,10 +375,10 @@ size_t CORD_str(CORD x, size_t start, CORD s)
size_t slen;
register size_t start_len;
const char * s_start;
- unsigned long s_buf = 0; /* The first few characters of s */
- unsigned long x_buf = 0; /* Start of candidate substring. */
+ unsigned long s_buf = 0; /* The first few characters of s */
+ unsigned long x_buf = 0; /* Start of candidate substring. */
/* Initialized only to make compilers */
- /* happy. */
+ /* happy. */
unsigned long mask = 0;
register size_t i;
register size_t match_pos;
@@ -460,9 +460,9 @@ CORD CORD_from_file_eager(FILE * f)
for(;;) {
c = getc(f);
if (c == 0) {
- /* Append the right number of NULs */
- /* Note that any string of NULs is rpresented in 4 words, */
- /* independent of its length. */
+ /* Append the right number of NULs */
+ /* Note that any string of NULs is rpresented in 4 words, */
+ /* independent of its length. */
register size_t count = 1;
CORD_ec_flush_buf(ecord);
@@ -476,18 +476,18 @@ CORD CORD_from_file_eager(FILE * f)
return(CORD_balance(CORD_ec_to_cord(ecord)));
}
-/* The state maintained for a lazily read file consists primarily */
-/* of a large direct-mapped cache of previously read values. */
-/* We could rely more on stdio buffering. That would have 2 */
-/* disadvantages: */
-/* 1) Empirically, not all fseek implementations preserve the */
-/* buffer whenever they could. */
-/* 2) It would fail if 2 different sections of a long cord */
-/* were being read alternately. */
-/* We do use the stdio buffer for read ahead. */
-/* To guarantee thread safety in the presence of atomic pointer */
-/* writes, cache lines are always replaced, and never modified in */
-/* place. */
+/* The state maintained for a lazily read file consists primarily */
+/* of a large direct-mapped cache of previously read values. */
+/* We could rely more on stdio buffering. That would have 2 */
+/* disadvantages: */
+/* 1) Empirically, not all fseek implementations preserve the */
+/* buffer whenever they could. */
+/* 2) It would fail if 2 different sections of a long cord */
+/* were being read alternately. */
+/* We do use the stdio buffer for read ahead. */
+/* To guarantee thread safety in the presence of atomic pointer */
+/* writes, cache lines are always replaced, and never modified in */
+/* place. */
# define LOG_CACHE_SZ 14
# define CACHE_SZ (1 << LOG_CACHE_SZ)
diff --git a/extra/AmigaOS.c b/extra/AmigaOS.c
index 759b3df..4c747ab 100644
--- a/extra/AmigaOS.c
+++ b/extra/AmigaOS.c
@@ -47,13 +47,13 @@ ptr_t GC_get_main_stack_base()
/* Reference: Amiga Guru Book Pages: 42,567,574 */
if (proc->pr_Task.tc_Node.ln_Type==NT_PROCESS
&& proc->pr_CLI != NULL) {
- /* first ULONG is StackSize */
- /*longPtr = proc->pr_ReturnAddr;
- size = longPtr[0];*/
+ /* first ULONG is StackSize */
+ /*longPtr = proc->pr_ReturnAddr;
+ size = longPtr[0];*/
- return (char *)proc->pr_ReturnAddr + sizeof(ULONG);
+ return (char *)proc->pr_ReturnAddr + sizeof(ULONG);
} else {
- return (char *)proc->pr_Task.tc_SPUpper;
+ return (char *)proc->pr_Task.tc_SPUpper;
}
}
@@ -69,16 +69,16 @@ ptr_t GC_get_stack_base()
long size;
if ((task = FindTask(0)) == 0) {
- GC_err_puts("Cannot find own task structure\n");
- ABORT("task missing");
+ GC_err_puts("Cannot find own task structure\n");
+ ABORT("task missing");
}
proc = (struct Process *)task;
cli = BADDR(proc->pr_CLI);
if (_WBenchMsg != 0 || cli == 0) {
- size = (char *)task->tc_SPUpper - (char *)task->tc_SPLower;
+ size = (char *)task->tc_SPUpper - (char *)task->tc_SPLower;
} else {
- size = cli->cli_DefaultStack * 4;
+ size = cli->cli_DefaultStack * 4;
}
return (ptr_t)(__base + GC_max(size, __stack));
}
@@ -95,96 +95,96 @@ ptr_t GC_get_stack_base()
void GC_register_data_segments()
{
- struct Process *proc;
+ struct Process *proc;
struct CommandLineInterface *cli;
BPTR myseglist;
ULONG *data;
- int num;
+ int num;
# ifdef __GNUC__
ULONG dataSegSize;
GC_bool found_segment = FALSE;
- extern char __data_size[];
+ extern char __data_size[];
- dataSegSize=__data_size+8;
- /* Can`t find the Location of __data_size, because
+ dataSegSize=__data_size+8;
+ /* Can`t find the Location of __data_size, because
it`s possible that is it, inside the segment. */
# endif
- proc= (struct Process*)SysBase->ThisTask;
-
- /* Reference: Amiga Guru Book Pages: 538ff,565,573
- and XOper.asm */
- if (proc->pr_Task.tc_Node.ln_Type==NT_PROCESS) {
- if (proc->pr_CLI == NULL) {
- myseglist = proc->pr_SegList;
- } else {
- /* ProcLoaded 'Loaded as a command: '*/
- cli = BADDR(proc->pr_CLI);
- myseglist = cli->cli_Module;
- }
- } else {
- ABORT("Not a Process.");
- }
-
- if (myseglist == NULL) {
- ABORT("Arrrgh.. can't find segments, aborting");
- }
-
- /* xoper hunks Shell Process */
-
- num=0;
+ proc= (struct Process*)SysBase->ThisTask;
+
+ /* Reference: Amiga Guru Book Pages: 538ff,565,573
+ and XOper.asm */
+ if (proc->pr_Task.tc_Node.ln_Type==NT_PROCESS) {
+ if (proc->pr_CLI == NULL) {
+ myseglist = proc->pr_SegList;
+ } else {
+ /* ProcLoaded 'Loaded as a command: '*/
+ cli = BADDR(proc->pr_CLI);
+ myseglist = cli->cli_Module;
+ }
+ } else {
+ ABORT("Not a Process.");
+ }
+
+ if (myseglist == NULL) {
+ ABORT("Arrrgh.. can't find segments, aborting");
+ }
+
+ /* xoper hunks Shell Process */
+
+ num=0;
for (data = (ULONG *)BADDR(myseglist); data != NULL;
data = (ULONG *)BADDR(data[0])) {
- if (((ULONG) GC_register_data_segments < (ULONG) &data[1]) ||
- ((ULONG) GC_register_data_segments > (ULONG) &data[1] + data[-1])) {
+ if (((ULONG) GC_register_data_segments < (ULONG) &data[1]) ||
+ ((ULONG) GC_register_data_segments > (ULONG) &data[1] + data[-1])) {
# ifdef __GNUC__
- if (dataSegSize == data[-1]) {
- found_segment = TRUE;
- }
-# endif
- GC_add_roots_inner((char *)&data[1],
- ((char *)&data[1]) + data[-1], FALSE);
+ if (dataSegSize == data[-1]) {
+ found_segment = TRUE;
+ }
+# endif
+ GC_add_roots_inner((char *)&data[1],
+ ((char *)&data[1]) + data[-1], FALSE);
}
++num;
} /* for */
-# ifdef __GNUC__
- if (!found_segment) {
- ABORT("Can`t find correct Segments.\nSolution: Use an newer version of ixemul.library");
- }
-# endif
+# ifdef __GNUC__
+ if (!found_segment) {
+ ABORT("Can`t find correct Segments.\nSolution: Use an newer version of ixemul.library");
+ }
+# endif
}
#if 0 /* old version */
void GC_register_data_segments()
{
extern struct WBStartup *_WBenchMsg;
- struct Process *proc;
+ struct Process *proc;
struct CommandLineInterface *cli;
BPTR myseglist;
ULONG *data;
if ( _WBenchMsg != 0 ) {
- if ((myseglist = _WBenchMsg->sm_Segment) == 0) {
- GC_err_puts("No seglist from workbench\n");
- return;
- }
+ if ((myseglist = _WBenchMsg->sm_Segment) == 0) {
+ GC_err_puts("No seglist from workbench\n");
+ return;
+ }
} else {
- if ((proc = (struct Process *)FindTask(0)) == 0) {
- GC_err_puts("Cannot find process structure\n");
- return;
- }
- if ((cli = BADDR(proc->pr_CLI)) == 0) {
- GC_err_puts("No CLI\n");
- return;
- }
- if ((myseglist = cli->cli_Module) == 0) {
- GC_err_puts("No seglist from CLI\n");
- return;
- }
+ if ((proc = (struct Process *)FindTask(0)) == 0) {
+ GC_err_puts("Cannot find process structure\n");
+ return;
+ }
+ if ((cli = BADDR(proc->pr_CLI)) == 0) {
+ GC_err_puts("No CLI\n");
+ return;
+ }
+ if ((myseglist = cli->cli_Module) == 0) {
+ GC_err_puts("No seglist from CLI\n");
+ return;
+ }
}
for (data = (ULONG *)BADDR(myseglist); data != 0;
@@ -192,11 +192,11 @@ ptr_t GC_get_stack_base()
# ifdef AMIGA_SKIP_SEG
if (((ULONG) GC_register_data_segments < (ULONG) &data[1]) ||
((ULONG) GC_register_data_segments > (ULONG) &data[1] + data[-1])) {
-# else
- {
-# endif /* AMIGA_SKIP_SEG */
+# else
+ {
+# endif /* AMIGA_SKIP_SEG */
GC_add_roots_inner((char *)&data[1],
- ((char *)&data[1]) + data[-1], FALSE);
+ ((char *)&data[1]) + data[-1], FALSE);
}
}
}
@@ -212,11 +212,11 @@ ptr_t GC_get_stack_base()
#ifndef GC_AMIGA_FASTALLOC
void *GC_amiga_allocwrapper(size_t size,void *(*AllocFunction)(size_t size2)){
- return (*AllocFunction)(size);
+ return (*AllocFunction)(size);
}
void *(*GC_amiga_allocwrapper_do)(size_t size,void *(*AllocFunction)(size_t size2))
- =GC_amiga_allocwrapper;
+ =GC_amiga_allocwrapper;
#else
@@ -226,13 +226,13 @@ void *(*GC_amiga_allocwrapper_do)(size_t size,void *(*AllocFunction)(size_t size
void *GC_amiga_allocwrapper_firsttime(size_t size,void *(*AllocFunction)(size_t size2));
void *(*GC_amiga_allocwrapper_do)(size_t size,void *(*AllocFunction)(size_t size2))
- =GC_amiga_allocwrapper_firsttime;
+ =GC_amiga_allocwrapper_firsttime;
/******************************************************************
Amiga-spesific routines to obtain memory, and force GC to give
back fast-mem whenever possible.
- These hacks makes gc-programs go many times faster when
+ These hacks makes gc-programs go many times faster when
the amiga is low on memory, and are therefore strictly necesarry.
-Kjetil S. Matheussen, 2000.
@@ -243,8 +243,8 @@ void *(*GC_amiga_allocwrapper_do)(size_t size,void *(*AllocFunction)(size_t size
/* List-header for all allocated memory. */
struct GC_Amiga_AllocedMemoryHeader{
- ULONG size;
- struct GC_Amiga_AllocedMemoryHeader *next;
+ ULONG size;
+ struct GC_Amiga_AllocedMemoryHeader *next;
};
struct GC_Amiga_AllocedMemoryHeader *GC_AMIGAMEM=(struct GC_Amiga_AllocedMemoryHeader *)(int)~(NULL);
@@ -285,42 +285,42 @@ int ncur151=0;
/* Free everything at program-end. */
void GC_amiga_free_all_mem(void){
- struct GC_Amiga_AllocedMemoryHeader *gc_am=(struct GC_Amiga_AllocedMemoryHeader *)(~(int)(GC_AMIGAMEM));
- struct GC_Amiga_AllocedMemoryHeader *temp;
+ struct GC_Amiga_AllocedMemoryHeader *gc_am=(struct GC_Amiga_AllocedMemoryHeader *)(~(int)(GC_AMIGAMEM));
+ struct GC_Amiga_AllocedMemoryHeader *temp;
#ifdef GC_AMIGA_PRINTSTATS
- printf("\n\n"
- "%d bytes of chip-mem, and %d bytes of fast-mem where allocated from the OS.\n",
- allochip,allocfast
- );
- printf(
- "%d bytes of chip-mem were returned from the GC_AMIGA_FASTALLOC supported allocating functions.\n",
- chipa
- );
- printf("\n");
- printf("GC_gcollect was called %d times to avoid returning NULL or start allocating with the MEMF_ANY flag.\n",numcollects);
- printf("%d of them was a success. (the others had to use allocation from the OS.)\n",nullretries);
- printf("\n");
- printf("Succeded forcing %d gc-allocations (%d bytes) of chip-mem to be fast-mem.\n",succ,succ2);
- printf("Failed forcing %d gc-allocations (%d bytes) of chip-mem to be fast-mem.\n",nsucc,nsucc2);
- printf("\n");
- printf(
- "Number of retries before succeding a chip->fast force:\n"
- "0: %d, 1: %d, 2-9: %d, 10-49: %d, 50-149: %d, >150: %d\n",
- cur0,cur1,cur10,cur50,cur150,cur151
- );
- printf(
- "Number of retries before giving up a chip->fast force:\n"
- "0: %d, 1: %d, 2-9: %d, 10-49: %d, 50-149: %d, >150: %d\n",
- ncur0,ncur1,ncur10,ncur50,ncur150,ncur151
- );
+ printf("\n\n"
+ "%d bytes of chip-mem, and %d bytes of fast-mem where allocated from the OS.\n",
+ allochip,allocfast
+ );
+ printf(
+ "%d bytes of chip-mem were returned from the GC_AMIGA_FASTALLOC supported allocating functions.\n",
+ chipa
+ );
+ printf("\n");
+ printf("GC_gcollect was called %d times to avoid returning NULL or start allocating with the MEMF_ANY flag.\n",numcollects);
+ printf("%d of them was a success. (the others had to use allocation from the OS.)\n",nullretries);
+ printf("\n");
+ printf("Succeded forcing %d gc-allocations (%d bytes) of chip-mem to be fast-mem.\n",succ,succ2);
+ printf("Failed forcing %d gc-allocations (%d bytes) of chip-mem to be fast-mem.\n",nsucc,nsucc2);
+ printf("\n");
+ printf(
+ "Number of retries before succeding a chip->fast force:\n"
+ "0: %d, 1: %d, 2-9: %d, 10-49: %d, 50-149: %d, >150: %d\n",
+ cur0,cur1,cur10,cur50,cur150,cur151
+ );
+ printf(
+ "Number of retries before giving up a chip->fast force:\n"
+ "0: %d, 1: %d, 2-9: %d, 10-49: %d, 50-149: %d, >150: %d\n",
+ ncur0,ncur1,ncur10,ncur50,ncur150,ncur151
+ );
#endif
- while(gc_am!=NULL){
- temp=gc_am->next;
- FreeMem(gc_am,gc_am->size);
- gc_am=(struct GC_Amiga_AllocedMemoryHeader *)(~(int)(temp));
- }
+ while(gc_am!=NULL){
+ temp=gc_am->next;
+ FreeMem(gc_am,gc_am->size);
+ gc_am=(struct GC_Amiga_AllocedMemoryHeader *)(~(int)(temp));
+ }
}
#ifndef GC_AMIGA_ONLYFAST
@@ -346,36 +346,36 @@ size_t latestsize;
*/
void *GC_amiga_get_mem(size_t size){
- struct GC_Amiga_AllocedMemoryHeader *gc_am;
+ struct GC_Amiga_AllocedMemoryHeader *gc_am;
#ifndef GC_AMIGA_ONLYFAST
- if(GC_amiga_dontalloc==TRUE){
-// printf("rejected, size: %d, latestsize: %d\n",size,latestsize);
- return NULL;
- }
+ if(GC_amiga_dontalloc==TRUE){
+// printf("rejected, size: %d, latestsize: %d\n",size,latestsize);
+ return NULL;
+ }
- // We really don't want to use chip-mem, but if we must, then as little as possible.
- if(GC_AMIGA_MEMF==(MEMF_ANY|MEMF_CLEAR) && size>100000 && latestsize<50000) return NULL;
+ // We really don't want to use chip-mem, but if we must, then as little as possible.
+ if(GC_AMIGA_MEMF==(MEMF_ANY|MEMF_CLEAR) && size>100000 && latestsize<50000) return NULL;
#endif
- gc_am=AllocMem((ULONG)(size + sizeof(struct GC_Amiga_AllocedMemoryHeader)),GC_AMIGA_MEMF);
- if(gc_am==NULL) return NULL;
+ gc_am=AllocMem((ULONG)(size + sizeof(struct GC_Amiga_AllocedMemoryHeader)),GC_AMIGA_MEMF);
+ if(gc_am==NULL) return NULL;
- gc_am->next=GC_AMIGAMEM;
- gc_am->size=size + sizeof(struct GC_Amiga_AllocedMemoryHeader);
- GC_AMIGAMEM=(struct GC_Amiga_AllocedMemoryHeader *)(~(int)(gc_am));
+ gc_am->next=GC_AMIGAMEM;
+ gc_am->size=size + sizeof(struct GC_Amiga_AllocedMemoryHeader);
+ GC_AMIGAMEM=(struct GC_Amiga_AllocedMemoryHeader *)(~(int)(gc_am));
-// printf("Allocated %d (%d) bytes at address: %x. Latest: %d\n",size,tot,gc_am,latestsize);
+// printf("Allocated %d (%d) bytes at address: %x. Latest: %d\n",size,tot,gc_am,latestsize);
#ifdef GC_AMIGA_PRINTSTATS
- if((char *)gc_am<chipmax){
- allochip+=size;
- }else{
- allocfast+=size;
- }
+ if((char *)gc_am<chipmax){
+ allochip+=size;
+ }else{
+ allocfast+=size;
+ }
#endif
- return gc_am+1;
+ return gc_am+1;
}
@@ -391,40 +391,40 @@ void *GC_amiga_get_mem(size_t size){
*/
#ifdef GC_AMIGA_RETRY
void *GC_amiga_rec_alloc(size_t size,void *(*AllocFunction)(size_t size2),const int rec){
- void *ret;
+ void *ret;
- ret=(*AllocFunction)(size);
+ ret=(*AllocFunction)(size);
#ifdef GC_AMIGA_PRINTSTATS
- if((char *)ret>chipmax || ret==NULL){
- if(ret==NULL){
- nsucc++;
- nsucc2+=size;
- if(rec==0) ncur0++;
- if(rec==1) ncur1++;
- if(rec>1 && rec<10) ncur10++;
- if(rec>=10 && rec<50) ncur50++;
- if(rec>=50 && rec<150) ncur150++;
- if(rec>=150) ncur151++;
- }else{
- succ++;
- succ2+=size;
- if(rec==0) cur0++;
- if(rec==1) cur1++;
- if(rec>1 && rec<10) cur10++;
- if(rec>=10 && rec<50) cur50++;
- if(rec>=50 && rec<150) cur150++;
- if(rec>=150) cur151++;
- }
- }
+ if((char *)ret>chipmax || ret==NULL){
+ if(ret==NULL){
+ nsucc++;
+ nsucc2+=size;
+ if(rec==0) ncur0++;
+ if(rec==1) ncur1++;
+ if(rec>1 && rec<10) ncur10++;
+ if(rec>=10 && rec<50) ncur50++;
+ if(rec>=50 && rec<150) ncur150++;
+ if(rec>=150) ncur151++;
+ }else{
+ succ++;
+ succ2+=size;
+ if(rec==0) cur0++;
+ if(rec==1) cur1++;
+ if(rec>1 && rec<10) cur10++;
+ if(rec>=10 && rec<50) cur50++;
+ if(rec>=50 && rec<150) cur150++;
+ if(rec>=150) cur151++;
+ }
+ }
#endif
- if (((char *)ret)<=chipmax && ret!=NULL && (rec<(size>500000?9:size/5000))){
- ret=GC_amiga_rec_alloc(size,AllocFunction,rec+1);
-// GC_free(ret2);
- }
+ if (((char *)ret)<=chipmax && ret!=NULL && (rec<(size>500000?9:size/5000))){
+ ret=GC_amiga_rec_alloc(size,AllocFunction,rec+1);
+// GC_free(ret2);
+ }
- return ret;
+ return ret;
}
#endif
@@ -435,81 +435,81 @@ void *GC_amiga_rec_alloc(size_t size,void *(*AllocFunction)(size_t size2),const
void *GC_amiga_allocwrapper_any(size_t size,void *(*AllocFunction)(size_t size2)){
- void *ret,*ret2;
+ void *ret,*ret2;
- GC_amiga_dontalloc=TRUE; // Pretty tough thing to do, but its indeed necesarry.
- latestsize=size;
+ GC_amiga_dontalloc=TRUE; // Pretty tough thing to do, but its indeed necesarry.
+ latestsize=size;
- ret=(*AllocFunction)(size);
+ ret=(*AllocFunction)(size);
- if(((char *)ret) <= chipmax){
- if(ret==NULL){
- //Give GC access to allocate memory.
+ if(((char *)ret) <= chipmax){
+ if(ret==NULL){
+ //Give GC access to allocate memory.
#ifdef GC_AMIGA_GC
- if(!GC_dont_gc){
- GC_gcollect();
+ if(!GC_dont_gc){
+ GC_gcollect();
#ifdef GC_AMIGA_PRINTSTATS
- numcollects++;
+ numcollects++;
#endif
- ret=(*AllocFunction)(size);
- }
+ ret=(*AllocFunction)(size);
+ }
#endif
- if(ret==NULL){
- GC_amiga_dontalloc=FALSE;
- ret=(*AllocFunction)(size);
- if(ret==NULL){
- WARN("Out of Memory! Returning NIL!\n", 0);
- }
- }
+ if(ret==NULL){
+ GC_amiga_dontalloc=FALSE;
+ ret=(*AllocFunction)(size);
+ if(ret==NULL){
+ WARN("Out of Memory! Returning NIL!\n", 0);
+ }
+ }
#ifdef GC_AMIGA_PRINTSTATS
- else{
- nullretries++;
- }
- if(ret!=NULL && (char *)ret<=chipmax) chipa+=size;
+ else{
+ nullretries++;
+ }
+ if(ret!=NULL && (char *)ret<=chipmax) chipa+=size;
#endif
- }
+ }
#ifdef GC_AMIGA_RETRY
- else{
- /* We got chip-mem. Better try again and again and again etc., we might get fast-mem sooner or later... */
- /* Using gctest to check the effectiviness of doing this, does seldom give a very good result. */
- /* However, real programs doesn't normally rapidly allocate and deallocate. */
-// printf("trying to force... %d bytes... ",size);
- if(
- AllocFunction!=GC_malloc_uncollectable
+ else{
+ /* We got chip-mem. Better try again and again and again etc., we might get fast-mem sooner or later... */
+ /* Using gctest to check the effectiviness of doing this, does seldom give a very good result. */
+ /* However, real programs doesn't normally rapidly allocate and deallocate. */
+// printf("trying to force... %d bytes... ",size);
+ if(
+ AllocFunction!=GC_malloc_uncollectable
#ifdef ATOMIC_UNCOLLECTABLE
- && AllocFunction!=GC_malloc_atomic_uncollectable
+ && AllocFunction!=GC_malloc_atomic_uncollectable
#endif
- ){
- ret2=GC_amiga_rec_alloc(size,AllocFunction,0);
- }else{
- ret2=(*AllocFunction)(size);
+ ){
+ ret2=GC_amiga_rec_alloc(size,AllocFunction,0);
+ }else{
+ ret2=(*AllocFunction)(size);
#ifdef GC_AMIGA_PRINTSTATS
- if((char *)ret2<chipmax || ret2==NULL){
- nsucc++;
- nsucc2+=size;
- ncur0++;
- }else{
- succ++;
- succ2+=size;
- cur0++;
- }
+ if((char *)ret2<chipmax || ret2==NULL){
+ nsucc++;
+ nsucc2+=size;
+ ncur0++;
+ }else{
+ succ++;
+ succ2+=size;
+ cur0++;
+ }
#endif
- }
- if(((char *)ret2)>chipmax){
-// printf("Succeeded.\n");
- GC_free(ret);
- ret=ret2;
- }else{
- GC_free(ret2);
-// printf("But did not succeed.\n");
- }
- }
+ }
+ if(((char *)ret2)>chipmax){
+// printf("Succeeded.\n");
+ GC_free(ret);
+ ret=ret2;
+ }else{
+ GC_free(ret2);
+// printf("But did not succeed.\n");
+ }
+ }
#endif
- }
+ }
- GC_amiga_dontalloc=FALSE;
+ GC_amiga_dontalloc=FALSE;
- return ret;
+ return ret;
}
@@ -517,52 +517,52 @@ void *GC_amiga_allocwrapper_any(size_t size,void *(*AllocFunction)(size_t size2)
void (*GC_amiga_toany)(void)=NULL;
void GC_amiga_set_toany(void (*func)(void)){
- GC_amiga_toany=func;
+ GC_amiga_toany=func;
}
#endif // !GC_AMIGA_ONLYFAST
void *GC_amiga_allocwrapper_fast(size_t size,void *(*AllocFunction)(size_t size2)){
- void *ret;
+ void *ret;
- ret=(*AllocFunction)(size);
+ ret=(*AllocFunction)(size);
- if(ret==NULL){
- // Enable chip-mem allocation.
-// printf("ret==NULL\n");
+ if(ret==NULL){
+ // Enable chip-mem allocation.
+// printf("ret==NULL\n");
#ifdef GC_AMIGA_GC
- if(!GC_dont_gc){
- GC_gcollect();
+ if(!GC_dont_gc){
+ GC_gcollect();
#ifdef GC_AMIGA_PRINTSTATS
- numcollects++;
+ numcollects++;
#endif
- ret=(*AllocFunction)(size);
- }
+ ret=(*AllocFunction)(size);
+ }
#endif
- if(ret==NULL){
+ if(ret==NULL){
#ifndef GC_AMIGA_ONLYFAST
- GC_AMIGA_MEMF=MEMF_ANY | MEMF_CLEAR;
- if(GC_amiga_toany!=NULL) (*GC_amiga_toany)();
- GC_amiga_allocwrapper_do=GC_amiga_allocwrapper_any;
- return GC_amiga_allocwrapper_any(size,AllocFunction);
+ GC_AMIGA_MEMF=MEMF_ANY | MEMF_CLEAR;
+ if(GC_amiga_toany!=NULL) (*GC_amiga_toany)();
+ GC_amiga_allocwrapper_do=GC_amiga_allocwrapper_any;
+ return GC_amiga_allocwrapper_any(size,AllocFunction);
#endif
- }
+ }
#ifdef GC_AMIGA_PRINTSTATS
- else{
- nullretries++;
- }
+ else{
+ nullretries++;
+ }
#endif
- }
+ }
- return ret;
+ return ret;
}
void *GC_amiga_allocwrapper_firsttime(size_t size,void *(*AllocFunction)(size_t size2)){
- atexit(&GC_amiga_free_all_mem);
- chipmax=(char *)SysBase->MaxLocMem; // For people still having SysBase in chip-mem, this might speed up a bit.
- GC_amiga_allocwrapper_do=GC_amiga_allocwrapper_fast;
- return GC_amiga_allocwrapper_fast(size,AllocFunction);
+ atexit(&GC_amiga_free_all_mem);
+ chipmax=(char *)SysBase->MaxLocMem; // For people still having SysBase in chip-mem, this might speed up a bit.
+ GC_amiga_allocwrapper_do=GC_amiga_allocwrapper_fast;
+ return GC_amiga_allocwrapper_fast(size,AllocFunction);
}
@@ -576,45 +576,45 @@ void *GC_amiga_allocwrapper_firsttime(size_t size,void *(*AllocFunction)(size_t
*/
void *GC_amiga_realloc(void *old_object,size_t new_size_in_bytes){
#ifndef GC_AMIGA_FASTALLOC
- return GC_realloc(old_object,new_size_in_bytes);
+ return GC_realloc(old_object,new_size_in_bytes);
#else
- void *ret;
- latestsize=new_size_in_bytes;
- ret=GC_realloc(old_object,new_size_in_bytes);
- if(ret==NULL && GC_AMIGA_MEMF==(MEMF_FAST | MEMF_CLEAR)){
- /* Out of fast-mem. */
+ void *ret;
+ latestsize=new_size_in_bytes;
+ ret=GC_realloc(old_object,new_size_in_bytes);
+ if(ret==NULL && GC_AMIGA_MEMF==(MEMF_FAST | MEMF_CLEAR)){
+ /* Out of fast-mem. */
#ifdef GC_AMIGA_GC
- if(!GC_dont_gc){
- GC_gcollect();
+ if(!GC_dont_gc){
+ GC_gcollect();
#ifdef GC_AMIGA_PRINTSTATS
- numcollects++;
+ numcollects++;
#endif
- ret=GC_realloc(old_object,new_size_in_bytes);
- }
+ ret=GC_realloc(old_object,new_size_in_bytes);
+ }
#endif
- if(ret==NULL){
+ if(ret==NULL){
#ifndef GC_AMIGA_ONLYFAST
- GC_AMIGA_MEMF=MEMF_ANY | MEMF_CLEAR;
- if(GC_amiga_toany!=NULL) (*GC_amiga_toany)();
- GC_amiga_allocwrapper_do=GC_amiga_allocwrapper_any;
- ret=GC_realloc(old_object,new_size_in_bytes);
+ GC_AMIGA_MEMF=MEMF_ANY | MEMF_CLEAR;
+ if(GC_amiga_toany!=NULL) (*GC_amiga_toany)();
+ GC_amiga_allocwrapper_do=GC_amiga_allocwrapper_any;
+ ret=GC_realloc(old_object,new_size_in_bytes);
#endif
- }
+ }
#ifdef GC_AMIGA_PRINTSTATS
- else{
- nullretries++;
- }
+ else{
+ nullretries++;
+ }
#endif
- }
- if(ret==NULL){
- WARN("Out of Memory! Returning NIL!\n", 0);
- }
+ }
+ if(ret==NULL){
+ WARN("Out of Memory! Returning NIL!\n", 0);
+ }
#ifdef GC_AMIGA_PRINTSTATS
- if(((char *)ret)<chipmax && ret!=NULL){
- chipa+=new_size_in_bytes;
- }
+ if(((char *)ret)<chipmax && ret!=NULL){
+ chipa+=new_size_in_bytes;
+ }
#endif
- return ret;
+ return ret;
#endif
}
diff --git a/extra/MacOS.c b/extra/MacOS.c
index 6403613..27f07eb 100644
--- a/extra/MacOS.c
+++ b/extra/MacOS.c
@@ -1,17 +1,17 @@
/*
- MacOS.c
+ MacOS.c
- Some routines for the Macintosh OS port of the Hans-J. Boehm, Alan J. Demers
- garbage collector.
+ Some routines for the Macintosh OS port of the Hans-J. Boehm, Alan J. Demers
+ garbage collector.
- <Revision History>
+ <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
+ 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.
+ by Patrick C. Beard.
*/
/* Boehm, February 15, 1996 2:55 pm PST */
@@ -29,23 +29,23 @@ unloading shared library.
// 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;
+ 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;
+ 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. */
@@ -53,8 +53,8 @@ void* GC_MacGetDataStart()
typedef struct TemporaryMemoryBlock TemporaryMemoryBlock, **TemporaryMemoryHandle;
struct TemporaryMemoryBlock {
- TemporaryMemoryHandle nextBlock;
- char data[];
+ TemporaryMemoryHandle nextBlock;
+ char data[];
};
static TemporaryMemoryHandle theTemporaryMemory = NULL;
@@ -64,32 +64,32 @@ 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;
- }
+ 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;
- }
+ // install an exit routine to clean up the memory used at the end.
+ if (firstTime) {
+ atexit(&GC_MacFreeTemporaryMemory);
+ firstTime = false;
+ }
# endif
- return tempPtr;
+ return tempPtr;
}
extern word GC_fo_entries;
@@ -119,22 +119,22 @@ void GC_MacFreeTemporaryMemory()
# 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;
+ 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(SHARED_LIBRARY_BUILD)
- if (GC_print_stats) {
+ if (GC_print_stats) {
fprintf(stdout, "[total memory used: %ld bytes.]\n",
totalMemoryUsed);
fprintf(stdout, "[total collections: %ld.]\n", GC_gc_no);
- }
+ }
# endif
}
}
@@ -143,15 +143,15 @@ void GC_MacFreeTemporaryMemory()
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;
+ 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) */
diff --git a/extra/Mac_files/dataend.c b/extra/Mac_files/dataend.c
index 09d47b3..0bed469 100644
--- a/extra/Mac_files/dataend.c
+++ b/extra/Mac_files/dataend.c
@@ -1,9 +1,9 @@
/*
- dataend.c
+ dataend.c
- A hack to get the extent of global data for the Macintosh.
+ A hack to get the extent of global data for the Macintosh.
- by Patrick C. Beard.
+ by Patrick C. Beard.
*/
long __dataend;
diff --git a/extra/Mac_files/datastart.c b/extra/Mac_files/datastart.c
index ec9f9af..a1dc6f6 100644
--- a/extra/Mac_files/datastart.c
+++ b/extra/Mac_files/datastart.c
@@ -1,9 +1,9 @@
/*
- datastart.c
+ datastart.c
- A hack to get the extent of global data for the Macintosh.
+ A hack to get the extent of global data for the Macintosh.
- by Patrick C. Beard.
+ by Patrick C. Beard.
*/
long __datastart;
diff --git a/extra/symbian.cpp b/extra/symbian.cpp
index 29a960d..94dd4de 100644
--- a/extra/symbian.cpp
+++ b/extra/symbian.cpp
@@ -11,45 +11,45 @@ extern "C" {
#endif
int GC_get_main_symbian_stack_base()
- {
- TThreadStackInfo aInfo;
- TInt err = RThread().StackInfo(aInfo);
- if ( !err )
- {
- return aInfo.iBase;
- }
- else
- {
- return 0;
- }
- }
+ {
+ TThreadStackInfo aInfo;
+ TInt err = RThread().StackInfo(aInfo);
+ if ( !err )
+ {
+ return aInfo.iBase;
+ }
+ else
+ {
+ return 0;
+ }
+ }
char* GC_get_private_path_and_zero_file()
- {
- // always on c: drive
- RFs fs;
- fs.Connect();
- fs.CreatePrivatePath( EDriveC );
- TFileName path;
- fs.PrivatePath( path );
- fs.Close();
- _LIT( KCDrive, "c:" );
- path.Insert( 0, KCDrive );
-
-
- //convert to char*, assume ascii
- TBuf8<KMaxFileName> path8;
- path8.Copy( path );
- _LIT8( KZero8, "zero" );
- path8.Append( KZero8 );
-
- size_t size = path8.Length() + 1;
- char* copyChar = (char*) malloc( size );
- memcpy( copyChar, path8.PtrZ(), size );
-
- return copyChar; // ownership passed
- }
+ {
+ // always on c: drive
+ RFs fs;
+ fs.Connect();
+ fs.CreatePrivatePath( EDriveC );
+ TFileName path;
+ fs.PrivatePath( path );
+ fs.Close();
+ _LIT( KCDrive, "c:" );
+ path.Insert( 0, KCDrive );
+
+
+ //convert to char*, assume ascii
+ TBuf8<KMaxFileName> path8;
+ path8.Copy( path );
+ _LIT8( KZero8, "zero" );
+ path8.Append( KZero8 );
+
+ size_t size = path8.Length() + 1;
+ char* copyChar = (char*) malloc( size );
+ memcpy( copyChar, path8.PtrZ(), size );
+
+ return copyChar; // ownership passed
+ }
#ifdef __cplusplus
- }
+ }
#endif