From: Julien Desfossez Date: Thu, 19 Sep 2013 17:51:55 +0000 (-0400) Subject: Per-stream ioctl to get the current timestamp X-Git-Tag: v2.4.0-rc1~34 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=fca361e81cbb39f076182e9d2c6dd2c4c8c25b5d;p=lttng-ust.git Per-stream ioctl to get the current timestamp Signed-off-by: Julien Desfossez Signed-off-by: Mathieu Desnoyers --- diff --git a/include/lttng/ust-ctl.h b/include/lttng/ust-ctl.h index 88112adc..c8ac3f90 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 7830132b..11fc7044 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 c43aa756..85d4e1bc 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 46717135..2cdecbe9 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 = {