Fix: endianness of integers received by filter
[lttng-ust.git] / include / lttng / ust-tracepoint-event.h
index 6632f67a3c8bb8c5e29d21efcb21c082ac407da2..c3275d46e82454ffb52e98e611c45a11bc5104a5 100644 (file)
@@ -28,6 +28,7 @@
 #include <lttng/ringbuffer-config.h>
 #include <lttng/ust-compiler.h>
 #include <lttng/tracepoint.h>
+#include <byteswap.h>
 #include <string.h>
 
 #undef tp_list_for_each_entry_rcu
@@ -317,18 +318,24 @@ size_t __event_get_size__##_provider##___##_name(size_t *__dynamic_len, _TP_ARGS
                case 2:                                                        \
                {                                                              \
                        union { _type t; int16_t v; } __tmp = { (_type) (_src) }; \
+                       if (_byte_order != BYTE_ORDER)                         \
+                               __tmp.v = bswap_16(__tmp.v);                   \
                        __ctf_tmp_int64 = (int64_t) __tmp.v;                   \
                        break;                                                 \
                }                                                              \
                case 4:                                                        \
                {                                                              \
                        union { _type t; int32_t v; } __tmp = { (_type) (_src) }; \
+                       if (_byte_order != BYTE_ORDER)                         \
+                               __tmp.v = bswap_32(__tmp.v);                   \
                        __ctf_tmp_int64 = (int64_t) __tmp.v;                   \
                        break;                                                 \
                }                                                              \
                case 8:                                                        \
                {                                                              \
                        union { _type t; int64_t v; } __tmp = { (_type) (_src) }; \
+                       if (_byte_order != BYTE_ORDER)                         \
+                               __tmp.v = bswap_64(__tmp.v);                   \
                        __ctf_tmp_int64 = (int64_t) __tmp.v;                   \
                        break;                                                 \
                }                                                              \
@@ -348,18 +355,24 @@ size_t __event_get_size__##_provider##___##_name(size_t *__dynamic_len, _TP_ARGS
                case 2:                                                        \
                {                                                              \
                        union { _type t; uint16_t v; } __tmp = { (_type) (_src) }; \
+                       if (_byte_order != BYTE_ORDER)                         \
+                               __tmp.v = bswap_16(__tmp.v);                   \
                        __ctf_tmp_uint64 = (uint64_t) __tmp.v;                 \
                        break;                                                 \
                }                                                              \
                case 4:                                                        \
                {                                                              \
                        union { _type t; uint32_t v; } __tmp = { (_type) (_src) }; \
+                       if (_byte_order != BYTE_ORDER)                         \
+                               __tmp.v = bswap_32(__tmp.v);                   \
                        __ctf_tmp_uint64 = (uint64_t) __tmp.v;                 \
                        break;                                                 \
                }                                                              \
                case 8:                                                        \
                {                                                              \
                        union { _type t; uint64_t v; } __tmp = { (_type) (_src) }; \
+                       if (_byte_order != BYTE_ORDER)                         \
+                               __tmp.v = bswap_64(__tmp.v);                   \
                        __ctf_tmp_uint64 = (uint64_t) __tmp.v;                 \
                        break;                                                 \
                }                                                              \
@@ -565,11 +578,23 @@ size_t __event_get_align__##_provider##___##_name(_TP_ARGS_PROTO(_args))      \
 #define _TP_SESSION_CHECK(session, csession)   1
 #endif /* TP_SESSION_CHECK */
 
+/*
+ * Use of __builtin_return_address(0) sometimes seems to cause stack
+ * corruption on 32-bit PowerPC. Disable this feature on that
+ * architecture for now by always using the NULL value for the ip
+ * context.
+ */
 #undef _TP_IP_PARAM
 #ifdef TP_IP_PARAM
 #define _TP_IP_PARAM(x)                (x)
 #else /* TP_IP_PARAM */
+
+#if defined(__PPC__) && !defined(__PPC64__)
+#define _TP_IP_PARAM(x)                NULL
+#else /* #if defined(__PPC__) && !defined(__PPC64__) */
 #define _TP_IP_PARAM(x)                __builtin_return_address(0)
+#endif /* #else #if defined(__PPC__) && !defined(__PPC64__) */
+
 #endif /* TP_IP_PARAM */
 
 /*
This page took 0.023819 seconds and 4 git commands to generate.