Signed-off-by: Julien Desfossez <[email protected]>
---
 include/lttng/ust-ctl.h                 |  2 ++
 liblttng-ust-ctl/ustctl.c               | 15 +++++++++++++++
 liblttng-ust/lttng-rb-clients.h         |  3 +++
 liblttng-ust/lttng-ring-buffer-client.h | 13 +++++++++++++
 4 files changed, 33 insertions(+)

diff --git a/include/lttng/ust-ctl.h b/include/lttng/ust-ctl.h
index 88112ad..c8ac3f9 100644
--- a/include/lttng/ust-ctl.h
+++ b/include/lttng/ust-ctl.h
@@ -233,6 +233,8 @@ int ustctl_get_packet_size(struct ustctl_consumer_stream 
*stream,
        uint64_t *packet_size);
 int ustctl_get_stream_id(struct ustctl_consumer_stream *stream,
                uint64_t *stream_id);
+int ustctl_get_current_timestamp(struct ustctl_consumer_stream *stream,
+               uint64_t *ts);
 
 /* event registry management */
 
diff --git a/liblttng-ust-ctl/ustctl.c b/liblttng-ust-ctl/ustctl.c
index 7830132..11fc704 100644
--- a/liblttng-ust-ctl/ustctl.c
+++ b/liblttng-ust-ctl/ustctl.c
@@ -1571,6 +1571,21 @@ int ustctl_get_stream_id(struct ustctl_consumer_stream 
*stream,
        return client_cb->stream_id(buf, handle, stream_id);
 }
 
+int ustctl_get_current_timestamp(struct ustctl_consumer_stream *stream,
+               uint64_t *ts)
+{
+       struct lttng_ust_client_lib_ring_buffer_client_cb *client_cb;
+       struct lttng_ust_lib_ring_buffer *buf = stream->buf;
+       struct lttng_ust_shm_handle *handle = stream->chan->chan->handle;
+
+       if (!stream || !ts)
+               return -EINVAL;
+       client_cb = get_client_cb(buf, handle);
+       if (!client_cb || !client_cb->current_timestamp)
+               return -ENOSYS;
+       return client_cb->current_timestamp(buf, handle, ts);
+}
+
 /*
  * Returns 0 on success, negative error value on error.
  */
diff --git a/liblttng-ust/lttng-rb-clients.h b/liblttng-ust/lttng-rb-clients.h
index c43aa75..85d4e1b 100644
--- a/liblttng-ust/lttng-rb-clients.h
+++ b/liblttng-ust/lttng-rb-clients.h
@@ -40,6 +40,9 @@ struct lttng_ust_client_lib_ring_buffer_client_cb {
        int (*stream_id) (struct lttng_ust_lib_ring_buffer *buf,
                        struct lttng_ust_shm_handle *handle,
                        uint64_t *stream_id);
+       int (*current_timestamp) (struct lttng_ust_lib_ring_buffer *buf,
+                       struct lttng_ust_shm_handle *handle,
+                       uint64_t *ts);
 };
 
 #endif /* _LTTNG_RB_CLIENT_H */
diff --git a/liblttng-ust/lttng-ring-buffer-client.h 
b/liblttng-ust/lttng-ring-buffer-client.h
index 4671713..2cdecbe 100644
--- a/liblttng-ust/lttng-ring-buffer-client.h
+++ b/liblttng-ust/lttng-ring-buffer-client.h
@@ -470,6 +470,18 @@ static int client_stream_id(struct 
lttng_ust_lib_ring_buffer *buf,
        return 0;
 }
 
+static int client_current_timestamp(struct lttng_ust_lib_ring_buffer *buf,
+               struct lttng_ust_shm_handle *handle,
+               uint64_t *ts)
+{
+       struct channel *chan;
+
+       chan = shmp(handle, handle->chan);
+       *ts = client_ring_buffer_clock_read(chan);
+
+       return 0;
+}
+
 static const
 struct lttng_ust_client_lib_ring_buffer_client_cb client_cb = {
        .parent = {
@@ -487,6 +499,7 @@ struct lttng_ust_client_lib_ring_buffer_client_cb client_cb 
= {
        .content_size = client_content_size,
        .packet_size = client_packet_size,
        .stream_id = client_stream_id,
+       .current_timestamp = client_current_timestamp,
 };
 
 static const struct lttng_ust_lib_ring_buffer_config client_config = {
-- 
1.8.3.2


_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

Reply via email to