pike.git / src / threads.h

version» Context lines:

pike.git/src/threads.h:1:   /* -  * $Id: threads.h,v 1.65 1999/04/15 19:12:51 hubbe Exp $ +  * $Id: threads.h,v 1.66 1999/05/08 00:41:03 hubbe Exp $    */   #ifndef THREADS_H   #define THREADS_H      #include "machine.h"   #include "interpret.h"   #include "object.h"   #include "error.h"   #ifdef HAVE_SYS_TYPES_H   /* Needed for pthread_t on OSF/1 */
pike.git/src/threads.h:119:   #define MUTEX_T mutex_t   #define mt_init(X) mutex_init((X),USYNC_THREAD,0)   #define mt_lock(X) mutex_lock(X)   #define mt_trylock(X) mutex_trylock(X)   #define mt_unlock(X) mutex_unlock(X)   #define mt_destroy(X) mutex_destroy(X)      #define th_setconcurrency(X) thr_setconcurrency(X)      #define th_create(ID,fun,arg) thr_create(NULL,thread_stack_size,fun,arg,THR_DAEMON|THR_DETACHED,ID) - #define th_create_small(ID,fun,arg) thr_create(NULL,32768,fun,arg,THR_DAEMON|THR_DETACHED,ID) + #define th_create_small(ID,fun,arg) thr_create(NULL,8192*sizeof(char *),fun,arg,THR_DAEMON|THR_DETACHED,ID)   #define th_exit(foo) thr_exit(foo)   #define th_self() thr_self()   #define th_kill(ID,sig) thr_kill((ID),(sig))   #define th_yield() thr_yield()   #define th_join(ID,res) thr_join((ID), NULL, (res))      #define COND_T cond_t   #define co_init(X) cond_init((X),USYNC_THREAD,0)   #define co_wait(COND, MUTEX) cond_wait((COND), (MUTEX))   #define co_signal(X) cond_signal(X)
pike.git/src/threads.h:172:    * No cond_vars yet    */      #endif /* SGI_SPROC_THREADS */         #ifdef NT_THREADS   #include <process.h>   #include <windows.h>    - #define THREAD_T HANDLE + #define THREAD_T unsigned   #define th_setconcurrency(X) - #define th_create(ID,fun,arg) (!(*(ID)=_beginthread(fun, 2*1024*1024, arg))) - #define th_create_small(ID,fun,arg) (!(*(ID)=_beginthread(fun, 32768, arg))) + #define th_create(ID,fun,arg) (!_beginthreadex(NULL, 2*1024*1024,fun, arg,0,ID)) + #define th_create_small(ID,fun,arg) (!_beginthreadex(NULL, 8192*sizeof(char *), fun,arg,0,ID)) + #define TH_RETURN_TYPE unsigned __stdcall   #define th_exit(foo) _endthread(foo)   #define th_join(ID,res) /******************* FIXME! ****************/ - #define th_self() GetCurrentThread() + #define th_self() GetCurrentThreadId()   #define th_destroy(X)   #define th_yield() Sleep(0)   #define th_equal(X,Y) ((X)==(Y)) - #define th_hash(X) ((unsigned INT32)(X)) + #define th_hash(X) (X)      #define MUTEX_T HANDLE   #define mt_init(X) CheckValidHandle((*(X)=CreateMutex(NULL, 0, NULL)))   #define mt_lock(X) (CheckValidHandle(*(X)),WaitForSingleObject(*(X), INFINITE))   #define mt_trylock(X) (CheckValidHandle(*(X)),WaitForSingleObject(*(X), 0))   #define mt_unlock(X) (CheckValidHandle(*(X)),ReleaseMutex(*(X)))   #define mt_destroy(X) (CheckValidHandle(*(X)),CloseHandle(*(X)))      #define EVENT_T HANDLE   #define event_init(X) CheckValidHandle(*(X)=CreateEvent(NULL, 1, 0, NULL))
pike.git/src/threads.h:309: Inside #if defined(PROFILING) and #if defined(HAVE_GETHRTIME)
   long long accounted_time;    long long time_base;   #endif   #endif      #ifdef THREAD_TRACE    int t_flag;   #endif /* THREAD_TRACE */   };    + #ifndef TH_RETURN_TYPE + #define TH_RETURN_TYPE void * + #endif +    #ifndef th_destroy   #define th_destroy(X)   #endif      #ifndef th_yield   #define th_yield()   #endif      #ifndef th_equal   #define th_equal(X,Y) (!MEMCMP(&(X),&(Y),sizeof(THREAD_T)))
