version 1.2, 1997/06/15 19:43:49
|
version 1.3, 1997/07/02 17:56:58
|
Line 177 UCell checksum(Label symbols[])
|
Line 177 UCell checksum(Label symbols[])
|
return r; |
return r; |
} |
} |
|
|
|
Address verbose_malloc(Cell size) |
|
{ |
|
Address r; |
|
/* leave a little room (64B) for stack underflows */ |
|
if ((r = malloc(size+64))==NULL) { |
|
perror(progname); |
|
exit(1); |
|
} |
|
r = (Address)((((Cell)r)+(sizeof(Float)-1))&(-sizeof(Float))); |
|
if (debug) |
|
fprintf(stderr, "malloc succeeds, address=$%lx\n", (long)r); |
|
return r; |
|
} |
|
|
Address my_alloc(Cell size) |
Address my_alloc(Cell size) |
{ |
{ |
static Address next_address=0; |
static Address next_address=0; |
Address r; |
Address r; |
|
|
/* the 256MB jump restriction on the MIPS architecture makes the |
#if HAVE_MMAP |
combination of direct threading and mmap unsafe. */ |
|
#if HAVE_MMAP && (!defined(mips) || defined(INDIRECT_THREADED)) |
|
#if defined(MAP_ANON) |
#if defined(MAP_ANON) |
if (debug) |
if (debug) |
fprintf(stderr,"try mmap($%lx, $%lx, ..., MAP_ANON, ...); ", (long)next_address, (long)size); |
fprintf(stderr,"try mmap($%lx, $%lx, ..., MAP_ANON, ...); ", (long)next_address, (long)size); |
Line 224 Address my_alloc(Cell size)
|
Line 236 Address my_alloc(Cell size)
|
if (debug) |
if (debug) |
fprintf(stderr, "failed: %s\n", strerror(errno)); |
fprintf(stderr, "failed: %s\n", strerror(errno)); |
#endif /* HAVE_MMAP */ |
#endif /* HAVE_MMAP */ |
/* use malloc as fallback, leave a little room (64B) for stack underflows */ |
/* use malloc as fallback */ |
if ((r = malloc(size+64))==NULL) { |
return verbose_malloc(size); |
perror(progname); |
|
exit(1); |
|
} |
|
r = (Address)((((Cell)r)+(sizeof(Float)-1))&(-sizeof(Float))); |
|
if (debug) |
|
fprintf(stderr, "malloc succeeds, address=$%lx\n", (long)r); |
|
return r; |
|
} |
} |
|
|
|
#if (defined(mips) && !defined(INDIRECT_THREADED)) |
|
/* the 256MB jump restriction on the MIPS architecture makes the |
|
combination of direct threading and mmap unsafe. */ |
|
#define dict_alloc(size) verbose_malloc(size) |
|
#else |
|
#define dict_alloc(size) my_alloc(size) |
|
#endif |
|
|
Address loader(FILE *imagefile, char* filename) |
Address loader(FILE *imagefile, char* filename) |
/* returns the address of the image proper (after the preamble) */ |
/* returns the address of the image proper (after the preamble) */ |
{ |
{ |
Line 315 Address loader(FILE *imagefile, char* fi
|
Line 328 Address loader(FILE *imagefile, char* fi
|
if (debug) |
if (debug) |
fprintf(stderr,"pagesize=%d\n",pagesize); |
fprintf(stderr,"pagesize=%d\n",pagesize); |
|
|
image = my_alloc(preamblesize+dictsize+data_offset)+data_offset; |
image = dict_alloc(preamblesize+dictsize+data_offset)+data_offset; |
rewind(imagefile); /* fseek(imagefile,0L,SEEK_SET); */ |
rewind(imagefile); /* fseek(imagefile,0L,SEEK_SET); */ |
if (clear_dictionary) |
if (clear_dictionary) |
memset(image,0,dictsize); |
memset(image,0,dictsize); |