4 * Copyright 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
8 * Woojin Jung <woojin2.jung@samsung.com>
9 * Jaewon Lim <jaewon81.lim@samsung.com>
10 * Juyoung Kim <j0.kim@samsung.com>
12 * This library is free software; you can redistribute it and/or modify it under
13 * the terms of the GNU Lesser General Public License as published by the
14 * Free Software Foundation; either version 2.1 of the License, or (at your option)
17 * This library is distributed in the hope that it will be useful, but WITHOUT ANY
18 * WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
20 * License for more details.
22 * You should have received a copy of the GNU Lesser General Public License
23 * along with this library; if not, write to the Free Software Foundation, Inc., 51
24 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
35 #include "probeinfo.h"
41 static enum DaOptions _sopt = OPT_THREAD;
43 int pthread_mutex_init(pthread_mutex_t *mutex,
44 const pthread_mutexattr_t *attr) {
45 static int (*pthread_mutex_initp)(pthread_mutex_t *mutex,
46 const pthread_mutexattr_t *attr);
48 BEFORE_ORIGINAL_SYNC(pthread_mutex_init, LIBPTHREAD);
50 ret = pthread_mutex_initp(mutex, attr);
52 AFTER_PACK_ORIGINAL_SYNC(ret, mutex, SYNC_PTHREAD_MUTEX,
53 SYNC_API_OTHER, "pp", mutex, attr);
58 int pthread_mutex_destroy(pthread_mutex_t *mutex) {
59 static int (*pthread_mutex_destroyp)(pthread_mutex_t *mutex);
61 BEFORE_ORIGINAL_SYNC(pthread_mutex_destroy, LIBPTHREAD);
63 ret = pthread_mutex_destroyp(mutex);
65 AFTER_PACK_ORIGINAL_SYNC(ret, mutex, SYNC_PTHREAD_MUTEX,
66 SYNC_API_OTHER, "p", mutex);
71 int real_pthread_mutex_lock(pthread_mutex_t *mutex) {
72 static int (*pthread_mutex_lockp)(pthread_mutex_t *mutex);
74 GET_REAL_FUNC(pthread_mutex_lock, LIBPTHREAD);
76 return pthread_mutex_lockp(mutex);
79 int pthread_mutex_lock(pthread_mutex_t *mutex) {
80 static int (*pthread_mutex_lockp)(pthread_mutex_t *mutex);
82 DECLARE_VARIABLE_STANDARD;
83 GET_REAL_FUNC(pthread_mutex_lock, LIBPTHREAD);
85 PRE_PROBEBLOCK_BEGIN();
88 PACK_COMMON_BEGIN(MSG_PROBE_SYNC, LC_SYNC, "p", mutex);
89 PACK_COMMON_END(0, 0, blockresult);
90 PACK_SYNC(mutex, SYNC_PTHREAD_MUTEX, SYNC_API_ACQUIRE_WAIT_START);
95 ret = pthread_mutex_lockp(mutex);
99 if(postBlockBegin(blockresult)) {
100 setProbePoint(&probeInfo);
103 PACK_COMMON_BEGIN(MSG_PROBE_SYNC, LC_SYNC, "p", mutex);
104 PACK_COMMON_END(ret, errno, blockresult);
105 PACK_SYNC(mutex, SYNC_PTHREAD_MUTEX, SYNC_API_ACQUIRE_WAIT_END);
114 int pthread_mutex_timedlock(pthread_mutex_t *mutex,
115 const struct timespec *abs_timeout) {
116 static int (*pthread_mutex_timedlockp)(pthread_mutex_t *mutex,
117 const struct timespec *abs_timeout);
119 DECLARE_VARIABLE_STANDARD;
120 GET_REAL_FUNC(pthread_mutex_timedlock, LIBPTHREAD);
122 PRE_PROBEBLOCK_BEGIN();
125 PACK_COMMON_BEGIN(MSG_PROBE_SYNC, LC_SYNC, "pp", mutex, abs_timeout);
126 PACK_COMMON_END(0, 0, blockresult);
127 PACK_SYNC(mutex, SYNC_PTHREAD_MUTEX, SYNC_API_ACQUIRE_WAIT_START);
130 PRE_PROBEBLOCK_END();
132 ret = pthread_mutex_timedlockp(mutex, abs_timeout);
136 if(postBlockBegin(blockresult)) {
137 setProbePoint(&probeInfo);
140 PACK_COMMON_BEGIN(MSG_PROBE_SYNC, LC_SYNC, "pp", mutex, abs_timeout);
141 PACK_COMMON_END(ret, errno, blockresult);
142 PACK_SYNC(mutex, SYNC_PTHREAD_MUTEX, SYNC_API_ACQUIRE_WAIT_END);
151 int pthread_mutex_trylock(pthread_mutex_t *mutex) {
152 static int (*pthread_mutex_trylockp)(pthread_mutex_t *mutex);
154 BEFORE_ORIGINAL_SYNC(pthread_mutex_trylock, LIBPTHREAD);
156 ret = pthread_mutex_trylockp(mutex);
158 AFTER_PACK_ORIGINAL_SYNC(ret, mutex, SYNC_PTHREAD_MUTEX,
159 SYNC_API_TRY_ACQUIRE, "p", mutex);
164 int real_pthread_mutex_unlock(pthread_mutex_t *mutex) {
165 static int (*pthread_mutex_unlockp)(pthread_mutex_t *mutex);
167 GET_REAL_FUNC(pthread_mutex_unlock, LIBPTHREAD);
169 return pthread_mutex_unlockp(mutex);
172 int pthread_mutex_unlock(pthread_mutex_t *mutex) {
173 static int (*pthread_mutex_unlockp)(pthread_mutex_t *mutex);
175 BEFORE_ORIGINAL_SYNC(pthread_mutex_unlock, LIBPTHREAD);
177 ret = pthread_mutex_unlockp(mutex);
179 AFTER_PACK_ORIGINAL_SYNC(ret, mutex, SYNC_PTHREAD_MUTEX,
180 SYNC_API_RELEASE, "p", mutex);
185 int pthread_mutexattr_init(pthread_mutexattr_t *attr) {
186 static int (*pthread_mutexattr_initp)(pthread_mutexattr_t *attr);
188 BEFORE_ORIGINAL_SYNC(pthread_mutexattr_init, LIBPTHREAD);
190 ret = pthread_mutexattr_initp(attr);
192 AFTER_PACK_ORIGINAL_SYNC(ret, 0, SYNC_PTHREAD_MUTEX,
193 SYNC_API_OTHER, "p", attr);
198 int pthread_mutexattr_destroy(pthread_mutexattr_t *attr) {
199 static int (*pthread_mutexattr_destroyp)(pthread_mutexattr_t *attr);
201 BEFORE_ORIGINAL_SYNC(pthread_mutexattr_destroy, LIBPTHREAD);
203 ret = pthread_mutexattr_destroyp(attr);
205 AFTER_PACK_ORIGINAL_SYNC(ret, 0, SYNC_PTHREAD_MUTEX,
206 SYNC_API_OTHER, "p", attr);
211 int pthread_mutexattr_getprioceiling(const pthread_mutexattr_t *attr,
213 static int (*pthread_mutexattr_getprioceilingp)(
214 const pthread_mutexattr_t *attr, int *prioceiling);
216 BEFORE_ORIGINAL_SYNC(pthread_mutexattr_getprioceiling, LIBPTHREAD);
218 ret = pthread_mutexattr_getprioceilingp(attr, prioceiling);
220 AFTER_PACK_ORIGINAL_SYNC(ret, 0, SYNC_PTHREAD_MUTEX,
221 SYNC_API_OTHER, "pp", attr, prioceiling);
226 int pthread_mutexattr_setprioceiling(pthread_mutexattr_t *attr,
228 static int (*pthread_mutexattr_setprioceilingp)(
229 pthread_mutexattr_t *attr, int prioceiling);
231 BEFORE_ORIGINAL_SYNC(pthread_mutexattr_setprioceiling, LIBPTHREAD);
233 ret = pthread_mutexattr_setprioceilingp(attr, prioceiling);
235 AFTER_PACK_ORIGINAL_SYNC(ret, 0, SYNC_PTHREAD_MUTEX,
236 SYNC_API_OTHER, "pd", attr, prioceiling);
241 int pthread_mutexattr_getprotocol(const pthread_mutexattr_t *attr,
243 static int (*pthread_mutexattr_getprotocolp)(
244 const pthread_mutexattr_t *attr, int *protocol);
246 BEFORE_ORIGINAL_SYNC(pthread_mutexattr_getprotocol, LIBPTHREAD);
248 ret = pthread_mutexattr_getprotocolp(attr, protocol);
250 AFTER_PACK_ORIGINAL_SYNC(ret, 0, SYNC_PTHREAD_MUTEX,
251 SYNC_API_OTHER, "pp", attr, protocol);
256 int pthread_mutexattr_setprotocol(pthread_mutexattr_t *attr,
258 static int (*pthread_mutexattr_setprotocolp)(
259 pthread_mutexattr_t *attr, int protocol);
261 BEFORE_ORIGINAL_SYNC(pthread_mutexattr_setprotocol, LIBPTHREAD);
263 ret = pthread_mutexattr_setprotocolp(attr, protocol);
265 AFTER_PACK_ORIGINAL_SYNC(ret, 0, SYNC_PTHREAD_MUTEX,
266 SYNC_API_OTHER, "pd", attr, protocol);
271 int pthread_mutexattr_getpshared(const pthread_mutexattr_t *attr,
273 static int (*pthread_mutexattr_getpsharedp)(
274 const pthread_mutexattr_t *attr, int *pshared);
276 BEFORE_ORIGINAL_SYNC(pthread_mutexattr_getpshared, LIBPTHREAD);
278 ret = pthread_mutexattr_getpsharedp(attr, pshared);
280 AFTER_PACK_ORIGINAL_SYNC(ret, 0, SYNC_PTHREAD_MUTEX,
281 SYNC_API_OTHER, "pp", attr, pshared);
286 int pthread_mutexattr_setpshared(pthread_mutexattr_t *attr,
288 static int (*pthread_mutexattr_setpsharedp)(
289 pthread_mutexattr_t *attr, int pshared);
291 BEFORE_ORIGINAL_SYNC(pthread_mutexattr_setpshared, LIBPTHREAD);
293 ret = pthread_mutexattr_setpsharedp(attr, pshared);
295 AFTER_PACK_ORIGINAL_SYNC(ret, 0, SYNC_PTHREAD_MUTEX,
296 SYNC_API_OTHER, "pd", attr, pshared);
301 int pthread_mutexattr_gettype(const pthread_mutexattr_t *attr, int *type) {
302 static int (*pthread_mutexattr_gettypep)(
303 const pthread_mutexattr_t *attr, int *type);
305 BEFORE_ORIGINAL_SYNC(pthread_mutexattr_gettype, LIBPTHREAD);
307 ret = pthread_mutexattr_gettypep(attr, type);
309 AFTER_PACK_ORIGINAL_SYNC(ret, 0, SYNC_PTHREAD_MUTEX,
310 SYNC_API_OTHER, "pp", attr, type);
315 int pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type) {
316 static int (*pthread_mutexattr_settypep)(
317 pthread_mutexattr_t *attr, int type);
319 BEFORE_ORIGINAL_SYNC(pthread_mutexattr_settype, LIBPTHREAD);
321 ret = pthread_mutexattr_settypep(attr, type);
323 AFTER_PACK_ORIGINAL_SYNC(ret, 0, SYNC_PTHREAD_MUTEX,
324 SYNC_API_OTHER, "pd", attr, type);
330 int pthread_mutex_getprioceiling(const pthread_mutex_t *mutex,
332 int pthread_mutex_setprioceiling(pthread_mutex_t *mutex,
333 int prioceiling, int *old_ceiling);
336 int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr) {
337 static int (*pthread_cond_initp)(pthread_cond_t *cond,
338 const pthread_condattr_t *attr);
340 BEFORE_ORIGINAL_SYNC(pthread_cond_init, LIBPTHREAD);
342 ret = pthread_cond_initp(cond, attr);
344 AFTER_PACK_ORIGINAL_SYNC(ret, cond, SYNC_PTHREAD_COND_VARIABLE,
345 SYNC_API_OTHER, "pp", cond, attr);
350 int pthread_cond_destroy(pthread_cond_t *cond) {
351 static int (*pthread_cond_destroyp)(pthread_cond_t *cond);
353 BEFORE_ORIGINAL_SYNC(pthread_cond_destroy, LIBPTHREAD);
355 ret = pthread_cond_destroyp(cond);
357 AFTER_PACK_ORIGINAL_SYNC(ret, cond, SYNC_PTHREAD_COND_VARIABLE,
358 SYNC_API_OTHER, "p", cond);
363 int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex) {
364 static int (*pthread_cond_waitp)(pthread_cond_t *cond,
365 pthread_mutex_t *mutex);
367 DECLARE_VARIABLE_STANDARD;
368 GET_REAL_FUNC(pthread_cond_wait, LIBPTHREAD);
370 PRE_PROBEBLOCK_BEGIN();
371 // send WAIT_START log
374 PACK_COMMON_BEGIN(MSG_PROBE_SYNC, LC_SYNC, "pp", cond, mutex);
375 PACK_COMMON_END(0, 0, blockresult);
376 PACK_SYNC(cond, SYNC_PTHREAD_COND_VARIABLE, SYNC_API_COND_WAIT_START);
379 PRE_PROBEBLOCK_END();
381 ret = pthread_cond_waitp(cond, mutex);
385 if(postBlockBegin(blockresult)) {
386 setProbePoint(&probeInfo);
389 PACK_COMMON_BEGIN(MSG_PROBE_SYNC, LC_SYNC, "pp", cond, mutex);
390 PACK_COMMON_END(ret, errno, blockresult);
391 PACK_SYNC(cond, SYNC_PTHREAD_COND_VARIABLE, SYNC_API_COND_WAIT_END);
400 int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
401 const struct timespec *abstime) {
402 static int (*pthread_cond_timedwaitp)(pthread_cond_t *cond,
403 pthread_mutex_t *mutex, const struct timespec *abstime);
405 DECLARE_VARIABLE_STANDARD;
406 GET_REAL_FUNC(pthread_cond_timedwait, LIBPTHREAD);
408 PRE_PROBEBLOCK_BEGIN();
409 // send WAIT_START log
412 PACK_COMMON_BEGIN(MSG_PROBE_SYNC, LC_SYNC, "ppp", cond, mutex, abstime);
413 PACK_COMMON_END(0, 0, blockresult);
414 PACK_SYNC(cond, SYNC_PTHREAD_COND_VARIABLE, SYNC_API_COND_WAIT_START);
417 PRE_PROBEBLOCK_END();
419 ret = pthread_cond_timedwaitp(cond, mutex, abstime);
423 if(postBlockBegin(blockresult)) {
424 setProbePoint(&probeInfo);
427 PACK_COMMON_BEGIN(MSG_PROBE_SYNC, LC_SYNC, "ppp", cond, mutex, abstime);
428 PACK_COMMON_END(ret, errno, blockresult);
429 PACK_SYNC(cond, SYNC_PTHREAD_COND_VARIABLE, SYNC_API_COND_WAIT_END);
438 int pthread_cond_signal(pthread_cond_t *cond) {
439 static int (*pthread_cond_signalp)(pthread_cond_t *cond);
441 BEFORE_ORIGINAL_SYNC(pthread_cond_signal, LIBPTHREAD);
443 ret = pthread_cond_signalp(cond);
445 AFTER_PACK_ORIGINAL_SYNC(ret, cond, SYNC_PTHREAD_COND_VARIABLE,
446 SYNC_API_NOTIFY, "p", cond);
451 int pthread_cond_broadcast(pthread_cond_t *cond) {
452 static int (*pthread_cond_broadcastp)(pthread_cond_t *cond);
454 BEFORE_ORIGINAL_SYNC(pthread_cond_broadcast, LIBPTHREAD);
456 ret = pthread_cond_broadcastp(cond);
458 AFTER_PACK_ORIGINAL_SYNC(ret, cond, SYNC_PTHREAD_COND_VARIABLE,
459 SYNC_API_NOTIFY_ALL, "p", cond);
465 int pthread_condattr_init(pthread_condattr_t *attr);
466 int pthread_condattr_destroy(pthread_condattr_t *attr);
467 int pthread_condattr_getclock(const pthread_condattr_t *attr,
468 clockid_t *clock_id);
469 int pthread_condattr_setclock(pthread_condattr_t *attr,
471 int pthread_condattr_getpshared(const pthread_condattr_t *attr, int *pshared);
472 int pthread_condattr_setpshared(pthread_condattr_t *attr, int pshared);
476 int pthread_rwlock_init(pthread_rwlock_t *rwlock,
477 const pthread_rwlockattr_t *attr);
478 int pthread_rwlock_destroy(pthread_rwlock_t *rwlock);
479 int pthread_rwlock_rdlock(pthread_rwlock_t *rwlock);
480 int pthread_rwlock_wrlock(pthread_rwlock_t *rwlock);
481 int pthread_rwlock_timedrdlock(pthread_rwlock_t *rwlock,
482 const struct timespec *abs_timeout);
483 int pthread_rwlock_timedwrlock(pthread_rwlock_t *rwlock,
484 const struct timespec *abs_timeout);
485 int pthread_rwlock_tryrdlock(pthread_rwlock_t *rwlock);
486 int pthread_rwlock_trywrlock(pthread_rwlock_t *rwlock);
487 int pthread_rwlock_unlock(pthread_rwlock_t *rwlock);
488 int pthread_rwlockattr_init(pthread_rwlockattr_t *attr);
489 int pthread_rwlockattr_destroy(pthread_rwlockattr_t *attr);
490 int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t *attr,
492 int pthread_rwlockattr_setpshared(pthread_rwlockattr_t *attr,
495 int pthread_spin_init(pthread_spinlock_t *lock, int pshared);
496 int pthread_spin_destroy(pthread_spinlock_t *lock);
497 int pthread_spin_lock(pthread_spinlock_t *lock);
498 int pthread_spin_trylock(pthread_spinlock_t *lock);
499 int pthread_spin_unlock(pthread_spinlock_t *lock);
501 int pthread_barrier_init(pthread_barrier_t *barrier,
502 const pthread_barrierattr_t *attr, unsigned int count);
503 int pthread_barrier_destroy(pthread_barrier_t *barrier);
504 int pthread_barrier_wait(pthread_barrier_t *barrier);
505 int pthread_barrierattr_init(pthread_barrierattr_t *attr);
506 int pthread_barrierattr_destroy(pthread_barrierattr_t *attr);
507 int pthread_barrierattr_getpshared(const pthread_barrierattr_t *attr,
509 int pthread_barrierattr_setpshared(pthread_barrierattr_t,