2 * Copyright (C) 2014 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
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; version 2.1 of
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
23 #include <usterr-signal-safe.h>
24 #include <lttng/ust-clock.h>
25 #include <urcu/system.h>
26 #include <urcu/arch.h>
31 struct lttng_trace_clock
*lttng_trace_clock
;
34 struct lttng_trace_clock user_tc
;
39 int lttng_ust_trace_clock_set_read64_cb(uint64_t (*read64
)(void))
41 if (CMM_LOAD_SHARED(lttng_trace_clock
))
43 user_tc
.read64
= read64
;
47 int lttng_ust_trace_clock_set_freq_cb(uint64_t (*freq
)(void))
49 if (CMM_LOAD_SHARED(lttng_trace_clock
))
55 int lttng_ust_trace_clock_set_uuid_cb(int (*uuid
)(char *uuid
))
57 if (CMM_LOAD_SHARED(lttng_trace_clock
))
63 int lttng_ust_trace_clock_set_name_cb(const char *(*name
)(void))
65 if (CMM_LOAD_SHARED(lttng_trace_clock
))
71 int lttng_ust_trace_clock_set_description_cb(const char *(*description
)(void))
73 if (CMM_LOAD_SHARED(lttng_trace_clock
))
75 user_tc
.description
= description
;
79 int lttng_ust_enable_trace_clock_override(void)
81 if (CMM_LOAD_SHARED(lttng_trace_clock
))
89 if (!user_tc
.description
)
91 /* Use default uuid cb when NULL */
92 cmm_smp_mb(); /* Store callbacks before trace clock */
93 CMM_STORE_SHARED(lttng_trace_clock
, &user_tc
);
97 void lttng_ust_clock_init(void)
100 void (*libinit
)(void);
104 libname
= lttng_secure_getenv("LTTNG_UST_CLOCK_PLUGIN");
107 clock_handle
= dlopen(libname
, RTLD_NOW
);
109 PERROR("Cannot load LTTng UST clock override library %s",
114 libinit
= (void (*)(void)) dlsym(clock_handle
,
115 "lttng_ust_clock_plugin_init");
117 PERROR("Cannot find LTTng UST clock override library %s initialization function lttng_ust_clock_plugin_init()",