2 * SPDX-License-Identifier: LGPL-2.1-or-later
4 * Copyright (C) 2013 Mentor Graphics
8 * Do _not_ define _LGPL_SOURCE because we don't want to create a
9 * circular dependency loop between this malloc wrapper, liburcu and
13 /* Has to be included first to override dlfcn.h */
14 #include <common/compat/dlfcn.h>
16 #include "common/macros.h"
19 #define TRACEPOINT_DEFINE
20 #define TRACEPOINT_CREATE_PROBES
21 #define TP_IP_PARAM ip
22 #include "ust_pthread.h"
24 static __thread
int thread_in_trace
;
26 int pthread_mutex_lock(pthread_mutex_t
*mutex
)
28 static int (*mutex_lock
)(pthread_mutex_t
*);
32 mutex_lock
= dlsym(RTLD_NEXT
, "pthread_mutex_lock");
34 if (thread_in_trace
) {
37 fprintf(stderr
, "unable to initialize pthread wrapper library.\n");
41 if (thread_in_trace
) {
42 return mutex_lock(mutex
);
46 tracepoint(lttng_ust_pthread
, pthread_mutex_lock_req
, mutex
,
47 LTTNG_UST_CALLER_IP());
48 retval
= mutex_lock(mutex
);
49 tracepoint(lttng_ust_pthread
, pthread_mutex_lock_acq
, mutex
,
50 retval
, LTTNG_UST_CALLER_IP());
55 int pthread_mutex_trylock(pthread_mutex_t
*mutex
)
57 static int (*mutex_trylock
)(pthread_mutex_t
*);
61 mutex_trylock
= dlsym(RTLD_NEXT
, "pthread_mutex_trylock");
63 if (thread_in_trace
) {
66 fprintf(stderr
, "unable to initialize pthread wrapper library.\n");
70 if (thread_in_trace
) {
71 return mutex_trylock(mutex
);
75 retval
= mutex_trylock(mutex
);
76 tracepoint(lttng_ust_pthread
, pthread_mutex_trylock
, mutex
,
77 retval
, LTTNG_UST_CALLER_IP());
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(lttng_ust_pthread
, pthread_mutex_unlock
, mutex
,
104 retval
, LTTNG_UST_CALLER_IP());
This page took 0.042985 seconds and 5 git commands to generate.