]> git.lttng.org Git - lttng-modules.git/commitdiff
Makes write operation a parameter for tp_memcpy macro
authorFrancis Giraldeau <francis.giraldeau@gmail.com>
Tue, 5 Jun 2012 15:16:14 +0000 (11:16 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 5 Jun 2012 15:16:14 +0000 (11:16 -0400)
Memcpy source can be either user-space or kernel-space. To avoid code
duplication, this patch makes the operation a parameter to the macros.
Available macros are thus:

* tp_memcpy:               kernel-space array copy
* tp_memcpy_from_user:     user-space array copy
* tp_memcpy_dyn:           kernel-space sequence copy
* tp_memcpy_dyn_from_user: user-space sequence copy

Those are TP_fast_assign macros that can be used with __dynamic_array
macros in TP_STRUCT__entry in a TRACE_EVENT.

Signed-off-by: Francis Giraldeau <francis.giraldeau@gmail.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
probes/lttng-events.h

index 05e17b9bd8e3e9ba3f32037583b2727f63eee551..492423acce0ea5786cab65fb7818775050945f21 100644 (file)
@@ -523,17 +523,27 @@ __assign_##dest:                                                  \
        }                                                               \
        goto __end_field_##dest;
 
-#undef tp_memcpy
-#define tp_memcpy(dest, src, len)                                      \
+/* fixed length array memcpy */
+#undef tp_memcpy_gen
+#define tp_memcpy_gen(write_ops, dest, src, len)                       \
 __assign_##dest:                                                       \
        if (0)                                                          \
                (void) __typemap.dest;                                  \
        lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(__typemap.dest));       \
-       __chan->ops->event_write(&__ctx, src, len);                     \
+       __chan->ops->write_ops(&__ctx, src, len);                       \
        goto __end_field_##dest;
 
-#undef tp_memcpy_dyn
-#define tp_memcpy_dyn(dest, src)                                       \
+#undef tp_memcpy
+#define tp_memcpy(dest, src, len)                                      \
+       tp_memcpy_gen(event_write, dest, src, len)
+
+#undef tp_memcpy_from_user
+#define tp_memcpy_from_user(dest, src, len)                            \
+       tp_memcpy_gen(event_write_from_user, dest, src, len)
+
+/* variable length sequence memcpy */
+#undef tp_memcpy_dyn_gen
+#define tp_memcpy_dyn_gen(write_ops, dest, src)                                \
 __assign_##dest##_1:                                                   \
        {                                                               \
                u32 __tmpl = __dynamic_len[__dynamic_len_idx];          \
@@ -543,18 +553,17 @@ __assign_##dest##_1:                                                      \
        goto __end_field_##dest##_1;                                    \
 __assign_##dest##_2:                                                   \
        lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(__typemap.dest));       \
-       __chan->ops->event_write(&__ctx, src,                           \
+       __chan->ops->write_ops(&__ctx, src,                             \
                sizeof(__typemap.dest) * __get_dynamic_array_len(dest));\
        goto __end_field_##dest##_2;
 
-#undef tp_memcpy_from_user
-#define tp_memcpy_from_user(dest, src, len)                            \
-       __assign_##dest:                                                \
-       if (0)                                                          \
-               (void) __typemap.dest;                                  \
-       lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(__typemap.dest));       \
-       __chan->ops->event_write_from_user(&__ctx, src, len);           \
-       goto __end_field_##dest;
+#undef tp_memcpy_dyn
+#define tp_memcpy_dyn(dest, src)                                       \
+       tp_memcpy_dyn_gen(event_write, dest, src)
+
+#undef tp_memcpy_dyn_from_user
+#define tp_memcpy_dyn_from_user(dest, src)                             \
+       tp_memcpy_dyn_gen(event_write_from_user, dest, src)
 
 /*
  * The string length including the final \0.
This page took 0.030938 seconds and 4 git commands to generate.