Privatize headers
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 19 May 2011 21:03:11 +0000 (17:03 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 19 May 2011 21:03:11 +0000 (17:03 -0400)
Remove most installed headers, which should be internal. The header
kcompat (kernel-style compatibility header) only makes sense within the
UST package: this should never be exported, nor be included into
instrumented applications.

Move the type-serializer header back into libust/. It is so internal it
does not even belong to include/ust/.

Standardize all the installed headers on non-kcompat style: use uint64_t
instead of u64 for types, open-code likely/unlikely.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
22 files changed:
include/Makefile.am
include/ust/clock.h
include/ust/core.h
include/ust/define_trace.h
include/ust/kcompat/stringify.h [deleted file]
include/ust/marker.h
include/ust/stringify.h [new file with mode: 0644]
include/ust/tracepoint.h
include/ust/type-serializer.h [deleted file]
include/ust/ust.h [deleted file]
include/ust/ustconsumer.h
libust/Makefile.am
libust/buffers.h
libust/header-inline.h [deleted file]
libust/type-serializer.c
libust/type-serializer.h [new file with mode: 0644]
libustconsumer/libustconsumer.c
libustfork/ustfork.c
tests/exit-fast/exit-fast.c
tests/test-nevents/prog.c
tests/tracepoint/benchmark/tracepoint_benchmark.c
ust-consumerd/ust-consumerd.c

index 901462795aaeefd9923c8a3c4b913f95b50298fd..9fd7dee5ee02868b5726d87ccef533f5714edbec 100644 (file)
@@ -3,22 +3,25 @@ nobase_include_HEADERS = \
        ust/tracepoint.h \
        ust/define_trace.h \
        ust/ust_trace.h \
-       ust/processor.h \
-       ust/probe.h \
-       ust/ust.h \
        ust/tracectl.h \
        ust/config.h \
+       ust/stringify.h \
+       ust/ustctl.h \
+       ust/ustconsumer.h
+
+noinst_HEADERS = \
+       share.h \
+       usterr.h \
+       ust_snprintf.h \
+       usterr_signal_safe.h \
        ust/core.h \
+       ust/marker-internal.h \
+       ust/tracepoint-internal.h \
        ust/clock.h \
+       ust/probe.h \
+       ust/processor.h \
        ust/kcompat/kcompat.h \
-       ust/kcompat/compiler.h \
        ust/kcompat/jhash.h \
+       ust/kcompat/compiler.h \
        ust/kcompat/simple.h \
-       ust/kcompat/types.h \
-       ust/kcompat/stringify.h \
-       ust/ustctl.h \
-       ust/ustconsumer.h
-
-noinst_HEADERS = share.h usterr.h ust_snprintf.h usterr_signal_safe.h \
-       ust/marker-internal.h ust/tracepoint-internal.h \
-       ust/type-serializer.h
+       ust/kcompat/types.h
index 22d2efc65c9666905ff896d0fac4c89a8bbd2462..5e8f755b9c08573d1fd7ec110156fe3ea71bdaf4 100644 (file)
@@ -20,7 +20,9 @@
 
 #include <time.h>
 #include <sys/time.h>
-#include <ust/kcompat/kcompat.h>
+#include <stdint.h>
+#include <stddef.h>
+#include <ust/core.h>
 
 /* TRACE CLOCK */
 
 #define CLOCK_TRACE  15
 union lttng_timespec {
        struct timespec ts;
-       u64 lttng_ts;
+       uint64_t lttng_ts;
 };
 
 extern int ust_clock_source;
 
 /* Choosing correct trace clock */
 
-static __inline__ u64 trace_clock_read64(void)
+static __inline__ uint64_t trace_clock_read64(void)
 {
        struct timespec ts;
-       u64 retval;
+       uint64_t retval;
        union lttng_timespec *lts = (union lttng_timespec *) &ts;
 
        clock_gettime(ust_clock_source, &ts);
@@ -75,7 +77,7 @@ static __inline__ u64 trace_clock_read64(void)
 }
 
 #if __i386__ || __x86_64__
-static __inline__ u64 trace_clock_frequency(void)
+static __inline__ uint64_t trace_clock_frequency(void)
 {
        struct timespec ts;
        union lttng_timespec *lts = (union lttng_timespec *) &ts;
@@ -87,13 +89,13 @@ static __inline__ u64 trace_clock_frequency(void)
        return 1000000000LL;
 }
 #else /* #if __i386__ || __x86_64__ */
-static __inline__ u64 trace_clock_frequency(void)
+static __inline__ uint64_t trace_clock_frequency(void)
 {
        return 1000000000LL;
 }
 #endif /* #else #if __i386__ || __x86_64__ */
 
-static __inline__ u32 trace_clock_freq_scale(void)
+static __inline__ uint32_t trace_clock_freq_scale(void)
 {
        return 1;
 }
index d0e2750f1fab74253c9f2bcd2c843ccf7943241c..eee405dd4c27a46d743eecb625daaed5c144f065 100644 (file)
 #define likely(x)      __builtin_expect(!!(x), 1)
 #define unlikely(x)    __builtin_expect(!!(x), 0)
 
-#ifndef HAVE_EFFICIENT_UNALIGNED_ACCESS
-
-/*
- * Calculate the offset needed to align the type.
- * size_of_type must be non-zero.
- */
-static inline unsigned int ltt_align(size_t align_drift, size_t size_of_type)
-{
-       size_t alignment = min(sizeof(void *), size_of_type);
-       return (alignment - align_drift) & (alignment - 1);
-}
-/* Default arch alignment */
-#define LTT_ALIGN
-
-static inline int ltt_get_alignment(void)
-{
-       return sizeof(void *);
-}
-
-#else /* HAVE_EFFICIENT_UNALIGNED_ACCESS */
-
-static inline unsigned int ltt_align(size_t align_drift,
-                size_t size_of_type)
-{
-       return 0;
-}
-
-#define LTT_ALIGN __attribute__((packed))
-
-static inline int ltt_get_alignment(void)
-{
-       return 0;
-}
-#endif /* HAVE_EFFICIENT_UNALIGNED_ACCESS */
-
-
 /* ARRAYS */
 
 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
index f377ddbcc5ff26eb7c13aed1eedf3f97f3f24363..14543f929ba7e4dfd82b89fa7d80d55a02bbe363 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2009     Steven Rostedt <srostedt@redhat.com>
+ * Copyright (C) 2011     Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -37,7 +38,7 @@
 /* Prevent recursion */
 #undef TRACEPOINT_CREATE_PROBES
 
-#include <ust/kcompat/stringify.h>
+#include <ust/stringify.h>
 
 #undef TRACEPOINT_EVENT
 #define TRACEPOINT_EVENT(name, proto, args, fields)            \
diff --git a/include/ust/kcompat/stringify.h b/include/ust/kcompat/stringify.h
deleted file mode 100644 (file)
index 4ae13d0..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-#ifndef __LINUX_STRINGIFY_H
-#define __LINUX_STRINGIFY_H
-/*
- * Copyright (C) 2009 Zhaolei <zhaolei@cn.fujitsu.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
-
- */
-
-/* Indirect stringification.  Doing two levels allows the parameter to be a
- * macro itself.  For example, compile with -DFOO=bar, __stringify(FOO)
- * converts to "bar".
- */
-
-#define __stringify_1(x...)    #x
-#define __stringify(x...)      __stringify_1(x)
-
-#endif /* !__LINUX_STRINGIFY_H */
index 41ae10ab4a07301ed63fc998f8d592dffe2d61e0..af15ad4efee84be05dcda5b76c4f53cdb6532771 100644 (file)
  */
 
 #include <stdarg.h>
+#include <stdint.h>
+#include <stddef.h>
 #include <bits/wordsize.h>
 #include <urcu/list.h>
-#include <ust/core.h>
-#include <ust/kcompat/kcompat.h>
 
 struct ust_marker;
 
@@ -64,8 +64,8 @@ struct ust_marker {
        char state;             /* State. */
        char ptype;             /* probe type : 0 : single, 1 : multi */
                                /* Probe wrapper */
-       u16 channel_id;         /* Numeric channel identifier, dynamic */
-       u16 event_id;           /* Numeric event identifier, dynamic */
+       uint16_t channel_id;    /* Numeric channel identifier, dynamic */
+       uint16_t event_id;      /* Numeric event identifier, dynamic */
        void (*call)(const struct ust_marker *mdata, void *call_private, ...);
        struct ust_marker_probe_closure single;
        struct ust_marker_probe_closure *multi;
@@ -109,7 +109,7 @@ struct ust_marker {
        do {                                                            \
                _DEFINE_UST_MARKER(channel, name, NULL, NULL, format);  \
                __ust_marker_check_format(format, ## args);             \
-               if (unlikely(__ust_marker_def_##name.state))            \
+               if (__builtin_expect(!!(__ust_marker_def_##name.state), 0)) \
                        (__ust_marker_def_##name.call)                  \
                                (&__ust_marker_def_##name, call_private,\
                                ## args);                               \
@@ -138,7 +138,8 @@ void __trace_mark_is_deprecated()
 
 /* To be used for string format validity checking with gcc */
 static inline
-void __printf(1, 2) ___ust_marker_check_format(const char *fmt, ...)
+void __attribute__((format(printf, 1, 2)))
+ ___ust_marker_check_format(const char *fmt, ...)
 {
 }
 
diff --git a/include/ust/stringify.h b/include/ust/stringify.h
new file mode 100644 (file)
index 0000000..b8dfd90
--- /dev/null
@@ -0,0 +1,29 @@
+#ifndef __LINUX_STRINGIFY_H
+#define __LINUX_STRINGIFY_H
+/*
+ * Copyright (C) 2009 Zhaolei <zhaolei@cn.fujitsu.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
+ */
+
+/* Indirect stringification.  Doing two levels allows the parameter to be a
+ * macro itself.  For example, compile with -DFOO=bar, __stringify(FOO)
+ * converts to "bar".
+ */
+
+#define __stringify_1(x...)    #x
+#define __stringify(x...)      __stringify_1(x)
+
+#endif /* !__LINUX_STRINGIFY_H */
index 4d84eaddbe19bdbf9c0fb253c2eb967978a85f1e..3d61f72883c762cc44ad64fb5c4c005d281d2084 100644 (file)
@@ -26,7 +26,6 @@
  */
 
 #include <urcu-bp.h>
-#include <ust/core.h>
 #include <urcu/list.h>
 
 struct tracepoint_probe {
diff --git a/include/ust/type-serializer.h b/include/ust/type-serializer.h
deleted file mode 100644 (file)
index d4e2a1e..0000000
+++ /dev/null
@@ -1,182 +0,0 @@
-#ifndef _LTT_TYPE_SERIALIZER_H
-#define _LTT_TYPE_SERIALIZER_H
-
-#include <ust/marker.h>
-#include <ust/marker-internal.h>
-#include <ust/core.h>
-
-/*
- * largest_align must be non-zero, equal to the minimum between the largest type
- * and sizeof(void *).
- */
-extern void _ltt_specialized_trace(const struct ust_marker *mdata, void *probe_data,
-               void *serialize_private, unsigned int data_size,
-               unsigned int largest_align);
-
-/*
- * Statically check that 0 < largest_align < sizeof(void *) to make sure it is
- * dumb-proof. It will make sure 0 is changed into 1 and unsigned long long is
- * changed into sizeof(void *) on 32-bit architectures.
- */
-static inline void ltt_specialized_trace(const struct ust_marker *mdata,
-               void *probe_data,
-               void *serialize_private, unsigned int data_size,
-               unsigned int largest_align)
-{
-       largest_align = min_t(unsigned int, largest_align, sizeof(void *));
-       largest_align = max_t(unsigned int, largest_align, 1);
-       _ltt_specialized_trace(mdata, probe_data, serialize_private, data_size,
-               largest_align);
-}
-
-/*
- * Type serializer definitions.
- */
-
-/*
- * Return size of structure without end-of-structure padding.
- */
-#define serialize_sizeof(type) offsetof(typeof(type), end_field)
-
-struct serialize_long_int {
-       unsigned long f1;
-       unsigned int f2;
-       unsigned char end_field[0];
-} LTT_ALIGN;
-
-struct serialize_int_int_long {
-       unsigned int f1;
-       unsigned int f2;
-       unsigned long f3;
-       unsigned char end_field[0];
-} LTT_ALIGN;
-
-struct serialize_int_int_short {
-       unsigned int f1;
-       unsigned int f2;
-       unsigned short f3;
-       unsigned char end_field[0];
-} LTT_ALIGN;
-
-struct serialize_long_long_long {
-       unsigned long f1;
-       unsigned long f2;
-       unsigned long f3;
-       unsigned char end_field[0];
-} LTT_ALIGN;
-
-struct serialize_long_long_int {
-       unsigned long f1;
-       unsigned long f2;
-       unsigned int f3;
-       unsigned char end_field[0];
-} LTT_ALIGN;
-
-struct serialize_long_long_short_char {
-       unsigned long f1;
-       unsigned long f2;
-       unsigned short f3;
-       unsigned char f4;
-       unsigned char end_field[0];
-} LTT_ALIGN;
-
-struct serialize_long_long_short {
-       unsigned long f1;
-       unsigned long f2;
-       unsigned short f3;
-       unsigned char end_field[0];
-} LTT_ALIGN;
-
-struct serialize_long_short_char {
-       unsigned long f1;
-       unsigned short f2;
-       unsigned char f3;
-       unsigned char end_field[0];
-} LTT_ALIGN;
-
-struct serialize_long_short {
-       unsigned long f1;
-       unsigned short f2;
-       unsigned char end_field[0];
-} LTT_ALIGN;
-
-struct serialize_long_char {
-       unsigned long f1;
-       unsigned char f2;
-       unsigned char end_field[0];
-} LTT_ALIGN;
-
-struct serialize_sizet_int {
-       size_t f1;
-       unsigned int f2;
-       unsigned char end_field[0];
-} LTT_ALIGN;
-
-struct serialize_long_long_sizet_int {
-       unsigned long f1;
-       unsigned long f2;
-       size_t f3;
-       unsigned int f4;
-       unsigned char end_field[0];
-} LTT_ALIGN;
-
-struct serialize_long_long_sizet_int_int {
-       unsigned long f1;
-       unsigned long f2;
-       size_t f3;
-       unsigned int f4;
-       unsigned int f5;
-       unsigned char end_field[0];
-} LTT_ALIGN;
-
-struct serialize_l4421224411111 {
-       unsigned long f1;
-       uint32_t f2;
-       uint32_t f3;
-       uint16_t f4;
-       uint8_t f5;
-       uint16_t f6;
-       uint16_t f7;
-       uint32_t f8;
-       uint32_t f9;
-       uint8_t f10;
-       uint8_t f11;
-       uint8_t f12;
-       uint8_t f13;
-       uint8_t f14;
-       unsigned char end_field[0];
-} LTT_ALIGN;
-
-struct serialize_l214421224411111 {
-       unsigned long f1;
-       uint16_t f2;
-       uint8_t f3;
-       uint32_t f4;
-       uint32_t f5;
-       uint16_t f6;
-       uint8_t f7;
-       uint16_t f8;
-       uint16_t f9;
-       uint32_t f10;
-       uint32_t f11;
-       uint8_t f12;
-       uint8_t f13;
-       uint8_t f14;
-       uint8_t f15;
-       uint8_t f16;
-       uint8_t end_field[0];
-} LTT_ALIGN;
-
-struct serialize_l4412228 {
-       unsigned long f1;
-       uint32_t f2;
-       uint32_t f3;
-       uint8_t f4;
-       uint16_t f5;
-       uint16_t f6;
-       uint16_t f7;
-       uint64_t f8;
-       unsigned char end_field[0];
-} LTT_ALIGN;
-
-#endif /* _LTT_TYPE_SERIALIZER_H */
diff --git a/include/ust/ust.h b/include/ust/ust.h
deleted file mode 100644 (file)
index a7da4b3..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Copyright (C) 2009  Pierre-Marc Fournier
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
- */
-
-#ifndef UST_H
-#define UST_H
-
-#include <ust/marker.h>
-#include <ust/processor.h>
-#include <ust/tracepoint.h>
-#include <ust/probe.h>
-#include <ust/core.h>
-
-#endif /* UST_H */
index cde84408d936b55ecdfb0e0de6f8efc0e9992480..8c534888bf41082fd0400e12ff608ddfdfcac3e3 100644 (file)
@@ -28,7 +28,7 @@
 
 #include <pthread.h>
 #include <dirent.h>
-#include <ust/kcompat/kcompat.h>
+#include <unistd.h>
 #include <urcu/list.h>
 
 #define USTCONSUMER_DEFAULT_TRACE_PATH "/tmp/usttrace"
@@ -67,7 +67,7 @@ struct buffer_info {
 
        long consumed_old;
 
-       s64 pidunique;
+       int64_t pidunique;
 
        void *user_data;
 };
index 697b4699d1f4e8f9d0aa436e1d16c5c2dfd39d3c..44addf0d92f1536acf00cd7f167315f662caa71f 100644 (file)
@@ -20,7 +20,7 @@ libust_la_SOURCES = \
        serialize.c \
        tracectl.c \
        tracerconst.h \
-       header-inline.h \
+       type-serializer.h \
        type-serializer.c
 
 libust_la_LDFLAGS = -no-undefined -version-info 0:0:0
index 4017964c7ea7410967ef610e7d6477163d7f608f..afeaef35897e7d7b0c71e3fe28950452bf5364cc 100644 (file)
@@ -32,7 +32,6 @@
 #include "channels.h"
 #include "tracerconst.h"
 #include "tracercore.h"
-#include "header-inline.h"
 
 /***** FIXME: SHOULD BE REMOVED ***** */
 
@@ -122,6 +121,40 @@ extern int ltt_reserve_slot_lockless_slow(struct ust_channel *chan,
 extern void ltt_force_switch_lockless_slow(struct ust_buffer *buf,
                enum force_switch_mode mode);
 
+#ifndef HAVE_EFFICIENT_UNALIGNED_ACCESS
+
+/*
+ * Calculate the offset needed to align the type.
+ * size_of_type must be non-zero.
+ */
+static inline unsigned int ltt_align(size_t align_drift, size_t size_of_type)
+{
+       size_t alignment = min(sizeof(void *), size_of_type);
+       return (alignment - align_drift) & (alignment - 1);
+}
+/* Default arch alignment */
+#define LTT_ALIGN
+
+static inline int ltt_get_alignment(void)
+{
+       return sizeof(void *);
+}
+
+#else /* HAVE_EFFICIENT_UNALIGNED_ACCESS */
+
+static inline unsigned int ltt_align(size_t align_drift,
+                size_t size_of_type)
+{
+       return 0;
+}
+
+#define LTT_ALIGN __attribute__((packed))
+
+static inline int ltt_get_alignment(void)
+{
+       return 0;
+}
+#endif /* HAVE_EFFICIENT_UNALIGNED_ACCESS */
 
 static __inline__ void ust_buffers_do_copy(void *dest, const void *src, size_t len)
 {
@@ -194,6 +227,63 @@ static __inline__ int last_tsc_overflow(struct ust_buffer *ltt_buf,
 }
 #endif
 
+/*
+ * ust_get_header_size
+ *
+ * Calculate alignment offset to 32-bits. This is the alignment offset of the
+ * event header.
+ *
+ * Important note :
+ * The event header must be 32-bits. The total offset calculated here :
+ *
+ * Alignment of header struct on 32 bits (min arch size, header size)
+ * + sizeof(header struct)  (32-bits)
+ * + (opt) u16 (ext. event id)
+ * + (opt) u16 (event_size) (if event_size == 0xFFFFUL, has ext. event size)
+ * + (opt) u32 (ext. event size)
+ * + (opt) u64 full TSC (aligned on min(64-bits, arch size))
+ *
+ * The payload must itself determine its own alignment from the biggest type it
+ * contains.
+ * */
+static __inline__ unsigned char ust_get_header_size(
+               struct ust_channel *channel,
+               size_t offset,
+               size_t data_size,
+               size_t *before_hdr_pad,
+               unsigned int rflags)
+{
+       size_t orig_offset = offset;
+       size_t padding;
+
+       padding = ltt_align(offset, sizeof(struct ltt_event_header));
+       offset += padding;
+       offset += sizeof(struct ltt_event_header);
+
+       if(unlikely(rflags)) {
+               switch (rflags) {
+               case LTT_RFLAG_ID_SIZE_TSC:
+                       offset += sizeof(u16) + sizeof(u16);
+                       if (data_size >= 0xFFFFU)
+                               offset += sizeof(u32);
+                       offset += ltt_align(offset, sizeof(u64));
+                       offset += sizeof(u64);
+                       break;
+               case LTT_RFLAG_ID_SIZE:
+                       offset += sizeof(u16) + sizeof(u16);
+                       if (data_size >= 0xFFFFU)
+                               offset += sizeof(u32);
+                       break;
+               case LTT_RFLAG_ID:
+                       offset += sizeof(u16);
+                       break;
+               }
+       }
+
+       *before_hdr_pad = padding;
+       return offset - orig_offset;
+}
+
 static __inline__ void ltt_reserve_push_reader(
                struct ust_channel *rchan,
                struct ust_buffer *buf,
diff --git a/libust/header-inline.h b/libust/header-inline.h
deleted file mode 100644 (file)
index 04abaa9..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (C) 2008 - Mathieu Desnoyers (mathieu.desnoyers@polymtl.ca)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
- */
-
-#ifndef UST_HEADER_INLINE_H
-#define UST_HEADER_INLINE_H
-
-#include <ust/core.h>
-
-/*
- * ust_get_header_size
- *
- * Calculate alignment offset to 32-bits. This is the alignment offset of the
- * event header.
- *
- * Important note :
- * The event header must be 32-bits. The total offset calculated here :
- *
- * Alignment of header struct on 32 bits (min arch size, header size)
- * + sizeof(header struct)  (32-bits)
- * + (opt) u16 (ext. event id)
- * + (opt) u16 (event_size) (if event_size == 0xFFFFUL, has ext. event size)
- * + (opt) u32 (ext. event size)
- * + (opt) u64 full TSC (aligned on min(64-bits, arch size))
- *
- * The payload must itself determine its own alignment from the biggest type it
- * contains.
- * */
-static __inline__ unsigned char ust_get_header_size(
-               struct ust_channel *channel,
-               size_t offset,
-               size_t data_size,
-               size_t *before_hdr_pad,
-               unsigned int rflags)
-{
-       size_t orig_offset = offset;
-       size_t padding;
-
-       padding = ltt_align(offset, sizeof(struct ltt_event_header));
-       offset += padding;
-       offset += sizeof(struct ltt_event_header);
-
-       if(unlikely(rflags)) {
-               switch (rflags) {
-               case LTT_RFLAG_ID_SIZE_TSC:
-                       offset += sizeof(u16) + sizeof(u16);
-                       if (data_size >= 0xFFFFU)
-                               offset += sizeof(u32);
-                       offset += ltt_align(offset, sizeof(u64));
-                       offset += sizeof(u64);
-                       break;
-               case LTT_RFLAG_ID_SIZE:
-                       offset += sizeof(u16) + sizeof(u16);
-                       if (data_size >= 0xFFFFU)
-                               offset += sizeof(u32);
-                       break;
-               case LTT_RFLAG_ID:
-                       offset += sizeof(u16);
-                       break;
-               }
-       }
-
-       *before_hdr_pad = padding;
-       return offset - orig_offset;
-}
-
-#endif /* UST_HEADER_INLINE_H */
index 611f91f49caab4f5dfa219c321ebaa2135056b6f..070542c65e2a938a158e00e88aad320f867a55b2 100644 (file)
 #define _GNU_SOURCE
 #define _LGPL_SOURCE
 #include <urcu/rculist.h>
-#include <ust/type-serializer.h>
 #include <ust/core.h>
 #include <ust/clock.h>
 #include <urcu-bp.h>
 #include "tracer.h"
+#include "type-serializer.h"
 
 notrace
 void _ltt_specialized_trace(const struct ust_marker *mdata, void *probe_data,
diff --git a/libust/type-serializer.h b/libust/type-serializer.h
new file mode 100644 (file)
index 0000000..3b1a23a
--- /dev/null
@@ -0,0 +1,183 @@
+#ifndef _LTT_TYPE_SERIALIZER_H
+#define _LTT_TYPE_SERIALIZER_H
+
+#include <ust/marker.h>
+#include <ust/marker-internal.h>
+#include <ust/core.h>
+#include "buffers.h"
+
+/*
+ * largest_align must be non-zero, equal to the minimum between the largest type
+ * and sizeof(void *).
+ */
+extern void _ltt_specialized_trace(const struct ust_marker *mdata, void *probe_data,
+               void *serialize_private, unsigned int data_size,
+               unsigned int largest_align);
+
+/*
+ * Statically check that 0 < largest_align < sizeof(void *) to make sure it is
+ * dumb-proof. It will make sure 0 is changed into 1 and unsigned long long is
+ * changed into sizeof(void *) on 32-bit architectures.
+ */
+static inline void ltt_specialized_trace(const struct ust_marker *mdata,
+               void *probe_data,
+               void *serialize_private, unsigned int data_size,
+               unsigned int largest_align)
+{
+       largest_align = min_t(unsigned int, largest_align, sizeof(void *));
+       largest_align = max_t(unsigned int, largest_align, 1);
+       _ltt_specialized_trace(mdata, probe_data, serialize_private, data_size,
+               largest_align);
+}
+
+/*
+ * Type serializer definitions.
+ */
+
+/*
+ * Return size of structure without end-of-structure padding.
+ */
+#define serialize_sizeof(type) offsetof(typeof(type), end_field)
+
+struct serialize_long_int {
+       unsigned long f1;
+       unsigned int f2;
+       unsigned char end_field[0];
+} LTT_ALIGN;
+
+struct serialize_int_int_long {
+       unsigned int f1;
+       unsigned int f2;
+       unsigned long f3;
+       unsigned char end_field[0];
+} LTT_ALIGN;
+
+struct serialize_int_int_short {
+       unsigned int f1;
+       unsigned int f2;
+       unsigned short f3;
+       unsigned char end_field[0];
+} LTT_ALIGN;
+
+struct serialize_long_long_long {
+       unsigned long f1;
+       unsigned long f2;
+       unsigned long f3;
+       unsigned char end_field[0];
+} LTT_ALIGN;
+
+struct serialize_long_long_int {
+       unsigned long f1;
+       unsigned long f2;
+       unsigned int f3;
+       unsigned char end_field[0];
+} LTT_ALIGN;
+
+struct serialize_long_long_short_char {
+       unsigned long f1;
+       unsigned long f2;
+       unsigned short f3;
+       unsigned char f4;
+       unsigned char end_field[0];
+} LTT_ALIGN;
+
+struct serialize_long_long_short {
+       unsigned long f1;
+       unsigned long f2;
+       unsigned short f3;
+       unsigned char end_field[0];
+} LTT_ALIGN;
+
+struct serialize_long_short_char {
+       unsigned long f1;
+       unsigned short f2;
+       unsigned char f3;
+       unsigned char end_field[0];
+} LTT_ALIGN;
+
+struct serialize_long_short {
+       unsigned long f1;
+       unsigned short f2;
+       unsigned char end_field[0];
+} LTT_ALIGN;
+
+struct serialize_long_char {
+       unsigned long f1;
+       unsigned char f2;
+       unsigned char end_field[0];
+} LTT_ALIGN;
+
+struct serialize_sizet_int {
+       size_t f1;
+       unsigned int f2;
+       unsigned char end_field[0];
+} LTT_ALIGN;
+
+struct serialize_long_long_sizet_int {
+       unsigned long f1;
+       unsigned long f2;
+       size_t f3;
+       unsigned int f4;
+       unsigned char end_field[0];
+} LTT_ALIGN;
+
+struct serialize_long_long_sizet_int_int {
+       unsigned long f1;
+       unsigned long f2;
+       size_t f3;
+       unsigned int f4;
+       unsigned int f5;
+       unsigned char end_field[0];
+} LTT_ALIGN;
+
+struct serialize_l4421224411111 {
+       unsigned long f1;
+       uint32_t f2;
+       uint32_t f3;
+       uint16_t f4;
+       uint8_t f5;
+       uint16_t f6;
+       uint16_t f7;
+       uint32_t f8;
+       uint32_t f9;
+       uint8_t f10;
+       uint8_t f11;
+       uint8_t f12;
+       uint8_t f13;
+       uint8_t f14;
+       unsigned char end_field[0];
+} LTT_ALIGN;
+
+struct serialize_l214421224411111 {
+       unsigned long f1;
+       uint16_t f2;
+       uint8_t f3;
+       uint32_t f4;
+       uint32_t f5;
+       uint16_t f6;
+       uint8_t f7;
+       uint16_t f8;
+       uint16_t f9;
+       uint32_t f10;
+       uint32_t f11;
+       uint8_t f12;
+       uint8_t f13;
+       uint8_t f14;
+       uint8_t f15;
+       uint8_t f16;
+       uint8_t end_field[0];
+} LTT_ALIGN;
+
+struct serialize_l4412228 {
+       unsigned long f1;
+       uint32_t f2;
+       uint32_t f3;
+       uint8_t f4;
+       uint16_t f5;
+       uint16_t f6;
+       uint16_t f7;
+       uint64_t f8;
+       unsigned char end_field[0];
+} LTT_ALIGN;
+
+#endif /* _LTT_TYPE_SERIALIZER_H */
index b47f04ab08779ce03db1f5f845110ef9f13ca172..c6dd20c355050c69c04ec8a5e97562f9d49c7056 100644 (file)
@@ -146,7 +146,7 @@ void decrement_active_buffers(void *arg)
        pthread_mutex_unlock(&instance->mutex);
 }
 
-static int get_pidunique(int sock, s64 *pidunique)
+static int get_pidunique(int sock, int64_t *pidunique)
 {
        struct ustcomm_header _send_hdr, *send_hdr;
        struct ustcomm_header _recv_hdr, *recv_hdr;
index ecc39e38ca78c3e413de26da20c99367b2c50554..c88805f73165f9ddb4835e96d7300ee16c1314be 100644 (file)
@@ -20,7 +20,6 @@
 #include <unistd.h>
 #include <stdio.h>
 #include <signal.h>
-#include <ust/ust.h>
 #include <sched.h>
 #include <stdarg.h>
 #include <ust/tracectl.h>
index 84bb0c5e36ad95e601494e6d6e504ad87c674e4a..ee987f2e51a74d3c9399c018573297de7ec16c4c 100644 (file)
@@ -20,7 +20,9 @@
 
 #include <signal.h>
 #include <string.h>
-#include <ust/ust.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <ust/marker.h>
 
 int main(int argc, char *argv[])
 {
index 21e01f026b994ad276f90bd22bf74aab5486f956..6d6ba96ddb78dae178db02c0e32b582eeebd07e4 100644 (file)
@@ -21,7 +21,7 @@
 
 #include <string.h>
 #include <stdlib.h>
-#include <ust/ust.h>
+#include <ust/marker.h>
 
 #define N_ITER 100000
 
index 45f7d3c0957aaf28fb948fd087cac30e8672b573..c1208b09cd17ddc69f2d9355a5b648dba2284380 100644 (file)
@@ -28,7 +28,9 @@
 
 #define TRACEPOINT_CREATE_PROBES
 #include "tracepoint_benchmark.h"
-#include <ust/type-serializer.h>
+
+/* Yes, this is now internal. */
+#include "../../../libust/type-serializer.h"
 
 #define NR_EVENTS      10000000
 
index c96139455d24ecdbb54014f9f829b42819ef2f5f..0761253183eef1b5509a201a63e46611456f1b68 100644 (file)
@@ -24,6 +24,7 @@
 #include <fcntl.h>
 #include <unistd.h>
 #include <signal.h>
+#include <inttypes.h>
 
 #include <stdlib.h>
 #include <stdio.h>
@@ -192,8 +193,8 @@ int on_open_buffer(struct ustconsumer_callbacks *data, struct buffer_info *buf)
                trace_path = USTCONSUMER_DEFAULT_TRACE_PATH;
        }
 
-       if (asprintf(&tmp, "%s/%u_%lld", trace_path, buf->pid, buf->pidunique) < 0) {
-               ERR("on_open_buffer : asprintf failed (%s/%u_%lld)",
+       if (asprintf(&tmp, "%s/%u_%" PRId64 "", trace_path, buf->pid, buf->pidunique) < 0) {
+               ERR("on_open_buffer : asprintf failed (%s/%u_%" PRId64 ")",
                    trace_path, buf->pid, buf->pidunique);
                return 1;
        }
@@ -205,8 +206,8 @@ int on_open_buffer(struct ustconsumer_callbacks *data, struct buffer_info *buf)
        }
        free(tmp);
 
-       if (asprintf(&tmp, "%s/%u_%lld/%s", trace_path, buf->pid, buf->pidunique, buf->name) < 0) {
-               ERR("on_open_buffer : asprintf failed (%s/%u_%lld/%s)",
+       if (asprintf(&tmp, "%s/%u_%" PRId64 "/%s", trace_path, buf->pid, buf->pidunique, buf->name) < 0) {
+               ERR("on_open_buffer : asprintf failed (%s/%u_%" PRId64 "/%s)",
                    trace_path, buf->pid, buf->pidunique, buf->name);
                return 1;
        }
This page took 0.038241 seconds and 4 git commands to generate.