pike.git/src/threads.h:426:    */   #define REVEAL_GLOBAL_VARIABLES() ; } while(0)   #else /* PIKE_DEBUG */   #define HIDE_GLOBAL_VARIABLES()   #define REVEAL_GLOBAL_VARIABLES()   #endif /* PIKE_DEBUG */      #define OBJ2THREAD(X) \    ((struct thread_state *)((X)->storage+thread_storage_offset))    + #define THREADSTATE2OBJ(X) BASEOF((X),object,storage[thread_storage_offset]) +    #define THREADS_ALLOW() do { \    struct thread_state *_tmp=OBJ2THREAD(thread_id); \ -  +  DO_IF_DEBUG( if(thread_for_id(th_self()) != thread_id) \ +  fatal("thread_for_id() (or thread_id) failed! %p != %p\n",thread_for_id(th_self()),thread_id) ; ) \    if(num_threads > 1 && !threads_disabled) { \    SWAP_OUT_THREAD(_tmp); \    THREADS_FPRINTF(1, (stderr, "THREADS_ALLOW() %s:%d t:%08x(#%d)\n", \    __FILE__, __LINE__, \    (unsigned int)_tmp->thread_id, live_threads)); \    mt_unlock(& interpreter_lock); \    } else {} \    HIDE_GLOBAL_VARIABLES()      #define THREADS_DISALLOW() \
pike.git/src/threads.h:451:    THREADS_FPRINTF(1, (stderr, "THREADS_DISALLOW() %s:%d t:%08x(#%d)\n", \    __FILE__, __LINE__, \    (unsigned int)_tmp->thread_id, live_threads)); \    while (threads_disabled) { \    THREADS_FPRINTF(1, (stderr, \    "THREADS_DISALLOW(): Threads disabled\n")); \    co_wait(&threads_disabled_change, &interpreter_lock); \    } \    SWAP_IN_THREAD(_tmp);\    } \ +  DO_IF_DEBUG( if(thread_for_id(th_self()) != thread_id) \ +  fatal("thread_for_id() (or thread_id) failed! %p != %p\n",thread_for_id(th_self()),thread_id) ; ) \    } while(0)      #define THREADS_ALLOW_UID() do { \    struct thread_state *_tmp_uid=OBJ2THREAD(thread_id); \    if(num_threads > 1 && !threads_disabled) { \    SWAP_OUT_THREAD(_tmp_uid); \    live_threads++; \    THREADS_FPRINTF(1, (stderr, "THREADS_ALLOW_UID() %s:%d t:%08x(#%d)\n", \    __FILE__, __LINE__, \    (unsigned int)_tmp_uid->thread_id, live_threads)); \
pike.git/src/threads.h:500:    struct thread_state *_tmp=thread_state_for_id(th_self()); \    if(_tmp->swapped) fatal("Thread is not swapped in!\n"); \    }while(0)      #else   #define ASSERT_THREAD_SWAPPED_IN()   #endif      /* Prototypes begin here */   struct thread_starter; - void *new_thread_func(void * data); + TH_RETURN_TYPE new_thread_func(void * data);   void f_thread_create(INT32 args);   void f_thread_set_concurrency(INT32 args);   void f_this_thread(INT32 args);   struct mutex_storage;   struct key_storage;   void f_mutex_lock(INT32 args);   void f_mutex_trylock(INT32 args);   void init_mutex_obj(struct object *o);   void exit_mutex_obj(struct object *o);   void init_mutex_key_obj(struct object *o);