OSDN Git Service

2002-03-01 David O'Brien <obrien@FreeBSD.org>
[pf3gnuchains/pf3gnuchains3x.git] / winsup / cygwin / pthread.cc
1 /* pthread.cc: posix pthread interface for Cygwin
2
3    Copyright 1998, 1999, 2000, 2001 Red Hat, Inc.
4
5    Originally written by Marco Fuykschot <marco@ddi.nl>
6
7    This file is part of Cygwin.
8
9    This software is a copyrighted work licensed under the terms of the
10    Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
11    details. */
12
13 #include "winsup.h"
14 #include "thread.h"
15
16 extern "C"
17 {
18 /*  ThreadCreation */
19 int
20 pthread_create (pthread_t * thread, const pthread_attr_t * attr,
21                 void *(*start_routine) (void *), void *arg)
22 {
23   return __pthread_create (thread, attr, start_routine, arg);
24 }
25
26 int
27 pthread_once (pthread_once_t * once_control, void (*init_routine) (void))
28 {
29   return __pthread_once (once_control, init_routine);
30 }
31
32 int
33 pthread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void))
34 {
35   return __pthread_atfork(prepare, parent, child);
36 }
37
38 int
39 pthread_attr_init (pthread_attr_t * attr)
40 {
41   return __pthread_attr_init (attr);
42 }
43
44 int
45 pthread_attr_destroy (pthread_attr_t * attr)
46 {
47   return __pthread_attr_destroy (attr);
48 }
49
50 int
51 pthread_attr_setdetachstate (pthread_attr_t * attr, int detachstate)
52 {
53   return __pthread_attr_setdetachstate (attr, detachstate);
54 }
55
56 int
57 pthread_attr_getdetachstate (const pthread_attr_t * attr, int *detachstate)
58 {
59   return __pthread_attr_getdetachstate (attr, detachstate);
60 }
61
62
63 int
64 pthread_attr_setstacksize (pthread_attr_t * attr, size_t size)
65 {
66   return __pthread_attr_setstacksize (attr, size);
67 }
68
69 int
70 pthread_attr_getstacksize (const pthread_attr_t * attr, size_t * size)
71 {
72   return __pthread_attr_getstacksize (attr, size);
73 }
74
75 int
76 pthread_attr_setinheritsched (pthread_attr_t * attr, int inheritsched)
77 {
78   return __pthread_attr_setinheritsched (attr, inheritsched);
79 }
80
81 int
82 pthread_attr_getinheritsched (const pthread_attr_t * attr, int *inheritsched)
83 {
84   return __pthread_attr_getinheritsched (attr, inheritsched);
85 }
86
87 int
88 pthread_attr_setschedparam (pthread_attr_t * attr,
89                             const struct sched_param *param)
90 {
91   return __pthread_attr_setschedparam (attr, param);
92 }
93
94 int
95 pthread_attr_getschedparam (const pthread_attr_t * attr,
96                             struct sched_param *param)
97 {
98   return __pthread_attr_getschedparam (attr, param);
99 }
100
101 int
102 pthread_attr_setschedpolicy (pthread_attr_t * attr, int policy)
103 {
104   return __pthread_attr_setschedpolicy (attr, policy);
105 }
106
107 int
108 pthread_attr_getschedpolicy (const pthread_attr_t * attr, int *policy)
109 {
110   return __pthread_attr_getschedpolicy (attr, policy);
111 }
112
113 int
114 pthread_attr_setscope (pthread_attr_t * attr, int contentionscope)
115 {
116   return __pthread_attr_setscope (attr, contentionscope);
117 }
118
119 int
120 pthread_attr_getscope (const pthread_attr_t * attr, int *contentionscope)
121 {
122   return __pthread_attr_getscope (attr, contentionscope);
123 }
124
125 #ifdef _POSIX_THREAD_ATTR_STACKADDR
126 int
127 pthread_attr_setstackaddr (pthread_attr_t * attr, void *stackaddr)
128 {
129   return __pthread_attr_setstackaddr (attr, stackaddr);
130 }
131
132 int
133 pthread_attr_getstackaddr (const pthread_attr_t * attr, void **stackaddr)
134 {
135   return __pthread_attr_getstackaddr (attr, stackaddr);
136 }
137 #endif
138
139 /* Thread Exit */
140 void
141 pthread_exit (void *value_ptr)
142 {
143   return __pthread_exit (value_ptr);
144 }
145
146 int
147 pthread_join (pthread_t thread, void **return_val)
148 {
149   return __pthread_join (&thread, (void **) return_val);
150 }
151
152 int
153 pthread_detach (pthread_t thread)
154 {
155   return __pthread_detach (&thread);
156 }
157
158
159 /* This isn't a posix call... should we keep it? */
160 int
161 pthread_suspend (pthread_t thread)
162 {
163   return __pthread_suspend (&thread);
164 }
165
166 /* same */
167 int
168 pthread_continue (pthread_t thread)
169 {
170   return __pthread_continue (&thread);
171 }
172
173 unsigned long
174 pthread_getsequence_np (pthread_t * thread)
175 {
176   return __pthread_getsequence_np (thread);
177 }
178
179 /* Thread SpecificData */
180 int
181 pthread_key_create (pthread_key_t * key, void (*destructor) (void *))
182 {
183   return __pthread_key_create (key, destructor);
184 }
185
186 int
187 pthread_key_delete (pthread_key_t key)
188 {
189   return __pthread_key_delete (key);
190 }
191
192 int
193 pthread_setspecific (pthread_key_t key, const void *value)
194 {
195   return __pthread_setspecific (key, value);
196 }
197
198 void *
199 pthread_getspecific (pthread_key_t key)
200 {
201   return (void *) __pthread_getspecific (key);
202 }
203
204 /* Thread signal */
205 int
206 pthread_kill (pthread_t thread, int sig)
207 {
208   return __pthread_kill (thread, sig);
209 }
210
211 int
212 pthread_sigmask (int operation, const sigset_t * set, sigset_t * old_set)
213 {
214   return __pthread_sigmask (operation, set, old_set);
215 }
216
217 /*  ID */
218
219 pthread_t pthread_self ()
220 {
221   return __pthread_self ();
222 }
223
224 int
225 pthread_equal (pthread_t t1, pthread_t t2)
226 {
227   return __pthread_equal (&t1, &t2);
228 }
229
230 /* Mutexes  */
231 int
232 pthread_mutex_init (pthread_mutex_t * mutex, const pthread_mutexattr_t * attr)
233 {
234   return __pthread_mutex_init (mutex, attr);
235 }
236
237 int
238 pthread_mutex_lock (pthread_mutex_t * mutex)
239 {
240   return __pthread_mutex_lock (mutex);
241 }
242
243 int
244 pthread_mutex_trylock (pthread_mutex_t * mutex)
245 {
246   return __pthread_mutex_trylock (mutex);
247 }
248
249 int
250 pthread_mutex_unlock (pthread_mutex_t * mutex)
251 {
252   return __pthread_mutex_unlock (mutex);
253 }
254
255 int
256 pthread_mutex_destroy (pthread_mutex_t * mutex)
257 {
258   return __pthread_mutex_destroy (mutex);
259 }
260
261 int
262 pthread_mutex_setprioceiling (pthread_mutex_t * mutex,
263                               int prioceiling, int *old_ceiling)
264 {
265   return __pthread_mutex_setprioceiling (mutex, prioceiling, old_ceiling);
266 }
267
268 int
269 pthread_mutex_getprioceiling (const pthread_mutex_t * mutex, int *prioceiling)
270 {
271   return __pthread_mutex_getprioceiling (mutex, prioceiling);
272 }
273
274
275
276 int
277 pthread_mutexattr_destroy (pthread_mutexattr_t * attr)
278 {
279   return __pthread_mutexattr_destroy (attr);
280 }
281
282 int
283 pthread_mutexattr_getprioceiling (const pthread_mutexattr_t * attr,
284                                   int *prioceiling)
285 {
286   return __pthread_mutexattr_getprioceiling (attr, prioceiling);
287 }
288
289 int
290 pthread_mutexattr_getprotocol (const pthread_mutexattr_t * attr,
291                                int *protocol)
292 {
293   return __pthread_mutexattr_getprotocol (attr, protocol);
294 }
295
296 int
297 pthread_mutexattr_getpshared (const pthread_mutexattr_t * attr, int *pshared)
298 {
299   return __pthread_mutexattr_getpshared (attr, pshared);
300 }
301
302 int
303 pthread_mutexattr_gettype (const pthread_mutexattr_t * attr, int *type)
304 {
305   return __pthread_mutexattr_gettype (attr, type);
306 }
307
308 int
309 pthread_mutexattr_init (pthread_mutexattr_t * attr)
310 {
311   return __pthread_mutexattr_init (attr);
312 }
313
314 int
315 pthread_mutexattr_setprioceiling (pthread_mutexattr_t * attr, int prioceiling)
316 {
317   return __pthread_mutexattr_setprioceiling (attr, prioceiling);
318 }
319
320 int
321 pthread_mutexattr_setprotocol (pthread_mutexattr_t * attr, int protocol)
322 {
323   return __pthread_mutexattr_setprotocol (attr, protocol);
324 }
325
326 int
327 pthread_mutexattr_setpshared (pthread_mutexattr_t * attr, int pshared)
328 {
329   return __pthread_mutexattr_setpshared (attr, pshared);
330 }
331
332 int
333 pthread_mutexattr_settype (pthread_mutexattr_t * attr, int type)
334 {
335   return __pthread_mutexattr_settype (attr, type);
336 }
337
338 /* Synchronisation */
339
340 int
341 pthread_cond_destroy (pthread_cond_t * cond)
342 {
343   return __pthread_cond_destroy (cond);
344 }
345
346 int
347 pthread_cond_init (pthread_cond_t * cond, const pthread_condattr_t * attr)
348 {
349   return __pthread_cond_init (cond, attr);
350 }
351
352 int
353 pthread_cond_signal (pthread_cond_t * cond)
354 {
355   return __pthread_cond_signal (cond);
356 }
357
358 int
359 pthread_cond_broadcast (pthread_cond_t * cond)
360 {
361   return __pthread_cond_broadcast (cond);
362 }
363
364 int
365 pthread_condattr_init (pthread_condattr_t * condattr)
366 {
367   return __pthread_condattr_init (condattr);
368 }
369
370 int
371 pthread_condattr_destroy (pthread_condattr_t * condattr)
372 {
373   return __pthread_condattr_destroy (condattr);
374 }
375
376 int
377 pthread_condattr_getpshared (const pthread_condattr_t * attr, int *pshared)
378 {
379   return __pthread_condattr_getpshared (attr, pshared);
380 }
381
382 int
383 pthread_condattr_setpshared (pthread_condattr_t * attr, int pshared)
384 {
385   return __pthread_condattr_setpshared (attr, pshared);
386 }
387
388 /* Scheduling */
389
390 int
391 pthread_getconcurrency (void)
392 {
393   return __pthread_getconcurrency ();
394 }
395
396 int
397 pthread_setconcurrency (int new_level)
398 {
399   return __pthread_setconcurrency (new_level);
400 }
401
402
403
404
405 int
406 pthread_getschedparam (pthread_t thread, int *policy,
407                        struct sched_param *param)
408 {
409   return __pthread_getschedparam (thread, policy, param);
410 }
411
412 int
413 pthread_setschedparam (pthread_t thread, int policy,
414                        const struct sched_param *param)
415 {
416   return __pthread_setschedparam (thread, policy, param);
417 }
418
419
420 /* Cancelability */
421
422 int
423 pthread_cancel (pthread_t thread)
424 {
425   return __pthread_cancel (thread);
426 }
427
428
429
430 int
431 pthread_setcancelstate (int state, int *oldstate)
432 {
433   return __pthread_setcancelstate (state, oldstate);
434 }
435
436 int
437 pthread_setcanceltype (int type, int *oldtype)
438 {
439   return __pthread_setcanceltype (type, oldtype);
440 }
441
442 void
443 pthread_testcancel (void)
444 {
445   __pthread_testcancel ();
446 }
447
448 /* Semaphores */
449 int
450 sem_init (sem_t * sem, int pshared, unsigned int value)
451 {
452   return __sem_init (sem, pshared, value);
453 }
454
455 int
456 sem_destroy (sem_t * sem)
457 {
458   return __sem_destroy (sem);
459 }
460
461 int
462 sem_wait (sem_t * sem)
463 {
464   return __sem_wait (sem);
465 }
466
467 int
468 sem_trywait (sem_t * sem)
469 {
470   return __sem_trywait (sem);
471 }
472
473 int
474 sem_post (sem_t * sem)
475 {
476   return __sem_post (sem);
477 }
478
479 }