2 * SPDX-License-Identifier: LGPL-2.1-only
4 * Copyright (C) 2016 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
7 #ifndef _UST_COMMON_CLOCK_H
8 #define _UST_COMMON_CLOCK_H
16 #include <urcu/system.h>
17 #include <urcu/arch.h>
18 #include <lttng/ust-clock.h>
20 struct lttng_ust_trace_clock
{
21 uint64_t (*read64
)(void);
22 uint64_t (*freq
)(void);
23 int (*uuid
)(char *uuid
);
24 const char *(*name
)(void);
25 const char *(*description
)(void);
29 * The trace clock is a public symbol of liblttng-ust-common accessed by other
30 * libraries through the trace_clock_read64 static inline function. It is
31 * initialised in the liblttng-ust-common constructor.
33 extern struct lttng_ust_trace_clock
*lttng_ust_trace_clock
;
35 /* Use the kernel MONOTONIC clock. */
38 uint64_t trace_clock_read64_monotonic(void)
42 if (caa_unlikely(clock_gettime(CLOCK_MONOTONIC
, &ts
))) {
46 return ((uint64_t) ts
.tv_sec
* 1000000000ULL) + ts
.tv_nsec
;
50 uint64_t trace_clock_read64(void)
52 struct lttng_ust_trace_clock
*ltc
= CMM_LOAD_SHARED(lttng_ust_trace_clock
);
54 if (caa_likely(!ltc
)) {
55 return trace_clock_read64_monotonic();
57 cmm_read_barrier_depends(); /* load ltc before content */
62 #endif /* _UST_COMMON_CLOCK_H */
This page took 0.030543 seconds and 4 git commands to generate.