OSDN Git Service

* path.cc (conv_path_list): Take cygwin_conv_path_t as third parameter.
[pf3gnuchains/pf3gnuchains4x.git] / winsup / cygwin / pthread.cc
1 /* pthread.cc: posix pthread interface for Cygwin
2
3    Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2007, 2011 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 /* Spinlocks */
95 int
96 pthread_spin_init (pthread_spinlock_t *spinlock, int pshared)
97 {
98   return pthread_spinlock::init (spinlock, pshared);
99 }
100
101
102 /* Synchronisation */
103 int
104 pthread_cond_init (pthread_cond_t * cond, const pthread_condattr_t * attr)
105 {
106   return pthread_cond::init (cond, attr);
107 }
108
109 /* RW Locks */
110 int
111 pthread_rwlock_init (pthread_rwlock_t *rwlock, const pthread_rwlockattr_t *attr)
112 {
113   return pthread_rwlock::init (rwlock, attr);
114 }
115
116 /* Cancelability */
117
118 int
119 pthread_cancel (pthread_t thread)
120 {
121   return pthread::cancel (thread);
122 }
123
124 int
125 pthread_setcancelstate (int state, int *oldstate)
126 {
127   return pthread::self ()->setcancelstate (state, oldstate);
128 }
129
130 int
131 pthread_setcanceltype (int type, int *oldtype)
132 {
133   return pthread::self ()->setcanceltype (type, oldtype);
134 }
135
136 void
137 pthread_testcancel ()
138 {
139   pthread::self ()->testcancel ();
140 }
141
142 void
143 _pthread_cleanup_push (__pthread_cleanup_handler *handler)
144 {
145   pthread::self ()->push_cleanup_handler (handler);
146 }
147
148 void
149 _pthread_cleanup_pop (int execute)
150 {
151   pthread::self ()->pop_cleanup_handler (execute);
152 }
153
154 /* Semaphores */
155 int
156 sem_init (sem_t * sem, int pshared, unsigned int value)
157 {
158   return semaphore::init (sem, pshared, value);
159 }
160
161 int
162 sem_destroy (sem_t * sem)
163 {
164   return semaphore::destroy (sem);
165 }
166
167 int
168 sem_wait (sem_t * sem)
169 {
170   return semaphore::wait (sem);
171 }
172
173 int
174 sem_trywait (sem_t * sem)
175 {
176   return semaphore::trywait (sem);
177 }
178
179 int
180 sem_timedwait (sem_t * sem, const struct timespec *abstime)
181 {
182   return semaphore::timedwait (sem, abstime);
183 }
184
185 int
186 sem_post (sem_t * sem)
187 {
188   return semaphore::post (sem);
189 }
190
191 int
192 sem_getvalue (sem_t * sem, int *sval)
193 {
194   return semaphore::getvalue (sem, sval);
195 }
196
197 }