45789aa3463108c72990ad752912309870514a39
2 * Copyright (C) 2013 Mentor Graphics
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 #include <lttng/ust-dlfcn.h>
23 #define TRACEPOINT_DEFINE
24 #define TRACEPOINT_CREATE_PROBES
25 #include "ust_pthread.h"
27 static __thread
int thread_in_trace
;
29 int pthread_mutex_lock(pthread_mutex_t
*mutex
)
31 static int (*mutex_lock
)(pthread_mutex_t
*);
35 mutex_lock
= dlsym(RTLD_NEXT
, "pthread_mutex_lock");
37 if (thread_in_trace
) {
40 fprintf(stderr
, "unable to initialize pthread wrapper library.\n");
44 if (thread_in_trace
) {
45 return mutex_lock(mutex
);
49 tracepoint(ust_pthread
, pthread_mutex_lock_req
, mutex
);
50 retval
= mutex_lock(mutex
);
51 tracepoint(ust_pthread
, pthread_mutex_lock_acq
, mutex
, retval
);
56 int pthread_mutex_trylock(pthread_mutex_t
*mutex
)
58 static int (*mutex_trylock
)(pthread_mutex_t
*);
62 mutex_trylock
= dlsym(RTLD_NEXT
, "pthread_mutex_trylock");
64 if (thread_in_trace
) {
67 fprintf(stderr
, "unable to initialize pthread wrapper library.\n");
71 if (thread_in_trace
) {
72 return mutex_trylock(mutex
);
76 retval
= mutex_trylock(mutex
);
77 tracepoint(ust_pthread
, pthread_mutex_trylock
, mutex
, retval
);
82 int pthread_mutex_unlock(pthread_mutex_t
*mutex
)
84 static int (*mutex_unlock
)(pthread_mutex_t
*);
88 mutex_unlock
= dlsym(RTLD_NEXT
, "pthread_mutex_unlock");
90 if (thread_in_trace
) {
93 fprintf(stderr
, "unable to initialize pthread wrapper library.\n");
97 if (thread_in_trace
) {
98 return mutex_unlock(mutex
);
102 retval
= mutex_unlock(mutex
);
103 tracepoint(ust_pthread
, pthread_mutex_unlock
, mutex
, retval
);
This page took 0.030726 seconds and 3 git commands to generate.