pike.git / src / threads.c

version» Context lines:

pike.git/src/threads.c:1:   #include "global.h" - RCSID("$Id: threads.c,v 1.146 2000/12/01 01:15:02 hubbe Exp $"); + RCSID("$Id: threads.c,v 1.147 2000/12/01 08:09:55 hubbe Exp $");      PMOD_EXPORT int num_threads = 1;   PMOD_EXPORT int threads_disabled = 0;      #ifdef _REENTRANT   #include "threads.h"   #include "array.h"   #include "mapping.h"   #include "object.h"   #include "pike_macros.h"
pike.git/src/threads.c:711:    check_threads, 0,0);    dmalloc_accept_leak(threads_evaluator_callback);    }    ref_push_object(arg->id);    THREADS_FPRINTF(0, (stderr, "THREAD_CREATE -> t:%08x\n",    (unsigned int)arg->id));    } else {    free_object(arg->id);    free_array(arg->args);    free((char *)arg); -  error("Failed to create thread (errno = %d).\n",tmp); +  Pike_error("Failed to create thread (errno = %d).\n",tmp);    }   }      #ifdef UNIX_THREADS   void f_thread_set_concurrency(INT32 args)   {    int c=1;    if(args) c=Pike_sp[-args].u.integer; -  else error("No argument to thread_set_concurrency(int concurrency);\n"); +  else Pike_error("No argument to thread_set_concurrency(int concurrency);\n");    pop_n_elems(args);    num_lwps=c;    th_setconcurrency(c);   }   #endif      PMOD_EXPORT void f_this_thread(INT32 args)   {    pop_n_elems(args);    ref_push_object(Pike_interpreter.thread_id);
pike.git/src/threads.c:787:    case 2:    if(m->key && OB2KEY(m->key)->owner == Pike_interpreter.thread_id)    {    THREADS_FPRINTF(0,    (stderr, "Recursive LOCK k:%08x, m:%08x(%08x), t:%08x\n",    (unsigned int)OB2KEY(m->key),    (unsigned int)m,    (unsigned int)OB2KEY(m->key)->mut,    (unsigned int) Pike_interpreter.thread_id));    -  if(type==0) error("Recursive mutex locks!\n"); +  if(type==0) Pike_error("Recursive mutex locks!\n");       pop_n_elems(args);    push_int(0);    return;    }    case 1:    break;    }       /* Needs to be cloned here, since create()
pike.git/src/threads.c:810:    o=clone_object(mutex_key,0);       DO_IF_DEBUG( if(thread_for_id(th_self()) != Pike_interpreter.thread_id)    fatal("thread_for_id() (or Pike_interpreter.thread_id) failed! %p != %p\n",thread_for_id(th_self()),Pike_interpreter.thread_id) ; )       if(m->key)    {    if(threads_disabled)    {    free_object(o); -  error("Cannot wait for mutexes when threads are disabled!\n"); +  Pike_error("Cannot wait for mutexes when threads are disabled!\n");    }    SWAP_OUT_CURRENT_THREAD();    do    {    THREADS_FPRINTF(1, (stderr,"WAITING TO LOCK m:%08x\n",(unsigned int)m));    co_wait_interpreter(& m->condition);    }while(m->key);    SWAP_IN_CURRENT_THREAD();    }    m->key=o;
pike.git/src/threads.c:862:       switch(type)    {    default:    bad_arg_error("mutex->trylock", Pike_sp-args, args, 2, "int(0..2)", Pike_sp+1-args,    "Unknown mutex locking style: %d\n",type);       case 0:    if(m->key && OB2KEY(m->key)->owner == Pike_interpreter.thread_id)    { -  error("Recursive mutex locks!\n"); +  Pike_error("Recursive mutex locks!\n");    }       case 2:    case 1:    break;    }       o=clone_object(mutex_key,0);       if(!m->key)
pike.git/src/threads.c:947:    co_signal(& mut->condition);    }   }      #define THIS_COND ((COND_T *)(CURRENT_STORAGE))   void f_cond_wait(INT32 args)   {    COND_T *c;       if(threads_disabled) -  error("Cannot wait for conditions when threads are disabled!\n"); +  Pike_error("Cannot wait for conditions when threads are disabled!\n");       if(args > 1) {    pop_n_elems(args - 1);    args = 1;    }       c=THIS_COND;       if((args > 0) && !IS_ZERO(Pike_sp-1))    {    struct object *key;    struct mutex_storage *mut;       if(Pike_sp[-1].type != T_OBJECT) -  error("Bad argument 1 to condition->wait()\n"); +  Pike_error("Bad argument 1 to condition->wait()\n");       key=Pike_sp[-1].u.object;       if(key->prog != mutex_key) -  error("Bad argument 1 to condition->wait()\n"); +  Pike_error("Bad argument 1 to condition->wait()\n");       if (OB2KEY(key)->initialized) {       mut = OB2KEY(key)->mut;    if(!mut) -  error("Bad argument 1 to condition->wait()\n"); +  Pike_error("Bad argument 1 to condition->wait()\n");       /* Unlock mutex */    mut->key=0;    OB2KEY(key)->mut=0;    co_signal(& mut->condition);       /* Wait and allow mutex operations */    SWAP_OUT_CURRENT_THREAD();    co_wait_interpreter(c);   
pike.git/src/threads.c:1154:   void f_thread_local_set(INT32 args)   {    struct svalue key;    struct mapping *m;    key.u.integer = ((struct thread_local *)CURRENT_STORAGE)->id;    key.type = T_INT;    key.subtype = NUMBER_NUMBER;    if(args>1)    pop_n_elems(args-1);    else if(args<1) -  error("Too few arguments to thread_local->set()\n"); +  Pike_error("Too few arguments to thread_local->set()\n");       if(Pike_interpreter.thread_id == NULL) -  error("Trying to set thread_local without thread!\n"); +  Pike_error("Trying to set thread_local without thread!\n");       if((m = OBJ2THREAD(Pike_interpreter.thread_id)->thread_local) == NULL)    m = OBJ2THREAD(Pike_interpreter.thread_id)->thread_local =    allocate_mapping(4);       mapping_insert(m, &key, &Pike_sp[-1]);   }      /* Thread farm code by Per    *
pike.git/src/threads.c:1290:    new_farmer( fun, here );   }      /*    * Glue code.    */      void low_th_init(void)   {   #ifdef SGI_SPROC_THREADS - #error /* Need to specify a filename */ + #Pike_error /* Need to specify a filename */    us_cookie = usinit("");   #endif /* SGI_SPROC_THREADS */       THREADS_FPRINTF(0, (stderr, "THREADS_DISALLOW() Initializing threads.\n"));      #ifdef POSIX_THREADS   #ifdef HAVE_PTHREAD_INIT    pthread_init();   #endif /* HAVE_PTHREAD_INIT */   #endif /* POSIX_THREADS */