pike.git / src / threads.h

version» Context lines:

pike.git/src/threads.h:63:    * needed to make usable multi-threaded programs on solaris machines    * with only one CPU. Otherwise, only systemcalls are actually    * threaded.    */   #define th_setconcurrency(X)   #ifdef HAVE_PTHREAD_YIELD   #define th_yield() pthread_yield()   #else   #define th_yield()   #endif /* HAVE_PTHREAD_YIELD */ + extern pthread_attr_t pattr; + extern pthread_attr_t small_pattr;      #define th_create(ID,fun,arg) pthread_create(ID,&pattr,fun,arg) -  + #define th_create_small(ID,fun,arg) pthread_create(ID,&small_pattr,fun,arg)   #define th_exit(foo) pthread_exit(foo)   #define th_self() pthread_self()      #ifdef HAVE_PTHREAD_COND_INIT   #define COND_T pthread_cond_t      #ifdef HAVE_PTHREAD_CONDATTR_DEFAULT   #define co_init(X) pthread_cond_init((X), pthread_condattr_default)   #else   #define co_init(X) pthread_cond_init((X), 0)
pike.git/src/threads.h:103:   #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,0,fun,arg,THR_DAEMON,ID) + #define th_create_small(ID,fun,arg) thr_create(NULL,32768,fun,arg,THR_DAEMON,ID)   #define th_exit(foo) thr_exit(foo)   #define th_self() thr_self()   #define th_yield() thr_yield()      #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)   #define co_broadcast(X) cond_broadcast(X)   #define co_destroy(X) cond_destroy(X)
pike.git/src/threads.h:134:   #define 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)   #define th_exit(X) exit(X)   #define th_self() getpid()   #define th_yield() sginap(0)      /*    * No cond_vars yet    */      #endif /* SGI_SPROC_THREADS */         #ifdef NT_THREADS   #include <process.h>   #include <windows.h>      #define THREAD_T HANDLE   #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_exit(foo) _endthread(foo)   #define th_self() GetCurrentThread()   #define th_destroy(X)   #define th_yield() Sleep(0)      #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)))