OSDN Git Service

gas/opcodes: blackfin: move dsp mac func defines to common header
[pf3gnuchains/sourceware.git] / winsup / cygwin / pthread.cc
1 /* pthread.cc: posix pthread interface for Cygwin
2
3    Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2007 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 /* Thread Exit */
39 void
40 pthread_exit (void *value_ptr)
41 {
42   return pthread::self ()->exit (value_ptr);
43 }
44
45 int
46 pthread_join (pthread_t thread, void **return_val)
47 {
48   return pthread::join (&thread, (void **) return_val);
49 }
50
51 int
52 pthread_detach (pthread_t thread)
53 {
54   return pthread::detach (&thread);
55 }
56
57
58 /* This isn't a posix call... should we keep it? */
59 int
60 pthread_suspend (pthread_t thread)
61 {
62   return pthread::suspend (&thread);
63 }
64
65 /* same */
66 int
67 pthread_continue (pthread_t thread)
68 {
69   return pthread::resume (&thread);
70 }
71
72 unsigned long
73 pthread_getsequence_np (pthread_t * thread)
74 {
75   if (!pthread::is_good_object (thread))
76     return EINVAL;
77   return (*thread)->getsequence_np ();
78 }
79
80 /*  ID */
81
82 pthread_t pthread_self ()
83 {
84   return pthread::self ();
85 }
86
87 /* Mutexes  */
88 int
89 pthread_mutex_init (pthread_mutex_t * mutex, const pthread_mutexattr_t * attr)
90 {
91   return pthread_mutex::init (mutex, attr, NULL);
92 }
93
94 /* Synchronisation */
95 int
96 pthread_cond_init (pthread_cond_t * cond, const pthread_condattr_t * attr)
97 {
98   return pthread_cond::init (cond, attr);
99 }
100
101 /* RW Locks */
102 int
103 pthread_rwlock_init (pthread_rwlock_t *rwlock, const pthread_rwlockattr_t *attr)
104 {
105   return pthread_rwlock::init (rwlock, attr);
106 }
107
108 /* Cancelability */
109
110 int
111 pthread_cancel (pthread_t thread)
112 {
113   return pthread::cancel (thread);
114 }
115
116 int
117 pthread_setcancelstate (int state, int *oldstate)
118 {
119   return pthread::self ()->setcancelstate (state, oldstate);
120 }
121
122 int
123 pthread_setcanceltype (int type, int *oldtype)
124 {
125   return pthread::self ()->setcanceltype (type, oldtype);
126 }
127
128 void
129 pthread_testcancel ()
130 {
131   pthread::self ()->testcancel ();
132 }
133
134 void
135 _pthread_cleanup_push (__pthread_cleanup_handler *handler)
136 {
137   pthread::self ()->push_cleanup_handler (handler);
138 }
139
140 void
141 _pthread_cleanup_pop (int execute)
142 {
143   pthread::self ()->pop_cleanup_handler (execute);
144 }
145
146 /* Semaphores */
147 int
148 sem_init (sem_t * sem, int pshared, unsigned int value)
149 {
150   return semaphore::init (sem, pshared, value);
151 }
152
153 int
154 sem_destroy (sem_t * sem)
155 {
156   return semaphore::destroy (sem);
157 }
158
159 int
160 sem_wait (sem_t * sem)
161 {
162   return semaphore::wait (sem);
163 }
164
165 int
166 sem_trywait (sem_t * sem)
167 {
168   return semaphore::trywait (sem);
169 }
170
171 int
172 sem_timedwait (sem_t * sem, const struct timespec *abstime)
173 {
174   return semaphore::timedwait (sem, abstime);
175 }
176
177 int
178 sem_post (sem_t * sem)
179 {
180   return semaphore::post (sem);
181 }
182
183 int
184 sem_getvalue (sem_t * sem, int *sval)
185 {
186   return semaphore::getvalue (sem, sval);
187 }
188
189 }