pike.git / src / threads.c

version» Context lines:

pike.git/src/threads.c:1:   #include "global.h" - RCSID("$Id: threads.c,v 1.57 1998/02/27 20:09:04 marcus Exp $"); + RCSID("$Id: threads.c,v 1.58 1998/03/01 03:33:50 hubbe Exp $");      int num_threads = 1;   int threads_disabled = 0;      #ifdef _REENTRANT   #include "threads.h"   #include "array.h"   #include "object.h"   #include "pike_macros.h"   #include "callback.h"
pike.git/src/threads.c:161:      void thread_table_init()   {    INT32 x;    for(x=0; x<THREAD_TABLE_SIZE; x++)    thread_table_chains[x] = NULL;   }      unsigned INT32 thread_table_hash(THREAD_T *tid)   { -  return hashmem((unsigned char *)tid, sizeof(*tid), 16) % THREAD_TABLE_SIZE; +  return th_hash(*tid) % THREAD_TABLE_SIZE;   }      void thread_table_insert(struct object *o)   {    struct thread_state *s = (struct thread_state *)o->storage;    unsigned INT32 h = thread_table_hash(&s->id);    mt_lock( & thread_table_lock );    if((s->hashlink = thread_table_chains[h]) != NULL)    s->hashlink->backlink = &s->hashlink;    thread_table_chains[h] = s;
pike.git/src/threads.c:191:    s->hashlink->backlink = s->backlink;    *(s->backlink) = s->hashlink;    mt_unlock( & thread_table_lock );   }      struct thread_state *thread_state_for_id(THREAD_T tid)   {    unsigned INT32 h = thread_table_hash(&tid);    struct thread_state *s = NULL;    mt_lock( & thread_table_lock ); -  if(thread_table_chains[h] == NULL) { +  if(thread_table_chains[h] == NULL) +  {    /* NULL result */ -  } else if((s=thread_table_chains[h])->id == tid) { +  } +  else if(th_equal((s=thread_table_chains[h])->id, tid)) +  {    /* Quick return */ -  } else { +  } +  else +  {    while((s = s->hashlink) != NULL) -  if(s->id == tid) +  if(th_equal(s->id, tid))    break;    if(s != NULL) {    /* Move the thread_state to the head of the chain, in case    we want to search for it again */       /* Unlink */    if(s->hashlink != NULL)    s->hashlink->backlink = s->backlink;    *(s->backlink) = s->hashlink;    /* And relink at the head of the chain */