4 * Copyright 2000 - 2013 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>
11 * Anastasia Lyupa <a.lyupa@samsung.com>
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)
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.
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
29 * - Samsung RnD Institute Russia
37 #include "probeinfo.h"
43 static enum DaOptions _sopt = OPT_THREAD;
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);
50 BEFORE_ORIGINAL_SYNC(pthread_mutex_init, LIBPTHREAD);
52 ret = pthread_mutex_initp(mutex, attr);
54 AFTER_PACK_ORIGINAL_SYNC(API_ID_pthread_mutex_init,
55 'd', ret, mutex, SYNC_PTHREAD_MUTEX,
57 voidp_to_uint64(mutex), voidp_to_uint64(attr));
62 int pthread_mutex_destroy(pthread_mutex_t *mutex) {
63 static int (*pthread_mutex_destroyp)(pthread_mutex_t *mutex);
65 BEFORE_ORIGINAL_SYNC(pthread_mutex_destroy, LIBPTHREAD);
67 ret = pthread_mutex_destroyp(mutex);
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));
76 int real_pthread_mutex_lock(pthread_mutex_t *mutex) {
77 static int (*pthread_mutex_lockp)(pthread_mutex_t *mutex);
79 GET_REAL_FUNC(pthread_mutex_lock, LIBPTHREAD);
81 return pthread_mutex_lockp(mutex);
84 int pthread_mutex_lock(pthread_mutex_t *mutex) {
85 static int (*pthread_mutex_lockp)(pthread_mutex_t *mutex);
87 DECLARE_VARIABLE_STANDARD;
88 GET_REAL_FUNC(pthread_mutex_lock, LIBPTHREAD);
90 PRE_PROBEBLOCK_BEGIN();
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);
100 PRE_PROBEBLOCK_END();
102 ret = pthread_mutex_lockp(mutex);
106 if(postBlockBegin(blockresult)) {
107 setProbePoint(&probeInfo);
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);
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);
128 DECLARE_VARIABLE_STANDARD;
129 GET_REAL_FUNC(pthread_mutex_timedlock, LIBPTHREAD);
131 PRE_PROBEBLOCK_BEGIN();
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);
142 PRE_PROBEBLOCK_END();
144 ret = pthread_mutex_timedlockp(mutex, abs_timeout);
148 if(postBlockBegin(blockresult)) {
149 setProbePoint(&probeInfo);
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);
166 int pthread_mutex_trylock(pthread_mutex_t *mutex) {
167 static int (*pthread_mutex_trylockp)(pthread_mutex_t *mutex);
169 BEFORE_ORIGINAL_SYNC(pthread_mutex_trylock, LIBPTHREAD);
171 ret = pthread_mutex_trylockp(mutex);
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));
181 int real_pthread_mutex_unlock(pthread_mutex_t *mutex) {
182 static int (*pthread_mutex_unlockp)(pthread_mutex_t *mutex);
184 GET_REAL_FUNC(pthread_mutex_unlock, LIBPTHREAD);
186 return pthread_mutex_unlockp(mutex);
189 int pthread_mutex_unlock(pthread_mutex_t *mutex) {
190 static int (*pthread_mutex_unlockp)(pthread_mutex_t *mutex);
192 BEFORE_ORIGINAL_SYNC(pthread_mutex_unlock, LIBPTHREAD);
194 ret = pthread_mutex_unlockp(mutex);
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));
204 int pthread_mutexattr_init(pthread_mutexattr_t *attr) {
205 static int (*pthread_mutexattr_initp)(pthread_mutexattr_t *attr);
207 BEFORE_ORIGINAL_SYNC(pthread_mutexattr_init, LIBPTHREAD);
209 ret = pthread_mutexattr_initp(attr);
211 AFTER_PACK_ORIGINAL_SYNC(API_ID_pthread_mutexattr_init,
212 'd', ret, 0, SYNC_PTHREAD_MUTEX,
214 voidp_to_uint64(attr));
219 int pthread_mutexattr_destroy(pthread_mutexattr_t *attr) {
220 static int (*pthread_mutexattr_destroyp)(pthread_mutexattr_t *attr);
222 BEFORE_ORIGINAL_SYNC(pthread_mutexattr_destroy, LIBPTHREAD);
224 ret = pthread_mutexattr_destroyp(attr);
226 AFTER_PACK_ORIGINAL_SYNC(API_ID_pthread_mutexattr_destroy,
227 'd', ret, 0, SYNC_PTHREAD_MUTEX,
229 voidp_to_uint64(attr));
234 int pthread_mutexattr_getprioceiling(const pthread_mutexattr_t *attr,
236 static int (*pthread_mutexattr_getprioceilingp)(
237 const pthread_mutexattr_t *attr, int *prioceiling);
239 BEFORE_ORIGINAL_SYNC(pthread_mutexattr_getprioceiling, LIBPTHREAD);
241 ret = pthread_mutexattr_getprioceilingp(attr, prioceiling);
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));
252 int pthread_mutexattr_setprioceiling(pthread_mutexattr_t *attr,
254 static int (*pthread_mutexattr_setprioceilingp)(
255 pthread_mutexattr_t *attr, int prioceiling);
257 BEFORE_ORIGINAL_SYNC(pthread_mutexattr_setprioceiling, LIBPTHREAD);
259 ret = pthread_mutexattr_setprioceilingp(attr, prioceiling);
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),
269 int pthread_mutexattr_getprotocol(const pthread_mutexattr_t *attr,
271 static int (*pthread_mutexattr_getprotocolp)(
272 const pthread_mutexattr_t *attr, int *protocol);
274 BEFORE_ORIGINAL_SYNC(pthread_mutexattr_getprotocol, LIBPTHREAD);
276 ret = pthread_mutexattr_getprotocolp(attr, protocol);
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));
287 int pthread_mutexattr_setprotocol(pthread_mutexattr_t *attr,
289 static int (*pthread_mutexattr_setprotocolp)(
290 pthread_mutexattr_t *attr, int protocol);
292 BEFORE_ORIGINAL_SYNC(pthread_mutexattr_setprotocol, LIBPTHREAD);
294 ret = pthread_mutexattr_setprotocolp(attr, protocol);
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),
304 int pthread_mutexattr_getpshared(const pthread_mutexattr_t *attr,
306 static int (*pthread_mutexattr_getpsharedp)(
307 const pthread_mutexattr_t *attr, int *pshared);
309 BEFORE_ORIGINAL_SYNC(pthread_mutexattr_getpshared, LIBPTHREAD);
311 ret = pthread_mutexattr_getpsharedp(attr, pshared);
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));
322 int pthread_mutexattr_setpshared(pthread_mutexattr_t *attr,
324 static int (*pthread_mutexattr_setpsharedp)(
325 pthread_mutexattr_t *attr, int pshared);
327 BEFORE_ORIGINAL_SYNC(pthread_mutexattr_setpshared, LIBPTHREAD);
329 ret = pthread_mutexattr_setpsharedp(attr, pshared);
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),
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);
343 BEFORE_ORIGINAL_SYNC(pthread_mutexattr_gettype, LIBPTHREAD);
345 ret = pthread_mutexattr_gettypep(attr, type);
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));
356 int pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type) {
357 static int (*pthread_mutexattr_settypep)(
358 pthread_mutexattr_t *attr, int type);
360 BEFORE_ORIGINAL_SYNC(pthread_mutexattr_settype, LIBPTHREAD);
362 ret = pthread_mutexattr_settypep(attr, type);
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),
374 int pthread_mutex_getprioceiling(const pthread_mutex_t *mutex,
376 int pthread_mutex_setprioceiling(pthread_mutex_t *mutex,
377 int prioceiling, int *old_ceiling);
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);
384 BEFORE_ORIGINAL_SYNC(pthread_cond_init, LIBPTHREAD);
386 ret = pthread_cond_initp(cond, attr);
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));
397 int pthread_cond_destroy(pthread_cond_t *cond) {
398 static int (*pthread_cond_destroyp)(pthread_cond_t *cond);
400 BEFORE_ORIGINAL_SYNC(pthread_cond_destroy, LIBPTHREAD);
402 ret = pthread_cond_destroyp(cond);
404 AFTER_PACK_ORIGINAL_SYNC(API_ID_pthread_cond_destroy,
405 'd', ret, cond, SYNC_PTHREAD_COND_VARIABLE,
407 voidp_to_uint64(cond));
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);
416 DECLARE_VARIABLE_STANDARD;
417 GET_REAL_FUNC(pthread_cond_wait, LIBPTHREAD);
419 PRE_PROBEBLOCK_BEGIN();
420 // send WAIT_START log
423 PACK_COMMON_BEGIN(MSG_PROBE_SYNC,
424 API_ID_pthread_cond_wait,
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);
432 PRE_PROBEBLOCK_END();
434 ret = pthread_cond_waitp(cond, mutex);
438 if(postBlockBegin(blockresult)) {
439 setProbePoint(&probeInfo);
442 PACK_COMMON_BEGIN(MSG_PROBE_SYNC,
443 API_ID_pthread_cond_wait,
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);
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);
462 DECLARE_VARIABLE_STANDARD;
463 GET_REAL_FUNC(pthread_cond_timedwait, LIBPTHREAD);
465 PRE_PROBEBLOCK_BEGIN();
466 // send WAIT_START log
469 PACK_COMMON_BEGIN(MSG_PROBE_SYNC,
470 API_ID_pthread_cond_timedwait,
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);
479 PRE_PROBEBLOCK_END();
481 ret = pthread_cond_timedwaitp(cond, mutex, abstime);
485 if(postBlockBegin(blockresult)) {
486 setProbePoint(&probeInfo);
489 PACK_COMMON_BEGIN(MSG_PROBE_SYNC,
490 API_ID_pthread_cond_timedwait,
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);
505 int pthread_cond_signal(pthread_cond_t *cond) {
506 static int (*pthread_cond_signalp)(pthread_cond_t *cond);
508 BEFORE_ORIGINAL_SYNC(pthread_cond_signal, LIBPTHREAD);
510 ret = pthread_cond_signalp(cond);
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));
519 int pthread_cond_broadcast(pthread_cond_t *cond) {
520 static int (*pthread_cond_broadcastp)(pthread_cond_t *cond);
522 BEFORE_ORIGINAL_SYNC(pthread_cond_broadcast, LIBPTHREAD);
524 ret = pthread_cond_broadcastp(cond);
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));
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,
540 int pthread_condattr_getpshared(const pthread_condattr_t *attr, int *pshared);
541 int pthread_condattr_setpshared(pthread_condattr_t *attr, int pshared);
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,
561 int pthread_rwlockattr_setpshared(pthread_rwlockattr_t *attr,
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);
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,
578 int pthread_barrierattr_setpshared(pthread_barrierattr_t,