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 LTTNG_UST_TRACEPOINT_HIDDEN_DEFINITION
20 #define LTTNG_UST_TRACEPOINT_PROVIDER_HIDDEN_DEFINITION
22 #define LTTNG_UST_TRACEPOINT_DEFINE
23 #define LTTNG_UST_TRACEPOINT_CREATE_PROBES
24 #define LTTNG_UST_TP_IP_PARAM ip
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 lttng_ust_tracepoint(lttng_ust_pthread
, pthread_mutex_lock_req
, mutex
,
50 LTTNG_UST_CALLER_IP());
51 retval
= mutex_lock(mutex
);
52 lttng_ust_tracepoint(lttng_ust_pthread
, pthread_mutex_lock_acq
, mutex
,
53 retval
, LTTNG_UST_CALLER_IP());
58 int pthread_mutex_trylock(pthread_mutex_t
*mutex
)
60 static int (*mutex_trylock
)(pthread_mutex_t
*);
64 mutex_trylock
= dlsym(RTLD_NEXT
, "pthread_mutex_trylock");
66 if (thread_in_trace
) {
69 fprintf(stderr
, "unable to initialize pthread wrapper library.\n");
73 if (thread_in_trace
) {
74 return mutex_trylock(mutex
);
78 retval
= mutex_trylock(mutex
);
79 lttng_ust_tracepoint(lttng_ust_pthread
, pthread_mutex_trylock
, mutex
,
80 retval
, LTTNG_UST_CALLER_IP());
85 int pthread_mutex_unlock(pthread_mutex_t
*mutex
)
87 static int (*mutex_unlock
)(pthread_mutex_t
*);
91 mutex_unlock
= dlsym(RTLD_NEXT
, "pthread_mutex_unlock");
93 if (thread_in_trace
) {
96 fprintf(stderr
, "unable to initialize pthread wrapper library.\n");
100 if (thread_in_trace
) {
101 return mutex_unlock(mutex
);
105 retval
= mutex_unlock(mutex
);
106 lttng_ust_tracepoint(lttng_ust_pthread
, pthread_mutex_unlock
, mutex
,
107 retval
, LTTNG_UST_CALLER_IP());
This page took 0.031462 seconds and 4 git commands to generate.