version 1.172, 2007/01/20 19:41:01
|
version 1.173, 2007/01/21 17:38:28
|
Line 499 static void after_alloc(Address r, Cell
|
Line 499 static void after_alloc(Address r, Cell
|
{ |
{ |
if (r != (Address)-1) { |
if (r != (Address)-1) { |
debugp(stderr, "success, address=$%lx\n", (long) r); |
debugp(stderr, "success, address=$%lx\n", (long) r); |
|
#if 0 |
|
/* not needed now that we protect the stacks with mprotect */ |
if (pagesize != 1) |
if (pagesize != 1) |
next_address = (Address)(((((Cell)r)+size-1)&-pagesize)+2*pagesize); /* leave one page unmapped */ |
next_address = (Address)(((((Cell)r)+size-1)&-pagesize)+2*pagesize); /* leave one page unmapped */ |
|
#endif |
} else { |
} else { |
debugp(stderr, "failed: %s\n", strerror(errno)); |
debugp(stderr, "failed: %s\n", strerror(errno)); |
} |
} |
Line 564 static void page_noaccess(Address a)
|
Line 567 static void page_noaccess(Address a)
|
debugp(stderr, "failed: %s\n", strerror(errno)); |
debugp(stderr, "failed: %s\n", strerror(errno)); |
} |
} |
|
|
static size_t next_pagesize(size_t n) |
static size_t wholepage(size_t n) |
{ |
{ |
return (n+pagesize-1)&~(pagesize-1); |
return (n+pagesize-1)&~(pagesize-1); |
} |
} |
Line 628 void set_stack_sizes(ImageHeader * heade
|
Line 631 void set_stack_sizes(ImageHeader * heade
|
fsize=maxaligned(fsize); |
fsize=maxaligned(fsize); |
} |
} |
|
|
void alloc_stacks(ImageHeader * header) |
void alloc_stacks(ImageHeader * h) |
{ |
{ |
header->dict_size=dictsize; |
h->dict_size=dictsize; |
header->data_stack_size=dsize; |
h->data_stack_size=dsize; |
header->fp_stack_size=fsize; |
h->fp_stack_size=fsize; |
header->return_stack_size=rsize; |
h->return_stack_size=rsize; |
header->locals_stack_size=lsize; |
h->locals_stack_size=lsize; |
|
|
#if defined(HAVE_MMAP) |
#if defined(HAVE_MMAP) |
if (pagesize > 1) { |
if (pagesize > 1) { |
size_t totalsize = (next_pagesize(dsize)+ |
size_t p = pagesize; |
next_pagesize(fsize)+ |
size_t totalsize = |
next_pagesize(rsize)+ |
wholepage(dsize)+wholepage(fsize)+wholepage(rsize)+wholepage(lsize)+5*p; |
next_pagesize(lsize)+ |
|
5*pagesize); |
|
Address a = alloc_mmap(totalsize); |
Address a = alloc_mmap(totalsize); |
if (a != (Address)MAP_FAILED) { |
if (a != (Address)MAP_FAILED) { |
page_noaccess(a); |
page_noaccess(a); a+=p; h-> data_stack_base=a; a+=wholepage(dsize); |
a += pagesize; |
page_noaccess(a); a+=p; h-> fp_stack_base=a; a+=wholepage(fsize); |
header->data_stack_base = a; |
page_noaccess(a); a+=p; h->return_stack_base=a; a+=wholepage(rsize); |
a += next_pagesize(dsize); |
page_noaccess(a); a+=p; h->locals_stack_base=a; a+=wholepage(lsize); |
page_noaccess(a); |
|
a += pagesize; |
|
header->fp_stack_base = a; |
|
a += next_pagesize(fsize); |
|
page_noaccess(a); |
|
a += pagesize; |
|
header->return_stack_base = a; |
|
a += next_pagesize(rsize); |
|
page_noaccess(a); |
|
a += pagesize; |
|
header->locals_stack_base = a; |
|
a += next_pagesize(lsize); |
|
page_noaccess(a); |
page_noaccess(a); |
debugp(stderr,"stack addresses: d=%p f=%p r=%p l=%p\n", |
debugp(stderr,"stack addresses: d=%p f=%p r=%p l=%p\n", |
header->data_stack_base, |
h->data_stack_base, |
header->fp_stack_base, |
h->fp_stack_base, |
header->return_stack_base, |
h->return_stack_base, |
header->locals_stack_base); |
h->locals_stack_base); |
return; |
return; |
} |
} |
} |
} |
#endif |
#endif |
header->data_stack_base=gforth_alloc(dsize); |
h->data_stack_base=gforth_alloc(dsize); |
header->fp_stack_base=gforth_alloc(fsize); |
h->fp_stack_base=gforth_alloc(fsize); |
header->return_stack_base=gforth_alloc(rsize); |
h->return_stack_base=gforth_alloc(rsize); |
header->locals_stack_base=gforth_alloc(lsize); |
h->locals_stack_base=gforth_alloc(lsize); |
} |
} |
|
|
#warning You can ignore the warnings about clobbered variables in gforth_go |
#warning You can ignore the warnings about clobbered variables in gforth_go |