pike.git / src / threads.h

version» Context lines:

pike.git/src/threads.h:1:   /* -  * $Id: threads.h,v 1.70 1999/09/06 11:13:23 hubbe Exp $ +  * $Id: threads.h,v 1.71 1999/11/18 04:14:55 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:46:   #undef HAVE_SPROC   #endif /* _SGI_SPROC_THREADS */         extern int num_threads;   extern int live_threads;   struct object;   extern size_t thread_stack_size;   extern struct object *thread_id;    - #define DEFINE_MUTEX(X) MUTEX_T X + #define DEFINE_MUTEX(X) PIKE_MUTEX_T X         #ifdef POSIX_THREADS      #ifdef HAVE_PTHREAD_ATFORK   #define th_atfork(X,Y,Z) pthread_atfork((X),(Y),(Z))   #define th_atfork_prepare()   #define th_atfork_parent()   #define th_atfork_child()   #else   int th_atfork(void (*)(void),void (*)(void),void (*)(void));   void th_atfork_prepare(void);   void th_atfork_parent(void);   void th_atfork_child(void);   #endif      #define THREAD_T pthread_t - #define MUTEX_T pthread_mutex_t + #define PIKE_MUTEX_T pthread_mutex_t   #define mt_init(X) pthread_mutex_init((X),0)   #define mt_lock(X) pthread_mutex_lock(X)   #define mt_trylock(X) pthread_mutex_trylock(X)   #define mt_unlock(X) pthread_mutex_unlock(X)   #define mt_destroy(X) pthread_mutex_destroy(X)      /* SIGH! No setconcurrency in posix threads. This is more or less    * needed to make usable multi-threaded programs on solaris machines    * with only one CPU. Otherwise, only systemcalls are actually    * threaded.
pike.git/src/threads.h:122:   #endif /* HAVE_PTHREAD_COND_INIT */      #endif /* POSIX_THREADS */               #ifdef UNIX_THREADS   #define THREAD_T thread_t   #define PTHREAD_MUTEX_INITIALIZER DEFAULTMUTEX - #define MUTEX_T mutex_t + #define PIKE_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,8192*sizeof(char *),fun,arg,THR_DAEMON|THR_DETACHED,ID)
pike.git/src/threads.h:156:      #endif /* UNIX_THREADS */      #ifdef SGI_SPROC_THREADS      /*    * Not fully supported yet    */   #define THREAD_T int    - #define MUTEX_T ulock_t + #define PIKE_MUTEX_T ulock_t   #define mt_init(X) (usinitlock(((*X) = usnewlock(/*********/))))   #define mt_lock(X) ussetlock(*X)   #define mt_unlock(X) usunsetlock(*X)   #define mt_destroy(X) usfreelock((*X), /*******/)      #define th_setconcurrency(X) /*******/      #define PIKE_SPROC_FLAGS (PR_SADDR|PR_SFDS|PR_SDIR|PS_SETEXITSIG)   #define th_create(ID, fun, arg) (((*(ID)) = sproc(fun, PIKE_SPROC_FLAGS, arg)) == -1)   #define th_create_small(ID, fun, arg) (((*(ID)) = sproc(fun, PIKE_SPROC_FLAGS, arg)) == -1)
pike.git/src/threads.h:199:   #define TH_RETURN_TYPE unsigned __stdcall   #define TH_STDCALL __stdcall   #define th_exit(foo) _endthreadex(foo)   #define th_join(ID,res) /******************* FIXME! ****************/   #define th_self() GetCurrentThreadId()   #define th_destroy(X)   #define th_yield() Sleep(0)   #define th_equal(X,Y) ((X)==(Y))   #define th_hash(X) (X)    - #define MUTEX_T HANDLE + #define PIKE_MUTEX_T HANDLE   #define mt_init(X) CheckValidHandle((*(X)=CreateMutex(NULL, 0, NULL)))   #define mt_lock(X) WaitForSingleObject(CheckValidHandle(*(X)), INFINITE)   #define mt_trylock(X) WaitForSingleObject(CheckValidHandle(*(X)), 0)   #define mt_unlock(X) ReleaseMutex(CheckValidHandle(*(X)))   #define mt_destroy(X) CloseHandle(CheckValidHandle(*(X)))      #define EVENT_T HANDLE   #define event_init(X) CheckValidHandle(*(X)=CreateEvent(NULL, 1, 0, NULL))   #define event_signal(X) SetEvent(CheckValidHandle(*(X)))   #define event_destroy(X) CloseHandle(CheckValidHandle(*(X)))   #define event_wait(X) WaitForSingleObject(CheckValidHandle(*(X)), INFINITE)      #endif       - #if !defined(COND_T) && defined(EVENT_T) && defined(MUTEX_T) + #if !defined(COND_T) && defined(EVENT_T) && defined(PIKE_MUTEX_T)      #define SIMULATE_COND_WITH_EVENT      struct cond_t_queue   {    struct cond_t_queue *next;    EVENT_T event;   };      typedef struct cond_t_s   { -  MUTEX_T lock; +  PIKE_MUTEX_T lock;    struct cond_t_queue *head, *tail;   } COND_T;      #define COND_T struct cond_t_s      #define co_init(X) do { mt_init(& (X)->lock), (X)->head=(X)->tail=0; }while(0)    - int co_wait(COND_T *c, MUTEX_T *m); + int co_wait(COND_T *c, PIKE_MUTEX_T *m);   int co_signal(COND_T *c);   int co_broadcast(COND_T *c);   int co_destroy(COND_T *c);      #endif       - extern MUTEX_T interpreter_lock; + extern PIKE_MUTEX_T interpreter_lock;      extern COND_T live_threads_change; /* Used by _disable_threads */   extern COND_T threads_disabled_change; /* Used by _disable_threads */      struct svalue;   struct pike_frame;    - extern MUTEX_T interleave_lock; + extern PIKE_MUTEX_T interleave_lock;      struct interleave_mutex   {    struct interleave_mutex *next;    struct interleave_mutex *prev; -  MUTEX_T lock; +  PIKE_MUTEX_T lock;   };      #define IMUTEX_T struct interleave_mutex      #define DEFINE_IMUTEX(name) IMUTEX_T name      /* If threads are disabled, we already hold the lock. */   #define LOCK_IMUTEX(im) do { \    if (!threads_disabled) { \    THREADS_FPRINTF(0, (stderr, "Locking IMutex 0x%08p...\n", (im))); \
pike.git/src/threads.h:628: Inside #if defined(__NT__)
  #ifndef PIKE_DEBUG   #define CheckValidHandle(X) (X)   #else   HANDLE CheckValidHandle(HANDLE h);   #endif   #endif      extern int threads_disabled;   extern int thread_storage_offset;    + #ifndef NO_PIKE_SHORTHAND + #define MUTEX_T PIKE_MUTEX_T + #endif +    #endif /* THREADS_H */