From 939b18baae58e987992829a517fce93a7c44282a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=BCbinette=20=28Hubbe=29?= <hubbe@hubbe.net> Date: Fri, 17 Jul 1998 15:37:11 -0700 Subject: [PATCH] more debug Rev: src/program.c:1.98 Rev: src/threads.c:1.79 --- src/program.c | 13 +++++++++++-- src/threads.c | 10 +++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/program.c b/src/program.c index f249213a43..8569a858ff 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.97 1998/07/17 13:31:22 grubba Exp $"); +RCSID("$Id: program.c,v 1.98 1998/07/17 22:37:10 hubbe Exp $"); #include "program.h" #include "object.h" #include "dynamic_buffer.h" @@ -2683,7 +2683,12 @@ static struct find_child_cache_s find_child_cache[FIND_CHILD_HASHSIZE]; int find_child(struct program *parent, struct program *child) { - INT32 h=(parent->id * 9248339 + child->id) % FIND_CHILD_HASHSIZE; + unsigned INT32 h=(parent->id * 9248339 + child->id); + h= h % FIND_CHILD_HASHSIZE; +#ifdef DEBUG + if(h>=FIND_CHILD_HASHSIZE) + fatal("find_child failed to hash within boundaries.\n"); +#endif if(find_child_cache[h].pid == parent->id && find_child_cache[h].cid == child->id) { @@ -2761,6 +2766,10 @@ int implements(struct program *a, struct program *b) hval = a->id*9248339 + b->id; hval %= IMPLEMENTS_CACHE_SIZE; +#ifdef DEBUG + if(hval >= IMPLEMENTS_CACHE_SIZE) + fatal("Implements_cache failed!\n"); +#endif if(implements_cache[hval].aid==a->id && implements_cache[hval].bid==b->id) { return implements_cache[hval].ret; diff --git a/src/threads.c b/src/threads.c index 3e41bee78c..f581827bd1 100644 --- a/src/threads.c +++ b/src/threads.c @@ -1,5 +1,5 @@ #include "global.h" -RCSID("$Id: threads.c,v 1.78 1998/07/17 13:28:25 grubba Exp $"); +RCSID("$Id: threads.c,v 1.79 1998/07/17 22:37:11 hubbe Exp $"); int num_threads = 1; int threads_disabled = 0; @@ -326,6 +326,10 @@ void thread_table_insert(struct object *o) { struct thread_state *s = (struct thread_state *)o->storage; unsigned INT32 h = thread_table_hash(&s->id); +#ifdef DEBUG + if(h>=THREAD_TABLE_SIZE) + fatal("thread_table_hash failed miserably!\n"); +#endif mt_lock( & thread_table_lock ); if((s->hashlink = thread_table_chains[h]) != NULL) s->hashlink->backlink = &s->hashlink; @@ -348,6 +352,10 @@ struct thread_state *thread_state_for_id(THREAD_T tid) { unsigned INT32 h = thread_table_hash(&tid); struct thread_state *s = NULL; +#ifdef DEBUG + if(h>=THREAD_TABLE_SIZE) + fatal("thread_table_hash failed miserably!\n"); +#endif mt_lock( & thread_table_lock ); if(thread_table_chains[h] == NULL) { -- GitLab