Refactoring: Introduce extensibility scheme for tracepoint structures
[lttng-ust.git] / include / lttng / ringbuffer-config.h
index dc0c00c80b5c14b2509d95cbef45290b5f6a5b9d..00f655e5a164dab34a27f926c208742c36f3301b 100644 (file)
@@ -20,7 +20,7 @@
 #include <lttng/ust-compiler.h>
 
 struct lttng_ust_lib_ring_buffer;
-struct channel;
+struct lttng_ust_lib_ring_buffer_channel;
 struct lttng_ust_lib_ring_buffer_config;
 struct lttng_ust_lib_ring_buffer_ctx;
 struct lttng_ust_shm_handle;
@@ -35,9 +35,10 @@ struct lttng_ust_lib_ring_buffer_client_cb {
        /* Mandatory callbacks */
 
        /* A static inline version is also required for fast path */
-       uint64_t (*ring_buffer_clock_read) (struct channel *chan);
+       uint64_t (*ring_buffer_clock_read) (struct lttng_ust_lib_ring_buffer_channel *chan);
        size_t (*record_header_size) (const struct lttng_ust_lib_ring_buffer_config *config,
-                                     struct channel *chan, size_t offset,
+                                     struct lttng_ust_lib_ring_buffer_channel *chan,
+                                     size_t offset,
                                      size_t *pre_header_padding,
                                      struct lttng_ust_lib_ring_buffer_ctx *ctx,
                                      void *client_ctx);
@@ -71,7 +72,8 @@ struct lttng_ust_lib_ring_buffer_client_cb {
         * iterator.
         */
        void (*record_get) (const struct lttng_ust_lib_ring_buffer_config *config,
-                           struct channel *chan, struct lttng_ust_lib_ring_buffer *buf,
+                           struct lttng_ust_lib_ring_buffer_channel *chan,
+                           struct lttng_ust_lib_ring_buffer *buf,
                            size_t offset, size_t *header_len,
                            size_t *payload_len, uint64_t *timestamp,
                            struct lttng_ust_shm_handle *handle);
@@ -210,11 +212,12 @@ struct lttng_ust_lib_ring_buffer_config {
  * UST. Fields need to be only added at the end, never reordered, never
  * removed.
  */
-#define LTTNG_UST_RING_BUFFER_CTX_PADDING      \
-               (24 - sizeof(int) - sizeof(void *) - sizeof(void *))
+#define LTTNG_UST_RING_BUFFER_CTX_PADDING      64
 struct lttng_ust_lib_ring_buffer_ctx {
+       uint32_t struct_size;           /* Size of this structure. */
+
        /* input received by lib_ring_buffer_reserve(), saved here. */
-       struct channel *chan;           /* channel */
+       struct lttng_ust_lib_ring_buffer_channel *chan; /* channel */
        void *priv;                     /* client private data */
        struct lttng_ust_shm_handle *handle;    /* shared-memory handle */
        size_t data_size;               /* size of payload */
@@ -239,21 +242,7 @@ struct lttng_ust_lib_ring_buffer_ctx {
                                         */
        uint64_t tsc;                   /* time-stamp counter value */
        unsigned int rflags;            /* reservation flags */
-       /*
-        * The field ctx_len is the length of struct
-        * lttng_ust_lib_ring_buffer_ctx as known by the user of
-        * lib_ring_buffer_ctx_init.
-        */
-       unsigned int ctx_len;
        void *ip;                       /* caller ip address */
-       void *priv2;                    /* 2nd priv data */
-       char padding2[LTTNG_UST_RING_BUFFER_CTX_PADDING];
-       /*
-        * This is the end of the initial fields expected by the original ABI
-        * between probes and UST. Only the fields above can be used if
-        * ctx_len is 0. Use the value of ctx_len to find out which of the
-        * following fields may be used.
-        */
        struct lttng_ust_lib_ring_buffer_backend_pages *backend_pages;
 };
 
@@ -268,17 +257,16 @@ struct lttng_ust_lib_ring_buffer_ctx {
  */
 static inline lttng_ust_notrace
 void lib_ring_buffer_ctx_init(struct lttng_ust_lib_ring_buffer_ctx *ctx,
-                             struct channel *chan, void *priv,
-                             size_t data_size, int largest_align,
-                             int cpu, struct lttng_ust_shm_handle *handle,
-                             void *priv2);
+                             struct lttng_ust_lib_ring_buffer_channel *chan,
+                             void *priv, size_t data_size, int largest_align,
+                             int cpu, struct lttng_ust_shm_handle *handle);
 static inline
 void lib_ring_buffer_ctx_init(struct lttng_ust_lib_ring_buffer_ctx *ctx,
-                             struct channel *chan, void *priv,
-                             size_t data_size, int largest_align,
-                             int cpu, struct lttng_ust_shm_handle *handle,
-                             void *priv2)
+                             struct lttng_ust_lib_ring_buffer_channel *chan,
+                             void *priv, size_t data_size, int largest_align,
+                             int cpu, struct lttng_ust_shm_handle *handle)
 {
+       ctx->struct_size = sizeof(struct lttng_ust_lib_ring_buffer_ctx);
        ctx->chan = chan;
        ctx->priv = priv;
        ctx->data_size = data_size;
@@ -286,10 +274,7 @@ void lib_ring_buffer_ctx_init(struct lttng_ust_lib_ring_buffer_ctx *ctx,
        ctx->cpu = cpu;
        ctx->rflags = 0;
        ctx->handle = handle;
-       ctx->ctx_len = sizeof(struct lttng_ust_lib_ring_buffer_ctx);
        ctx->ip = 0;
-       ctx->priv2 = priv2;
-       memset(ctx->padding2, 0, LTTNG_UST_RING_BUFFER_CTX_PADDING);
 }
 
 /*
This page took 0.024262 seconds and 4 git commands to generate.