* Renamed "link" into "linked" because of namespace collision with libc.

git-svn-id: svn://svn.zoy.org/elk/trunk@110 55e467fa-43c5-0310-a8a2-de718669efc6
This commit is contained in:
sam 2003-09-06 15:41:48 +00:00
parent 4f60aa8bd1
commit f253c8e261
1 changed files with 14 additions and 16 deletions

View File

@ -43,9 +43,7 @@
# include <sys/mman.h> # include <sys/mman.h>
#endif #endif
#if defined(HAVE_GETPAGESIZE) || defined(SC_PAGESIZE_IN_UNISTD_H) #if defined(HAVE_GETPAGESIZE) || defined(SC_PAGESIZE_IN_UNISTD_H)
# define link FOO
# include <unistd.h> # include <unistd.h>
# undef link
# if defined(_SC_PAGE_SIZE) && !defined(_SC_PAGESIZE) /* Wrong in HP-UX */ # if defined(_SC_PAGE_SIZE) && !defined(_SC_PAGESIZE) /* Wrong in HP-UX */
# define _SC_PAGESIZE _SC_PAGE_SIZE # define _SC_PAGESIZE _SC_PAGE_SIZE
# endif # endif
@ -102,7 +100,7 @@ static pageno_t firstpage, lastpage;
static char *saved_heap_ptr; static char *saved_heap_ptr;
gcspace_t *space; gcspace_t *space;
static gcspace_t *type, *pmap; static gcspace_t *type, *pmap;
static pageno_t *link; static pageno_t *linked;
static pageno_t current_pages, forwarded_pages; static pageno_t current_pages, forwarded_pages;
static pageno_t protected_pages, allocated_pages; static pageno_t protected_pages, allocated_pages;
@ -390,10 +388,10 @@ static void UnprotectCluster (gcptr_t addr, int len) {
static void AddQueue (pageno_t page) { static void AddQueue (pageno_t page) {
if (stable_queue != (pageno_t)-1) if (stable_queue != (pageno_t)-1)
link[stable_tail] = page; linked[stable_tail] = page;
else else
stable_queue = page; stable_queue = page;
link[page] = (pageno_t)-1; linked[page] = (pageno_t)-1;
stable_tail = page; stable_tail = page;
} }
@ -419,7 +417,7 @@ static void PromoteStableQueue () {
start = stable_queue; start = stable_queue;
while (pcount--) while (pcount--)
space[start++] = current_space; space[start++] = current_space;
stable_queue = link[stable_queue]; stable_queue = linked[stable_queue];
} }
current_pages = allocated_pages; current_pages = allocated_pages;
forwarded_pages = 0; forwarded_pages = 0;
@ -539,23 +537,23 @@ void Make_Heap (int size) {
space = (gcspace_t *)malloc (logical_pages*sizeof (gcspace_t)); space = (gcspace_t *)malloc (logical_pages*sizeof (gcspace_t));
type = (gcspace_t *)malloc ((logical_pages + 1)*sizeof (gcspace_t)); type = (gcspace_t *)malloc ((logical_pages + 1)*sizeof (gcspace_t));
pmap = (gcspace_t *)malloc (physical_pages*sizeof (gcspace_t)); pmap = (gcspace_t *)malloc (physical_pages*sizeof (gcspace_t));
link = (pageno_t *)malloc (logical_pages*sizeof (pageno_t)); linked = (pageno_t *)malloc (logical_pages*sizeof (pageno_t));
if (!space || !type || !pmap || !link) { if (!space || !type || !pmap || !linked) {
free (heap_ptr); free (heap_ptr);
if (space) free ((char*)space); if (space) free ((char*)space);
if (type) free ((char*)type); if (type) free ((char*)type);
if (pmap) free ((char*)pmap); if (pmap) free ((char*)pmap);
if (link) free ((char*)link); if (linked) free ((char*)linked);
Fatal_Error ("cannot allocate heap maps"); Fatal_Error ("cannot allocate heap maps");
} }
memset (type, 0, (logical_pages + 1)*sizeof (gcspace_t)); memset (type, 0, (logical_pages + 1)*sizeof (gcspace_t));
memset (pmap, 0, physical_pages*sizeof (gcspace_t)); memset (pmap, 0, physical_pages*sizeof (gcspace_t));
memset (link, 0, logical_pages*sizeof (unsigned int)); memset (linked, 0, logical_pages*sizeof (unsigned int));
space -= firstpage; /* to index the arrays with the heap page number */ space -= firstpage; /* to index the arrays with the heap page number */
type -= firstpage; type -= firstpage;
type[lastpage+1] = OBJECTPAGE; type[lastpage+1] = OBJECTPAGE;
link -= firstpage; linked -= firstpage;
#ifndef ARRAY_BROKEN #ifndef ARRAY_BROKEN
pmap -= (PAGE_TO_ADDR (firstpage) >> pp_shift); pmap -= (PAGE_TO_ADDR (firstpage) >> pp_shift);
#endif #endif
@ -690,7 +688,7 @@ static int ExpandHeap (char *reason) {
/* FIXME: memmove! */ /* FIXME: memmove! */
for (i = firstpage; i <= lastpage; i++) { for (i = firstpage; i <= lastpage; i++) {
new_link[i + offset] = link[i] + offset; new_link[i + offset] = linked[i] + offset;
new_type[i + offset] = type[i]; new_type[i + offset] = type[i];
} }
for (addr = PAGE_TO_ADDR (firstpage); addr <= PAGE_TO_ADDR (lastpage); for (addr = PAGE_TO_ADDR (firstpage); addr <= PAGE_TO_ADDR (lastpage);
@ -718,7 +716,7 @@ static int ExpandHeap (char *reason) {
forward_freepage += offset; forward_freepage += offset;
last_forward_freepage += offset; last_forward_freepage += offset;
free ((char*)(link+firstpage)); free ((char*)(linked+firstpage));
free ((char*)(type+firstpage)); free ((char*)(type+firstpage));
free ((char*)(space+firstpage)); free ((char*)(space+firstpage));
@ -728,7 +726,7 @@ static int ExpandHeap (char *reason) {
free ((char*)pmap); free ((char*)pmap);
#endif #endif
link = new_link; linked = new_link;
type = new_type; type = new_type;
space = new_space; space = new_space;
pmap = new_pmap; pmap = new_pmap;
@ -757,7 +755,7 @@ static int ExpandHeap (char *reason) {
void Free_Heap () { void Free_Heap () {
free (saved_heap_ptr); free (saved_heap_ptr);
free ((char*)(link+firstpage)); free ((char*)(linked+firstpage));
free ((char*)(type+firstpage)); free ((char*)(type+firstpage));
free ((char*)(space+firstpage)); free ((char*)(space+firstpage));
@ -1583,7 +1581,7 @@ static void General_Collect (int initiate) {
page = stable_queue; page = stable_queue;
while (page != (pageno_t)-1) { while (page != (pageno_t)-1) {
ProtectCluster (PHYSPAGE (page), 0); ProtectCluster (PHYSPAGE (page), 0);
page = link[page]; page = linked[page];
} }
if (!initiate) { if (!initiate) {