Specialize lttng_ust_lib_ring_buffer_client_cb
authorJulien Desfossez <jdesfossez@efficios.com>
Thu, 19 Sep 2013 17:51:53 +0000 (13:51 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 19 Sep 2013 19:28:13 +0000 (14:28 -0500)
Prepare the ring-buffer config to have custom callbacks. These custom
callbacks are not related to the ring-buffer operations but allow
applications to add custom functions.
No additional feature or change in behaviour in this patch.

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Acked-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
include/lttng/ringbuffer-config.h
include/lttng/ust-events.h
liblttng-ust/Makefile.am
liblttng-ust/lttng-rb-clients.h [new file with mode: 0644]
liblttng-ust/lttng-ring-buffer-client.h
liblttng-ust/lttng-ring-buffer-metadata-client.h

index 3b7d348aa8b2d0e1f8b5be0ea00039ea13fa5e2d..9de9a73807ca634e4795bf70e39e44e5e0f9bf11 100644 (file)
@@ -133,7 +133,7 @@ struct lttng_ust_lib_ring_buffer_client_cb {
  * RING_BUFFER_WAKEUP_NONE does not perform any wakeup whatsoever. The client
  * has the responsibility to perform wakeups.
  */
-#define LTTNG_UST_RING_BUFFER_CONFIG_PADDING   32
+#define LTTNG_UST_RING_BUFFER_CONFIG_PADDING   20
 
 enum lttng_ust_lib_ring_buffer_alloc_types {
        RING_BUFFER_ALLOC_PER_CPU,
@@ -204,6 +204,8 @@ struct lttng_ust_lib_ring_buffer_config {
         * callbacks and update the cb pointers.
         */
        int client_type;
+       int _unused1;
+       const struct lttng_ust_lib_ring_buffer_client_cb *cb_ptr;
        char padding[LTTNG_UST_RING_BUFFER_CONFIG_PADDING];
 };
 
index f40c04488ba8e1cac5b2cb7318a98355ecbbccd5..74a3bc651f4302c98aaff17e9db878a48e07ca47 100644 (file)
@@ -569,9 +569,9 @@ int lttng_add_ip_to_ctx(struct lttng_ctx **ctx);
 void lttng_context_vtid_reset(void);
 void lttng_context_vpid_reset(void);
 
-extern const struct lttng_ust_lib_ring_buffer_client_cb *lttng_client_callbacks_metadata;
-extern const struct lttng_ust_lib_ring_buffer_client_cb *lttng_client_callbacks_discard;
-extern const struct lttng_ust_lib_ring_buffer_client_cb *lttng_client_callbacks_overwrite;
+extern const struct lttng_ust_client_lib_ring_buffer_client_cb *lttng_client_callbacks_metadata;
+extern const struct lttng_ust_client_lib_ring_buffer_client_cb *lttng_client_callbacks_discard;
+extern const struct lttng_ust_client_lib_ring_buffer_client_cb *lttng_client_callbacks_overwrite;
 
 struct lttng_transport *lttng_transport_find(const char *name);
 
index f06571cc25502372e832b17e301d1a0c9b2aaa08..a33331391eb59662092009c1df1ea30c76705b15 100644 (file)
@@ -47,6 +47,7 @@ liblttng_ust_support_la_SOURCES = \
        lttng-tracer.h \
        lttng-tracer-core.h \
        ust-core.c \
+       lttng-rb-clients.h \
        lttng-ring-buffer-client.h \
        lttng-ring-buffer-client-discard.c \
        lttng-ring-buffer-client-discard-rt.c \
diff --git a/liblttng-ust/lttng-rb-clients.h b/liblttng-ust/lttng-rb-clients.h
new file mode 100644 (file)
index 0000000..c9a1619
--- /dev/null
@@ -0,0 +1,26 @@
+#ifndef _LTTNG_RB_CLIENT_H
+#define _LTTNG_RB_CLIENT_H
+
+/*
+ * Copyright (c) 2013 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+struct lttng_ust_client_lib_ring_buffer_client_cb {
+       struct lttng_ust_lib_ring_buffer_client_cb parent;
+};
+
+#endif /* _LTTNG_RB_CLIENT_H */
index 72b6d2c8f1a21a2328f726eb94b50d6503929cd2..383fce0186ae25a05acb3c5f43315b890697c485 100644 (file)
@@ -161,6 +161,7 @@ unsigned char record_header_size(const struct lttng_ust_lib_ring_buffer_config *
 }
 
 #include "../libringbuffer/api.h"
+#include "lttng-rb-clients.h"
 
 static
 void lttng_write_event_header_slow(const struct lttng_ust_lib_ring_buffer_config *config,
@@ -385,6 +386,19 @@ static void client_buffer_finalize(struct lttng_ust_lib_ring_buffer *buf, void *
 {
 }
 
+static const
+struct lttng_ust_client_lib_ring_buffer_client_cb client_cb = {
+       .parent = {
+               .ring_buffer_clock_read = client_ring_buffer_clock_read,
+               .record_header_size = client_record_header_size,
+               .subbuffer_header_size = client_packet_header_size,
+               .buffer_begin = client_buffer_begin,
+               .buffer_end = client_buffer_end,
+               .buffer_create = client_buffer_create,
+               .buffer_finalize = client_buffer_finalize,
+       },
+};
+
 static const struct lttng_ust_lib_ring_buffer_config client_config = {
        .cb.ring_buffer_clock_read = client_ring_buffer_clock_read,
        .cb.record_header_size = client_record_header_size,
@@ -404,9 +418,11 @@ static const struct lttng_ust_lib_ring_buffer_config client_config = {
        .ipi = RING_BUFFER_NO_IPI_BARRIER,
        .wakeup = LTTNG_CLIENT_WAKEUP,
        .client_type = LTTNG_CLIENT_TYPE,
+
+       .cb_ptr = &client_cb.parent,
 };
 
-const struct lttng_ust_lib_ring_buffer_client_cb *LTTNG_CLIENT_CALLBACKS = &client_config.cb;
+const struct lttng_ust_client_lib_ring_buffer_client_cb *LTTNG_CLIENT_CALLBACKS = &client_cb;
 
 static
 struct lttng_channel *_channel_create(const char *name,
index 89f2620c9fbd710a3adbcf30304e2a8d62d5c04a..0d2a1f838e623ab8147221f23ed4e9ad3a487720 100644 (file)
@@ -61,6 +61,7 @@ unsigned char record_header_size(const struct lttng_ust_lib_ring_buffer_config *
 }
 
 #include "../libringbuffer/api.h"
+#include "lttng-rb-clients.h"
 
 static uint64_t client_ring_buffer_clock_read(struct channel *chan)
 {
@@ -153,6 +154,19 @@ static void client_buffer_finalize(struct lttng_ust_lib_ring_buffer *buf,
 {
 }
 
+static const
+struct lttng_ust_client_lib_ring_buffer_client_cb client_cb = {
+       .parent = {
+               .ring_buffer_clock_read = client_ring_buffer_clock_read,
+               .record_header_size = client_record_header_size,
+               .subbuffer_header_size = client_packet_header_size,
+               .buffer_begin = client_buffer_begin,
+               .buffer_end = client_buffer_end,
+               .buffer_create = client_buffer_create,
+               .buffer_finalize = client_buffer_finalize,
+       },
+};
+
 static const struct lttng_ust_lib_ring_buffer_config client_config = {
        .cb.ring_buffer_clock_read = client_ring_buffer_clock_read,
        .cb.record_header_size = client_record_header_size,
@@ -172,9 +186,11 @@ static const struct lttng_ust_lib_ring_buffer_config client_config = {
        .ipi = RING_BUFFER_NO_IPI_BARRIER,
        .wakeup = RING_BUFFER_WAKEUP_BY_WRITER,
        .client_type = LTTNG_CLIENT_TYPE,
+
+        .cb_ptr = &client_cb.parent,
 };
 
-const struct lttng_ust_lib_ring_buffer_client_cb *LTTNG_CLIENT_CALLBACKS = &client_config.cb;
+const struct lttng_ust_client_lib_ring_buffer_client_cb *LTTNG_CLIENT_CALLBACKS = &client_cb;
 
 static
 struct lttng_channel *_channel_create(const char *name,
This page took 0.028231 seconds and 4 git commands to generate.