Cleanup: apply `include-what-you-use` guideline for `uint*_t`
[lttng-ust.git] / liblttng-ust-ctl / ustctl.c
index 7b41b992fc03dc511554bb52e5fc350ac435e8cf..39c8baa4b4fea4b586a9323290b6287acd4e86f4 100644 (file)
  */
 
 #define _GNU_SOURCE
+#include <byteswap.h>
+#include <stdint.h>
 #include <string.h>
+#include <sys/mman.h>
+
 #include <lttng/ust-config.h>
 #include <lttng/ust-ctl.h>
 #include <lttng/ust-abi.h>
 #include <lttng/ust-events.h>
-#include <sys/mman.h>
-#include <byteswap.h>
-
 #include <usterr-signal-safe.h>
 #include <ust-comm.h>
 #include <helper.h>
@@ -77,8 +78,6 @@ extern void lttng_ring_buffer_client_discard_exit(void);
 extern void lttng_ring_buffer_client_discard_rt_exit(void);
 extern void lttng_ring_buffer_metadata_client_exit(void);
 
-volatile enum ust_loglevel ust_loglevel;
-
 int ustctl_release_handle(int sock, int handle)
 {
        struct ustcomm_ust_msg lum;
@@ -1057,7 +1056,8 @@ struct ustctl_consumer_channel *
                        attr->switch_timer_interval,
                        attr->read_timer_interval,
                        attr->uuid, attr->chan_id,
-                       stream_fds, nr_stream_fds);
+                       stream_fds, nr_stream_fds,
+                       attr->blocking_timeout);
        if (!chan->chan) {
                goto chan_error;
        }
@@ -1501,6 +1501,25 @@ int ustctl_snapshot(struct ustctl_consumer_stream *stream)
                        &buf->prod_snapshot, consumer_chan->chan->handle);
 }
 
+/*
+ * Get a snapshot of the current ring buffer producer and consumer positions
+ * even if the consumed and produced positions are contained within the same
+ * subbuffer.
+ */
+int ustctl_snapshot_sample_positions(struct ustctl_consumer_stream *stream)
+{
+       struct lttng_ust_lib_ring_buffer *buf;
+       struct ustctl_consumer_channel *consumer_chan;
+
+       if (!stream)
+               return -EINVAL;
+       buf = stream->buf;
+       consumer_chan = stream->chan;
+       return lib_ring_buffer_snapshot_sample_positions(buf,
+                       &buf->cons_snapshot, &buf->prod_snapshot,
+                       consumer_chan->chan->handle);
+}
+
 /* Get the consumer position (iteration start) */
 int ustctl_snapshot_get_consumed(struct ustctl_consumer_stream *stream,
                unsigned long *pos)
@@ -1570,6 +1589,19 @@ void ustctl_flush_buffer(struct ustctl_consumer_stream *stream,
                consumer_chan->chan->handle);
 }
 
+void ustctl_clear_buffer(struct ustctl_consumer_stream *stream)
+{
+       struct lttng_ust_lib_ring_buffer *buf;
+       struct ustctl_consumer_channel *consumer_chan;
+
+       assert(stream);
+       buf = stream->buf;
+       consumer_chan = stream->chan;
+       lib_ring_buffer_switch_slow(buf, SWITCH_ACTIVE,
+               consumer_chan->chan->handle);
+       lib_ring_buffer_clear_reader(buf, consumer_chan->chan->handle);
+}
+
 static
 struct lttng_ust_client_lib_ring_buffer_client_cb *get_client_cb(
                struct lttng_ust_lib_ring_buffer *buf,
This page took 0.02458 seconds and 4 git commands to generate.