remove pic->native_stack_start
This commit is contained in:
parent
29d7a7fc48
commit
73e38657ff
|
@ -29,6 +29,8 @@ struct fullcont {
|
|||
pic_value *retv;
|
||||
};
|
||||
|
||||
char *picrin_native_stack_start;
|
||||
|
||||
static void
|
||||
cont_dtor(pic_state *pic, void *data)
|
||||
{
|
||||
|
@ -84,17 +86,17 @@ static void save_cont(pic_state *, struct fullcont **);
|
|||
static void restore_cont(pic_state *, struct fullcont *);
|
||||
|
||||
static ptrdiff_t
|
||||
native_stack_length(pic_state *pic, char **pos)
|
||||
native_stack_length(char **pos)
|
||||
{
|
||||
char t;
|
||||
|
||||
*pos = (pic->native_stack_start > &t)
|
||||
*pos = (picrin_native_stack_start > &t)
|
||||
? &t
|
||||
: pic->native_stack_start;
|
||||
: picrin_native_stack_start;
|
||||
|
||||
return (pic->native_stack_start > &t)
|
||||
? pic->native_stack_start - &t
|
||||
: &t - pic->native_stack_start;
|
||||
return (picrin_native_stack_start > &t)
|
||||
? picrin_native_stack_start - &t
|
||||
: &t - picrin_native_stack_start;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -112,7 +114,7 @@ save_cont(pic_state *pic, struct fullcont **c)
|
|||
|
||||
cont->cp = pic->cp;
|
||||
|
||||
cont->stk_len = native_stack_length(pic, &pos);
|
||||
cont->stk_len = native_stack_length(&pos);
|
||||
cont->stk_pos = pos;
|
||||
assert(cont->stk_len > 0);
|
||||
cont->stk_ptr = pic_malloc(pic, cont->stk_len);
|
||||
|
@ -154,7 +156,7 @@ restore_cont(pic_state *pic, struct fullcont *cont)
|
|||
char v;
|
||||
struct fullcont *tmp = cont;
|
||||
|
||||
if (&v < pic->native_stack_start) {
|
||||
if (&v < picrin_native_stack_start) {
|
||||
if (&v > cont->stk_pos) native_stack_extend(pic, cont);
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -59,10 +59,10 @@ struct pic_state {
|
|||
pic_value globals; /* weak */
|
||||
pic_value macros; /* weak */
|
||||
khash_t(ltable) ltable;
|
||||
struct list_head ireps; /* chain */
|
||||
struct list_head ireps;
|
||||
|
||||
xFILE files[XOPEN_MAX];
|
||||
struct code iseq[2]; /* for pic_apply_trampoline */
|
||||
struct code iseq[2]; /* for pic_apply_trampoline */
|
||||
|
||||
bool gc_enable;
|
||||
struct heap *heap;
|
||||
|
@ -70,9 +70,8 @@ struct pic_state {
|
|||
size_t arena_size, arena_idx;
|
||||
|
||||
pic_value err;
|
||||
pic_panicf panicf;
|
||||
|
||||
char *native_stack_start;
|
||||
pic_panicf panicf;
|
||||
};
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
|
|
@ -190,8 +190,6 @@ pic_init_core(pic_state *pic)
|
|||
pic_state *
|
||||
pic_open(pic_allocf allocf, void *userdata)
|
||||
{
|
||||
char t;
|
||||
|
||||
pic_state *pic;
|
||||
|
||||
pic = allocf(userdata, NULL, sizeof(pic_state));
|
||||
|
@ -284,9 +282,6 @@ pic_open(pic_allocf allocf, void *userdata)
|
|||
xfopen_null(pic, "w");
|
||||
#endif
|
||||
|
||||
/* native stack marker */
|
||||
pic->native_stack_start = &t;
|
||||
|
||||
/* root tables */
|
||||
pic->globals = pic_make_weak(pic);
|
||||
pic->macros = pic_make_weak(pic);
|
||||
|
|
|
@ -19,9 +19,12 @@ int picrin_argc;
|
|||
char **picrin_argv;
|
||||
char **picrin_envp;
|
||||
|
||||
extern char *picrin_native_stack_start; /* for call/cc */
|
||||
|
||||
int
|
||||
main(int argc, char *argv[], char **envp)
|
||||
{
|
||||
char t;
|
||||
pic_state *pic;
|
||||
int status;
|
||||
|
||||
|
@ -31,6 +34,8 @@ main(int argc, char *argv[], char **envp)
|
|||
picrin_argv = argv;
|
||||
picrin_envp = envp;
|
||||
|
||||
picrin_native_stack_start = &t;
|
||||
|
||||
pic_try {
|
||||
pic_init_picrin(pic);
|
||||
|
||||
|
|
Loading…
Reference in New Issue