--- gforth/engine/main.c 2012/03/23 20:49:44 1.246 +++ gforth/engine/main.c 2012/03/23 21:48:06 1.247 @@ -427,7 +427,7 @@ void gforth_relocate(Cell *image, const } #endif } 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 { int tok = -token & 0x1FF; @@ -445,7 +445,7 @@ void gforth_relocate(Cell *image, const } #endif } 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 { /* if base is > 0: 0 is a null reference so don't adjust*/ @@ -496,7 +496,7 @@ static Address verbose_malloc(Cell size) exit(1); } 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; } @@ -504,7 +504,7 @@ static void *next_address=0; static void after_alloc(Address r, Cell size) { if (r != (Address)-1) { - debugp(stderr, "success, address=$%lx\n", (long) r); + debugp(stderr, "success, address=$%p\n", r); #if 0 /* not needed now that we protect the stacks with mprotect */ if (pagesize != 1) @@ -537,7 +537,7 @@ static Address alloc_mmap(Cell size) void *r; #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); #else /* !defined(MAP_ANON) */ /* Ultrix (at least) does not define MAP_FILE and MAP_PRIVATE (both are @@ -551,7 +551,7 @@ static Address alloc_mmap(Cell size) debugp(stderr, "open(\"/dev/zero\"...) failed (%s), no mmap; ", strerror(errno)); } 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); } #endif /* !defined(MAP_ANON) */ @@ -604,7 +604,7 @@ static void *dict_alloc_read(FILE *file, image=alloc_mmap(dictsize); if (image != (void *)MAP_FAILED) { 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); after_alloc(image1,dictsize); if (image1 == (void *)MAP_FAILED) @@ -712,6 +712,9 @@ int gforth_go(void *image, int stack, Ce int throw_code; jmp_buf throw_jmp_buf; #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 */ #if !(defined(GFORTH_DEBUGGING) || defined(INDIRECT_THREADED) || defined(DOUBLY_INDIRECT) || defined(VM_PROFILING)) @@ -729,12 +732,8 @@ int gforth_go(void *image, int stack, Ce throw_jmp_handler = &throw_jmp_buf; - debugp(stderr, "setjmp(%lx)\n", *throw_jmp_handler); - if ((throw_code=setjmp(*throw_jmp_handler))) { - static Cell signal_data_stack[24]; - static Cell signal_return_stack[16]; - static Float signal_fp_stack[1]; - + debugp(stderr, "setjmp(%p)\n", *throw_jmp_handler); + while((throw_code=setjmp(*throw_jmp_handler))) { signal_data_stack[15]=throw_code; #ifdef GFORTH_DEBUGGING @@ -749,12 +748,13 @@ int gforth_go(void *image, int stack, Ce rp0 = signal_return_stack+16; #else /* !defined(GFORTH_DEBUGGING) */ debugp(stderr,"\ncaught signal, throwing exception %d\n", throw_code); - rp0 = signal_return_stack+16; + rp0 = signal_return_stack+16; #endif /* !defined(GFORTH_DEBUGGING) */ /* fprintf(stderr, "rp=$%x\n",rp0);*/ - return((int)(Cell)gforth_engine(image_header->throw_entry, signal_data_stack+15, - rp0, signal_fp_stack, 0 sr_call)); + ip0=image_header->throw_entry; + sp0=signal_data_stack+15; + fp0=signal_fp_stack; } #endif @@ -1978,15 +1978,15 @@ Address gforth_loader(FILE *imagefile, c #endif } else if(header.base!=imp) { - fprintf(stderr,"%s: Cannot load nonrelocatable image (compiled for address $%lx) at address $%lx\n", - progname, (unsigned long)header.base, (unsigned long)imp); + fprintf(stderr,"%s: Cannot load nonrelocatable image (compiled for address $%p) at address $%p\n", + progname, header.base, imp); exit(1); } if (header.checksum==0) ((ImageHeader *)imp)->checksum=check_sum; else if (header.checksum != check_sum) { 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); } #ifdef DOUBLY_INDIRECT @@ -2074,7 +2074,7 @@ Address gforth_alloc(Cell size) exit(1); } 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; } #endif