From: Mathieu Desnoyers Date: Thu, 19 May 2011 21:03:11 +0000 (-0400) Subject: Privatize headers X-Git-Tag: v1.9.1~363 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=9edd34bd25f52dd39b354a84f02697254121aefd;p=lttng-ust.git Privatize headers 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 --- diff --git a/include/Makefile.am b/include/Makefile.am index 90146279..9fd7dee5 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -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 diff --git a/include/ust/clock.h b/include/ust/clock.h index 22d2efc6..5e8f755b 100644 --- a/include/ust/clock.h +++ b/include/ust/clock.h @@ -20,7 +20,9 @@ #include #include -#include +#include +#include +#include /* TRACE CLOCK */ @@ -44,17 +46,17 @@ #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; } diff --git a/include/ust/core.h b/include/ust/core.h index d0e2750f..eee405dd 100644 --- a/include/ust/core.h +++ b/include/ust/core.h @@ -24,42 +24,6 @@ #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])) diff --git a/include/ust/define_trace.h b/include/ust/define_trace.h index f377ddbc..14543f92 100644 --- a/include/ust/define_trace.h +++ b/include/ust/define_trace.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2009 Steven Rostedt + * Copyright (C) 2011 Mathieu Desnoyers * * 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 +#include #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 index 4ae13d0e..00000000 --- a/include/ust/kcompat/stringify.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef __LINUX_STRINGIFY_H -#define __LINUX_STRINGIFY_H -/* - * Copyright (C) 2009 Zhaolei - * - * 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 */ diff --git a/include/ust/marker.h b/include/ust/marker.h index 41ae10ab..af15ad4e 100644 --- a/include/ust/marker.h +++ b/include/ust/marker.h @@ -26,10 +26,10 @@ */ #include +#include +#include #include #include -#include -#include 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 index 00000000..b8dfd90c --- /dev/null +++ b/include/ust/stringify.h @@ -0,0 +1,29 @@ +#ifndef __LINUX_STRINGIFY_H +#define __LINUX_STRINGIFY_H +/* + * Copyright (C) 2009 Zhaolei + * + * 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 */ diff --git a/include/ust/tracepoint.h b/include/ust/tracepoint.h index 4d84eadd..3d61f728 100644 --- a/include/ust/tracepoint.h +++ b/include/ust/tracepoint.h @@ -26,7 +26,6 @@ */ #include -#include #include struct tracepoint_probe { diff --git a/include/ust/type-serializer.h b/include/ust/type-serializer.h deleted file mode 100644 index d4e2a1eb..00000000 --- a/include/ust/type-serializer.h +++ /dev/null @@ -1,182 +0,0 @@ -#ifndef _LTT_TYPE_SERIALIZER_H -#define _LTT_TYPE_SERIALIZER_H - -#include -#include -#include - -/* - * 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 index a7da4b36..00000000 --- a/include/ust/ust.h +++ /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 -#include -#include -#include -#include - -#endif /* UST_H */ diff --git a/include/ust/ustconsumer.h b/include/ust/ustconsumer.h index cde84408..8c534888 100644 --- a/include/ust/ustconsumer.h +++ b/include/ust/ustconsumer.h @@ -28,7 +28,7 @@ #include #include -#include +#include #include #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; }; diff --git a/libust/Makefile.am b/libust/Makefile.am index 697b4699..44addf0d 100644 --- a/libust/Makefile.am +++ b/libust/Makefile.am @@ -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 diff --git a/libust/buffers.h b/libust/buffers.h index 4017964c..afeaef35 100644 --- a/libust/buffers.h +++ b/libust/buffers.h @@ -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 index 04abaa9d..00000000 --- a/libust/header-inline.h +++ /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_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 */ diff --git a/libust/type-serializer.c b/libust/type-serializer.c index 611f91f4..070542c6 100644 --- a/libust/type-serializer.c +++ b/libust/type-serializer.c @@ -13,11 +13,11 @@ #define _GNU_SOURCE #define _LGPL_SOURCE #include -#include #include #include #include #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 index 00000000..3b1a23a9 --- /dev/null +++ b/libust/type-serializer.h @@ -0,0 +1,183 @@ +#ifndef _LTT_TYPE_SERIALIZER_H +#define _LTT_TYPE_SERIALIZER_H + +#include +#include +#include +#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 */ diff --git a/libustconsumer/libustconsumer.c b/libustconsumer/libustconsumer.c index b47f04ab..c6dd20c3 100644 --- a/libustconsumer/libustconsumer.c +++ b/libustconsumer/libustconsumer.c @@ -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; diff --git a/libustfork/ustfork.c b/libustfork/ustfork.c index ecc39e38..c88805f7 100644 --- a/libustfork/ustfork.c +++ b/libustfork/ustfork.c @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include diff --git a/tests/exit-fast/exit-fast.c b/tests/exit-fast/exit-fast.c index 84bb0c5e..ee987f2e 100644 --- a/tests/exit-fast/exit-fast.c +++ b/tests/exit-fast/exit-fast.c @@ -20,7 +20,9 @@ #include #include -#include +#include +#include +#include int main(int argc, char *argv[]) { diff --git a/tests/test-nevents/prog.c b/tests/test-nevents/prog.c index 21e01f02..6d6ba96d 100644 --- a/tests/test-nevents/prog.c +++ b/tests/test-nevents/prog.c @@ -21,7 +21,7 @@ #include #include -#include +#include #define N_ITER 100000 diff --git a/tests/tracepoint/benchmark/tracepoint_benchmark.c b/tests/tracepoint/benchmark/tracepoint_benchmark.c index 45f7d3c0..c1208b09 100644 --- a/tests/tracepoint/benchmark/tracepoint_benchmark.c +++ b/tests/tracepoint/benchmark/tracepoint_benchmark.c @@ -28,7 +28,9 @@ #define TRACEPOINT_CREATE_PROBES #include "tracepoint_benchmark.h" -#include + +/* Yes, this is now internal. */ +#include "../../../libust/type-serializer.h" #define NR_EVENTS 10000000 diff --git a/ust-consumerd/ust-consumerd.c b/ust-consumerd/ust-consumerd.c index c9613945..07612531 100644 --- a/ust-consumerd/ust-consumerd.c +++ b/ust-consumerd/ust-consumerd.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -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; }