xref: /haiku/src/libs/posix_error_mapper/pthread_cond.cpp (revision 2222d0559df303a9846a2fad53741f8b20b14d7c)
1 /*
2  * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3  * Distributed under the terms of the MIT License.
4  */
5 
6 #include <pthread.h>
7 
8 #include "posix_error_mapper.h"
9 
10 
11 WRAPPER_FUNCTION(int, pthread_cond_destroy, (pthread_cond_t *cond),
12 	return B_TO_POSITIVE_ERROR(sReal_pthread_cond_destroy(cond));
13 )
14 
15 
16 WRAPPER_FUNCTION(int, pthread_cond_init, (pthread_cond_t *cond,
17 		const pthread_condattr_t *attr),
18 	return B_TO_POSITIVE_ERROR(sReal_pthread_cond_init(cond, attr));
19 )
20 
21 
22 WRAPPER_FUNCTION(int, pthread_cond_broadcast, (pthread_cond_t *cond),
23 	return B_TO_POSITIVE_ERROR(sReal_pthread_cond_broadcast(cond));
24 )
25 
26 
27 WRAPPER_FUNCTION(int, pthread_cond_signal, (pthread_cond_t *cond),
28 	return B_TO_POSITIVE_ERROR(sReal_pthread_cond_signal(cond));
29 )
30 
31 
32 WRAPPER_FUNCTION(int, pthread_cond_timedwait, (pthread_cond_t *cond,
33 		pthread_mutex_t *mutex, const struct timespec *abstime),
34 	return B_TO_POSITIVE_ERROR(sReal_pthread_cond_timedwait(cond, mutex,
35 		abstime));
36 )
37 
38 
39 WRAPPER_FUNCTION(int, pthread_cond_wait, (pthread_cond_t *cond,
40 		pthread_mutex_t *mutex),
41 	return B_TO_POSITIVE_ERROR(sReal_pthread_cond_wait(cond, mutex));
42 )
43 
44 
45 WRAPPER_FUNCTION(int, pthread_condattr_destroy,
46 		(pthread_condattr_t *condAttr),
47 	return B_TO_POSITIVE_ERROR(sReal_pthread_condattr_destroy(condAttr));
48 )
49 
50 
51 WRAPPER_FUNCTION(int, pthread_condattr_init,
52 		(pthread_condattr_t *condAttr),
53  	return B_TO_POSITIVE_ERROR(sReal_pthread_condattr_init(condAttr));
54 )
55 
56 
57 WRAPPER_FUNCTION(int, pthread_condattr_getpshared,
58 		(const pthread_condattr_t *condAttr, int *processShared),
59 	return B_TO_POSITIVE_ERROR(sReal_pthread_condattr_getpshared(condAttr,
60 		processShared));
61 )
62 
63 
64 WRAPPER_FUNCTION(int, pthread_condattr_setpshared,
65 		(pthread_condattr_t *condAttr, int processShared),
66 	return B_TO_POSITIVE_ERROR(sReal_pthread_condattr_setpshared(condAttr,
67 		processShared));
68 )
69 
70 
71 WRAPPER_FUNCTION(int, pthread_rwlock_init,
72 		(pthread_rwlock_t *lock, const pthread_rwlockattr_t *attr),
73 	return B_TO_POSITIVE_ERROR(sReal_pthread_rwlock_init(lock, attr));
74 )
75 
76 
77 WRAPPER_FUNCTION(int, pthread_rwlock_destroy, (pthread_rwlock_t *lock),
78 	return B_TO_POSITIVE_ERROR(sReal_pthread_rwlock_destroy(lock));
79 )
80 
81 
82 WRAPPER_FUNCTION(int, pthread_rwlock_rdlock, (pthread_rwlock_t *lock),
83 	return B_TO_POSITIVE_ERROR(sReal_pthread_rwlock_rdlock(lock));
84 )
85 
86 
87 WRAPPER_FUNCTION(int, pthread_rwlock_tryrdlock, (pthread_rwlock_t *lock),
88 	return B_TO_POSITIVE_ERROR(sReal_pthread_rwlock_tryrdlock(lock));
89 )
90 
91 
92 WRAPPER_FUNCTION(int, pthread_rwlock_timedrdlock,
93 		(pthread_rwlock_t *lock, const struct timespec *timeout),
94 	return B_TO_POSITIVE_ERROR(sReal_pthread_rwlock_timedrdlock(lock, timeout));
95 )
96 
97 
98 WRAPPER_FUNCTION(int, pthread_rwlock_wrlock, (pthread_rwlock_t *lock),
99 	return B_TO_POSITIVE_ERROR(sReal_pthread_rwlock_wrlock(lock));
100 )
101 
102 
103 WRAPPER_FUNCTION(int, pthread_rwlock_trywrlock, (pthread_rwlock_t *lock),
104 	return B_TO_POSITIVE_ERROR(sReal_pthread_rwlock_trywrlock(lock));
105 )
106 
107 
108 WRAPPER_FUNCTION(int, pthread_rwlock_timedwrlock,
109 		(pthread_rwlock_t *lock, const struct timespec *timeout),
110 	return B_TO_POSITIVE_ERROR(sReal_pthread_rwlock_timedwrlock(lock, timeout));
111 )
112 
113 
114 WRAPPER_FUNCTION(int, pthread_rwlock_unlock, (pthread_rwlock_t *lock),
115 	return B_TO_POSITIVE_ERROR(sReal_pthread_rwlock_unlock(lock));
116 )
117 
118 
119 WRAPPER_FUNCTION(int, pthread_rwlockattr_init,
120 		(pthread_rwlockattr_t *attr),
121 	return B_TO_POSITIVE_ERROR(sReal_pthread_rwlockattr_init(attr));
122 )
123 
124 
125 WRAPPER_FUNCTION(int, pthread_rwlockattr_destroy,
126 		(pthread_rwlockattr_t *attr),
127 	return B_TO_POSITIVE_ERROR(sReal_pthread_rwlockattr_destroy(attr));
128 )
129 
130 
131 WRAPPER_FUNCTION(int, pthread_rwlockattr_getpshared,
132 		(const pthread_rwlockattr_t *attr, int *shared),
133 	return B_TO_POSITIVE_ERROR(sReal_pthread_rwlockattr_getpshared(attr,
134 		shared));
135 )
136 
137 
138 WRAPPER_FUNCTION(int, pthread_rwlockattr_setpshared,
139 		(pthread_rwlockattr_t *attr, int shared),
140 	return B_TO_POSITIVE_ERROR(sReal_pthread_rwlockattr_setpshared(attr,
141 		shared));
142 )
143 
144 
145 WRAPPER_FUNCTION(int, pthread_atfork,
146 		(void (*prepare)(void), void (*parent)(void), void (*child)(void)),
147 	return B_TO_POSITIVE_ERROR(sReal_pthread_atfork(prepare, parent, child));
148 )
149 
150 
151 WRAPPER_FUNCTION(int, pthread_once,
152 		(pthread_once_t *once_control, void (*init_routine)(void)),
153 	return B_TO_POSITIVE_ERROR(sReal_pthread_once(once_control, init_routine));
154 )
155 
156 
157 WRAPPER_FUNCTION(int, pthread_attr_destroy, (pthread_attr_t *attr),
158 	return B_TO_POSITIVE_ERROR(sReal_pthread_attr_destroy(attr));
159 )
160 
161 
162 WRAPPER_FUNCTION(int, pthread_attr_init, (pthread_attr_t *attr),
163 	return B_TO_POSITIVE_ERROR(sReal_pthread_attr_init(attr));
164 )
165 
166 
167 WRAPPER_FUNCTION(int, pthread_attr_getdetachstate,
168 		(const pthread_attr_t *attr, int *detachstate),
169 	return B_TO_POSITIVE_ERROR(sReal_pthread_attr_getdetachstate(attr,
170 		detachstate));
171 )
172 
173 
174 WRAPPER_FUNCTION(int, pthread_attr_setdetachstate,
175 		(pthread_attr_t *attr, int detachstate),
176 	return B_TO_POSITIVE_ERROR(sReal_pthread_attr_setdetachstate(attr,
177 		detachstate));
178 )
179 
180 
181 WRAPPER_FUNCTION(int, pthread_attr_getstacksize,
182 		(const pthread_attr_t *attr, size_t *stacksize),
183 	return B_TO_POSITIVE_ERROR(sReal_pthread_attr_getstacksize(attr,
184 		stacksize));
185 )
186 
187 
188 WRAPPER_FUNCTION(int, pthread_attr_setstacksize,
189 		(pthread_attr_t *attr, size_t stacksize),
190 	return B_TO_POSITIVE_ERROR(sReal_pthread_attr_setstacksize(attr,
191 		stacksize));
192 )
193 
194 
195 WRAPPER_FUNCTION(int, pthread_attr_getscope,
196 		(const pthread_attr_t *attr, int *contentionScope),
197 	return B_TO_POSITIVE_ERROR(sReal_pthread_attr_getscope(attr,
198 		contentionScope));
199 )
200 
201 
202 WRAPPER_FUNCTION(int, pthread_attr_setscope,
203 		(pthread_attr_t *attr, int contentionScope),
204 	return B_TO_POSITIVE_ERROR(sReal_pthread_attr_setscope(attr,
205 		contentionScope));
206 )
207 
208 
209 WRAPPER_FUNCTION(int, pthread_create,
210 		(pthread_t *thread, const pthread_attr_t *attr,
211 			void *(*start_routine)(void*), void *arg),
212 	return B_TO_POSITIVE_ERROR(sReal_pthread_create(thread, attr, start_routine,
213 		arg));
214 )
215 
216 
217 WRAPPER_FUNCTION(int, pthread_detach, (pthread_t thread),
218 	return B_TO_POSITIVE_ERROR(sReal_pthread_detach(thread));
219 )
220 
221 
222 WRAPPER_FUNCTION(int, pthread_join, (pthread_t thread, void **_value),
223 	return B_TO_POSITIVE_ERROR(sReal_pthread_join(thread, _value));
224 )
225 
226 
227 WRAPPER_FUNCTION(int, pthread_kill, (pthread_t thread, int sig),
228 	return B_TO_POSITIVE_ERROR(sReal_pthread_kill(thread, sig));
229 )
230 
231 
232 WRAPPER_FUNCTION(int, pthread_setconcurrency, (int newLevel),
233 	return B_TO_POSITIVE_ERROR(sReal_pthread_setconcurrency(newLevel));
234 )
235 
236 
237 WRAPPER_FUNCTION(int, pthread_cancel, (pthread_t thread),
238 	return B_TO_POSITIVE_ERROR(sReal_pthread_cancel(thread));
239 )
240 
241 
242 WRAPPER_FUNCTION(int, pthread_setcancelstate,
243 		(int state, int *_oldState),
244 	return B_TO_POSITIVE_ERROR(sReal_pthread_setcancelstate(state, _oldState));
245 )
246 
247 
248 WRAPPER_FUNCTION(int, pthread_setcanceltype, (int type, int *_oldType),
249 	return B_TO_POSITIVE_ERROR(sReal_pthread_setcanceltype(type, _oldType));
250 )
251 
252 
253 WRAPPER_FUNCTION(int, pthread_key_create,
254 		(pthread_key_t *key, void (*destructorFunc)(void*)),
255 	return B_TO_POSITIVE_ERROR(sReal_pthread_key_create(key, destructorFunc));
256 )
257 
258 
259 WRAPPER_FUNCTION(int, pthread_key_delete, (pthread_key_t key),
260 	return B_TO_POSITIVE_ERROR(sReal_pthread_key_delete(key));
261 )
262 
263 
264 WRAPPER_FUNCTION(int, pthread_setspecific,
265 		(pthread_key_t key, const void *value),
266 	return B_TO_POSITIVE_ERROR(sReal_pthread_setspecific(key, value));
267 )
268