9 #define CPTHREAD_THREADS_MAX 1000000000
10 #define CPTHREAD_KEYS_MAX 1000000000
11 #define CPTHREAD_STACK_MIN 32768
12 #define CPTHREAD_CREATE_DETACHED 1
13 #define CPTHREAD_CREATE_JOINABLE 0
15 struct Cpthread_attr_s
22 struct Cpthread_mutexattr_s
28 struct Cpthread_mutex_s
35 struct Cpthread_condattr_s
41 struct Cpthread_cond_s
48 typedef struct { int flag
[32]; } Cpthread_once_t
;
50 #define CPTHREAD_ONCE_INIT {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
52 typedef struct Cpthread_attr_s Cpthread_attr_t
;
53 typedef struct Cpthread_key_s
*Cpthread_key_t
;
54 typedef struct Cpthread_cleanup_s
*Cpthread_cleanup_t
;
55 typedef struct Cpthread_mutexattr_s Cpthread_mutexattr_t
;
56 typedef struct Cpthread_condattr_s Cpthread_condattr_t
;
57 typedef struct Cpthread_mutex_s Cpthread_mutex_t
;
58 typedef struct Cpthread_cond_s Cpthread_cond_t
;
59 typedef struct Cpthread_s
*Cpthread_t
;
61 #ifdef CPTHREAD_IS_HERE
62 CtvDeclare(Cpthread_t
, Cpthread_current
);
63 CtvDeclare(int, Cpthread_errcode
);
65 CtvExtern(Cpthread_t
, Cpthread_current
);
66 CtvExtern(int, Cpthread_errcode
);
69 #define Cpthread_self() (CtvAccess(Cpthread_current))
70 #define Cpthread_errno (CtvAccess(Cpthread_errcode))
72 int Cpthread_attr_init(Cpthread_attr_t
*attr
);
73 int Cpthread_attr_destroy(Cpthread_attr_t
*attr
);
74 int Cpthread_attr_getstacksize(Cpthread_attr_t
*attr
, size_t *size
);
75 int Cpthread_attr_setstacksize(Cpthread_attr_t
*attr
, size_t size
);
76 int Cpthread_attr_getdetachstate(Cpthread_attr_t
*attr
, int *state
);
77 int Cpthread_attr_setdetachstate(Cpthread_attr_t
*attr
, int state
);
78 int Cpthread_key_create(Cpthread_key_t
*keyp
, void (*destructo
)(void *));
79 int Cpthread_key_delete(Cpthread_key_t key
);
80 int Cpthread_setspecific(Cpthread_key_t key
, void *val
);
81 void *Cpthread_getspecific(Cpthread_key_t key
);
82 void Cpthread_cleanup_push(void (*routine
)(void*), void *arg
);
83 void Cpthread_cleanup_pop(int execute
);
84 void Cpthread_exit(void *status
);
85 void Cpthread_top(Cpthread_t pt
);
86 int Cpthread_create(Cpthread_t
*thread
, Cpthread_attr_t
*attr
,
87 void *(*fn
)(void *), void *arg
);
88 int Cpthread_equal(Cpthread_t t1
, Cpthread_t t2
);
89 int Cpthread_detach(Cpthread_t pt
);
90 int Cpthread_join(Cpthread_t pt
, void **status
);
91 int Cpthread_mutexattr_init(Cpthread_mutexattr_t
*mattr
);
92 int Cpthread_mutexattr_destroy(Cpthread_mutexattr_t
*mattr
);
93 int Cpthread_mutexattr_getpshared(Cpthread_mutexattr_t
*mattr
,int *pshared
);
94 int Cpthread_mutexattr_setpshared(Cpthread_mutexattr_t
*mattr
,int pshared
);
95 int Cpthread_mutex_init(Cpthread_mutex_t
*mutex
,Cpthread_mutexattr_t
*mattr
);
96 int Cpthread_mutex_destroy(Cpthread_mutex_t
*mutex
);
97 int Cpthread_mutex_lock(Cpthread_mutex_t
*mutex
);
98 int Cpthread_mutex_trylock(Cpthread_mutex_t
*mutex
);
99 int Cpthread_mutex_unlock(Cpthread_mutex_t
*mutex
);
100 int Cpthread_condattr_init(Cpthread_condattr_t
*cattr
);
101 int Cpthread_condattr_destroy(Cpthread_condattr_t
*cattr
);
102 int Cpthread_condattr_getpshared(Cpthread_condattr_t
*cattr
, int *pshared
);
103 int Cpthread_condattr_setpshared(Cpthread_condattr_t
*cattr
, int pshared
);
104 int Cpthread_cond_init(Cpthread_cond_t
*cond
, Cpthread_condattr_t
*cattr
);
105 int Cpthread_cond_destroy(Cpthread_cond_t
*cond
);
106 int Cpthread_cond_wait(Cpthread_cond_t
*cond
, Cpthread_mutex_t
*mutex
);
107 int Cpthread_cond_signal(Cpthread_cond_t
*cond
);
108 int Cpthread_cond_broadcast(Cpthread_cond_t
*cond
);
109 int Cpthread_once(Cpthread_once_t
*once
, void (*fn
)(void));
111 int Cpthread_init(void);
113 void Cpthread_initialize(void);
114 void Cpthread_start_main(CmiStartFn fn
, int argc
, char **argv
);
116 #define Cpthread_yield() (CthYield())
118 #ifndef SUPPRESS_PTHREADS
120 #define _POSIX_THREADS
121 #define _POSIX_THREAD_ATTR_STACKSIZE
122 /* #define _POSIX_THREAD_ATTR_STACKADDR */
123 /* #define _POSIX_THREAD_PRIORITY_SCHEDULING */
124 /* #define _POSIX_THREAD_PRIO_INHERIT */
125 /* #define _POSIX_THREAD_PRIO_PROTECT */
126 /* #define _POSIX_THREAD_PROCESS_SHARED */
128 #define PTHREAD_THREADS_MAX CPTHREAD_THREADS_MAX
129 #define PTHREAD_KEYS_MAX CPTHREAD_KEYS_MAX
130 #define PTHREAD_STACK_MIN CPTHREAD_STACK_MIN
131 #define PTHREAD_CREATE_DETACHED CPTHREAD_CREATE_DETACHED
132 #define PTHREAD_CREATE_JOINABLE CPTHREAD_CREATE_JOINABLE
134 #define PTHREAD_ONCE_INIT CPTHREAD_ONCE_INIT
136 #define pthread_once_t Cpthread_once_t
137 #define pthread_attr_t Cpthread_attr_t
138 #define pthread_key_t Cpthread_key_t
139 #define pthread_cleanup_t Cpthread_cleanup_t
140 #define pthread_mutexattr_t Cpthread_mutexattr_t
141 #define pthread_condattr_t Cpthread_condattr_t
142 #define pthread_mutex_t Cpthread_mutex_t
143 #define pthread_cond_t Cpthread_cond_t
144 #define pthread_t Cpthread_t
145 #define pthread_attr_init Cpthread_attr_init
146 #define pthread_attr_destroy Cpthread_attr_destroy
147 #define pthread_attr_getstacksize Cpthread_attr_getstacksize
148 #define pthread_attr_setstacksize Cpthread_attr_setstacksize
149 #define pthread_attr_getdetachstate Cpthread_attr_getdetachstate
150 #define pthread_attr_setdetachstate Cpthread_attr_setdetachstate
151 #define pthread_key_create Cpthread_key_create
152 #define pthread_key_delete Cpthread_key_delete
153 #define pthread_setspecific Cpthread_setspecific
154 #define pthread_getspecific Cpthread_getspecific
155 #define pthread_cleanup_push Cpthread_cleanup_push
156 #define pthread_cleanup_pop Cpthread_cleanup_pop
157 #define pthread_exit Cpthread_exit
158 #define pthread_top Cpthread_top
159 #define pthread_create Cpthread_create
160 #define pthread_equal Cpthread_equal
161 #define pthread_self Cpthread_self
162 #define pthread_detach Cpthread_detach
163 #define pthread_join Cpthread_join
164 #define pthread_mutexattr_init Cpthread_mutexattr_init
165 #define pthread_mutexattr_destroy Cpthread_mutexattr_destroy
166 #define pthread_mutexattr_getpshared Cpthread_mutexattr_getpshared
167 #define pthread_mutexattr_setpshared Cpthread_mutexattr_setpshared
168 #define pthread_mutex_init Cpthread_mutex_init
169 #define pthread_mutex_destroy Cpthread_mutex_destroy
170 #define pthread_mutex_lock Cpthread_mutex_lock
171 #define pthread_mutex_trylock Cpthread_mutex_trylock
172 #define pthread_mutex_unlock Cpthread_mutex_unlock
173 #define pthread_condattr_init Cpthread_condattr_init
174 #define pthread_condattr_destroy Cpthread_condattr_destroy
175 #define pthread_condattr_getpshared Cpthread_condattr_getpshared
176 #define pthread_condattr_setpshared Cpthread_condattr_setpshared
177 #define pthread_cond_init Cpthread_cond_init
178 #define pthread_cond_destroy Cpthread_cond_destroy
179 #define pthread_cond_wait Cpthread_cond_wait
180 #define pthread_cond_signal Cpthread_cond_signal
181 #define pthread_cond_broadcast Cpthread_cond_broadcast
182 #define pthread_once Cpthread_once
183 #define pthread_init Cpthread_init
185 #define pthread_yield (CthYield())
187 #endif /* SUPPRESS_PTHREADS */
189 #endif /* CPTHREAD_H */