implement ring buffer clients
[lttng-ust.git] / libust / ltt-ring-buffer-metadata-client.h
index 8b1079d98c7c930dced941601533b9a407a272d1..1ea41176b123ece92d855fb80cd022cef52f0256 100644 (file)
@@ -8,11 +8,11 @@
  * Dual LGPL v2.1/GPL v2 license.
  */
 
-#include <linux/module.h>
-#include <linux/types.h>
-#include "wrapper/vmalloc.h"   /* for wrapper_vmalloc_sync_all() */
+#include <stdint.h>
+#include "ust/bitfield.h"
 #include "ltt-events.h"
 #include "ltt-tracer.h"
+#include "../libringbuffer/frontend_types.h"
 
 struct metadata_packet_header {
        uint32_t magic;                 /* 0x75D11D57 */
@@ -47,7 +47,7 @@ unsigned char record_header_size(const struct lib_ring_buffer_config *config,
        return 0;
 }
 
-#include "wrapper/ringbuffer/api.h"
+#include "../libringbuffer/api.h"
 
 static u64 client_ring_buffer_clock_read(struct channel *chan)
 {
@@ -78,7 +78,7 @@ static size_t client_packet_header_size(void)
 static void client_buffer_begin(struct lib_ring_buffer *buf, u64 tsc,
                                unsigned int subbuf_idx)
 {
-       struct channel *chan = buf->backend.chan;
+       struct channel *chan = shmp(buf->backend.chan);
        struct metadata_packet_header *header =
                (struct metadata_packet_header *)
                        lib_ring_buffer_offset_address(&buf->backend,
@@ -87,7 +87,7 @@ static void client_buffer_begin(struct lib_ring_buffer *buf, u64 tsc,
        struct ltt_session *session = ltt_chan->session;
 
        header->magic = TSDL_MAGIC_NUMBER;
-       memcpy(header->uuid, session->uuid.b, sizeof(session->uuid));
+       memcpy(header->uuid, session->uuid, sizeof(session->uuid));
        header->checksum = 0;           /* 0 if unused */
        header->content_size = 0xFFFFFFFF; /* in bits, for debugging */
        header->packet_size = 0xFFFFFFFF;  /* in bits, for debugging */
@@ -103,7 +103,7 @@ static void client_buffer_begin(struct lib_ring_buffer *buf, u64 tsc,
 static void client_buffer_end(struct lib_ring_buffer *buf, u64 tsc,
                              unsigned int subbuf_idx, unsigned long data_size)
 {
-       struct channel *chan = buf->backend.chan;
+       struct channel *chan = shmp(buf->backend.chan);
        struct metadata_packet_header *header =
                (struct metadata_packet_header *)
                        lib_ring_buffer_offset_address(&buf->backend,
@@ -153,11 +153,12 @@ struct channel *_channel_create(const char *name,
                                struct ltt_channel *ltt_chan, void *buf_addr,
                                size_t subbuf_size, size_t num_subbuf,
                                unsigned int switch_timer_interval,
-                               unsigned int read_timer_interval)
+                               unsigned int read_timer_interval,
+                               int *shmid)
 {
        return channel_create(&client_config, name, ltt_chan, buf_addr,
                              subbuf_size, num_subbuf, switch_timer_interval,
-                             read_timer_interval);
+                             read_timer_interval, shmid);
 }
 
 static
@@ -209,7 +210,7 @@ size_t ltt_packet_avail_size(struct channel *chan)
        unsigned long o_begin;
        struct lib_ring_buffer *buf;
 
-       buf = chan->backend.buf;        /* Only for global buffer ! */
+       buf = shmp(chan->backend.buf);  /* Only for global buffer ! */
        o_begin = v_read(&client_config, &buf->offset);
        if (subbuf_offset(o_begin, chan) != 0) {
                return chan->backend.subbuf_size - subbuf_offset(o_begin, chan);
@@ -219,6 +220,7 @@ size_t ltt_packet_avail_size(struct channel *chan)
        }
 }
 
+#if 0
 static
 wait_queue_head_t *ltt_get_reader_wait_queue(struct channel *chan)
 {
@@ -230,6 +232,7 @@ wait_queue_head_t *ltt_get_hp_wait_queue(struct channel *chan)
 {
        return &chan->hp_wait;
 }
+#endif //0
 
 static
 int ltt_is_finalized(struct channel *chan)
@@ -245,7 +248,6 @@ int ltt_is_disabled(struct channel *chan)
 
 static struct ltt_transport ltt_relay_transport = {
        .name = "relay-" RING_BUFFER_MODE_TEMPLATE_STRING,
-       .owner = THIS_MODULE,
        .ops = {
                .channel_create = _channel_create,
                .channel_destroy = ltt_channel_destroy,
@@ -255,36 +257,23 @@ static struct ltt_transport ltt_relay_transport = {
                .event_commit = ltt_event_commit,
                .event_write = ltt_event_write,
                .packet_avail_size = ltt_packet_avail_size,
-               .get_reader_wait_queue = ltt_get_reader_wait_queue,
-               .get_hp_wait_queue = ltt_get_hp_wait_queue,
+               //.get_reader_wait_queue = ltt_get_reader_wait_queue,
+               //.get_hp_wait_queue = ltt_get_hp_wait_queue,
                .is_finalized = ltt_is_finalized,
                .is_disabled = ltt_is_disabled,
        },
 };
 
-static int __init ltt_ring_buffer_client_init(void)
+static
+void __attribute__((constructor)) ltt_ring_buffer_client_init(void)
 {
-       /*
-        * This vmalloc sync all also takes care of the lib ring buffer
-        * vmalloc'd module pages when it is built as a module into LTTng.
-        */
-       wrapper_vmalloc_sync_all();
-       printk(KERN_INFO "LTT : ltt ring buffer metadata client init\n");
+       printf("LTT : ltt ring buffer client init\n");
        ltt_transport_register(&ltt_relay_transport);
-       return 0;
 }
 
-module_init(ltt_ring_buffer_client_init);
-
-static void __exit ltt_ring_buffer_client_exit(void)
+static
+void __attribute__((destructor)) ltt_ring_buffer_client_exit(void)
 {
-       printk(KERN_INFO "LTT : ltt ring buffer metadata client exit\n");
+       printf("LTT : ltt ring buffer client exit\n");
        ltt_transport_unregister(&ltt_relay_transport);
 }
-
-module_exit(ltt_ring_buffer_client_exit);
-
-MODULE_LICENSE("GPL and additional rights");
-MODULE_AUTHOR("Mathieu Desnoyers");
-MODULE_DESCRIPTION("LTTng ring buffer " RING_BUFFER_MODE_TEMPLATE_STRING
-                  " client");
This page took 0.025398 seconds and 4 git commands to generate.