version 1.246, 2012/03/23 20:49:44
|
version 1.247, 2012/03/23 21:48:06
|
Line 427 void gforth_relocate(Cell *image, const
|
Line 427 void gforth_relocate(Cell *image, const
|
} |
} |
#endif |
#endif |
} else |
} else |
fprintf(stderr,"Primitive %ld used in this image at $%lx (offset $%x) is not implemented by this\n engine (%s); executing this code will crash.\n",(long)CF(token),(long)&image[i], i, PACKAGE_VERSION); |
fprintf(stderr,"Primitive %ld used in this image at $%p (offset $%x) is not implemented by this\n engine (%s); executing this code will crash.\n",(long)CF(token), &image[i], i, PACKAGE_VERSION); |
} |
} |
} else { |
} else { |
int tok = -token & 0x1FF; |
int tok = -token & 0x1FF; |
Line 445 void gforth_relocate(Cell *image, const
|
Line 445 void gforth_relocate(Cell *image, const
|
} |
} |
#endif |
#endif |
} else |
} else |
fprintf(stderr,"Primitive %lx, %d of group %d used in this image at $%lx (offset $%x) is not implemented by this\n engine (%s); executing this code will crash.\n", (long)-token, tok, group, (long)&image[i],i,PACKAGE_VERSION); |
fprintf(stderr,"Primitive %lx, %d of group %d used in this image at $%p (offset $%x) is not implemented by this\n engine (%s); executing this code will crash.\n", (long)-token, tok, group, &image[i],i,PACKAGE_VERSION); |
} |
} |
} else { |
} else { |
/* if base is > 0: 0 is a null reference so don't adjust*/ |
/* if base is > 0: 0 is a null reference so don't adjust*/ |
Line 496 static Address verbose_malloc(Cell size)
|
Line 496 static Address verbose_malloc(Cell size)
|
exit(1); |
exit(1); |
} |
} |
r = (Address)((((Cell)r)+(sizeof(Float)-1))&(-sizeof(Float))); |
r = (Address)((((Cell)r)+(sizeof(Float)-1))&(-sizeof(Float))); |
debugp(stderr, "malloc succeeds, address=$%lx\n", (long)r); |
debugp(stderr, "malloc succeeds, address=$%p\n", r); |
return r; |
return r; |
} |
} |
|
|
Line 504 static void *next_address=0;
|
Line 504 static void *next_address=0;
|
static void after_alloc(Address r, Cell size) |
static void after_alloc(Address r, Cell size) |
{ |
{ |
if (r != (Address)-1) { |
if (r != (Address)-1) { |
debugp(stderr, "success, address=$%lx\n", (long) r); |
debugp(stderr, "success, address=$%p\n", r); |
#if 0 |
#if 0 |
/* not needed now that we protect the stacks with mprotect */ |
/* not needed now that we protect the stacks with mprotect */ |
if (pagesize != 1) |
if (pagesize != 1) |
Line 537 static Address alloc_mmap(Cell size)
|
Line 537 static Address alloc_mmap(Cell size)
|
void *r; |
void *r; |
|
|
#if defined(MAP_ANON) |
#if defined(MAP_ANON) |
debugp(stderr,"try mmap($%lx, $%lx, ..., MAP_ANON, ...); ", (long)next_address, (long)size); |
debugp(stderr,"try mmap($%p, $%lx, ..., MAP_ANON, ...); ", next_address, size); |
r = mmap(next_address, size, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE|map_noreserve, -1, 0); |
r = mmap(next_address, size, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE|map_noreserve, -1, 0); |
#else /* !defined(MAP_ANON) */ |
#else /* !defined(MAP_ANON) */ |
/* Ultrix (at least) does not define MAP_FILE and MAP_PRIVATE (both are |
/* Ultrix (at least) does not define MAP_FILE and MAP_PRIVATE (both are |
Line 551 static Address alloc_mmap(Cell size)
|
Line 551 static Address alloc_mmap(Cell size)
|
debugp(stderr, "open(\"/dev/zero\"...) failed (%s), no mmap; ", |
debugp(stderr, "open(\"/dev/zero\"...) failed (%s), no mmap; ", |
strerror(errno)); |
strerror(errno)); |
} else { |
} else { |
debugp(stderr,"try mmap($%lx, $%lx, ..., MAP_FILE, dev_zero, ...); ", (long)next_address, (long)size); |
debugp(stderr,"try mmap($%p, $%lx, ..., MAP_FILE, dev_zero, ...); ", next_address, size); |
r=mmap(next_address, size, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_FILE|MAP_PRIVATE|map_noreserve, dev_zero, 0); |
r=mmap(next_address, size, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_FILE|MAP_PRIVATE|map_noreserve, dev_zero, 0); |
} |
} |
#endif /* !defined(MAP_ANON) */ |
#endif /* !defined(MAP_ANON) */ |
Line 604 static void *dict_alloc_read(FILE *file,
|
Line 604 static void *dict_alloc_read(FILE *file,
|
image=alloc_mmap(dictsize); |
image=alloc_mmap(dictsize); |
if (image != (void *)MAP_FAILED) { |
if (image != (void *)MAP_FAILED) { |
void *image1; |
void *image1; |
debugp(stderr,"try mmap($%lx, $%lx, ..., MAP_FIXED|MAP_FILE, imagefile, 0); ", (long)image, (long)imagesize); |
debugp(stderr,"try mmap($%p, $%lx, ..., MAP_FIXED|MAP_FILE, imagefile, 0); ", image, imagesize); |
image1 = mmap(image, imagesize, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_FIXED|MAP_FILE|MAP_PRIVATE|map_noreserve, fileno(file), 0); |
image1 = mmap(image, imagesize, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_FIXED|MAP_FILE|MAP_PRIVATE|map_noreserve, fileno(file), 0); |
after_alloc(image1,dictsize); |
after_alloc(image1,dictsize); |
if (image1 == (void *)MAP_FAILED) |
if (image1 == (void *)MAP_FAILED) |
Line 712 int gforth_go(void *image, int stack, Ce
|
Line 712 int gforth_go(void *image, int stack, Ce
|
int throw_code; |
int throw_code; |
jmp_buf throw_jmp_buf; |
jmp_buf throw_jmp_buf; |
#endif |
#endif |
|
Cell signal_data_stack[24]; |
|
Cell signal_return_stack[16]; |
|
Float signal_fp_stack[1]; |
|
|
/* ensure that the cached elements (if any) are accessible */ |
/* ensure that the cached elements (if any) are accessible */ |
#if !(defined(GFORTH_DEBUGGING) || defined(INDIRECT_THREADED) || defined(DOUBLY_INDIRECT) || defined(VM_PROFILING)) |
#if !(defined(GFORTH_DEBUGGING) || defined(INDIRECT_THREADED) || defined(DOUBLY_INDIRECT) || defined(VM_PROFILING)) |
Line 729 int gforth_go(void *image, int stack, Ce
|
Line 732 int gforth_go(void *image, int stack, Ce
|
|
|
throw_jmp_handler = &throw_jmp_buf; |
throw_jmp_handler = &throw_jmp_buf; |
|
|
debugp(stderr, "setjmp(%lx)\n", *throw_jmp_handler); |
debugp(stderr, "setjmp(%p)\n", *throw_jmp_handler); |
if ((throw_code=setjmp(*throw_jmp_handler))) { |
while((throw_code=setjmp(*throw_jmp_handler))) { |
static Cell signal_data_stack[24]; |
|
static Cell signal_return_stack[16]; |
|
static Float signal_fp_stack[1]; |
|
|
|
signal_data_stack[15]=throw_code; |
signal_data_stack[15]=throw_code; |
|
|
#ifdef GFORTH_DEBUGGING |
#ifdef GFORTH_DEBUGGING |
Line 749 int gforth_go(void *image, int stack, Ce
|
Line 748 int gforth_go(void *image, int stack, Ce
|
rp0 = signal_return_stack+16; |
rp0 = signal_return_stack+16; |
#else /* !defined(GFORTH_DEBUGGING) */ |
#else /* !defined(GFORTH_DEBUGGING) */ |
debugp(stderr,"\ncaught signal, throwing exception %d\n", throw_code); |
debugp(stderr,"\ncaught signal, throwing exception %d\n", throw_code); |
rp0 = signal_return_stack+16; |
rp0 = signal_return_stack+16; |
#endif /* !defined(GFORTH_DEBUGGING) */ |
#endif /* !defined(GFORTH_DEBUGGING) */ |
/* fprintf(stderr, "rp=$%x\n",rp0);*/ |
/* fprintf(stderr, "rp=$%x\n",rp0);*/ |
|
|
return((int)(Cell)gforth_engine(image_header->throw_entry, signal_data_stack+15, |
ip0=image_header->throw_entry; |
rp0, signal_fp_stack, 0 sr_call)); |
sp0=signal_data_stack+15; |
|
fp0=signal_fp_stack; |
} |
} |
#endif |
#endif |
|
|
Line 1978 Address gforth_loader(FILE *imagefile, c
|
Line 1978 Address gforth_loader(FILE *imagefile, c
|
#endif |
#endif |
} |
} |
else if(header.base!=imp) { |
else if(header.base!=imp) { |
fprintf(stderr,"%s: Cannot load nonrelocatable image (compiled for address $%lx) at address $%lx\n", |
fprintf(stderr,"%s: Cannot load nonrelocatable image (compiled for address $%p) at address $%p\n", |
progname, (unsigned long)header.base, (unsigned long)imp); |
progname, header.base, imp); |
exit(1); |
exit(1); |
} |
} |
if (header.checksum==0) |
if (header.checksum==0) |
((ImageHeader *)imp)->checksum=check_sum; |
((ImageHeader *)imp)->checksum=check_sum; |
else if (header.checksum != check_sum) { |
else if (header.checksum != check_sum) { |
fprintf(stderr,"%s: Checksum of image ($%lx) does not match the executable ($%lx)\n", |
fprintf(stderr,"%s: Checksum of image ($%lx) does not match the executable ($%lx)\n", |
progname, (unsigned long)(header.checksum),(unsigned long)check_sum); |
progname, header.checksum, check_sum); |
exit(1); |
exit(1); |
} |
} |
#ifdef DOUBLY_INDIRECT |
#ifdef DOUBLY_INDIRECT |
Line 2074 Address gforth_alloc(Cell size)
|
Line 2074 Address gforth_alloc(Cell size)
|
exit(1); |
exit(1); |
} |
} |
r = (Address)((((Cell)r)+(sizeof(Float)-1))&(-sizeof(Float))); |
r = (Address)((((Cell)r)+(sizeof(Float)-1))&(-sizeof(Float))); |
debugp(stderr, "malloc succeeds, address=$%lx\n", (long)r); |
debugp(stderr, "malloc succeeds, address=$%p\n", r); |
return r; |
return r; |
} |
} |
#endif |
#endif |