text
[lttv.git] / genevent-new / gentest.c
index b0908ccfcc11dfeddfc90da5dfcff3c1df6c1eed..f1dc3ec44bfb9d2419f32c52d3f61ac963a8f64d 100644 (file)
@@ -1,13 +1,21 @@
 
+#define __KERNEL__
+
 #include <assert.h>
 #include <sys/types.h>
 #include <stdint.h>
 #include <stdlib.h>
+#include <string.h>
+
+#include <linux/compiler.h>
 
 #define min(a,b) (((a)<(b))?a:b)
 #define max(a,b) (((a)>(b))?a:b)
 #define BUG_ON(a) assert(!(a))
 
+// Useful outside __KERNEL__. Not used here because inline is already redefined.
+#define force_inline inline __attribute__((always_inline))
+
 /* Calculate the offset needed to align the type */
 static inline unsigned int ltt_align(size_t align_drift,
                                                                                                                                                 size_t size_of_type)
@@ -74,7 +82,7 @@ static inline void lttng_write_mystruct2(
                size_t *len,
                struct lttng_mystruct2 *obj)
 {
-       size_t align, size, varalign;
+       size_t align, size;
 
        align = lttng_get_alignment_mystruct2(obj);
        size = lttng_get_size_mystruct2(obj);
@@ -161,6 +169,10 @@ static inline size_t lttng_get_size_sequence_mystruct_mysequence(
        locsize = sizeof(double);
        size += ltt_align(size, locsize) + (obj->len * locsize);
 
+       /* Realign on arch size */
+       locsize = sizeof(void *);
+       size += ltt_align(size, locsize);
+
        return size;
 }
 
@@ -222,7 +234,7 @@ static inline void lttng_write_sequence_mystruct_mysequence(
        *to = ltt_align(*to, sizeof(void *));
        *to_base = *to_base+*to;
        *to = 0;
-       
+
        /* Put source *from just after the C sequence */
        *from = obj+1;
 }
@@ -390,11 +402,11 @@ static inline void lttng_write_mystruct(
 
        /* Variable length field */
        lttng_write_sequence_mystruct_mysequence(to_base, to, from, len, &obj->mysequence);
+       //*to = 0;      /* Force the compiler to know it's 0 */
        /* After this previous write, we are sure that *to is 0, and *to_base is
         * aligned on the architecture size : to rest of alignment will be calculated
         * statically. */
 
-
        lttng_write_mystruct_myunion(to_base, to, from, len, &obj->myunion);
 
        /* Don't forget to flush last write..... */
This page took 0.023064 seconds and 4 git commands to generate.