pike.git / src / threads.c

version» Context lines:

pike.git/src/threads.c:1:   /*   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: threads.c,v 1.269 2008/12/19 15:22:32 mast Exp $ + || $Id: threads.c,v 1.270 2008/12/27 20:01:37 grubba Exp $   */      #include "global.h"      PMOD_EXPORT int num_threads = 1;   PMOD_EXPORT int threads_disabled = 0;      /* #define PICKY_MUTEX */      #ifdef _REENTRANT
pike.git/src/threads.c:647:   }      PMOD_EXPORT void call_with_interpreter(void (*func)(void *ctx), void *ctx)   {    struct thread_state *state;       if((state = thread_state_for_id(th_self()))!=NULL) {    /* This is a pike thread. Do we have the interpreter lock? */    if(!state->swapped) {    /* Yes. Go for it... */ + #ifdef PIKE_DEBUG +  /* Ensure that the thread isn't loose. */ +  int is_loose = state->debug_flags & THREAD_DEBUG_LOOSE; +  state->debug_flags &= ~THREAD_DEBUG_LOOSE; + #endif +     func(ctx); -  +  + #ifdef PIKE_DEBUG +  /* Restore the looseness property of the thread. */ +  state->debug_flags |= is_loose; + #endif    } else {    /* Nope, let's get it... */    mt_lock_interpreter();    SWAP_IN_THREAD(state); -  +  DO_IF_DEBUG(state->debug_flags &= ~THREAD_DEBUG_LOOSE;)       func(ctx);       /* Restore */ -  +  DO_IF_DEBUG(state->debug_flags |= THREAD_DEBUG_LOOSE;)    SWAP_OUT_THREAD(state);    mt_unlock_interpreter();    }    } else {    /* Not a pike thread. Create a temporary thread_id... */    struct object *thread_obj;       mt_lock_interpreter();    init_interpreter();    Pike_interpreter.stack_top=((char *)&state)+ (thread_stack_size-16384) * STACK_DIRECTION;