pike.git / src / threads.c

version» Context lines:

pike.git/src/threads.c:3:   #include "array.h"   #include "object.h"   #include "macros.h"      int num_threads = 1;   int threads_disabled = 0;   struct object *thread_id;      #ifdef _REENTRANT    - MUTEX_T interpreter_lock; + MUTEX_T interpreter_lock = PTHREAD_MUTEX_INITIALIZER;   struct program *mutex_key = 0;   struct program *thread_id_prog = 0;   pthread_attr_t pattr;      struct thread_starter   {    struct object *id;    struct array *args;   };      void *new_thread_func(void * data)   {    struct thread_starter arg = *(struct thread_starter *)data;    JMP_BUF back;    INT32 args; -  +     free((char *)data); -  +  +  if(args=mt_lock( & interpreter_lock)) +  fatal("Failed to lock interpreter, errno %d\n",args); +     args=arg.args->size; -  mt_lock( & interpreter_lock); +     init_interpreter();       thread_id=arg.id;       if(SETJMP(back))    {    ONERROR tmp;    SET_ONERROR(tmp,exit_on_error,"Error in handle_error in master object!");    assign_svalue_no_free(sp++, & throw_value);    APPLY_MASTER("handle_error", 1);    pop_stack();    UNSET_ONERROR(tmp);    } else {    push_array_items(arg.args);    arg.args=0; -  f_call_function(args); -  +     }       UNSETJMP(back);       destruct(thread_id); -  +     free_object(thread_id);    thread_id=0;       cleanup_interpret();    num_threads--;    mt_unlock(& interpreter_lock);    th_exit(0);   }    -  +    void f_thread_create(INT32 args)   { -  struct thread_starter *arg; +     pthread_t dummy; -  +  struct thread_starter *arg;    int tmp;    arg=ALLOC_STRUCT(thread_starter);    arg->args=aggregate_array(args);    arg->id=clone(thread_id_prog,0);    tmp=th_create(&dummy,new_thread_func,arg);    if(!tmp)    {    num_threads++;    push_object(arg->id);    arg->id->refs++;
pike.git/src/threads.c:115:    COND_T condition;    struct object *key;   };      struct key_storage   {    struct mutex_storage *mut;    int initialized;   };    - static MUTEX_T mutex_kluge; + static MUTEX_T mutex_kluge = PTHREAD_MUTEX_INITIALIZER;      #define OB2KEY(X) ((struct key_storage *)((X)->storage))      void f_mutex_lock(INT32 args)   {    struct mutex_storage *m;    struct object *o;       pop_n_elems(args);    m=THIS_MUTEX;