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
34 #include "probeinfo.h"
36 #include "da_thread.h"
40 typedef struct thread_routine_call_t {
41 void *(*thread_routine)(void *);
43 } thread_routine_call;
45 static enum DaOptions _sopt = OPT_THREAD;
47 // called when pthread_exit, pthread_cancel is called
48 void _da_cleanup_handler(void *data)
52 probeInfo_t probeInfo; log_t log;
55 PRE_UNCONDITIONAL_BLOCK_BEGIN();
56 APPEND_LOG_BASIC(LC_THREAD);
57 // input,ret,PCAddr,errno,InternalCall,CallerPCAddr
58 log.length += sprintf(log.data + log.length, "`,`,`,0`,0`,1`,0");
59 pSelf = pthread_self();
60 log.length += sprintf(log.data + log.length, "`,%lu`,`,%d`,%d",
61 pSelf, THREAD_PTHREAD, THREAD_API_INTERNAL_STOP);
62 APPEND_LOG_NULL_CALLSTACK();
63 printLog(&log, MSG_LOG);
66 PACK_COMMON_BEGIN(MSG_PROBE_THREAD, LC_THREAD, "p", data);
67 PACK_COMMON_END(0, 0, 1);
68 PACK_THREAD(pSelf, THREAD_PTHREAD, THREAD_API_INTERNAL_STOP);
71 PRE_UNCONDITIONAL_BLOCK_END();
76 void *_da_ThreadProc(void *params)
79 thread_routine_call *ptrc;
80 ptrc = (thread_routine_call *) params;
83 probeInfo_t probeInfo; log_t log;
85 // send INTERNAL_START log
88 PRE_UNCONDITIONAL_BLOCK_BEGIN();
89 APPEND_LOG_BASIC(LC_THREAD);
90 // input,ret,PCAddr,errno,InternalCall,CallerPCAddr
91 log.length += sprintf(log.data + log.length, "`,`,`,0`,0`,1`,0");
92 pSelf = pthread_self();
93 log.length += sprintf(log.data + log.length, "`,%lu`,`,%d`,%d",
94 pSelf, THREAD_PTHREAD, THREAD_API_INTERNAL_START);
95 APPEND_LOG_NULL_CALLSTACK();
96 printLog(&log, MSG_LOG);
99 PACK_COMMON_BEGIN(MSG_PROBE_THREAD, LC_THREAD, "p", params);
100 PACK_COMMON_END(0, 0, 1);
101 PACK_THREAD(pSelf, THREAD_PTHREAD, THREAD_API_INTERNAL_START);
104 PRE_UNCONDITIONAL_BLOCK_END();
106 pthread_cleanup_push(_da_cleanup_handler, NULL);
107 // call user-defined thread routine
108 ret = ptrc->thread_routine(ptrc->argument);
109 pthread_cleanup_pop(0);
111 // send INTERNAL_STOP log
114 PRE_UNCONDITIONAL_BLOCK_BEGIN();
115 APPEND_LOG_BASIC(LC_THREAD);
116 // input,ret,PCAddr,errno,InternalCall,CallerPCAddr
117 log.length += sprintf(log.data + log.length, "`,`,`,0`,0`,1`,0");
118 pSelf = pthread_self();
119 log.length += sprintf(log.data + log.length, "`,%lu`,`,%d`,%d",
120 pSelf, THREAD_PTHREAD, THREAD_API_INTERNAL_STOP);
121 APPEND_LOG_NULL_CALLSTACK();
122 printLog(&log, MSG_LOG);
125 PACK_COMMON_BEGIN(MSG_PROBE_THREAD, LC_THREAD, "p", params);
126 PACK_COMMON_END(ret, 0, 1);
127 PACK_THREAD(pSelf, THREAD_PTHREAD, THREAD_API_INTERNAL_STOP);
130 PRE_UNCONDITIONAL_BLOCK_END();
136 int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
137 void *(*start_routine) (void*), void *arg)
139 static int (*pthread_createp)(pthread_t *thread,
140 const pthread_attr_t *attr, void *(*start_routine)(void *), void *arg);
142 BEFORE_ORIGINAL_THREAD(pthread_create, LIBPTHREAD);
147 thread_routine_call *ptrc =
148 (thread_routine_call *) malloc(sizeof(thread_routine_call));
149 ptrc->thread_routine = start_routine;
150 ptrc->argument = arg;
153 ret = pthread_createp(thread, attr, _da_ThreadProc, (void *) ptrc);
155 else // when pthread_create is called inside probe so (ex. custom chart, sampling thread)
157 ret = pthread_createp(thread, attr, start_routine, arg);
160 AFTER_ORIGINAL_THREAD_RET(VT_INT, ret, *thread, THREAD_API_START,
161 "%p,%p,%p,%p", thread, attr, start_routine, arg);
163 AFTER_PACK_ORIGINAL_THREAD(ret, *thread, THREAD_API_START,
164 "pppp", thread, attr, start_routine, arg);
169 int pthread_join(pthread_t thread, void **retval)
171 static int (*pthread_joinp)(pthread_t thread, void **retval);
173 DECLARE_VARIABLE_STANDARD; log_t log;
174 GET_REAL_FUNC(pthread_join, LIBPTHREAD);
176 PRE_PROBEBLOCK_BEGIN();
177 // send WAIT_START log
179 APPEND_LOG_BASIC(LC_THREAD);
180 APPEND_LOG_INPUT("%lu,%p", thread, retval);
181 //ret,PCAddr,errno,InternalCall
182 log.length += sprintf(log.data + log.length, "`,`,0`,0`,%d", blockresult);
184 log.length += sprintf(log.data + log.length, "`,%lu`,`,%d`,%d", thread,
185 THREAD_PTHREAD, THREAD_API_WAIT_START);
186 APPEND_LOG_NULL_CALLSTACK();
187 printLog(&log, MSG_LOG);
190 PACK_COMMON_BEGIN(MSG_PROBE_THREAD, LC_THREAD, "xp", thread, retval);
191 PACK_COMMON_END(0, 0, blockresult);
192 PACK_THREAD(thread, THREAD_PTHREAD, THREAD_API_WAIT_START);
195 PRE_PROBEBLOCK_END();
197 ret = pthread_joinp(thread, retval);
201 if(postBlockBegin(blockresult)) {
202 setProbePoint(&probeInfo);
204 APPEND_LOG_BASIC(LC_THREAD);
205 APPEND_LOG_INPUT("%lu,%p", thread, retval);
206 APPEND_LOG_RESULT(VT_INT, ret);
209 POST_PROBEBLOCK_MIDDLE_THREAD(thread, THREAD_API_WAIT_END);
210 POST_PROBEBLOCK_CALLSTACK();
211 printLog(&log, MSG_LOG);
214 PACK_COMMON_BEGIN(MSG_PROBE_THREAD, LC_THREAD, "xp", thread, retval);
215 PACK_COMMON_END(ret, errno, blockresult);
216 PACK_THREAD(thread, THREAD_PTHREAD, THREAD_API_WAIT_END);
225 void pthread_exit(void *retval)
228 static void (*pthread_exitp)(void *retval) __attribute__((noreturn));
230 DECLARE_VARIABLE_STANDARD; log_t log;
231 GET_REAL_FUNC(pthread_exit, LIBPTHREAD);
233 PRE_PROBEBLOCK_BEGIN();
236 APPEND_LOG_BASIC(LC_THREAD);
237 APPEND_LOG_INPUT("%p", retval);
238 //ret,PCAddr,errno,InternalCall
239 log.length += sprintf(log.data + log.length, "`,`,0`,0`,%d", blockresult);
241 pSelf = pthread_self();
242 log.length += sprintf(log.data + log.length, "`,%lu`,`,%d`,%d",
243 pSelf, THREAD_PTHREAD, THREAD_API_EXIT);
244 APPEND_LOG_NULL_CALLSTACK();
245 printLog(&log, MSG_LOG);
248 PACK_COMMON_BEGIN(MSG_PROBE_THREAD, LC_THREAD, "p", retval);
249 PACK_COMMON_END(0, 0, blockresult);
250 PACK_THREAD(pSelf, THREAD_PTHREAD, THREAD_API_EXIT);
253 PRE_PROBEBLOCK_END();
255 pthread_exitp(retval);
258 int pthread_cancel(pthread_t thread)
260 static int (*pthread_cancelp)(pthread_t thread);
262 BEFORE_ORIGINAL_THREAD(pthread_cancel, LIBPTHREAD);
264 ret = pthread_cancelp(thread);
266 AFTER_ORIGINAL_THREAD_RET(VT_INT, ret, thread, THREAD_API_STOP, "%lu", thread);
268 AFTER_PACK_ORIGINAL_THREAD(ret, thread, THREAD_API_STOP, "x", thread);
273 int pthread_detach(pthread_t thread)
275 static int (*pthread_detachp)(pthread_t thread);
277 BEFORE_ORIGINAL_THREAD(pthread_detach, LIBPTHREAD);
279 ret = pthread_detachp(thread);
281 AFTER_ORIGINAL_THREAD_RET(VT_INT, ret, thread, THREAD_API_OTHER, "%lu", thread);
283 AFTER_PACK_ORIGINAL_THREAD(ret, thread, THREAD_API_OTHER, "x", thread);
288 pthread_t pthread_self(void)
291 static pthread_t (*pthread_selfp)(void);
293 BEFORE_ORIGINAL_THREAD(pthread_self, LIBPTHREAD);
295 ret_pthr = pthread_selfp();
298 if(postBlockBegin(blockresult)) {
300 APPEND_LOG_BASIC(LC_THREAD);
301 log.length += sprintf(log.data + log.length, "`,");
302 APPEND_LOG_RESULT(VT_ULONG, ret_pthr);
305 POST_PROBEBLOCK_MIDDLE_THREAD(ret_pthr, THREAD_API_OTHER);
306 POST_PROBEBLOCK_CALLSTACK();
307 printLog(&log, MSG_LOG);
309 AFTER_PACK_ORIGINAL_THREAD(ret_pthr, ret_pthr, THREAD_API_OTHER, "", 0);
317 int pthread_equal(pthread_t t1, pthread_t t2)
319 static int (*pthread_equalp)(pthread_t t1, pthread_t t2);
321 BEFORE_ORIGINAL_THREAD(pthread_equal, LIBPTHREAD);
323 ret = pthread_equalp(t1, t2);
325 AFTER_ORIGINAL_THREAD_RET(VT_INT, ret, t1, THREAD_API_OTHER, "%lu,%lu", t1, t2);
327 AFTER_PACK_ORIGINAL_THREAD(ret, t1, THREAD_API_OTHER, "xx", t1, t2);
332 int pthread_setcancelstate(int state, int *oldstate)
335 static int (*pthread_setcancelstatep)(int state, int *oldstate);
337 BEFORE_ORIGINAL_THREAD(pthread_setcancelstate, LIBPTHREAD);
339 pSelf = pthread_self();
340 ret = pthread_setcancelstatep(state, oldstate);
342 AFTER_ORIGINAL_THREAD_RET(VT_INT, ret, pSelf, THREAD_API_OTHER,
343 "%d,%p", state, oldstate);
345 AFTER_PACK_ORIGINAL_THREAD(ret, pSelf, THREAD_API_OTHER,
346 "dp", state, oldstate);
351 int pthread_setcanceltype(int type, int *oldtype)
354 static int (*pthread_setcanceltypep)(int type, int *oldtype);
356 BEFORE_ORIGINAL_THREAD(pthread_setcanceltype, LIBPTHREAD);
358 pSelf = pthread_self();
359 ret = pthread_setcanceltypep(type, oldtype);
361 AFTER_ORIGINAL_THREAD_RET(VT_INT, ret, pSelf, THREAD_API_OTHER,
362 "%d,%p", type, oldtype);
364 AFTER_PACK_ORIGINAL_THREAD(ret, pSelf, THREAD_API_OTHER,
365 "dp", type, oldtype);
370 int pthread_attr_init(pthread_attr_t *attr)
372 pthread_t thread = 0;
373 static int (*pthread_attr_initp)(pthread_attr_t *attr);
375 BEFORE_ORIGINAL_THREAD(pthread_attr_init, LIBPTHREAD);
377 ret = pthread_attr_initp(attr);
379 AFTER_ORIGINAL_THREAD_RET(VT_INT, ret, thread, THREAD_API_OTHER, "%p", attr);
381 AFTER_PACK_ORIGINAL_THREAD(ret, thread, THREAD_API_OTHER, "p", attr);
386 int pthread_attr_destroy(pthread_attr_t *attr)
388 pthread_t thread = 0;
389 static int (*pthread_attr_destroyp)(pthread_attr_t *attr);
391 BEFORE_ORIGINAL_THREAD(pthread_attr_destroy, LIBPTHREAD);
393 ret = pthread_attr_destroyp(attr);
395 AFTER_ORIGINAL_THREAD_RET(VT_INT, ret, thread, THREAD_API_OTHER, "%p", attr);
397 AFTER_PACK_ORIGINAL_THREAD(ret, thread, THREAD_API_OTHER, "p", attr);
402 int pthread_attr_getdetachstate(const pthread_attr_t *attr, int *detachstate)
404 pthread_t thread = 0;
405 static int (*pthread_attr_getdetachstatep)(const pthread_attr_t *attr,
408 BEFORE_ORIGINAL_THREAD(pthread_attr_getdetachstate, LIBPTHREAD);
410 ret = pthread_attr_getdetachstatep(attr, detachstate);
412 AFTER_ORIGINAL_THREAD_RET(VT_INT, ret, thread, THREAD_API_OTHER,
413 "%p,%p", attr, detachstate);
415 AFTER_PACK_ORIGINAL_THREAD(ret, thread, THREAD_API_OTHER,
416 "pp", attr, detachstate);
421 int pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate)
423 pthread_t thread = 0;
424 static int (*pthread_attr_setdetachstatep)(pthread_attr_t *attr,
427 BEFORE_ORIGINAL_THREAD(pthread_attr_setdetachstate, LIBPTHREAD);
429 ret = pthread_attr_setdetachstatep(attr, detachstate);
431 AFTER_ORIGINAL_THREAD_RET(VT_INT, ret, thread, THREAD_API_OTHER,
432 "%p,%d", attr, detachstate);
434 AFTER_PACK_ORIGINAL_THREAD(ret, thread, THREAD_API_OTHER,
435 "pd", attr, detachstate);
440 int pthread_attr_getstacksize(const pthread_attr_t *attr, size_t *stacksize)
442 pthread_t thread = 0;
443 static int (*pthread_attr_getstacksizep)(const pthread_attr_t *attr,
446 BEFORE_ORIGINAL_THREAD(pthread_attr_getstacksize, LIBPTHREAD);
448 ret = pthread_attr_getstacksizep(attr, stacksize);
450 AFTER_ORIGINAL_THREAD_RET(VT_INT, ret, thread, THREAD_API_OTHER,
451 "%p,%p", attr, stacksize);
453 AFTER_PACK_ORIGINAL_THREAD(ret, thread, THREAD_API_OTHER,
454 "pp", attr, stacksize);
459 int pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize)
461 pthread_t thread = 0;
462 static int (*pthread_attr_setstacksizep)(pthread_attr_t *attr,
465 BEFORE_ORIGINAL_THREAD(pthread_attr_setstacksize, LIBPTHREAD);
467 ret = pthread_attr_setstacksizep(attr, stacksize);
469 AFTER_ORIGINAL_THREAD_RET(VT_INT, ret, thread, THREAD_API_OTHER,
470 "%p,%u", attr, stacksize);
472 AFTER_PACK_ORIGINAL_THREAD(ret, thread, THREAD_API_OTHER,
473 "px", attr, stacksize);
478 int pthread_attr_getstackaddr(const pthread_attr_t *attr, void **stackaddr)
480 pthread_t thread = 0;
481 static int (*pthread_attr_getstackaddrp)(const pthread_attr_t *attr,
484 BEFORE_ORIGINAL_THREAD(pthread_attr_getstackaddr, LIBPTHREAD);
486 ret = pthread_attr_getstackaddrp(attr, stackaddr);
488 AFTER_ORIGINAL_THREAD_RET(VT_INT, ret, thread, THREAD_API_OTHER,
489 "%p,%p", attr, stackaddr);
491 AFTER_PACK_ORIGINAL_THREAD(ret, thread, THREAD_API_OTHER,
492 "pp", attr, stackaddr);
497 int pthread_attr_setstackaddr(pthread_attr_t *attr, void *stackaddr)
499 pthread_t thread = 0;
500 static int (*pthread_attr_setstackaddrp)(pthread_attr_t *attr,
503 BEFORE_ORIGINAL_THREAD(pthread_attr_setstackaddr, LIBPTHREAD);
505 ret = pthread_attr_setstackaddrp(attr, stackaddr);
507 AFTER_ORIGINAL_THREAD_RET(VT_INT, ret, thread, THREAD_API_OTHER,
508 "%p,%p", attr, stackaddr);
510 AFTER_PACK_ORIGINAL_THREAD(ret, thread, THREAD_API_OTHER,
511 "pp", attr, stackaddr);
516 int pthread_attr_getinheritsched(const pthread_attr_t *attr, int *inheritsched)
518 pthread_t thread = 0;
519 static int (*pthread_attr_getinheritschedp)(const pthread_attr_t *attr,
522 BEFORE_ORIGINAL_THREAD(pthread_attr_getinheritsched, LIBPTHREAD);
524 ret = pthread_attr_getinheritschedp(attr, inheritsched);
526 AFTER_ORIGINAL_THREAD_RET(VT_INT, ret, thread, THREAD_API_OTHER,
527 "%p,%p", attr, inheritsched);
529 AFTER_PACK_ORIGINAL_THREAD(ret, thread, THREAD_API_OTHER,
530 "pp", attr, inheritsched);
535 int pthread_attr_setinheritsched(pthread_attr_t *attr, int inheritsched)
537 pthread_t thread = 0;
538 static int (*pthread_attr_setinheritschedp)(pthread_attr_t *attr,
541 BEFORE_ORIGINAL_THREAD(pthread_attr_setinheritsched, LIBPTHREAD);
543 ret = pthread_attr_setinheritschedp(attr, inheritsched);
545 AFTER_ORIGINAL_THREAD_RET(VT_INT, ret, thread, THREAD_API_OTHER,
546 "%p,%d", attr, inheritsched);
548 AFTER_PACK_ORIGINAL_THREAD(ret, thread, THREAD_API_OTHER,
549 "pd", attr, inheritsched);
554 int pthread_attr_getschedparam(const pthread_attr_t *attr,
555 struct sched_param *param)
557 pthread_t thread = 0;
558 static int (*pthread_attr_getschedparamp)(const pthread_attr_t *attr,
559 struct sched_param *param);
561 BEFORE_ORIGINAL_THREAD(pthread_attr_getschedparam, LIBPTHREAD);
563 ret = pthread_attr_getschedparamp(attr, param);
565 AFTER_ORIGINAL_THREAD_RET(VT_INT, ret, thread, THREAD_API_OTHER,
566 "%p,%p", attr, param);
568 AFTER_PACK_ORIGINAL_THREAD(ret, thread, THREAD_API_OTHER,
574 int pthread_attr_setschedparam(pthread_attr_t *attr,
575 const struct sched_param *param)
577 pthread_t thread = 0;
578 static int (*pthread_attr_setschedparamp)(pthread_attr_t *attr,
579 const struct sched_param *param);
581 BEFORE_ORIGINAL_THREAD(pthread_attr_setschedparam, LIBPTHREAD);
583 ret = pthread_attr_setschedparamp(attr, param);
585 AFTER_ORIGINAL_THREAD_RET(VT_INT, ret, thread, THREAD_API_OTHER,
586 "%p,%p", attr, param);
588 AFTER_PACK_ORIGINAL_THREAD(ret, thread, THREAD_API_OTHER,
594 int pthread_attr_getschedpolicy(const pthread_attr_t *attr, int *policy)
596 pthread_t thread = 0;
597 static int (*pthread_attr_getschedpolicyp)(const pthread_attr_t *attr,
600 BEFORE_ORIGINAL_THREAD(pthread_attr_getschedpolicy, LIBPTHREAD);
602 ret = pthread_attr_getschedpolicyp(attr, policy);
604 AFTER_ORIGINAL_THREAD_RET(VT_INT, ret, thread, THREAD_API_OTHER,
605 "%p,%p", attr, policy);
607 AFTER_PACK_ORIGINAL_THREAD(ret, thread, THREAD_API_OTHER,
613 int pthread_attr_setschedpolicy(pthread_attr_t *attr, int policy)
615 pthread_t thread = 0;
616 static int (*pthread_attr_setschedpolicyp)(pthread_attr_t *attr,
619 BEFORE_ORIGINAL_THREAD(pthread_attr_setschedpolicy, LIBPTHREAD);
621 ret = pthread_attr_setschedpolicyp(attr, policy);
623 AFTER_ORIGINAL_THREAD_RET(VT_INT, ret, thread, THREAD_API_OTHER,
624 "%p,%d", attr, policy);
626 AFTER_PACK_ORIGINAL_THREAD(ret, thread, THREAD_API_OTHER,
632 int pthread_attr_getguardsize(const pthread_attr_t *attr, size_t *guardsize)
634 pthread_t thread = 0;
635 static int (*pthread_attr_getguardsizep)(const pthread_attr_t *attr,
638 BEFORE_ORIGINAL_THREAD(pthread_attr_getguardsize, LIBPTHREAD);
640 ret = pthread_attr_getguardsizep(attr, guardsize);
642 AFTER_ORIGINAL_THREAD_RET(VT_INT, ret, thread, THREAD_API_OTHER,
643 "%p,%p", attr, guardsize);
645 AFTER_PACK_ORIGINAL_THREAD(ret, thread, THREAD_API_OTHER,
646 "pp", attr, guardsize);
651 int pthread_attr_setguardsize(pthread_attr_t *attr, size_t guardsize)
653 pthread_t thread = 0;
654 static int (*pthread_attr_setguardsizep)(pthread_attr_t *attr,
657 BEFORE_ORIGINAL_THREAD(pthread_attr_setguardsize, LIBPTHREAD);
659 ret = pthread_attr_setguardsizep(attr, guardsize);
661 AFTER_ORIGINAL_THREAD_RET(VT_INT, ret, thread, THREAD_API_OTHER,
662 "%p,%u", attr, guardsize);
664 AFTER_PACK_ORIGINAL_THREAD(ret, thread, THREAD_API_OTHER,
665 "px", attr, guardsize);
670 int pthread_attr_getscope(const pthread_attr_t *attr, int *contentionscope)
672 pthread_t thread = 0;
673 static int (*pthread_attr_getscopep)(const pthread_attr_t *attr,
674 int *contentionscope);
676 BEFORE_ORIGINAL_THREAD(pthread_attr_getscope, LIBPTHREAD);
678 ret = pthread_attr_getscopep(attr, contentionscope);
680 AFTER_ORIGINAL_THREAD_RET(VT_INT, ret, thread, THREAD_API_OTHER,
681 "%p,%p", attr, contentionscope);
683 AFTER_PACK_ORIGINAL_THREAD(ret, thread, THREAD_API_OTHER,
684 "pp", attr, contentionscope);
689 int pthread_attr_setscope(pthread_attr_t *attr, int contentionscope)
691 pthread_t thread = 0;
692 static int (*pthread_attr_setscopep)(pthread_attr_t *attr,
693 int contentionscope);
695 BEFORE_ORIGINAL_THREAD(pthread_attr_setscope, LIBPTHREAD);
697 ret = pthread_attr_setscopep(attr, contentionscope);
699 AFTER_ORIGINAL_THREAD_RET(VT_INT, ret, thread, THREAD_API_OTHER,
700 "%p,%d", attr, contentionscope);
702 AFTER_PACK_ORIGINAL_THREAD(ret, thread, THREAD_API_OTHER,
703 "pd", attr, contentionscope);
708 int pthread_attr_getstack(const pthread_attr_t *attr,
709 void **stackaddr, size_t *stacksize)
711 pthread_t thread = 0;
712 static int (*pthread_attr_getstackp)(const pthread_attr_t *attr,
713 void **stackaddr, size_t *stacksize);
715 BEFORE_ORIGINAL_THREAD(pthread_attr_getstack, LIBPTHREAD);
717 ret = pthread_attr_getstackp(attr, stackaddr, stacksize);
719 AFTER_ORIGINAL_THREAD_RET(VT_INT, ret, thread, THREAD_API_OTHER,
720 "%p,%p,%p", attr, stackaddr, stacksize);
722 AFTER_PACK_ORIGINAL_THREAD(ret, thread, THREAD_API_OTHER,
723 "ppp", attr, stackaddr, stacksize);
728 int pthread_attr_setstack(pthread_attr_t *attr,
729 void *stackaddr, size_t stacksize)
731 pthread_t thread = 0;
732 static int (*pthread_attr_setstackp)(pthread_attr_t *attr,
733 void *stackaddr, size_t stacksize);
735 BEFORE_ORIGINAL_THREAD(pthread_attr_setstack, LIBPTHREAD);
737 ret = pthread_attr_setstackp(attr, stackaddr, stacksize);
739 AFTER_ORIGINAL_THREAD_RET(VT_INT, ret, thread, THREAD_API_OTHER,
740 "%p,%p,%u", attr, stackaddr, stacksize);
742 AFTER_PACK_ORIGINAL_THREAD(ret, thread, THREAD_API_OTHER,
743 "ppx", attr, stackaddr, stacksize);
749 void pthread_testcancel(void);
751 int pthread_key_create(pthread_key_t *key, void (*destructor)(void*));
752 int pthread_key_delete(pthread_key_t key);
754 int pthread_getconcurrency(void);
755 int pthread_setconcurrency(int new_level);
756 int pthread_getcpuclockid(pthread_t thread_id, clockid_t *clock_id);
757 int pthread_getschedparam(pthread_t thread, int *policy,
758 struct sched_param *param);
759 int pthread_setschedparam(pthread_t thread, int policy,
760 const struct sched_param *param);
761 int pthread_setschedprio(pthread_t thread, int prio);
762 void *pthread_getspecific(pthread_key_t key);
763 int pthread_setspecific(pthread_key_t key, const void *value);
765 int pthread_once(pthread_once_t *once_control, void (*init_routine)(void));
767 int pthread_atfork(void (*prepare)(void), void (*parent)(void),
768 void (*child)(void));