From b504ed939ca95b7ec8f321cc106dc2bfbba1a611 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=BCbinette=20=28Hubbe=29?= <hubbe@hubbe.net> Date: Sun, 21 Sep 1997 18:01:19 -0700 Subject: [PATCH] bugfixes Rev: bin/mkpeep.pike:1.6 Rev: src/docode.c:1.23 Rev: src/interpret.h:1.14 Rev: src/object.c:1.23 Rev: src/program.c:1.42 Rev: src/program.h:1.20 Rev: src/threads.c:1.42 --- bin/mkpeep.pike | 6 ++---- src/docode.c | 4 ++-- src/interpret.h | 1 + src/object.c | 9 ++++++++- src/program.c | 4 +++- src/program.h | 3 +++ src/threads.c | 21 ++++++++------------- 7 files changed, 27 insertions(+), 21 deletions(-) diff --git a/bin/mkpeep.pike b/bin/mkpeep.pike index dacaedbe37..c294fbe090 100755 --- a/bin/mkpeep.pike +++ b/bin/mkpeep.pike @@ -1,6 +1,6 @@ #!/usr/local/bin/pike -/* $Id: mkpeep.pike,v 1.5 1997/05/31 22:03:39 grubba Exp $ */ +/* $Id: mkpeep.pike,v 1.6 1997/09/22 01:00:49 hubbe Exp $ */ import Simulate; @@ -379,9 +379,7 @@ int main(int argc, string *argv) write("#ifdef DEBUG\n"); write(" if(a_flag>5) {\n"); write(" fprintf(stderr,\"#%d,%d:\",eye,fifo_len);\n"); - write(" fprintf(stderr,\"%s(%d)\", get_token_name(opcode(-2)),argument(-2));\n"); - write(" fprintf(stderr,\" %s(%d)\", get_token_name(opcode(-1)),argument(-1));\n"); - write(" fprintf(stderr,\" . %s(%d)\", get_token_name(opcode(0)),argument(0));\n"); + write(" fprintf(stderr,\" %s(%d)\", get_token_name(opcode(0)),argument(0));\n"); write(" fprintf(stderr,\" %s(%d)\", get_token_name(opcode(1)),argument(1));\n"); write(" fprintf(stderr,\" %s(%d)\", get_token_name(opcode(2)),argument(2));\n"); write(" fprintf(stderr,\" %s(%d)\\n\",get_token_name(opcode(3)),argument(3));\n"); diff --git a/src/docode.c b/src/docode.c index 3b4c414b3d..6db4d0f002 100644 --- a/src/docode.c +++ b/src/docode.c @@ -4,7 +4,7 @@ ||| See the files COPYING and DISCLAIMER for more information. \*/ #include "global.h" -RCSID("$Id: docode.c,v 1.22 1997/09/19 06:45:31 hubbe Exp $"); +RCSID("$Id: docode.c,v 1.23 1997/09/22 01:01:15 hubbe Exp $"); #include "las.h" #include "program.h" #include "language.h" @@ -804,7 +804,7 @@ static int do_docode2(node *n,int flags) { if(order[e] < cases-1) { - int o1=order[e]+1; + int o1=order[e]*2+1; if(current_switch_jumptable[o1]==current_switch_jumptable[o1+1] && current_switch_jumptable[o1]==current_switch_jumptable[o1+2]) { diff --git a/src/interpret.h b/src/interpret.h index 33811a6c8d..35936649ba 100644 --- a/src/interpret.h +++ b/src/interpret.h @@ -121,5 +121,6 @@ extern int stack_size; extern int evaluator_stack_malloced, mark_stack_malloced; struct callback; extern struct callback_list evaluator_callbacks; +extern void call_callback(struct callback_list *, void *); #endif diff --git a/src/object.c b/src/object.c index 24acce9e1d..3ce240db49 100644 --- a/src/object.c +++ b/src/object.c @@ -4,7 +4,7 @@ ||| See the files COPYING and DISCLAIMER for more information. \*/ #include "global.h" -RCSID("$Id: object.c,v 1.22 1997/09/09 03:36:12 hubbe Exp $"); +RCSID("$Id: object.c,v 1.23 1997/09/22 01:01:16 hubbe Exp $"); #include "object.h" #include "dynamic_buffer.h" #include "interpret.h" @@ -289,6 +289,13 @@ void destruct_objects_to_destruct(void) void really_free_object(struct object *o) { + if(o->prog && (o->prog->flags & PROG_DESTRUCT_IMMEDIATE)) + { + o->refs++; + destruct(o); + if(--o->refs > 0) return; + } + if(o->prev) o->prev->next=o->next; else diff --git a/src/program.c b/src/program.c index cc7545c7d0..d985970bc0 100644 --- a/src/program.c +++ b/src/program.c @@ -4,7 +4,7 @@ ||| See the files COPYING and DISCLAIMER for more information. \*/ #include "global.h" -RCSID("$Id: program.c,v 1.41 1997/09/11 22:51:40 hubbe Exp $"); +RCSID("$Id: program.c,v 1.42 1997/09/22 01:01:18 hubbe Exp $"); #include "program.h" #include "object.h" #include "dynamic_buffer.h" @@ -213,6 +213,7 @@ void setup_fake_program(void) fake_program.inherits[0].prog=&fake_program; fake_program.next=0; fake_program.prev=0; + fake_program.flags=0; /* fake_program.lfuns=0; fake_prog.num_lfuns=0; @@ -607,6 +608,7 @@ struct program *end_program(void) *prog = fake_program; prog->total_size = size; prog->refs = 1; + prog->flags=0; p += MY_ALIGN(sizeof (struct program)); INS_BLOCK(program,program_size,unsigned char,A_PROGRAM); diff --git a/src/program.h b/src/program.h index 3a7ebca5e7..243ccde548 100644 --- a/src/program.h +++ b/src/program.h @@ -134,6 +134,8 @@ struct inherit INT32 storage_offset; }; +#define PROG_DESTRUCT_IMMEDIATE 1 + struct program { INT32 refs; @@ -163,6 +165,7 @@ struct program SIZE_T total_size; SIZE_T num_linenumbers; SIZE_T program_size; + unsigned INT16 flags; unsigned INT16 num_constants; unsigned INT16 num_strings; unsigned INT16 num_identifiers; diff --git a/src/threads.c b/src/threads.c index 6ea9d62e2f..d91f4ab199 100644 --- a/src/threads.c +++ b/src/threads.c @@ -1,5 +1,5 @@ #include "global.h" -RCSID("$Id: threads.c,v 1.41 1997/09/17 13:04:14 hubbe Exp $"); +RCSID("$Id: threads.c,v 1.42 1997/09/22 01:01:19 hubbe Exp $"); int num_threads = 1; int threads_disabled = 0; @@ -205,17 +205,13 @@ void f_mutex_lock(INT32 args) if(m->key) { - destruct_objects_to_destruct(); - if(m->key) + SWAP_OUT_CURRENT_THREAD(); + do { - SWAP_OUT_CURRENT_THREAD(); - do - { - THREADS_FPRINTF((stderr,"WAITING TO LOCK m:%08x\n",(unsigned int)m)); - co_wait(& m->condition, & interpreter_lock); - }while(m->key); - SWAP_IN_CURRENT_THREAD(); - } + THREADS_FPRINTF((stderr,"WAITING TO LOCK m:%08x\n",(unsigned int)m)); + co_wait(& m->condition, & interpreter_lock); + }while(m->key); + SWAP_IN_CURRENT_THREAD(); } m->key=o; OB2KEY(o)->mut=m; @@ -250,8 +246,6 @@ void f_mutex_trylock(INT32 args) error("Recursive mutex locks!\n"); } } - if(m->key) - destruct_objects_to_destruct(); if(!m->key) { @@ -455,6 +449,7 @@ void th_init(void) set_init_callback(init_mutex_key_obj); set_exit_callback(exit_mutex_key_obj); mutex_key=end_program(); + mutex_key->flags|=PROG_DESTRUCT_IMMEDIATE; if(!mutex_key) fatal("Failed to initialize mutex_key program!\n"); -- GitLab