Namespace RING_BUFFER_ALIGN macros
[lttng-ust.git] / include / lttng / ringbuffer-context.h
index 53670d9313b2973694767889c055d50f5be43209..0092a0f19d122390f3e23f41dce62b47422129cc 100644 (file)
 #include <string.h>
 
 #include <lttng/ust-tracer.h>
-#include <lttng/ust-align.h>
+#include <lttng/ust-utils.h>
 #include <lttng/ust-compiler.h>
 
 struct lttng_ust_lib_ring_buffer;
 struct lttng_ust_lib_ring_buffer_channel;
 struct lttng_ust_lib_ring_buffer_ctx;
-struct lttng_ust_shm_handle;
 
 /*
  * ring buffer context
@@ -40,35 +39,35 @@ struct lttng_ust_shm_handle;
  * at the end of the structure.
  */
 struct lttng_ust_lib_ring_buffer_ctx {
-       uint32_t struct_size;           /* Size of this structure. */
+       uint32_t struct_size;                   /* Size of this structure. */
 
-       /* input received by lib_ring_buffer_reserve(), saved here. */
+       /* input received by lib_ring_buffer_reserve(). */
        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 */
-       int largest_align;              /*
-                                        * alignment of the largest element
-                                        * in the payload
-                                        */
+       void *priv;                             /* client private data */
+       size_t data_size;                       /* size of payload */
+       int largest_align;                      /*
+                                                * alignment of the largest element
+                                                * in the payload
+                                                */
 
        /* output from lib_ring_buffer_reserve() */
-       int reserve_cpu;                /* processor id updated by the reserve */
+       int reserve_cpu;                        /* processor id updated by the reserve */
+       size_t slot_size;                       /* size of the reserved slot */
+       unsigned long buf_offset;               /* offset following the record header */
+       unsigned long pre_offset;               /*
+                                                * Initial offset position _before_
+                                                * the record is written. Positioned
+                                                * prior to record header alignment
+                                                * padding.
+                                                */
+       uint64_t tsc;                           /* time-stamp counter value */
+       unsigned int rflags;                    /* reservation flags */
+       void *ip;                               /* caller ip address */
+
        struct lttng_ust_lib_ring_buffer *buf;  /*
-                                        * buffer corresponding to processor id
-                                        * for this channel
-                                        */
-       size_t slot_size;               /* size of the reserved slot */
-       unsigned long buf_offset;       /* offset following the record header */
-       unsigned long pre_offset;       /*
-                                        * Initial offset position _before_
-                                        * the record is written. Positioned
-                                        * prior to record header alignment
-                                        * padding.
-                                        */
-       uint64_t tsc;                   /* time-stamp counter value */
-       unsigned int rflags;            /* reservation flags */
-       void *ip;                       /* caller ip address */
+                                                * buffer corresponding to processor id
+                                                * for this channel
+                                                */
        struct lttng_ust_lib_ring_buffer_backend_pages *backend_pages;
 
        /* End of base ABI. Fields below should be used after checking struct_size. */
@@ -85,13 +84,11 @@ 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 lttng_ust_lib_ring_buffer_channel *chan,
-                             void *priv, size_t data_size, int largest_align,
-                             struct lttng_ust_shm_handle *handle);
+                             void *priv, size_t data_size, int largest_align);
 static inline
 void lib_ring_buffer_ctx_init(struct lttng_ust_lib_ring_buffer_ctx *ctx,
                              struct lttng_ust_lib_ring_buffer_channel *chan,
-                             void *priv, size_t data_size, int largest_align,
-                             struct lttng_ust_shm_handle *handle)
+                             void *priv, size_t data_size, int largest_align)
 {
        ctx->struct_size = sizeof(struct lttng_ust_lib_ring_buffer_ctx);
        ctx->chan = chan;
@@ -100,23 +97,24 @@ void lib_ring_buffer_ctx_init(struct lttng_ust_lib_ring_buffer_ctx *ctx,
        ctx->reserve_cpu = -1;
        ctx->largest_align = largest_align;
        ctx->rflags = 0;
-       ctx->handle = handle;
        ctx->ip = 0;
 }
 
 /*
- * We need to define RING_BUFFER_ALIGN_ATTR so it is known early at
+ * We need to define LTTNG_UST_RING_BUFFER_ALIGN_ATTR so it is known early at
  * compile-time. We have to duplicate the "config->align" information and the
  * definition here because config->align is used both in the slow and fast
- * paths, but RING_BUFFER_ALIGN_ATTR is only available for the client code.
+ * paths, but LTTNG_UST_RING_BUFFER_ALIGN_ATTR is only available for the client
+ * code.
  */
-#ifdef RING_BUFFER_ALIGN
+#ifdef LTTNG_UST_RING_BUFFER_NATURAL_ALIGN
 
-# define RING_BUFFER_ALIGN_ATTR                /* Default arch alignment */
+# define LTTNG_UST_RING_BUFFER_ALIGN_ATTR      /* Default arch alignment */
 
 /*
- * Calculate the offset needed to align the type.
- * size_of_type must be non-zero.
+ * lib_ring_buffer_align - Calculate the offset needed to align the type.
+ * @align_drift:  object offset from an "alignment"-aligned address.
+ * @size_of_type: Must be non-zero, power of 2.
  */
 static inline lttng_ust_notrace
 unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type);
@@ -128,17 +126,22 @@ unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type)
 
 #else
 
-# define RING_BUFFER_ALIGN_ATTR __attribute__((packed))
+# define LTTNG_UST_RING_BUFFER_ALIGN_ATTR __attribute__((packed))
 
 /*
- * Calculate the offset needed to align the type.
- * size_of_type must be non-zero.
+ * lib_ring_buffer_align - Calculate the offset needed to align the type.
+ * @align_drift:  object offset from an "alignment"-aligned address.
+ * @size_of_type: Must be non-zero, power of 2.
  */
 static inline lttng_ust_notrace
 unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type);
 static inline
 unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type)
 {
+       /*
+        * On architectures with efficient unaligned memory access, the content
+        * of the ringbuffer is packed and so the offset is always zero.
+        */
        return 0;
 }
 
This page took 0.027089 seconds and 4 git commands to generate.