ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libeio/xthread.h
(Generate patch)

Comparing libeio/xthread.h (file contents):
Revision 1.2 by root, Mon May 12 12:36:21 2008 UTC vs.
Revision 1.5 by root, Tue May 20 05:50:49 2008 UTC

35#define sigemptyset(s) 35#define sigemptyset(s)
36#define sigfillset(s) 36#define sigfillset(s)
37 37
38typedef pthread_mutex_t mutex_t; 38typedef pthread_mutex_t mutex_t;
39#define X_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER 39#define X_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER
40#define X_MUTEX_CHECK(mutex)
41#define X_LOCK(mutex) pthread_mutex_lock (&(mutex)) 40#define X_LOCK(mutex) pthread_mutex_lock (&(mutex))
42#define X_UNLOCK(mutex) pthread_mutex_unlock (&(mutex)) 41#define X_UNLOCK(mutex) pthread_mutex_unlock (&(mutex))
43 42
44typedef pthread_cond_t cond_t; 43typedef pthread_cond_t cond_t;
45#define X_COND_INIT PTHREAD_COND_INITIALIZER 44#define X_COND_INIT PTHREAD_COND_INITIALIZER
46#define X_COND_CHECK(cond)
47#define X_COND_SIGNAL(cond) pthread_cond_signal (&(cond)) 45#define X_COND_SIGNAL(cond) pthread_cond_signal (&(cond))
48#define X_COND_WAIT(cond,mutex) pthread_cond_wait (&(cond), &(mutex)) 46#define X_COND_WAIT(cond,mutex) pthread_cond_wait (&(cond), &(mutex))
49#define X_COND_TIMEDWAIT(cond,mutex,to) pthread_cond_timedwait (&(cond), &(mutex), &(to)) 47#define X_COND_TIMEDWAIT(cond,mutex,to) pthread_cond_timedwait (&(cond), &(mutex), &(to))
50 48
51typedef pthread_t thread_t; 49typedef pthread_t thread_t;
53#define X_THREAD_ATFORK(a,b,c) 51#define X_THREAD_ATFORK(a,b,c)
54 52
55static int 53static int
56thread_create (thread_t *tid, void *(*proc)(void *), void *arg) 54thread_create (thread_t *tid, void *(*proc)(void *), void *arg)
57{ 55{
58 int res; 56 int retval;
59 pthread_attr_t attr; 57 pthread_attr_t attr;
60 58
61 pthread_attr_init (&attr); 59 pthread_attr_init (&attr);
62 pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED); 60 pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED);
63 61
64 res = pthread_create (tid, &attr, proc, arg) == 0; 62 retval = pthread_create (tid, &attr, proc, arg) == 0;
65 63
66 pthread_attr_destroy (&attr); 64 pthread_attr_destroy (&attr);
67 65
68 return res; 66 return retval;
69} 67}
70 68
71#define respipe_read(a,b,c) PerlSock_recv ((a), (b), (c), 0) 69#define respipe_read(a,b,c) PerlSock_recv ((a), (b), (c), 0)
72#define respipe_write(a,b,c) send ((a), (b), (c), 0) 70#define respipe_write(a,b,c) send ((a), (b), (c), 0)
73#define respipe_close(a) PerlSock_closesocket ((a)) 71#define respipe_close(a) PerlSock_closesocket ((a))
113 111
114typedef pthread_t thread_t; 112typedef pthread_t thread_t;
115#define X_THREAD_PROC(name) static void *name (void *thr_arg) 113#define X_THREAD_PROC(name) static void *name (void *thr_arg)
116#define X_THREAD_ATFORK(prepare,parent,child) pthread_atfork (prepare, parent, child) 114#define X_THREAD_ATFORK(prepare,parent,child) pthread_atfork (prepare, parent, child)
117 115
116// the broken bsd's once more
117#ifndef PTHREAD_STACK_MIN
118# define PTHREAD_STACK_MIN 0
119#endif
120
118static int 121static int
119thread_create (thread_t *tid, void *(*proc)(void *), void *arg) 122thread_create (thread_t *tid, void *(*proc)(void *), void *arg)
120{ 123{
121 int retval; 124 int retval;
122 sigset_t fullsigset, oldsigset; 125 sigset_t fullsigset, oldsigset;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines