[FIX] app segfault if OPT_NETWORK_ALWAYS enabled
[platform/core/system/swap-probe.git] / probe_thread / libdasync.c
1 /*
2  *  DA probe
3  *
4  * Copyright 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact:
7  *
8  * Woojin Jung <woojin2.jung@samsung.com>
9  * Jaewon Lim <jaewon81.lim@samsung.com>
10  * Juyoung Kim <j0.kim@samsung.com>
11  * Anastasia Lyupa <a.lyupa@samsung.com>
12  *
13  * This library is free software; you can redistribute it and/or modify it under
14  * the terms of the GNU Lesser General Public License as published by the
15  * Free Software Foundation; either version 2.1 of the License, or (at your option)
16  * any later version.
17  *
18  * This library is distributed in the hope that it will be useful, but WITHOUT ANY
19  * WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
21  * License for more details.
22  *
23  * You should have received a copy of the GNU Lesser General Public License
24  * along with this library; if not, write to the Free Software Foundation, Inc., 51
25  * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
26  *
27  * Contributors:
28  * - S-Core Co., Ltd
29  * - Samsung RnD Institute Russia
30  *
31  */
32
33 #include <pthread.h>
34 #include <time.h>
35 #include <errno.h>
36 #include "daprobe.h"
37 #include "probeinfo.h"
38 #include "dahelper.h"
39 #include "da_sync.h"
40
41 #include "binproto.h"
42
43 static enum DaOptions _sopt = OPT_THREAD;
44
45 int pthread_mutex_init(pthread_mutex_t *mutex,
46                 const pthread_mutexattr_t *attr) {
47         static int (*pthread_mutex_initp)(pthread_mutex_t *mutex,
48                         const pthread_mutexattr_t *attr);
49
50         BEFORE_ORIGINAL_SYNC(pthread_mutex_init, LIBPTHREAD);
51
52         ret = pthread_mutex_initp(mutex, attr);
53
54         AFTER_PACK_ORIGINAL_SYNC(API_ID_pthread_mutex_init,
55                                  'd', ret, mutex, SYNC_PTHREAD_MUTEX,
56                                  SYNC_API_OTHER, "pp",
57                                  voidp_to_uint64(mutex), voidp_to_uint64(attr));
58
59         return ret;
60 }
61
62 int pthread_mutex_destroy(pthread_mutex_t *mutex) {
63         static int (*pthread_mutex_destroyp)(pthread_mutex_t *mutex);
64
65         BEFORE_ORIGINAL_SYNC(pthread_mutex_destroy, LIBPTHREAD);
66
67         ret = pthread_mutex_destroyp(mutex);
68
69         AFTER_PACK_ORIGINAL_SYNC(API_ID_pthread_mutex_destroy,
70                                  'd', ret, mutex, SYNC_PTHREAD_MUTEX,
71                                  SYNC_API_OTHER, "p", voidp_to_uint64(mutex));
72
73         return ret;
74 }
75
76 int real_pthread_mutex_lock(pthread_mutex_t *mutex) {
77         static int (*pthread_mutex_lockp)(pthread_mutex_t *mutex);
78
79         GET_REAL_FUNC(pthread_mutex_lock, LIBPTHREAD);
80
81         return pthread_mutex_lockp(mutex);
82 }
83
84 int pthread_mutex_lock(pthread_mutex_t *mutex) {
85         static int (*pthread_mutex_lockp)(pthread_mutex_t *mutex);
86
87         DECLARE_VARIABLE_STANDARD;
88         GET_REAL_FUNC(pthread_mutex_lock, LIBPTHREAD);
89
90         PRE_PROBEBLOCK_BEGIN();
91
92         PREPARE_LOCAL_BUF();
93         PACK_COMMON_BEGIN(MSG_PROBE_SYNC,
94                           API_ID_pthread_mutex_lock,
95                           "p", voidp_to_uint64(mutex));
96         PACK_COMMON_END('d', 0, 0, blockresult);
97         PACK_SYNC(mutex, SYNC_PTHREAD_MUTEX, SYNC_API_ACQUIRE_WAIT_START);
98         FLUSH_LOCAL_BUF();
99
100         PRE_PROBEBLOCK_END();
101
102         ret = pthread_mutex_lockp(mutex);
103
104         // send WAIT_END log
105         newerrno = errno;
106         if(postBlockBegin(blockresult)) {
107                 setProbePoint(&probeInfo);
108
109                 PREPARE_LOCAL_BUF();
110                 PACK_COMMON_BEGIN(MSG_PROBE_SYNC,
111                                   API_ID_pthread_mutex_lock,
112                                   "p", voidp_to_uint64(mutex));
113                 PACK_COMMON_END('p', ret, errno, blockresult);
114                 PACK_SYNC(mutex, SYNC_PTHREAD_MUTEX, SYNC_API_ACQUIRE_WAIT_END);
115                 FLUSH_LOCAL_BUF();
116
117                 postBlockEnd();
118         }
119
120         return ret;
121 }
122
123 int pthread_mutex_timedlock(pthread_mutex_t *mutex,
124                 const struct timespec *abs_timeout) {
125         static int (*pthread_mutex_timedlockp)(pthread_mutex_t *mutex,
126                         const struct timespec *abs_timeout);
127
128         DECLARE_VARIABLE_STANDARD;
129         GET_REAL_FUNC(pthread_mutex_timedlock, LIBPTHREAD);
130
131         PRE_PROBEBLOCK_BEGIN();
132
133         PREPARE_LOCAL_BUF();
134         PACK_COMMON_BEGIN(MSG_PROBE_SYNC,
135                           API_ID_pthread_mutex_timedlock,
136                           "pp", voidp_to_uint64(mutex),
137                           voidp_to_uint64(abs_timeout));
138         PACK_COMMON_END('d', 0, 0, blockresult);
139         PACK_SYNC(mutex, SYNC_PTHREAD_MUTEX, SYNC_API_ACQUIRE_WAIT_START);
140         FLUSH_LOCAL_BUF();
141
142         PRE_PROBEBLOCK_END();
143
144         ret = pthread_mutex_timedlockp(mutex, abs_timeout);
145
146         // send WAIT_END log
147         newerrno = errno;
148         if(postBlockBegin(blockresult)) {
149                 setProbePoint(&probeInfo);
150
151                 PREPARE_LOCAL_BUF();
152                 PACK_COMMON_BEGIN(MSG_PROBE_SYNC,
153                                   API_ID_pthread_mutex_timedlock,
154                                   "pp", voidp_to_uint64(mutex),
155                                   voidp_to_uint64(abs_timeout));
156                 PACK_COMMON_END('d', ret, errno, blockresult);
157                 PACK_SYNC(mutex, SYNC_PTHREAD_MUTEX, SYNC_API_ACQUIRE_WAIT_END);
158                 FLUSH_LOCAL_BUF();
159
160                 postBlockEnd();
161         }
162
163         return ret;
164 }
165
166 int pthread_mutex_trylock(pthread_mutex_t *mutex) {
167         static int (*pthread_mutex_trylockp)(pthread_mutex_t *mutex);
168
169         BEFORE_ORIGINAL_SYNC(pthread_mutex_trylock, LIBPTHREAD);
170
171         ret = pthread_mutex_trylockp(mutex);
172
173         AFTER_PACK_ORIGINAL_SYNC(API_ID_pthread_mutex_trylock,
174                                  'd', ret, mutex, SYNC_PTHREAD_MUTEX,
175                                  SYNC_API_TRY_ACQUIRE, "p",
176                                  voidp_to_uint64(mutex));
177
178         return ret;
179 }
180
181 int real_pthread_mutex_unlock(pthread_mutex_t *mutex) {
182         static int (*pthread_mutex_unlockp)(pthread_mutex_t *mutex);
183
184         GET_REAL_FUNC(pthread_mutex_unlock, LIBPTHREAD);
185
186         return pthread_mutex_unlockp(mutex);
187 }
188
189 int pthread_mutex_unlock(pthread_mutex_t *mutex) {
190         static int (*pthread_mutex_unlockp)(pthread_mutex_t *mutex);
191
192         BEFORE_ORIGINAL_SYNC(pthread_mutex_unlock, LIBPTHREAD);
193
194         ret = pthread_mutex_unlockp(mutex);
195
196         AFTER_PACK_ORIGINAL_SYNC(API_ID_pthread_mutex_unlock,
197                                  'd', ret, mutex, SYNC_PTHREAD_MUTEX,
198                                  SYNC_API_RELEASE, "p",
199                                  voidp_to_uint64(mutex));
200
201         return ret;
202 }
203
204 int pthread_mutexattr_init(pthread_mutexattr_t *attr) {
205         static int (*pthread_mutexattr_initp)(pthread_mutexattr_t *attr);
206
207         BEFORE_ORIGINAL_SYNC(pthread_mutexattr_init, LIBPTHREAD);
208
209         ret = pthread_mutexattr_initp(attr);
210
211         AFTER_PACK_ORIGINAL_SYNC(API_ID_pthread_mutexattr_init,
212                                  'd', ret, 0, SYNC_PTHREAD_MUTEX,
213                                  SYNC_API_OTHER, "p",
214                                  voidp_to_uint64(attr));
215
216         return ret;
217 }
218
219 int pthread_mutexattr_destroy(pthread_mutexattr_t *attr) {
220         static int (*pthread_mutexattr_destroyp)(pthread_mutexattr_t *attr);
221
222         BEFORE_ORIGINAL_SYNC(pthread_mutexattr_destroy, LIBPTHREAD);
223
224         ret = pthread_mutexattr_destroyp(attr);
225
226         AFTER_PACK_ORIGINAL_SYNC(API_ID_pthread_mutexattr_destroy,
227                                  'd', ret, 0, SYNC_PTHREAD_MUTEX,
228                                  SYNC_API_OTHER, "p",
229                                  voidp_to_uint64(attr));
230
231         return ret;
232 }
233
234 int pthread_mutexattr_getprioceiling(const pthread_mutexattr_t *attr,
235                 int *prioceiling) {
236         static int (*pthread_mutexattr_getprioceilingp)(
237                         const pthread_mutexattr_t *attr, int *prioceiling);
238
239         BEFORE_ORIGINAL_SYNC(pthread_mutexattr_getprioceiling, LIBPTHREAD);
240
241         ret = pthread_mutexattr_getprioceilingp(attr, prioceiling);
242
243         AFTER_PACK_ORIGINAL_SYNC(API_ID_pthread_mutexattr_getprioceiling,
244                                  'd', ret, 0, SYNC_PTHREAD_MUTEX,
245                                  SYNC_API_OTHER, "pp",
246                                  voidp_to_uint64(attr),
247                                  voidp_to_uint64(prioceiling));
248
249         return ret;
250 }
251
252 int pthread_mutexattr_setprioceiling(pthread_mutexattr_t *attr,
253                 int prioceiling) {
254         static int (*pthread_mutexattr_setprioceilingp)(
255                         pthread_mutexattr_t *attr, int prioceiling);
256
257         BEFORE_ORIGINAL_SYNC(pthread_mutexattr_setprioceiling, LIBPTHREAD);
258
259         ret = pthread_mutexattr_setprioceilingp(attr, prioceiling);
260
261         AFTER_PACK_ORIGINAL_SYNC(API_ID_pthread_mutexattr_setprioceiling,
262                                  'd', ret, 0, SYNC_PTHREAD_MUTEX,
263                                  SYNC_API_OTHER, "pd", voidp_to_uint64(attr),
264                                  prioceiling);
265
266         return ret;
267 }
268
269 int pthread_mutexattr_getprotocol(const pthread_mutexattr_t *attr,
270                 int *protocol) {
271         static int (*pthread_mutexattr_getprotocolp)(
272                         const pthread_mutexattr_t *attr, int *protocol);
273
274         BEFORE_ORIGINAL_SYNC(pthread_mutexattr_getprotocol, LIBPTHREAD);
275
276         ret = pthread_mutexattr_getprotocolp(attr, protocol);
277
278         AFTER_PACK_ORIGINAL_SYNC(API_ID_pthread_mutexattr_getprotocol,
279                                  'd', ret, 0, SYNC_PTHREAD_MUTEX,
280                                  SYNC_API_OTHER, "pp",
281                                  voidp_to_uint64(attr),
282                                  voidp_to_uint64(protocol));
283
284         return ret;
285 }
286
287 int pthread_mutexattr_setprotocol(pthread_mutexattr_t *attr,
288                 int protocol) {
289         static int (*pthread_mutexattr_setprotocolp)(
290                         pthread_mutexattr_t *attr, int protocol);
291
292         BEFORE_ORIGINAL_SYNC(pthread_mutexattr_setprotocol, LIBPTHREAD);
293
294         ret = pthread_mutexattr_setprotocolp(attr, protocol);
295
296         AFTER_PACK_ORIGINAL_SYNC(API_ID_pthread_mutexattr_setprotocol,
297                                  'd', ret, 0, SYNC_PTHREAD_MUTEX,
298                                  SYNC_API_OTHER, "pd", voidp_to_uint64(attr),
299                                  protocol);
300
301         return ret;
302 }
303
304 int pthread_mutexattr_getpshared(const pthread_mutexattr_t *attr,
305                 int *pshared) {
306         static int (*pthread_mutexattr_getpsharedp)(
307                         const pthread_mutexattr_t *attr, int *pshared);
308
309         BEFORE_ORIGINAL_SYNC(pthread_mutexattr_getpshared, LIBPTHREAD);
310
311         ret = pthread_mutexattr_getpsharedp(attr, pshared);
312
313         AFTER_PACK_ORIGINAL_SYNC(API_ID_pthread_mutexattr_getpshared,
314                                  'd', ret, 0, SYNC_PTHREAD_MUTEX,
315                                  SYNC_API_OTHER, "pp",
316                                  voidp_to_uint64(attr),
317                                  voidp_to_uint64(pshared));
318
319         return ret;
320 }
321
322 int pthread_mutexattr_setpshared(pthread_mutexattr_t *attr,
323                 int pshared) {
324         static int (*pthread_mutexattr_setpsharedp)(
325                         pthread_mutexattr_t *attr, int pshared);
326
327         BEFORE_ORIGINAL_SYNC(pthread_mutexattr_setpshared, LIBPTHREAD);
328
329         ret = pthread_mutexattr_setpsharedp(attr, pshared);
330
331         AFTER_PACK_ORIGINAL_SYNC(API_ID_pthread_mutexattr_setpshared,
332                                  'd', ret, 0, SYNC_PTHREAD_MUTEX,
333                                  SYNC_API_OTHER, "pd", voidp_to_uint64(attr),
334                                  pshared);
335
336         return ret;
337 }
338
339 int pthread_mutexattr_gettype(const pthread_mutexattr_t *attr, int *type) {
340         static int (*pthread_mutexattr_gettypep)(
341                         const pthread_mutexattr_t *attr, int *type);
342
343         BEFORE_ORIGINAL_SYNC(pthread_mutexattr_gettype, LIBPTHREAD);
344
345         ret = pthread_mutexattr_gettypep(attr, type);
346
347         AFTER_PACK_ORIGINAL_SYNC(API_ID_pthread_mutexattr_gettype,
348                                  'd', ret, 0, SYNC_PTHREAD_MUTEX,
349                                  SYNC_API_OTHER, "pp",
350                                  voidp_to_uint64(attr),
351                                  voidp_to_uint64(type));
352
353         return ret;
354 }
355
356 int pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type) {
357         static int (*pthread_mutexattr_settypep)(
358                         pthread_mutexattr_t *attr, int type);
359
360         BEFORE_ORIGINAL_SYNC(pthread_mutexattr_settype, LIBPTHREAD);
361
362         ret = pthread_mutexattr_settypep(attr, type);
363
364         AFTER_PACK_ORIGINAL_SYNC(API_ID_pthread_mutexattr_settype,
365                                  'd', ret, 0, SYNC_PTHREAD_MUTEX,
366                                  SYNC_API_OTHER, "pd",
367                                  voidp_to_uint64(attr),
368                                  type);
369
370         return ret;
371 }
372
373 /*
374 int pthread_mutex_getprioceiling(const pthread_mutex_t *mutex,
375                 int *prioceiling);
376 int pthread_mutex_setprioceiling(pthread_mutex_t *mutex,
377                 int prioceiling, int *old_ceiling);
378 */
379
380 int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr) {
381         static int (*pthread_cond_initp)(pthread_cond_t *cond,
382                         const pthread_condattr_t *attr);
383
384         BEFORE_ORIGINAL_SYNC(pthread_cond_init, LIBPTHREAD);
385
386         ret = pthread_cond_initp(cond, attr);
387
388         AFTER_PACK_ORIGINAL_SYNC(API_ID_pthread_cond_init,
389                                  'd', ret, cond, SYNC_PTHREAD_COND_VARIABLE,
390                                  SYNC_API_OTHER, "pp",
391                                  voidp_to_uint64(cond),
392                                  voidp_to_uint64(attr));
393
394         return ret;
395 }
396
397 int pthread_cond_destroy(pthread_cond_t *cond) {
398         static int (*pthread_cond_destroyp)(pthread_cond_t *cond);
399
400         BEFORE_ORIGINAL_SYNC(pthread_cond_destroy, LIBPTHREAD);
401
402         ret = pthread_cond_destroyp(cond);
403
404         AFTER_PACK_ORIGINAL_SYNC(API_ID_pthread_cond_destroy,
405                                  'd', ret, cond, SYNC_PTHREAD_COND_VARIABLE,
406                                  SYNC_API_OTHER, "p",
407                                  voidp_to_uint64(cond));
408
409         return ret;
410 }
411
412 int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex) {
413         static int (*pthread_cond_waitp)(pthread_cond_t *cond,
414                         pthread_mutex_t *mutex);
415
416         DECLARE_VARIABLE_STANDARD;
417         GET_REAL_FUNC(pthread_cond_wait, LIBPTHREAD);
418
419         PRE_PROBEBLOCK_BEGIN();
420         // send WAIT_START log
421
422         PREPARE_LOCAL_BUF();
423         PACK_COMMON_BEGIN(MSG_PROBE_SYNC,
424                           API_ID_pthread_cond_wait,
425                           "pp",
426                           voidp_to_uint64(cond),
427                           voidp_to_uint64(mutex));
428         PACK_COMMON_END('d', 0, 0, blockresult);
429         PACK_SYNC(cond, SYNC_PTHREAD_COND_VARIABLE, SYNC_API_COND_WAIT_START);
430         FLUSH_LOCAL_BUF();
431
432         PRE_PROBEBLOCK_END();
433
434         ret = pthread_cond_waitp(cond, mutex);
435
436         // send WAIT_END log
437         newerrno = errno;
438         if(postBlockBegin(blockresult)) {
439                 setProbePoint(&probeInfo);
440
441                 PREPARE_LOCAL_BUF();
442                 PACK_COMMON_BEGIN(MSG_PROBE_SYNC,
443                                   API_ID_pthread_cond_wait,
444                                   "pp",
445                                   voidp_to_uint64(cond),
446                                   voidp_to_uint64(mutex));
447                 PACK_COMMON_END('d', ret, errno, blockresult);
448                 PACK_SYNC(cond, SYNC_PTHREAD_COND_VARIABLE, SYNC_API_COND_WAIT_END);
449                 FLUSH_LOCAL_BUF();
450
451                 postBlockEnd();
452         }
453
454         return ret;
455 }
456
457 int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
458                 const struct timespec *abstime) {
459         static int (*pthread_cond_timedwaitp)(pthread_cond_t *cond,
460                                 pthread_mutex_t *mutex, const struct timespec *abstime);
461
462         DECLARE_VARIABLE_STANDARD;
463         GET_REAL_FUNC(pthread_cond_timedwait, LIBPTHREAD);
464
465         PRE_PROBEBLOCK_BEGIN();
466         // send WAIT_START log
467
468         PREPARE_LOCAL_BUF();
469         PACK_COMMON_BEGIN(MSG_PROBE_SYNC,
470                           API_ID_pthread_cond_timedwait,
471                           "ppp",
472                           voidp_to_uint64(cond),
473                           voidp_to_uint64(mutex),
474                           voidp_to_uint64(abstime));
475         PACK_COMMON_END('d', 0, 0, blockresult);
476         PACK_SYNC(cond, SYNC_PTHREAD_COND_VARIABLE, SYNC_API_COND_WAIT_START);
477         FLUSH_LOCAL_BUF();
478
479         PRE_PROBEBLOCK_END();
480
481         ret = pthread_cond_timedwaitp(cond, mutex, abstime);
482
483         // send WAIT_END log
484         newerrno = errno;
485         if(postBlockBegin(blockresult)) {
486                 setProbePoint(&probeInfo);
487
488                 PREPARE_LOCAL_BUF();
489                 PACK_COMMON_BEGIN(MSG_PROBE_SYNC,
490                                   API_ID_pthread_cond_timedwait,
491                                   "ppp",
492                                   voidp_to_uint64(cond),
493                                   voidp_to_uint64(mutex),
494                                   voidp_to_uint64(abstime));
495                 PACK_COMMON_END('d', ret, errno, blockresult);
496                 PACK_SYNC(cond, SYNC_PTHREAD_COND_VARIABLE, SYNC_API_COND_WAIT_END);
497                 FLUSH_LOCAL_BUF();
498
499                 postBlockEnd();
500         }
501
502         return ret;
503 }
504
505 int pthread_cond_signal(pthread_cond_t *cond) {
506         static int (*pthread_cond_signalp)(pthread_cond_t *cond);
507
508         BEFORE_ORIGINAL_SYNC(pthread_cond_signal, LIBPTHREAD);
509
510         ret = pthread_cond_signalp(cond);
511
512         AFTER_PACK_ORIGINAL_SYNC(API_ID_pthread_cond_signal,
513                                  'd', ret, cond, SYNC_PTHREAD_COND_VARIABLE,
514                                  SYNC_API_NOTIFY, "p", voidp_to_uint64(cond));
515
516         return ret;
517 }
518
519 int pthread_cond_broadcast(pthread_cond_t *cond) {
520         static int (*pthread_cond_broadcastp)(pthread_cond_t *cond);
521
522         BEFORE_ORIGINAL_SYNC(pthread_cond_broadcast, LIBPTHREAD);
523
524         ret = pthread_cond_broadcastp(cond);
525
526         AFTER_PACK_ORIGINAL_SYNC(API_ID_pthread_cond_broadcast,
527                                  'd', ret, cond, SYNC_PTHREAD_COND_VARIABLE,
528                                  SYNC_API_NOTIFY_ALL, "p", voidp_to_uint64(cond));
529
530         return ret;
531 }
532
533 /*
534 int pthread_condattr_init(pthread_condattr_t *attr);
535 int pthread_condattr_destroy(pthread_condattr_t *attr);
536 int pthread_condattr_getclock(const pthread_condattr_t *attr,
537                 clockid_t *clock_id);
538 int pthread_condattr_setclock(pthread_condattr_t *attr,
539                 clockid_t clock_id);
540 int pthread_condattr_getpshared(const pthread_condattr_t *attr, int *pshared);
541 int pthread_condattr_setpshared(pthread_condattr_t *attr, int pshared);
542 */
543
544 /*
545 int pthread_rwlock_init(pthread_rwlock_t *rwlock,
546                 const pthread_rwlockattr_t *attr);
547 int pthread_rwlock_destroy(pthread_rwlock_t *rwlock);
548 int pthread_rwlock_rdlock(pthread_rwlock_t *rwlock);
549 int pthread_rwlock_wrlock(pthread_rwlock_t *rwlock);
550 int pthread_rwlock_timedrdlock(pthread_rwlock_t *rwlock,
551                 const struct timespec *abs_timeout);
552 int pthread_rwlock_timedwrlock(pthread_rwlock_t *rwlock,
553                 const struct timespec *abs_timeout);
554 int pthread_rwlock_tryrdlock(pthread_rwlock_t *rwlock);
555 int pthread_rwlock_trywrlock(pthread_rwlock_t *rwlock);
556 int pthread_rwlock_unlock(pthread_rwlock_t *rwlock);
557 int pthread_rwlockattr_init(pthread_rwlockattr_t *attr);
558 int pthread_rwlockattr_destroy(pthread_rwlockattr_t *attr);
559 int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t *attr,
560                 int *pshared);
561 int pthread_rwlockattr_setpshared(pthread_rwlockattr_t *attr,
562                 int pshared);
563
564 int pthread_spin_init(pthread_spinlock_t *lock, int pshared);
565 int pthread_spin_destroy(pthread_spinlock_t *lock);
566 int pthread_spin_lock(pthread_spinlock_t *lock);
567 int pthread_spin_trylock(pthread_spinlock_t *lock);
568 int pthread_spin_unlock(pthread_spinlock_t *lock);
569
570 int pthread_barrier_init(pthread_barrier_t *barrier,
571                 const pthread_barrierattr_t *attr, unsigned int count);
572 int pthread_barrier_destroy(pthread_barrier_t *barrier);
573 int pthread_barrier_wait(pthread_barrier_t *barrier);
574 int pthread_barrierattr_init(pthread_barrierattr_t *attr);
575 int pthread_barrierattr_destroy(pthread_barrierattr_t *attr);
576 int pthread_barrierattr_getpshared(const pthread_barrierattr_t *attr,
577                 int *pshared);
578 int pthread_barrierattr_setpshared(pthread_barrierattr_t,
579                 int pshared);
580 */
581