Fix: bytecode linker: validate event and field array/sequence encoding
[lttng-ust.git] / liblttng-ust / clock.h
CommitLineData
8d8a24c8 1/*
c0c0989a 2 * SPDX-License-Identifier: LGPL-2.1-only
518d7abb 3 *
c0c0989a
MJ
4 * Copyright (C) 2010 Pierre-Marc Fournier
5 * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
518d7abb
PMF
6 */
7
9c6bb081
JD
8#ifndef _UST_CLOCK_H
9#define _UST_CLOCK_H
518d7abb 10
ca4525b5 11#include <time.h>
518d7abb 12#include <sys/time.h>
9edd34bd
MD
13#include <stdint.h>
14#include <stddef.h>
939950af 15#include <stdio.h>
f9364363
MD
16#include <urcu/system.h>
17#include <urcu/arch.h>
18#include <lttng/ust-clock.h>
19
eda498b8 20#include "lttng-ust-uuid.h"
518d7abb 21
f9364363
MD
22struct lttng_trace_clock {
23 uint64_t (*read64)(void);
24 uint64_t (*freq)(void);
25 int (*uuid)(char *uuid);
26 const char *(*name)(void);
27 const char *(*description)(void);
28};
518d7abb 29
f9364363 30extern struct lttng_trace_clock *lttng_trace_clock;
518d7abb 31
f9364363
MD
32void lttng_ust_clock_init(void);
33
34/* Use the kernel MONOTONIC clock. */
518d7abb 35
28b12049 36static __inline__
f9364363 37uint64_t trace_clock_read64_monotonic(void)
9c6bb081
JD
38{
39 struct timespec ts;
9c6bb081 40
77686037
MD
41 if (caa_unlikely(clock_gettime(CLOCK_MONOTONIC, &ts))) {
42 ts.tv_sec = 0;
43 ts.tv_nsec = 0;
44 }
dc190cc1 45 return ((uint64_t) ts.tv_sec * 1000000000ULL) + ts.tv_nsec;
9c6bb081
JD
46}
47
f9364363
MD
48static __inline__
49uint64_t trace_clock_read64(void)
50{
51 struct lttng_trace_clock *ltc = CMM_LOAD_SHARED(lttng_trace_clock);
52
53 if (caa_likely(!ltc)) {
54 return trace_clock_read64_monotonic();
55 } else {
56 cmm_read_barrier_depends(); /* load ltc before content */
57 return ltc->read64();
58 }
59}
60
9c6bb081 61#endif /* _UST_CLOCK_H */
This page took 0.037045 seconds and 4 git commands to generate.