#include <babeltrace/values.h>
#include <babeltrace/ref.h>
#include <babeltrace/object-internal.h>
-#include <babeltrace/compiler.h>
+#include <babeltrace/compiler-internal.h>
#include <babeltrace/graph/component-class.h>
#include <glib.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/mman.h>
-#include <babeltrace/compat/dirent.h>
+#include <babeltrace/compat/dirent-internal.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <babeltrace/babeltrace-internal.h>
#include <babeltrace/ctf/types.h>
-#include <babeltrace/compat/uuid.h>
-#include <babeltrace/compat/utc.h>
-#include <babeltrace/compat/stdio.h>
-#include <babeltrace/endian.h>
+#include <babeltrace/compat/uuid-internal.h>
+#include <babeltrace/compat/utc-internal.h>
+#include <babeltrace/compat/stdio-internal.h>
+#include <babeltrace/endian-internal.h>
#define NSEC_PER_USEC 1000UL
#define NSEC_PER_MSEC 1000000UL
#include <windows.h>
#include <stdlib.h>
-#include <babeltrace/compat/uuid.h>
+#include <babeltrace/compat/uuid-internal.h>
/* MinGW does not provide byteswap - implement our own version. */
static
babeltrace/graph/private-port.h
noinst_HEADERS = \
- babeltrace/align.h \
+ babeltrace/align-internal.h \
babeltrace/babeltrace-internal.h \
- babeltrace/bitfield.h \
+ babeltrace/bitfield-internal.h \
babeltrace/common-internal.h \
- babeltrace/compiler.h \
- babeltrace/prio_heap.h \
+ babeltrace/compiler-internal.h \
+ babeltrace/prio-heap-internal.h \
babeltrace/ref-internal.h \
babeltrace/object-internal.h \
babeltrace/ctf-writer/writer-internal.h \
babeltrace/ctf-ir/visitor-internal.h \
babeltrace/ctf-writer/clock-internal.h \
babeltrace/ctf-writer/functor-internal.h \
- babeltrace/compat/uuid.h \
- babeltrace/compat/memstream.h \
- babeltrace/compat/string.h \
- babeltrace/compat/utc.h \
- babeltrace/compat/limits.h \
- babeltrace/compat/glib.h \
- babeltrace/compat/send.h \
- babeltrace/compat/fcntl.h \
- babeltrace/compat/stdlib.h \
- babeltrace/compat/dirent.h \
- babeltrace/compat/stdio.h \
- babeltrace/compat/mman.h \
- babeltrace/endian.h \
- babeltrace/mmap-align.h \
+ babeltrace/compat/uuid-internal.h \
+ babeltrace/compat/memstream-internal.h \
+ babeltrace/compat/string-internal.h \
+ babeltrace/compat/utc-internal.h \
+ babeltrace/compat/limits-internal.h \
+ babeltrace/compat/glib-internal.h \
+ babeltrace/compat/send-internal.h \
+ babeltrace/compat/fcntl-internal.h \
+ babeltrace/compat/stdlib-internal.h \
+ babeltrace/compat/dirent-internal.h \
+ babeltrace/compat/stdio-internal.h \
+ babeltrace/compat/mman-internal.h \
+ babeltrace/endian-internal.h \
+ babeltrace/mmap-align-internal.h \
babeltrace/plugin/plugin-internal.h \
babeltrace/plugin/plugin-so-internal.h \
babeltrace/graph/component-class-internal.h \
--- /dev/null
+#ifndef _BABELTRACE_ALIGN_H
+#define _BABELTRACE_ALIGN_H
+
+/*
+ * BabelTrace align.h - alignment header
+ *
+ * Copyright 2010 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <babeltrace/compiler-internal.h>
+#include <unistd.h>
+#include <babeltrace/compat/limits-internal.h>
+
+#ifndef PAGE_SIZE /* Cygwin limits.h defines its own PAGE_SIZE */
+#define PAGE_SIZE sysconf(_SC_PAGE_SIZE)
+#endif
+
+#define ALIGN(x, a) __ALIGN_MASK(x, (typeof(x))(a) - 1)
+#define __ALIGN_MASK(x, mask) (((x) + (mask)) & ~(mask))
+#define PTR_ALIGN(p, a) ((typeof(p)) ALIGN((unsigned long) (p), a))
+#define ALIGN_FLOOR(x, a) __ALIGN_FLOOR_MASK(x, (typeof(x)) (a) - 1)
+#define __ALIGN_FLOOR_MASK(x, mask) ((x) & ~(mask))
+#define PTR_ALIGN_FLOOR(p, a) \
+ ((typeof(p)) ALIGN_FLOOR((unsigned long) (p), a))
+#define IS_ALIGNED(x, a) (((x) & ((typeof(x)) (a) - 1)) == 0)
+
+/*
+ * Align pointer on natural object alignment.
+ */
+#define object_align(obj) PTR_ALIGN(obj, __alignof__(*(obj)))
+#define object_align_floor(obj) PTR_ALIGN_FLOOR(obj, __alignof__(*(obj)))
+
+/**
+ * offset_align - Calculate the offset needed to align an object on its natural
+ * alignment towards higher addresses.
+ * @align_drift: object offset from an "alignment"-aligned address.
+ * @alignment: natural object alignment. Must be non-zero, power of 2.
+ *
+ * Returns the offset that must be added to align towards higher
+ * addresses.
+ */
+#define offset_align(align_drift, alignment) \
+ ({ \
+ MAYBE_BUILD_BUG_ON((alignment) == 0 \
+ || ((alignment) & ((alignment) - 1))); \
+ (((alignment) - (align_drift)) & ((alignment) - 1)); \
+ })
+
+/**
+ * offset_align_floor - Calculate the offset needed to align an object
+ * on its natural alignment towards lower addresses.
+ * @align_drift: object offset from an "alignment"-aligned address.
+ * @alignment: natural object alignment. Must be non-zero, power of 2.
+ *
+ * Returns the offset that must be substracted to align towards lower addresses.
+ */
+#define offset_align_floor(align_drift, alignment) \
+ ({ \
+ MAYBE_BUILD_BUG_ON((alignment) == 0 \
+ || ((alignment) & ((alignment) - 1))); \
+ (((align_drift) - (alignment)) & ((alignment) - 1)); \
+ })
+
+#endif /* _BABELTRACE_ALIGN_H */
+++ /dev/null
-#ifndef _BABELTRACE_ALIGN_H
-#define _BABELTRACE_ALIGN_H
-
-/*
- * BabelTrace align.h - alignment header
- *
- * Copyright 2010 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <babeltrace/compiler.h>
-#include <unistd.h>
-#include <babeltrace/compat/limits.h>
-
-#ifndef PAGE_SIZE /* Cygwin limits.h defines its own PAGE_SIZE */
-#define PAGE_SIZE sysconf(_SC_PAGE_SIZE)
-#endif
-
-#define ALIGN(x, a) __ALIGN_MASK(x, (typeof(x))(a) - 1)
-#define __ALIGN_MASK(x, mask) (((x) + (mask)) & ~(mask))
-#define PTR_ALIGN(p, a) ((typeof(p)) ALIGN((unsigned long) (p), a))
-#define ALIGN_FLOOR(x, a) __ALIGN_FLOOR_MASK(x, (typeof(x)) (a) - 1)
-#define __ALIGN_FLOOR_MASK(x, mask) ((x) & ~(mask))
-#define PTR_ALIGN_FLOOR(p, a) \
- ((typeof(p)) ALIGN_FLOOR((unsigned long) (p), a))
-#define IS_ALIGNED(x, a) (((x) & ((typeof(x)) (a) - 1)) == 0)
-
-/*
- * Align pointer on natural object alignment.
- */
-#define object_align(obj) PTR_ALIGN(obj, __alignof__(*(obj)))
-#define object_align_floor(obj) PTR_ALIGN_FLOOR(obj, __alignof__(*(obj)))
-
-/**
- * offset_align - Calculate the offset needed to align an object on its natural
- * alignment towards higher addresses.
- * @align_drift: object offset from an "alignment"-aligned address.
- * @alignment: natural object alignment. Must be non-zero, power of 2.
- *
- * Returns the offset that must be added to align towards higher
- * addresses.
- */
-#define offset_align(align_drift, alignment) \
- ({ \
- MAYBE_BUILD_BUG_ON((alignment) == 0 \
- || ((alignment) & ((alignment) - 1))); \
- (((alignment) - (align_drift)) & ((alignment) - 1)); \
- })
-
-/**
- * offset_align_floor - Calculate the offset needed to align an object
- * on its natural alignment towards lower addresses.
- * @align_drift: object offset from an "alignment"-aligned address.
- * @alignment: natural object alignment. Must be non-zero, power of 2.
- *
- * Returns the offset that must be substracted to align towards lower addresses.
- */
-#define offset_align_floor(align_drift, alignment) \
- ({ \
- MAYBE_BUILD_BUG_ON((alignment) == 0 \
- || ((alignment) & ((alignment) - 1))); \
- (((align_drift) - (alignment)) & ((alignment) - 1)); \
- })
-
-#endif /* _BABELTRACE_ALIGN_H */
#include <stdlib.h>
#include <errno.h>
#include <stdbool.h>
-#include <babeltrace/compat/string.h>
+#include <babeltrace/compat/string-internal.h>
#define PERROR_BUFLEN 200
--- /dev/null
+#ifndef _BABELTRACE_BITFIELD_H
+#define _BABELTRACE_BITFIELD_H
+
+/*
+ * BabelTrace
+ *
+ * Bitfields read/write functions.
+ *
+ * Copyright 2010 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <stdint.h> /* C99 5.2.4.2 Numerical limits */
+#include <babeltrace/compat/limits-internal.h> /* C99 5.2.4.2 Numerical limits */
+#include <assert.h>
+#include <babeltrace/endian-internal.h> /* Non-standard BIG_ENDIAN, LITTLE_ENDIAN, BYTE_ORDER */
+
+/* We can't shift a int from 32 bit, >> 32 and << 32 on int is undefined */
+#define _bt_piecewise_rshift(_v, _shift) \
+({ \
+ typeof(_v) ___v = (_v); \
+ typeof(_shift) ___shift = (_shift); \
+ unsigned long sb = (___shift) / (sizeof(___v) * CHAR_BIT - 1); \
+ unsigned long final = (___shift) % (sizeof(___v) * CHAR_BIT - 1); \
+ \
+ for (; sb; sb--) \
+ ___v >>= sizeof(___v) * CHAR_BIT - 1; \
+ ___v >>= final; \
+})
+
+#define _bt_piecewise_lshift(_v, _shift) \
+({ \
+ typeof(_v) ___v = (_v); \
+ typeof(_shift) ___shift = (_shift); \
+ unsigned long sb = (___shift) / (sizeof(___v) * CHAR_BIT - 1); \
+ unsigned long final = (___shift) % (sizeof(___v) * CHAR_BIT - 1); \
+ \
+ for (; sb; sb--) \
+ ___v <<= sizeof(___v) * CHAR_BIT - 1; \
+ ___v <<= final; \
+})
+
+#define _bt_is_signed_type(type) ((type) -1 < (type) 0)
+
+#define _bt_unsigned_cast(type, v) \
+({ \
+ (sizeof(v) < sizeof(type)) ? \
+ ((type) (v)) & (~(~(type) 0 << (sizeof(v) * CHAR_BIT))) : \
+ (type) (v); \
+})
+
+/*
+ * bt_bitfield_write - write integer to a bitfield in native endianness
+ *
+ * Save integer to the bitfield, which starts at the "start" bit, has "len"
+ * bits.
+ * The inside of a bitfield is from high bits to low bits.
+ * Uses native endianness.
+ * For unsigned "v", pad MSB with 0 if bitfield is larger than v.
+ * For signed "v", sign-extend v if bitfield is larger than v.
+ *
+ * On little endian, bytes are placed from the less significant to the most
+ * significant. Also, consecutive bitfields are placed from lower bits to higher
+ * bits.
+ *
+ * On big endian, bytes are places from most significant to less significant.
+ * Also, consecutive bitfields are placed from higher to lower bits.
+ */
+
+#define _bt_bitfield_write_le(_ptr, type, _start, _length, _v) \
+do { \
+ typeof(_v) __v = (_v); \
+ type *__ptr = (void *) (_ptr); \
+ unsigned long __start = (_start), __length = (_length); \
+ type mask, cmask; \
+ unsigned long ts = sizeof(type) * CHAR_BIT; /* type size */ \
+ unsigned long start_unit, end_unit, this_unit; \
+ unsigned long end, cshift; /* cshift is "complement shift" */ \
+ \
+ if (!__length) \
+ break; \
+ \
+ end = __start + __length; \
+ start_unit = __start / ts; \
+ end_unit = (end + (ts - 1)) / ts; \
+ \
+ /* Trim v high bits */ \
+ if (__length < sizeof(__v) * CHAR_BIT) \
+ __v &= ~((~(typeof(__v)) 0) << __length); \
+ \
+ /* We can now append v with a simple "or", shift it piece-wise */ \
+ this_unit = start_unit; \
+ if (start_unit == end_unit - 1) { \
+ mask = ~((~(type) 0) << (__start % ts)); \
+ if (end % ts) \
+ mask |= (~(type) 0) << (end % ts); \
+ cmask = (type) __v << (__start % ts); \
+ cmask &= ~mask; \
+ __ptr[this_unit] &= mask; \
+ __ptr[this_unit] |= cmask; \
+ break; \
+ } \
+ if (__start % ts) { \
+ cshift = __start % ts; \
+ mask = ~((~(type) 0) << cshift); \
+ cmask = (type) __v << cshift; \
+ cmask &= ~mask; \
+ __ptr[this_unit] &= mask; \
+ __ptr[this_unit] |= cmask; \
+ __v = _bt_piecewise_rshift(__v, ts - cshift); \
+ __start += ts - cshift; \
+ this_unit++; \
+ } \
+ for (; this_unit < end_unit - 1; this_unit++) { \
+ __ptr[this_unit] = (type) __v; \
+ __v = _bt_piecewise_rshift(__v, ts); \
+ __start += ts; \
+ } \
+ if (end % ts) { \
+ mask = (~(type) 0) << (end % ts); \
+ cmask = (type) __v; \
+ cmask &= ~mask; \
+ __ptr[this_unit] &= mask; \
+ __ptr[this_unit] |= cmask; \
+ } else \
+ __ptr[this_unit] = (type) __v; \
+} while (0)
+
+#define _bt_bitfield_write_be(_ptr, type, _start, _length, _v) \
+do { \
+ typeof(_v) __v = (_v); \
+ type *__ptr = (void *) (_ptr); \
+ unsigned long __start = (_start), __length = (_length); \
+ type mask, cmask; \
+ unsigned long ts = sizeof(type) * CHAR_BIT; /* type size */ \
+ unsigned long start_unit, end_unit, this_unit; \
+ unsigned long end, cshift; /* cshift is "complement shift" */ \
+ \
+ if (!__length) \
+ break; \
+ \
+ end = __start + __length; \
+ start_unit = __start / ts; \
+ end_unit = (end + (ts - 1)) / ts; \
+ \
+ /* Trim v high bits */ \
+ if (__length < sizeof(__v) * CHAR_BIT) \
+ __v &= ~((~(typeof(__v)) 0) << __length); \
+ \
+ /* We can now append v with a simple "or", shift it piece-wise */ \
+ this_unit = end_unit - 1; \
+ if (start_unit == end_unit - 1) { \
+ mask = ~((~(type) 0) << ((ts - (end % ts)) % ts)); \
+ if (__start % ts) \
+ mask |= (~((type) 0)) << (ts - (__start % ts)); \
+ cmask = (type) __v << ((ts - (end % ts)) % ts); \
+ cmask &= ~mask; \
+ __ptr[this_unit] &= mask; \
+ __ptr[this_unit] |= cmask; \
+ break; \
+ } \
+ if (end % ts) { \
+ cshift = end % ts; \
+ mask = ~((~(type) 0) << (ts - cshift)); \
+ cmask = (type) __v << (ts - cshift); \
+ cmask &= ~mask; \
+ __ptr[this_unit] &= mask; \
+ __ptr[this_unit] |= cmask; \
+ __v = _bt_piecewise_rshift(__v, cshift); \
+ end -= cshift; \
+ this_unit--; \
+ } \
+ for (; (long) this_unit >= (long) start_unit + 1; this_unit--) { \
+ __ptr[this_unit] = (type) __v; \
+ __v = _bt_piecewise_rshift(__v, ts); \
+ end -= ts; \
+ } \
+ if (__start % ts) { \
+ mask = (~(type) 0) << (ts - (__start % ts)); \
+ cmask = (type) __v; \
+ cmask &= ~mask; \
+ __ptr[this_unit] &= mask; \
+ __ptr[this_unit] |= cmask; \
+ } else \
+ __ptr[this_unit] = (type) __v; \
+} while (0)
+
+/*
+ * bt_bitfield_write - write integer to a bitfield in native endianness
+ * bt_bitfield_write_le - write integer to a bitfield in little endian
+ * bt_bitfield_write_be - write integer to a bitfield in big endian
+ */
+
+#if (BYTE_ORDER == LITTLE_ENDIAN)
+
+#define bt_bitfield_write(ptr, type, _start, _length, _v) \
+ _bt_bitfield_write_le(ptr, type, _start, _length, _v)
+
+#define bt_bitfield_write_le(ptr, type, _start, _length, _v) \
+ _bt_bitfield_write_le(ptr, type, _start, _length, _v)
+
+#define bt_bitfield_write_be(ptr, type, _start, _length, _v) \
+ _bt_bitfield_write_be(ptr, unsigned char, _start, _length, _v)
+
+#elif (BYTE_ORDER == BIG_ENDIAN)
+
+#define bt_bitfield_write(ptr, type, _start, _length, _v) \
+ _bt_bitfield_write_be(ptr, type, _start, _length, _v)
+
+#define bt_bitfield_write_le(ptr, type, _start, _length, _v) \
+ _bt_bitfield_write_le(ptr, unsigned char, _start, _length, _v)
+
+#define bt_bitfield_write_be(ptr, type, _start, _length, _v) \
+ _bt_bitfield_write_be(ptr, type, _start, _length, _v)
+
+#else /* (BYTE_ORDER == PDP_ENDIAN) */
+
+#error "Byte order not supported"
+
+#endif
+
+#define _bt_bitfield_read_le(_ptr, type, _start, _length, _vptr) \
+do { \
+ typeof(*(_vptr)) *__vptr = (_vptr); \
+ typeof(*__vptr) __v; \
+ type *__ptr = (void *) (_ptr); \
+ unsigned long __start = (_start), __length = (_length); \
+ type mask, cmask; \
+ unsigned long ts = sizeof(type) * CHAR_BIT; /* type size */ \
+ unsigned long start_unit, end_unit, this_unit; \
+ unsigned long end, cshift; /* cshift is "complement shift" */ \
+ \
+ if (!__length) { \
+ *__vptr = 0; \
+ break; \
+ } \
+ \
+ end = __start + __length; \
+ start_unit = __start / ts; \
+ end_unit = (end + (ts - 1)) / ts; \
+ \
+ this_unit = end_unit - 1; \
+ if (_bt_is_signed_type(typeof(__v)) \
+ && (__ptr[this_unit] & ((type) 1 << ((end % ts ? : ts) - 1)))) \
+ __v = ~(typeof(__v)) 0; \
+ else \
+ __v = 0; \
+ if (start_unit == end_unit - 1) { \
+ cmask = __ptr[this_unit]; \
+ cmask >>= (__start % ts); \
+ if ((end - __start) % ts) { \
+ mask = ~((~(type) 0) << (end - __start)); \
+ cmask &= mask; \
+ } \
+ __v = _bt_piecewise_lshift(__v, end - __start); \
+ __v |= _bt_unsigned_cast(typeof(__v), cmask); \
+ *__vptr = __v; \
+ break; \
+ } \
+ if (end % ts) { \
+ cshift = end % ts; \
+ mask = ~((~(type) 0) << cshift); \
+ cmask = __ptr[this_unit]; \
+ cmask &= mask; \
+ __v = _bt_piecewise_lshift(__v, cshift); \
+ __v |= _bt_unsigned_cast(typeof(__v), cmask); \
+ end -= cshift; \
+ this_unit--; \
+ } \
+ for (; (long) this_unit >= (long) start_unit + 1; this_unit--) { \
+ __v = _bt_piecewise_lshift(__v, ts); \
+ __v |= _bt_unsigned_cast(typeof(__v), __ptr[this_unit]);\
+ end -= ts; \
+ } \
+ if (__start % ts) { \
+ mask = ~((~(type) 0) << (ts - (__start % ts))); \
+ cmask = __ptr[this_unit]; \
+ cmask >>= (__start % ts); \
+ cmask &= mask; \
+ __v = _bt_piecewise_lshift(__v, ts - (__start % ts)); \
+ __v |= _bt_unsigned_cast(typeof(__v), cmask); \
+ } else { \
+ __v = _bt_piecewise_lshift(__v, ts); \
+ __v |= _bt_unsigned_cast(typeof(__v), __ptr[this_unit]);\
+ } \
+ *__vptr = __v; \
+} while (0)
+
+#define _bt_bitfield_read_be(_ptr, type, _start, _length, _vptr) \
+do { \
+ typeof(*(_vptr)) *__vptr = (_vptr); \
+ typeof(*__vptr) __v; \
+ type *__ptr = (void *) (_ptr); \
+ unsigned long __start = (_start), __length = (_length); \
+ type mask, cmask; \
+ unsigned long ts = sizeof(type) * CHAR_BIT; /* type size */ \
+ unsigned long start_unit, end_unit, this_unit; \
+ unsigned long end, cshift; /* cshift is "complement shift" */ \
+ \
+ if (!__length) { \
+ *__vptr = 0; \
+ break; \
+ } \
+ \
+ end = __start + __length; \
+ start_unit = __start / ts; \
+ end_unit = (end + (ts - 1)) / ts; \
+ \
+ this_unit = start_unit; \
+ if (_bt_is_signed_type(typeof(__v)) \
+ && (__ptr[this_unit] & ((type) 1 << (ts - (__start % ts) - 1)))) \
+ __v = ~(typeof(__v)) 0; \
+ else \
+ __v = 0; \
+ if (start_unit == end_unit - 1) { \
+ cmask = __ptr[this_unit]; \
+ cmask >>= (ts - (end % ts)) % ts; \
+ if ((end - __start) % ts) { \
+ mask = ~((~(type) 0) << (end - __start)); \
+ cmask &= mask; \
+ } \
+ __v = _bt_piecewise_lshift(__v, end - __start); \
+ __v |= _bt_unsigned_cast(typeof(__v), cmask); \
+ *__vptr = __v; \
+ break; \
+ } \
+ if (__start % ts) { \
+ cshift = __start % ts; \
+ mask = ~((~(type) 0) << (ts - cshift)); \
+ cmask = __ptr[this_unit]; \
+ cmask &= mask; \
+ __v = _bt_piecewise_lshift(__v, ts - cshift); \
+ __v |= _bt_unsigned_cast(typeof(__v), cmask); \
+ __start += ts - cshift; \
+ this_unit++; \
+ } \
+ for (; this_unit < end_unit - 1; this_unit++) { \
+ __v = _bt_piecewise_lshift(__v, ts); \
+ __v |= _bt_unsigned_cast(typeof(__v), __ptr[this_unit]);\
+ __start += ts; \
+ } \
+ if (end % ts) { \
+ mask = ~((~(type) 0) << (end % ts)); \
+ cmask = __ptr[this_unit]; \
+ cmask >>= ts - (end % ts); \
+ cmask &= mask; \
+ __v = _bt_piecewise_lshift(__v, end % ts); \
+ __v |= _bt_unsigned_cast(typeof(__v), cmask); \
+ } else { \
+ __v = _bt_piecewise_lshift(__v, ts); \
+ __v |= _bt_unsigned_cast(typeof(__v), __ptr[this_unit]);\
+ } \
+ *__vptr = __v; \
+} while (0)
+
+/*
+ * bt_bitfield_read - read integer from a bitfield in native endianness
+ * bt_bitfield_read_le - read integer from a bitfield in little endian
+ * bt_bitfield_read_be - read integer from a bitfield in big endian
+ */
+
+#if (BYTE_ORDER == LITTLE_ENDIAN)
+
+#define bt_bitfield_read(_ptr, type, _start, _length, _vptr) \
+ _bt_bitfield_read_le(_ptr, type, _start, _length, _vptr)
+
+#define bt_bitfield_read_le(_ptr, type, _start, _length, _vptr) \
+ _bt_bitfield_read_le(_ptr, type, _start, _length, _vptr)
+
+#define bt_bitfield_read_be(_ptr, type, _start, _length, _vptr) \
+ _bt_bitfield_read_be(_ptr, unsigned char, _start, _length, _vptr)
+
+#elif (BYTE_ORDER == BIG_ENDIAN)
+
+#define bt_bitfield_read(_ptr, type, _start, _length, _vptr) \
+ _bt_bitfield_read_be(_ptr, type, _start, _length, _vptr)
+
+#define bt_bitfield_read_le(_ptr, type, _start, _length, _vptr) \
+ _bt_bitfield_read_le(_ptr, unsigned char, _start, _length, _vptr)
+
+#define bt_bitfield_read_be(_ptr, type, _start, _length, _vptr) \
+ _bt_bitfield_read_be(_ptr, type, _start, _length, _vptr)
+
+#else /* (BYTE_ORDER == PDP_ENDIAN) */
+
+#error "Byte order not supported"
+
+#endif
+
+#endif /* _BABELTRACE_BITFIELD_H */
+++ /dev/null
-#ifndef _BABELTRACE_BITFIELD_H
-#define _BABELTRACE_BITFIELD_H
-
-/*
- * BabelTrace
- *
- * Bitfields read/write functions.
- *
- * Copyright 2010 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <stdint.h> /* C99 5.2.4.2 Numerical limits */
-#include <babeltrace/compat/limits.h> /* C99 5.2.4.2 Numerical limits */
-#include <assert.h>
-#include <babeltrace/endian.h> /* Non-standard BIG_ENDIAN, LITTLE_ENDIAN, BYTE_ORDER */
-
-/* We can't shift a int from 32 bit, >> 32 and << 32 on int is undefined */
-#define _bt_piecewise_rshift(_v, _shift) \
-({ \
- typeof(_v) ___v = (_v); \
- typeof(_shift) ___shift = (_shift); \
- unsigned long sb = (___shift) / (sizeof(___v) * CHAR_BIT - 1); \
- unsigned long final = (___shift) % (sizeof(___v) * CHAR_BIT - 1); \
- \
- for (; sb; sb--) \
- ___v >>= sizeof(___v) * CHAR_BIT - 1; \
- ___v >>= final; \
-})
-
-#define _bt_piecewise_lshift(_v, _shift) \
-({ \
- typeof(_v) ___v = (_v); \
- typeof(_shift) ___shift = (_shift); \
- unsigned long sb = (___shift) / (sizeof(___v) * CHAR_BIT - 1); \
- unsigned long final = (___shift) % (sizeof(___v) * CHAR_BIT - 1); \
- \
- for (; sb; sb--) \
- ___v <<= sizeof(___v) * CHAR_BIT - 1; \
- ___v <<= final; \
-})
-
-#define _bt_is_signed_type(type) ((type) -1 < (type) 0)
-
-#define _bt_unsigned_cast(type, v) \
-({ \
- (sizeof(v) < sizeof(type)) ? \
- ((type) (v)) & (~(~(type) 0 << (sizeof(v) * CHAR_BIT))) : \
- (type) (v); \
-})
-
-/*
- * bt_bitfield_write - write integer to a bitfield in native endianness
- *
- * Save integer to the bitfield, which starts at the "start" bit, has "len"
- * bits.
- * The inside of a bitfield is from high bits to low bits.
- * Uses native endianness.
- * For unsigned "v", pad MSB with 0 if bitfield is larger than v.
- * For signed "v", sign-extend v if bitfield is larger than v.
- *
- * On little endian, bytes are placed from the less significant to the most
- * significant. Also, consecutive bitfields are placed from lower bits to higher
- * bits.
- *
- * On big endian, bytes are places from most significant to less significant.
- * Also, consecutive bitfields are placed from higher to lower bits.
- */
-
-#define _bt_bitfield_write_le(_ptr, type, _start, _length, _v) \
-do { \
- typeof(_v) __v = (_v); \
- type *__ptr = (void *) (_ptr); \
- unsigned long __start = (_start), __length = (_length); \
- type mask, cmask; \
- unsigned long ts = sizeof(type) * CHAR_BIT; /* type size */ \
- unsigned long start_unit, end_unit, this_unit; \
- unsigned long end, cshift; /* cshift is "complement shift" */ \
- \
- if (!__length) \
- break; \
- \
- end = __start + __length; \
- start_unit = __start / ts; \
- end_unit = (end + (ts - 1)) / ts; \
- \
- /* Trim v high bits */ \
- if (__length < sizeof(__v) * CHAR_BIT) \
- __v &= ~((~(typeof(__v)) 0) << __length); \
- \
- /* We can now append v with a simple "or", shift it piece-wise */ \
- this_unit = start_unit; \
- if (start_unit == end_unit - 1) { \
- mask = ~((~(type) 0) << (__start % ts)); \
- if (end % ts) \
- mask |= (~(type) 0) << (end % ts); \
- cmask = (type) __v << (__start % ts); \
- cmask &= ~mask; \
- __ptr[this_unit] &= mask; \
- __ptr[this_unit] |= cmask; \
- break; \
- } \
- if (__start % ts) { \
- cshift = __start % ts; \
- mask = ~((~(type) 0) << cshift); \
- cmask = (type) __v << cshift; \
- cmask &= ~mask; \
- __ptr[this_unit] &= mask; \
- __ptr[this_unit] |= cmask; \
- __v = _bt_piecewise_rshift(__v, ts - cshift); \
- __start += ts - cshift; \
- this_unit++; \
- } \
- for (; this_unit < end_unit - 1; this_unit++) { \
- __ptr[this_unit] = (type) __v; \
- __v = _bt_piecewise_rshift(__v, ts); \
- __start += ts; \
- } \
- if (end % ts) { \
- mask = (~(type) 0) << (end % ts); \
- cmask = (type) __v; \
- cmask &= ~mask; \
- __ptr[this_unit] &= mask; \
- __ptr[this_unit] |= cmask; \
- } else \
- __ptr[this_unit] = (type) __v; \
-} while (0)
-
-#define _bt_bitfield_write_be(_ptr, type, _start, _length, _v) \
-do { \
- typeof(_v) __v = (_v); \
- type *__ptr = (void *) (_ptr); \
- unsigned long __start = (_start), __length = (_length); \
- type mask, cmask; \
- unsigned long ts = sizeof(type) * CHAR_BIT; /* type size */ \
- unsigned long start_unit, end_unit, this_unit; \
- unsigned long end, cshift; /* cshift is "complement shift" */ \
- \
- if (!__length) \
- break; \
- \
- end = __start + __length; \
- start_unit = __start / ts; \
- end_unit = (end + (ts - 1)) / ts; \
- \
- /* Trim v high bits */ \
- if (__length < sizeof(__v) * CHAR_BIT) \
- __v &= ~((~(typeof(__v)) 0) << __length); \
- \
- /* We can now append v with a simple "or", shift it piece-wise */ \
- this_unit = end_unit - 1; \
- if (start_unit == end_unit - 1) { \
- mask = ~((~(type) 0) << ((ts - (end % ts)) % ts)); \
- if (__start % ts) \
- mask |= (~((type) 0)) << (ts - (__start % ts)); \
- cmask = (type) __v << ((ts - (end % ts)) % ts); \
- cmask &= ~mask; \
- __ptr[this_unit] &= mask; \
- __ptr[this_unit] |= cmask; \
- break; \
- } \
- if (end % ts) { \
- cshift = end % ts; \
- mask = ~((~(type) 0) << (ts - cshift)); \
- cmask = (type) __v << (ts - cshift); \
- cmask &= ~mask; \
- __ptr[this_unit] &= mask; \
- __ptr[this_unit] |= cmask; \
- __v = _bt_piecewise_rshift(__v, cshift); \
- end -= cshift; \
- this_unit--; \
- } \
- for (; (long) this_unit >= (long) start_unit + 1; this_unit--) { \
- __ptr[this_unit] = (type) __v; \
- __v = _bt_piecewise_rshift(__v, ts); \
- end -= ts; \
- } \
- if (__start % ts) { \
- mask = (~(type) 0) << (ts - (__start % ts)); \
- cmask = (type) __v; \
- cmask &= ~mask; \
- __ptr[this_unit] &= mask; \
- __ptr[this_unit] |= cmask; \
- } else \
- __ptr[this_unit] = (type) __v; \
-} while (0)
-
-/*
- * bt_bitfield_write - write integer to a bitfield in native endianness
- * bt_bitfield_write_le - write integer to a bitfield in little endian
- * bt_bitfield_write_be - write integer to a bitfield in big endian
- */
-
-#if (BYTE_ORDER == LITTLE_ENDIAN)
-
-#define bt_bitfield_write(ptr, type, _start, _length, _v) \
- _bt_bitfield_write_le(ptr, type, _start, _length, _v)
-
-#define bt_bitfield_write_le(ptr, type, _start, _length, _v) \
- _bt_bitfield_write_le(ptr, type, _start, _length, _v)
-
-#define bt_bitfield_write_be(ptr, type, _start, _length, _v) \
- _bt_bitfield_write_be(ptr, unsigned char, _start, _length, _v)
-
-#elif (BYTE_ORDER == BIG_ENDIAN)
-
-#define bt_bitfield_write(ptr, type, _start, _length, _v) \
- _bt_bitfield_write_be(ptr, type, _start, _length, _v)
-
-#define bt_bitfield_write_le(ptr, type, _start, _length, _v) \
- _bt_bitfield_write_le(ptr, unsigned char, _start, _length, _v)
-
-#define bt_bitfield_write_be(ptr, type, _start, _length, _v) \
- _bt_bitfield_write_be(ptr, type, _start, _length, _v)
-
-#else /* (BYTE_ORDER == PDP_ENDIAN) */
-
-#error "Byte order not supported"
-
-#endif
-
-#define _bt_bitfield_read_le(_ptr, type, _start, _length, _vptr) \
-do { \
- typeof(*(_vptr)) *__vptr = (_vptr); \
- typeof(*__vptr) __v; \
- type *__ptr = (void *) (_ptr); \
- unsigned long __start = (_start), __length = (_length); \
- type mask, cmask; \
- unsigned long ts = sizeof(type) * CHAR_BIT; /* type size */ \
- unsigned long start_unit, end_unit, this_unit; \
- unsigned long end, cshift; /* cshift is "complement shift" */ \
- \
- if (!__length) { \
- *__vptr = 0; \
- break; \
- } \
- \
- end = __start + __length; \
- start_unit = __start / ts; \
- end_unit = (end + (ts - 1)) / ts; \
- \
- this_unit = end_unit - 1; \
- if (_bt_is_signed_type(typeof(__v)) \
- && (__ptr[this_unit] & ((type) 1 << ((end % ts ? : ts) - 1)))) \
- __v = ~(typeof(__v)) 0; \
- else \
- __v = 0; \
- if (start_unit == end_unit - 1) { \
- cmask = __ptr[this_unit]; \
- cmask >>= (__start % ts); \
- if ((end - __start) % ts) { \
- mask = ~((~(type) 0) << (end - __start)); \
- cmask &= mask; \
- } \
- __v = _bt_piecewise_lshift(__v, end - __start); \
- __v |= _bt_unsigned_cast(typeof(__v), cmask); \
- *__vptr = __v; \
- break; \
- } \
- if (end % ts) { \
- cshift = end % ts; \
- mask = ~((~(type) 0) << cshift); \
- cmask = __ptr[this_unit]; \
- cmask &= mask; \
- __v = _bt_piecewise_lshift(__v, cshift); \
- __v |= _bt_unsigned_cast(typeof(__v), cmask); \
- end -= cshift; \
- this_unit--; \
- } \
- for (; (long) this_unit >= (long) start_unit + 1; this_unit--) { \
- __v = _bt_piecewise_lshift(__v, ts); \
- __v |= _bt_unsigned_cast(typeof(__v), __ptr[this_unit]);\
- end -= ts; \
- } \
- if (__start % ts) { \
- mask = ~((~(type) 0) << (ts - (__start % ts))); \
- cmask = __ptr[this_unit]; \
- cmask >>= (__start % ts); \
- cmask &= mask; \
- __v = _bt_piecewise_lshift(__v, ts - (__start % ts)); \
- __v |= _bt_unsigned_cast(typeof(__v), cmask); \
- } else { \
- __v = _bt_piecewise_lshift(__v, ts); \
- __v |= _bt_unsigned_cast(typeof(__v), __ptr[this_unit]);\
- } \
- *__vptr = __v; \
-} while (0)
-
-#define _bt_bitfield_read_be(_ptr, type, _start, _length, _vptr) \
-do { \
- typeof(*(_vptr)) *__vptr = (_vptr); \
- typeof(*__vptr) __v; \
- type *__ptr = (void *) (_ptr); \
- unsigned long __start = (_start), __length = (_length); \
- type mask, cmask; \
- unsigned long ts = sizeof(type) * CHAR_BIT; /* type size */ \
- unsigned long start_unit, end_unit, this_unit; \
- unsigned long end, cshift; /* cshift is "complement shift" */ \
- \
- if (!__length) { \
- *__vptr = 0; \
- break; \
- } \
- \
- end = __start + __length; \
- start_unit = __start / ts; \
- end_unit = (end + (ts - 1)) / ts; \
- \
- this_unit = start_unit; \
- if (_bt_is_signed_type(typeof(__v)) \
- && (__ptr[this_unit] & ((type) 1 << (ts - (__start % ts) - 1)))) \
- __v = ~(typeof(__v)) 0; \
- else \
- __v = 0; \
- if (start_unit == end_unit - 1) { \
- cmask = __ptr[this_unit]; \
- cmask >>= (ts - (end % ts)) % ts; \
- if ((end - __start) % ts) { \
- mask = ~((~(type) 0) << (end - __start)); \
- cmask &= mask; \
- } \
- __v = _bt_piecewise_lshift(__v, end - __start); \
- __v |= _bt_unsigned_cast(typeof(__v), cmask); \
- *__vptr = __v; \
- break; \
- } \
- if (__start % ts) { \
- cshift = __start % ts; \
- mask = ~((~(type) 0) << (ts - cshift)); \
- cmask = __ptr[this_unit]; \
- cmask &= mask; \
- __v = _bt_piecewise_lshift(__v, ts - cshift); \
- __v |= _bt_unsigned_cast(typeof(__v), cmask); \
- __start += ts - cshift; \
- this_unit++; \
- } \
- for (; this_unit < end_unit - 1; this_unit++) { \
- __v = _bt_piecewise_lshift(__v, ts); \
- __v |= _bt_unsigned_cast(typeof(__v), __ptr[this_unit]);\
- __start += ts; \
- } \
- if (end % ts) { \
- mask = ~((~(type) 0) << (end % ts)); \
- cmask = __ptr[this_unit]; \
- cmask >>= ts - (end % ts); \
- cmask &= mask; \
- __v = _bt_piecewise_lshift(__v, end % ts); \
- __v |= _bt_unsigned_cast(typeof(__v), cmask); \
- } else { \
- __v = _bt_piecewise_lshift(__v, ts); \
- __v |= _bt_unsigned_cast(typeof(__v), __ptr[this_unit]);\
- } \
- *__vptr = __v; \
-} while (0)
-
-/*
- * bt_bitfield_read - read integer from a bitfield in native endianness
- * bt_bitfield_read_le - read integer from a bitfield in little endian
- * bt_bitfield_read_be - read integer from a bitfield in big endian
- */
-
-#if (BYTE_ORDER == LITTLE_ENDIAN)
-
-#define bt_bitfield_read(_ptr, type, _start, _length, _vptr) \
- _bt_bitfield_read_le(_ptr, type, _start, _length, _vptr)
-
-#define bt_bitfield_read_le(_ptr, type, _start, _length, _vptr) \
- _bt_bitfield_read_le(_ptr, type, _start, _length, _vptr)
-
-#define bt_bitfield_read_be(_ptr, type, _start, _length, _vptr) \
- _bt_bitfield_read_be(_ptr, unsigned char, _start, _length, _vptr)
-
-#elif (BYTE_ORDER == BIG_ENDIAN)
-
-#define bt_bitfield_read(_ptr, type, _start, _length, _vptr) \
- _bt_bitfield_read_be(_ptr, type, _start, _length, _vptr)
-
-#define bt_bitfield_read_le(_ptr, type, _start, _length, _vptr) \
- _bt_bitfield_read_le(_ptr, unsigned char, _start, _length, _vptr)
-
-#define bt_bitfield_read_be(_ptr, type, _start, _length, _vptr) \
- _bt_bitfield_read_be(_ptr, type, _start, _length, _vptr)
-
-#else /* (BYTE_ORDER == PDP_ENDIAN) */
-
-#error "Byte order not supported"
-
-#endif
-
-#endif /* _BABELTRACE_BITFIELD_H */
--- /dev/null
+#ifndef _BABELTRACE_COMPAT_DIRENT_H
+#define _BABELTRACE_COMPAT_DIRENT_H
+
+/*
+ * babeltrace/compat/dirent.h
+ *
+ * Copyright (C) 2015 Michael Jeanson <mjeanson@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <dirent.h>
+
+#ifdef HAVE_DIRFD
+static inline
+int bt_dirfd(DIR *dir) {
+ return dirfd(dir);
+}
+#else
+# ifndef __XOPEN_OR_POSIX
+static inline
+int bt_dirfd(DIR *dir) {
+ return dir->dd_fd;
+}
+# else
+static inline
+int bt_dirfd(DIR *dir) {
+ return dir->d_fd;
+}
+# endif
+#endif
+
+#endif /* _BABELTRACE_COMPAT_DIRENT_H */
+++ /dev/null
-#ifndef _BABELTRACE_COMPAT_DIRENT_H
-#define _BABELTRACE_COMPAT_DIRENT_H
-
-/*
- * babeltrace/compat/dirent.h
- *
- * Copyright (C) 2015 Michael Jeanson <mjeanson@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <dirent.h>
-
-#ifdef HAVE_DIRFD
-static inline
-int bt_dirfd(DIR *dir) {
- return dirfd(dir);
-}
-#else
-# ifndef __XOPEN_OR_POSIX
-static inline
-int bt_dirfd(DIR *dir) {
- return dir->dd_fd;
-}
-# else
-static inline
-int bt_dirfd(DIR *dir) {
- return dir->d_fd;
-}
-# endif
-#endif
-
-#endif /* _BABELTRACE_COMPAT_DIRENT_H */
--- /dev/null
+#ifndef _BABELTRACE_COMPAT_FCNTL_H
+#define _BABELTRACE_COMPAT_FCNTL_H
+
+/*
+ * babeltrace/compat/fcntl.h
+ *
+ * Copyright 2015 (c) - Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * fcntl compatibility layer.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifdef BABELTRACE_HAVE_POSIX_FALLOCATE
+
+#include <fcntl.h>
+
+static inline
+int bt_posix_fallocate(int fd, off_t offset, off_t len)
+{
+ return posix_fallocate(fd, offset, len);
+}
+
+#else /* #ifdef BABELTRACE_HAVE_POSIX_FALLOCATE */
+
+#include <sys/types.h>
+#include <unistd.h>
+#include <string.h>
+
+#define BABELTRACE_FALLOCATE_BUFLEN 256
+
+#ifndef min_t
+#define min_t(type, a, b) \
+ ((type) (a) < (type) (b) ? (type) (a) : (type) (b))
+#endif
+
+static inline
+int bt_posix_fallocate(int fd, off_t offset, off_t len)
+{
+ int ret = 0;
+ ssize_t copy_len;
+ char buf[BABELTRACE_FALLOCATE_BUFLEN];
+ off_t i, file_pos, orig_end_offset, range_end;
+
+ if (offset < 0 || len < 0) {
+ ret = EINVAL;
+ goto end;
+ }
+
+ range_end = offset + len;
+ if (range_end < 0) {
+ ret = EFBIG;
+ goto end;
+ }
+
+ file_pos = lseek(fd, 0, SEEK_CUR);
+ if (file_pos < 0) {
+ ret = errno;
+ goto end;
+ }
+
+ orig_end_offset = lseek(fd, 0, SEEK_END);
+ if (orig_end_offset < 0) {
+ ret = errno;
+ goto end;
+ }
+
+ /* Seek back to original position. */
+ ret = lseek(fd, file_pos, SEEK_SET);
+ if (ret) {
+ ret = errno;
+ goto end;
+ }
+
+ /*
+ * The file may not need to grow, but we want to ensure the
+ * space has actually been reserved by the file system. First, copy
+ * the "existing" region of the file, then grow the file if needed.
+ */
+ for (i = file_pos; i < min_t(off_t, range_end, orig_end_offset);
+ i += copy_len) {
+ ssize_t copy_ret;
+
+ copy_len = min_t(size_t, BABELTRACE_FALLOCATE_BUFLEN,
+ min_t(off_t, range_end - i,
+ orig_end_offset - i));
+ copy_ret = pread(fd, &buf, copy_len, i);
+ if (copy_ret < copy_len) {
+ /*
+ * The caller must handle any EINTR.
+ * POSIX_FALLOCATE(3) does not mention EINTR.
+ * However, glibc does forward to fallocate()
+ * directly on Linux, which may be interrupted.
+ */
+ ret = errno;
+ goto end;
+ }
+
+ copy_ret = pwrite(fd, &buf, copy_len, i);
+ if (copy_ret < copy_len) {
+ /* Same caveat as noted at pread() */
+ ret = errno;
+ goto end;
+ }
+ }
+
+ /* Grow file, as necessary. */
+ memset(&buf, 0, BABELTRACE_FALLOCATE_BUFLEN);
+ for (i = orig_end_offset; i < range_end; i += copy_len) {
+ ssize_t write_ret;
+
+ copy_len = min_t(size_t, BABELTRACE_FALLOCATE_BUFLEN,
+ range_end - i);
+ write_ret = pwrite(fd, &buf, copy_len, i);
+ if (write_ret < copy_len) {
+ ret = errno;
+ goto end;
+ }
+ }
+end:
+ return ret;
+}
+#endif /* #else #ifdef BABELTRACE_HAVE_POSIX_FALLOCATE */
+
+
+#ifdef BABELTRACE_HAVE_FACCESSAT
+
+#include <fcntl.h>
+#include <unistd.h>
+
+static inline
+int bt_faccessat(int dirfd, const char *dirname,
+ const char *pathname, int mode, int flags)
+{
+ return faccessat(dirfd, pathname, mode, flags);
+}
+
+#else /* #ifdef BABELTRACE_HAVE_FACCESSAT */
+
+#include <string.h>
+#include <unistd.h>
+
+static inline
+int bt_faccessat(int dirfd, const char *dirname,
+ const char *pathname, int mode, int flags)
+{
+ char cpath[PATH_MAX];
+
+ if (flags != 0) {
+ errno = EINVAL;
+ return -1;
+ }
+ /* Includes middle / and final \0. */
+ if (strlen(dirname) + strlen(pathname) + 2 > PATH_MAX) {
+ return -1;
+ }
+ strcpy(cpath, dirname);
+ strcat(cpath, "/");
+ strcat(cpath, pathname);
+ return access(cpath, mode);
+}
+
+#endif /* #else #ifdef BABELTRACE_HAVE_FACCESSAT */
+
+#endif /* _BABELTRACE_COMPAT_FCNTL_H */
+++ /dev/null
-#ifndef _BABELTRACE_COMPAT_FCNTL_H
-#define _BABELTRACE_COMPAT_FCNTL_H
-
-/*
- * babeltrace/compat/fcntl.h
- *
- * Copyright 2015 (c) - Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * fcntl compatibility layer.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#ifdef BABELTRACE_HAVE_POSIX_FALLOCATE
-
-#include <fcntl.h>
-
-static inline
-int bt_posix_fallocate(int fd, off_t offset, off_t len)
-{
- return posix_fallocate(fd, offset, len);
-}
-
-#else /* #ifdef BABELTRACE_HAVE_POSIX_FALLOCATE */
-
-#include <sys/types.h>
-#include <unistd.h>
-#include <string.h>
-
-#define BABELTRACE_FALLOCATE_BUFLEN 256
-
-#ifndef min_t
-#define min_t(type, a, b) \
- ((type) (a) < (type) (b) ? (type) (a) : (type) (b))
-#endif
-
-static inline
-int bt_posix_fallocate(int fd, off_t offset, off_t len)
-{
- int ret = 0;
- ssize_t copy_len;
- char buf[BABELTRACE_FALLOCATE_BUFLEN];
- off_t i, file_pos, orig_end_offset, range_end;
-
- if (offset < 0 || len < 0) {
- ret = EINVAL;
- goto end;
- }
-
- range_end = offset + len;
- if (range_end < 0) {
- ret = EFBIG;
- goto end;
- }
-
- file_pos = lseek(fd, 0, SEEK_CUR);
- if (file_pos < 0) {
- ret = errno;
- goto end;
- }
-
- orig_end_offset = lseek(fd, 0, SEEK_END);
- if (orig_end_offset < 0) {
- ret = errno;
- goto end;
- }
-
- /* Seek back to original position. */
- ret = lseek(fd, file_pos, SEEK_SET);
- if (ret) {
- ret = errno;
- goto end;
- }
-
- /*
- * The file may not need to grow, but we want to ensure the
- * space has actually been reserved by the file system. First, copy
- * the "existing" region of the file, then grow the file if needed.
- */
- for (i = file_pos; i < min_t(off_t, range_end, orig_end_offset);
- i += copy_len) {
- ssize_t copy_ret;
-
- copy_len = min_t(size_t, BABELTRACE_FALLOCATE_BUFLEN,
- min_t(off_t, range_end - i,
- orig_end_offset - i));
- copy_ret = pread(fd, &buf, copy_len, i);
- if (copy_ret < copy_len) {
- /*
- * The caller must handle any EINTR.
- * POSIX_FALLOCATE(3) does not mention EINTR.
- * However, glibc does forward to fallocate()
- * directly on Linux, which may be interrupted.
- */
- ret = errno;
- goto end;
- }
-
- copy_ret = pwrite(fd, &buf, copy_len, i);
- if (copy_ret < copy_len) {
- /* Same caveat as noted at pread() */
- ret = errno;
- goto end;
- }
- }
-
- /* Grow file, as necessary. */
- memset(&buf, 0, BABELTRACE_FALLOCATE_BUFLEN);
- for (i = orig_end_offset; i < range_end; i += copy_len) {
- ssize_t write_ret;
-
- copy_len = min_t(size_t, BABELTRACE_FALLOCATE_BUFLEN,
- range_end - i);
- write_ret = pwrite(fd, &buf, copy_len, i);
- if (write_ret < copy_len) {
- ret = errno;
- goto end;
- }
- }
-end:
- return ret;
-}
-#endif /* #else #ifdef BABELTRACE_HAVE_POSIX_FALLOCATE */
-
-
-#ifdef BABELTRACE_HAVE_FACCESSAT
-
-#include <fcntl.h>
-#include <unistd.h>
-
-static inline
-int bt_faccessat(int dirfd, const char *dirname,
- const char *pathname, int mode, int flags)
-{
- return faccessat(dirfd, pathname, mode, flags);
-}
-
-#else /* #ifdef BABELTRACE_HAVE_FACCESSAT */
-
-#include <string.h>
-#include <unistd.h>
-
-static inline
-int bt_faccessat(int dirfd, const char *dirname,
- const char *pathname, int mode, int flags)
-{
- char cpath[PATH_MAX];
-
- if (flags != 0) {
- errno = EINVAL;
- return -1;
- }
- /* Includes middle / and final \0. */
- if (strlen(dirname) + strlen(pathname) + 2 > PATH_MAX) {
- return -1;
- }
- strcpy(cpath, dirname);
- strcat(cpath, "/");
- strcat(cpath, pathname);
- return access(cpath, mode);
-}
-
-#endif /* #else #ifdef BABELTRACE_HAVE_FACCESSAT */
-
-#endif /* _BABELTRACE_COMPAT_FCNTL_H */
--- /dev/null
+#ifndef _BABELTRACE_COMPAT_GLIB_H
+#define _BABELTRACE_COMPAT_GLIB_H
+
+/*
+ * babeltrace/compat/glib.h
+ *
+ * Copyright (C) 2015 Michael Jeanson <mjeanson@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <glib.h>
+
+#if GLIB_CHECK_VERSION(2,31,8)
+
+static inline gboolean
+bt_g_hash_table_contains(GHashTable *hash_table, gconstpointer key)
+{
+ return g_hash_table_contains(hash_table, key);
+}
+
+#else
+
+static inline gboolean
+bt_g_hash_table_contains(GHashTable *hash_table, gconstpointer key)
+{
+ const char *value;
+
+ value = g_hash_table_lookup(hash_table, key);
+ if (value == NULL) {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+#endif
+
+
+#if GLIB_CHECK_VERSION(2,29,16)
+
+static inline GPtrArray *
+bt_g_ptr_array_new_full(guint reserved_size,
+ GDestroyNotify element_free_func)
+{
+ return g_ptr_array_new_full(reserved_size, element_free_func);
+}
+
+#else
+
+static inline GPtrArray *
+bt_g_ptr_array_new_full(guint reserved_size,
+ GDestroyNotify element_free_func)
+{
+ GPtrArray *array;
+
+ array = g_ptr_array_sized_new(reserved_size);
+ if (!array) {
+ goto end;
+ }
+ g_ptr_array_set_free_func(array, element_free_func);
+end:
+ return array;
+}
+#endif
+
+#endif /* _BABELTRACE_COMPAT_GLIB_H */
+++ /dev/null
-#ifndef _BABELTRACE_COMPAT_GLIB_H
-#define _BABELTRACE_COMPAT_GLIB_H
-
-/*
- * babeltrace/compat/glib.h
- *
- * Copyright (C) 2015 Michael Jeanson <mjeanson@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <glib.h>
-
-#if GLIB_CHECK_VERSION(2,31,8)
-
-static inline gboolean
-bt_g_hash_table_contains(GHashTable *hash_table, gconstpointer key)
-{
- return g_hash_table_contains(hash_table, key);
-}
-
-#else
-
-static inline gboolean
-bt_g_hash_table_contains(GHashTable *hash_table, gconstpointer key)
-{
- const char *value;
-
- value = g_hash_table_lookup(hash_table, key);
- if (value == NULL) {
- return FALSE;
- }
-
- return TRUE;
-}
-
-#endif
-
-
-#if GLIB_CHECK_VERSION(2,29,16)
-
-static inline GPtrArray *
-bt_g_ptr_array_new_full(guint reserved_size,
- GDestroyNotify element_free_func)
-{
- return g_ptr_array_new_full(reserved_size, element_free_func);
-}
-
-#else
-
-static inline GPtrArray *
-bt_g_ptr_array_new_full(guint reserved_size,
- GDestroyNotify element_free_func)
-{
- GPtrArray *array;
-
- array = g_ptr_array_sized_new(reserved_size);
- if (!array) {
- goto end;
- }
- g_ptr_array_set_free_func(array, element_free_func);
-end:
- return array;
-}
-#endif
-
-#endif /* _BABELTRACE_COMPAT_GLIB_H */
--- /dev/null
+#ifndef _BABELTRACE_LIMITS_H
+#define _BABELTRACE_LIMITS_H
+
+/*
+ * Copyright (C) 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <limits.h>
+
+#ifdef __linux__
+
+#define BABELTRACE_HOST_NAME_MAX HOST_NAME_MAX
+
+#elif defined(__FreeBSD__)
+
+#define BABELTRACE_HOST_NAME_MAX MAXHOSTNAMELEN
+
+#elif defined(_POSIX_HOST_NAME_MAX)
+
+#define BABELTRACE_HOST_NAME_MAX _POSIX_HOST_NAME_MAX
+
+#else
+
+#define BABELTRACE_HOST_NAME_MAX 256
+
+#endif /* __linux__, __FreeBSD__, _POSIX_HOST_NAME_MAX */
+
+#endif /* _BABELTRACE_LIMITS_H */
+++ /dev/null
-#ifndef _BABELTRACE_LIMITS_H
-#define _BABELTRACE_LIMITS_H
-
-/*
- * Copyright (C) 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <limits.h>
-
-#ifdef __linux__
-
-#define BABELTRACE_HOST_NAME_MAX HOST_NAME_MAX
-
-#elif defined(__FreeBSD__)
-
-#define BABELTRACE_HOST_NAME_MAX MAXHOSTNAMELEN
-
-#elif defined(_POSIX_HOST_NAME_MAX)
-
-#define BABELTRACE_HOST_NAME_MAX _POSIX_HOST_NAME_MAX
-
-#else
-
-#define BABELTRACE_HOST_NAME_MAX 256
-
-#endif /* __linux__, __FreeBSD__, _POSIX_HOST_NAME_MAX */
-
-#endif /* _BABELTRACE_LIMITS_H */
--- /dev/null
+#ifndef _BABELTRACE_FORMAT_CTF_MEMSTREAM_H
+#define _BABELTRACE_FORMAT_CTF_MEMSTREAM_H
+
+/*
+ * format/ctf/memstream.h
+ *
+ * Copyright 2012 (c) - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * memstream compatibility layer.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifdef BABELTRACE_HAVE_FMEMOPEN
+#include <stdio.h>
+
+static inline
+FILE *bt_fmemopen(void *buf, size_t size, const char *mode)
+{
+ return fmemopen(buf, size, mode);
+}
+
+#else /* BABELTRACE_HAVE_FMEMOPEN */
+
+#include <stdlib.h>
+#include <stdio.h>
+
+/*
+ * Fallback for systems which don't have fmemopen. Copy buffer to a
+ * temporary file, and use that file as FILE * input.
+ */
+static inline
+FILE *bt_fmemopen(void *buf, size_t size, const char *mode)
+{
+ char tmpname[PATH_MAX];
+ size_t len;
+ FILE *fp;
+ int ret;
+
+ /*
+ * Support reading only.
+ */
+ if (strcmp(mode, "rb") != 0) {
+ return NULL;
+ }
+ strncpy(tmpname, "/tmp/babeltrace-tmp-XXXXXX", PATH_MAX);
+ ret = mkstemp(tmpname);
+ if (ret < 0) {
+ return NULL;
+ }
+ /*
+ * We need to write to the file.
+ */
+ fp = fdopen(ret, "w+");
+ if (!fp) {
+ goto error_unlink;
+ }
+ /* Copy the entire buffer to the file */
+ len = fwrite(buf, sizeof(char), size, fp);
+ if (len != size) {
+ goto error_close;
+ }
+ ret = fseek(fp, 0L, SEEK_SET);
+ if (ret < 0) {
+ perror("fseek");
+ goto error_close;
+ }
+ /* We keep the handle open, but can unlink the file on the VFS. */
+ ret = unlink(tmpname);
+ if (ret < 0) {
+ perror("unlink");
+ }
+ return fp;
+
+error_close:
+ ret = fclose(fp);
+ if (ret < 0) {
+ perror("close");
+ }
+error_unlink:
+ ret = unlink(tmpname);
+ if (ret < 0) {
+ perror("unlink");
+ }
+ return NULL;
+}
+
+#endif /* BABELTRACE_HAVE_FMEMOPEN */
+
+#ifdef BABELTRACE_HAVE_OPEN_MEMSTREAM
+
+#include <stdio.h>
+
+static inline
+FILE *bt_open_memstream(char **ptr, size_t *sizeloc)
+{
+ return open_memstream(ptr, sizeloc);
+}
+
+static inline
+int bt_close_memstream(char **buf, size_t *size, FILE *fp)
+{
+ return fclose(fp);
+}
+
+#else /* BABELTRACE_HAVE_OPEN_MEMSTREAM */
+
+#include <stdlib.h>
+#include <stdio.h>
+
+/*
+ * Fallback for systems which don't have open_memstream. Create FILE *
+ * with bt_open_memstream, but require call to
+ * bt_close_memstream to flush all data written to the FILE *
+ * into the buffer (which we allocate).
+ */
+static inline
+FILE *bt_open_memstream(char **ptr, size_t *sizeloc)
+{
+ char tmpname[PATH_MAX];
+ int ret;
+ FILE *fp;
+
+ strncpy(tmpname, "/tmp/babeltrace-tmp-XXXXXX", PATH_MAX);
+ ret = mkstemp(tmpname);
+ if (ret < 0) {
+ return NULL;
+ }
+ fp = fdopen(ret, "w+");
+ if (!fp) {
+ goto error_unlink;
+ }
+ /*
+ * babeltrace_flush_memstream will update the buffer content
+ * with read from fp. No need to keep the file around, just the
+ * handle.
+ */
+ ret = unlink(tmpname);
+ if (ret < 0) {
+ perror("unlink");
+ }
+ return fp;
+
+error_unlink:
+ ret = unlink(tmpname);
+ if (ret < 0) {
+ perror("unlink");
+ }
+ return NULL;
+}
+
+/* Get file size, allocate buffer, copy. */
+static inline
+int bt_close_memstream(char **buf, size_t *size, FILE *fp)
+{
+ size_t len, n;
+ long pos;
+ int ret;
+
+ ret = fflush(fp);
+ if (ret < 0) {
+ perror("fflush");
+ return ret;
+ }
+ ret = fseek(fp, 0L, SEEK_END);
+ if (ret < 0) {
+ perror("fseek");
+ return ret;
+ }
+ pos = ftell(fp);
+ if (ret < 0) {
+ perror("ftell");
+ return ret;
+ }
+ *size = pos;
+ /* add final \0 */
+ *buf = calloc(pos + 1, sizeof(char));
+ if (!*buf) {
+ return -ENOMEM;
+ }
+ ret = fseek(fp, 0L, SEEK_SET);
+ if (ret < 0) {
+ perror("fseek");
+ goto error_free;
+ }
+ /* Copy the entire file into the buffer */
+ n = 0;
+ clearerr(fp);
+ while (!feof(fp) && !ferror(fp) && (*size - n > 0)) {
+ len = fread(*buf, sizeof(char), *size - n, fp);
+ n += len;
+ }
+ if (n != *size) {
+ ret = -1;
+ goto error_close;
+ }
+ ret = fclose(fp);
+ if (ret < 0) {
+ perror("fclose");
+ return ret;
+ }
+ return 0;
+
+error_close:
+ ret = fclose(fp);
+ if (ret < 0) {
+ perror("fclose");
+ }
+error_free:
+ free(*buf);
+ *buf = NULL;
+ return ret;
+}
+
+#endif /* BABELTRACE_HAVE_OPEN_MEMSTREAM */
+
+#endif /* _BABELTRACE_FORMAT_CTF_MEMSTREAM_H */
+++ /dev/null
-#ifndef _BABELTRACE_FORMAT_CTF_MEMSTREAM_H
-#define _BABELTRACE_FORMAT_CTF_MEMSTREAM_H
-
-/*
- * format/ctf/memstream.h
- *
- * Copyright 2012 (c) - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * memstream compatibility layer.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#ifdef BABELTRACE_HAVE_FMEMOPEN
-#include <stdio.h>
-
-static inline
-FILE *bt_fmemopen(void *buf, size_t size, const char *mode)
-{
- return fmemopen(buf, size, mode);
-}
-
-#else /* BABELTRACE_HAVE_FMEMOPEN */
-
-#include <stdlib.h>
-#include <stdio.h>
-
-/*
- * Fallback for systems which don't have fmemopen. Copy buffer to a
- * temporary file, and use that file as FILE * input.
- */
-static inline
-FILE *bt_fmemopen(void *buf, size_t size, const char *mode)
-{
- char tmpname[PATH_MAX];
- size_t len;
- FILE *fp;
- int ret;
-
- /*
- * Support reading only.
- */
- if (strcmp(mode, "rb") != 0) {
- return NULL;
- }
- strncpy(tmpname, "/tmp/babeltrace-tmp-XXXXXX", PATH_MAX);
- ret = mkstemp(tmpname);
- if (ret < 0) {
- return NULL;
- }
- /*
- * We need to write to the file.
- */
- fp = fdopen(ret, "w+");
- if (!fp) {
- goto error_unlink;
- }
- /* Copy the entire buffer to the file */
- len = fwrite(buf, sizeof(char), size, fp);
- if (len != size) {
- goto error_close;
- }
- ret = fseek(fp, 0L, SEEK_SET);
- if (ret < 0) {
- perror("fseek");
- goto error_close;
- }
- /* We keep the handle open, but can unlink the file on the VFS. */
- ret = unlink(tmpname);
- if (ret < 0) {
- perror("unlink");
- }
- return fp;
-
-error_close:
- ret = fclose(fp);
- if (ret < 0) {
- perror("close");
- }
-error_unlink:
- ret = unlink(tmpname);
- if (ret < 0) {
- perror("unlink");
- }
- return NULL;
-}
-
-#endif /* BABELTRACE_HAVE_FMEMOPEN */
-
-#ifdef BABELTRACE_HAVE_OPEN_MEMSTREAM
-
-#include <stdio.h>
-
-static inline
-FILE *bt_open_memstream(char **ptr, size_t *sizeloc)
-{
- return open_memstream(ptr, sizeloc);
-}
-
-static inline
-int bt_close_memstream(char **buf, size_t *size, FILE *fp)
-{
- return fclose(fp);
-}
-
-#else /* BABELTRACE_HAVE_OPEN_MEMSTREAM */
-
-#include <stdlib.h>
-#include <stdio.h>
-
-/*
- * Fallback for systems which don't have open_memstream. Create FILE *
- * with bt_open_memstream, but require call to
- * bt_close_memstream to flush all data written to the FILE *
- * into the buffer (which we allocate).
- */
-static inline
-FILE *bt_open_memstream(char **ptr, size_t *sizeloc)
-{
- char tmpname[PATH_MAX];
- int ret;
- FILE *fp;
-
- strncpy(tmpname, "/tmp/babeltrace-tmp-XXXXXX", PATH_MAX);
- ret = mkstemp(tmpname);
- if (ret < 0) {
- return NULL;
- }
- fp = fdopen(ret, "w+");
- if (!fp) {
- goto error_unlink;
- }
- /*
- * babeltrace_flush_memstream will update the buffer content
- * with read from fp. No need to keep the file around, just the
- * handle.
- */
- ret = unlink(tmpname);
- if (ret < 0) {
- perror("unlink");
- }
- return fp;
-
-error_unlink:
- ret = unlink(tmpname);
- if (ret < 0) {
- perror("unlink");
- }
- return NULL;
-}
-
-/* Get file size, allocate buffer, copy. */
-static inline
-int bt_close_memstream(char **buf, size_t *size, FILE *fp)
-{
- size_t len, n;
- long pos;
- int ret;
-
- ret = fflush(fp);
- if (ret < 0) {
- perror("fflush");
- return ret;
- }
- ret = fseek(fp, 0L, SEEK_END);
- if (ret < 0) {
- perror("fseek");
- return ret;
- }
- pos = ftell(fp);
- if (ret < 0) {
- perror("ftell");
- return ret;
- }
- *size = pos;
- /* add final \0 */
- *buf = calloc(pos + 1, sizeof(char));
- if (!*buf) {
- return -ENOMEM;
- }
- ret = fseek(fp, 0L, SEEK_SET);
- if (ret < 0) {
- perror("fseek");
- goto error_free;
- }
- /* Copy the entire file into the buffer */
- n = 0;
- clearerr(fp);
- while (!feof(fp) && !ferror(fp) && (*size - n > 0)) {
- len = fread(*buf, sizeof(char), *size - n, fp);
- n += len;
- }
- if (n != *size) {
- ret = -1;
- goto error_close;
- }
- ret = fclose(fp);
- if (ret < 0) {
- perror("fclose");
- return ret;
- }
- return 0;
-
-error_close:
- ret = fclose(fp);
- if (ret < 0) {
- perror("fclose");
- }
-error_free:
- free(*buf);
- *buf = NULL;
- return ret;
-}
-
-#endif /* BABELTRACE_HAVE_OPEN_MEMSTREAM */
-
-#endif /* _BABELTRACE_FORMAT_CTF_MEMSTREAM_H */
--- /dev/null
+#ifndef _BABELTRACE_COMPAT_MMAN_H
+#define _BABELTRACE_COMPAT_MMAN_H
+
+/*
+ * babeltrace/compat/mman.h
+ *
+ * Copyright (C) 2015 Michael Jeanson <mjeanson@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <sys/mman.h>
+
+#ifndef MAP_ANONYMOUS
+# ifdef MAP_ANON
+# define MAP_ANONYMOUS MAP_ANON
+# endif
+#endif
+
+#endif /* _BABELTRACE_COMPAT_MMAN_H */
+++ /dev/null
-#ifndef _BABELTRACE_COMPAT_MMAN_H
-#define _BABELTRACE_COMPAT_MMAN_H
-
-/*
- * babeltrace/compat/mman.h
- *
- * Copyright (C) 2015 Michael Jeanson <mjeanson@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <sys/mman.h>
-
-#ifndef MAP_ANONYMOUS
-# ifdef MAP_ANON
-# define MAP_ANONYMOUS MAP_ANON
-# endif
-#endif
-
-#endif /* _BABELTRACE_COMPAT_MMAN_H */
--- /dev/null
+#ifndef _BABELTRACE_COMPAT_SEND_H
+#define _BABELTRACE_COMPAT_SEND_H
+
+/*
+ * babeltrace/compat/send.h
+ *
+ * Copyright (C) 2015 Michael Jeanson <mjeanson@efficios.com>
+ * 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * This wrapper is used on platforms that have no way of ignoring SIGPIPE
+ * during a send().
+ */
+
+#ifndef MSG_NOSIGNAL
+# ifdef SO_NOSIGPIPE
+# define MSG_NOSIGNAL SO_NOSIGPIPE
+# endif
+#endif
+
+#if defined(MSG_NOSIGNAL)
+static inline
+ssize_t bt_send_nosigpipe(int fd, const void *buffer, size_t size)
+{
+ return send(fd, buffer, size, MSG_NOSIGNAL);
+}
+#else
+
+#include <signal.h>
+
+static inline
+ssize_t bt_send_nosigpipe(int fd, const void *buffer, size_t size)
+{
+ ssize_t sent;
+ int saved_err;
+ sigset_t sigpipe_set, pending_set, old_set;
+ int sigpipe_was_pending;
+
+ /*
+ * Discard the SIGPIPE from send(), not disturbing any SIGPIPE
+ * that might be already pending. If a bogus SIGPIPE is sent to
+ * the entire process concurrently by a malicious user, it may
+ * be simply discarded.
+ */
+ if (sigemptyset(&pending_set)) {
+ return -1;
+ }
+ /*
+ * sigpending returns the mask of signals that are _both_
+ * blocked for the thread _and_ pending for either the thread or
+ * the entire process.
+ */
+ if (sigpending(&pending_set)) {
+ return -1;
+ }
+ sigpipe_was_pending = sigismember(&pending_set, SIGPIPE);
+ /*
+ * If sigpipe was pending, it means it was already blocked, so
+ * no need to block it.
+ */
+ if (!sigpipe_was_pending) {
+ if (sigemptyset(&sigpipe_set)) {
+ return -1;
+ }
+ if (sigaddset(&sigpipe_set, SIGPIPE)) {
+ return -1;
+ }
+ if (pthread_sigmask(SIG_BLOCK, &sigpipe_set, &old_set)) {
+ return -1;
+ }
+ }
+
+ /* Send and save errno. */
+ sent = send(fd, buffer, size, 0);
+ saved_err = errno;
+
+ if (sent == -1 && errno == EPIPE && !sigpipe_was_pending) {
+ struct timespec timeout = { 0, 0 };
+ int ret;
+
+ do {
+ ret = sigtimedwait(&sigpipe_set, NULL,
+ &timeout);
+ } while (ret == -1 && errno == EINTR);
+ }
+ if (!sigpipe_was_pending) {
+ if (pthread_sigmask(SIG_SETMASK, &old_set, NULL)) {
+ return -1;
+ }
+ }
+ /* Restore send() errno */
+ errno = saved_err;
+
+ return sent;
+}
+#endif
+
+#endif /* _BABELTRACE_COMPAT_SEND_H */
+++ /dev/null
-#ifndef _BABELTRACE_COMPAT_SEND_H
-#define _BABELTRACE_COMPAT_SEND_H
-
-/*
- * babeltrace/compat/send.h
- *
- * Copyright (C) 2015 Michael Jeanson <mjeanson@efficios.com>
- * 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-/*
- * This wrapper is used on platforms that have no way of ignoring SIGPIPE
- * during a send().
- */
-
-#ifndef MSG_NOSIGNAL
-# ifdef SO_NOSIGPIPE
-# define MSG_NOSIGNAL SO_NOSIGPIPE
-# endif
-#endif
-
-#if defined(MSG_NOSIGNAL)
-static inline
-ssize_t bt_send_nosigpipe(int fd, const void *buffer, size_t size)
-{
- return send(fd, buffer, size, MSG_NOSIGNAL);
-}
-#else
-
-#include <signal.h>
-
-static inline
-ssize_t bt_send_nosigpipe(int fd, const void *buffer, size_t size)
-{
- ssize_t sent;
- int saved_err;
- sigset_t sigpipe_set, pending_set, old_set;
- int sigpipe_was_pending;
-
- /*
- * Discard the SIGPIPE from send(), not disturbing any SIGPIPE
- * that might be already pending. If a bogus SIGPIPE is sent to
- * the entire process concurrently by a malicious user, it may
- * be simply discarded.
- */
- if (sigemptyset(&pending_set)) {
- return -1;
- }
- /*
- * sigpending returns the mask of signals that are _both_
- * blocked for the thread _and_ pending for either the thread or
- * the entire process.
- */
- if (sigpending(&pending_set)) {
- return -1;
- }
- sigpipe_was_pending = sigismember(&pending_set, SIGPIPE);
- /*
- * If sigpipe was pending, it means it was already blocked, so
- * no need to block it.
- */
- if (!sigpipe_was_pending) {
- if (sigemptyset(&sigpipe_set)) {
- return -1;
- }
- if (sigaddset(&sigpipe_set, SIGPIPE)) {
- return -1;
- }
- if (pthread_sigmask(SIG_BLOCK, &sigpipe_set, &old_set)) {
- return -1;
- }
- }
-
- /* Send and save errno. */
- sent = send(fd, buffer, size, 0);
- saved_err = errno;
-
- if (sent == -1 && errno == EPIPE && !sigpipe_was_pending) {
- struct timespec timeout = { 0, 0 };
- int ret;
-
- do {
- ret = sigtimedwait(&sigpipe_set, NULL,
- &timeout);
- } while (ret == -1 && errno == EINTR);
- }
- if (!sigpipe_was_pending) {
- if (pthread_sigmask(SIG_SETMASK, &old_set, NULL)) {
- return -1;
- }
- }
- /* Restore send() errno */
- errno = saved_err;
-
- return sent;
-}
-#endif
-
-#endif /* _BABELTRACE_COMPAT_SEND_H */
--- /dev/null
+#ifndef _BABELTRACE_COMPAT_STDIO_H
+#define _BABELTRACE_COMPAT_STDIO_H
+
+/*
+ * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <errno.h>
+#include <assert.h>
+
+#define BT_GETLINE_MINBUFLEN 64
+
+static inline
+char * _bt_getline_bufalloc(char **lineptr, size_t *n, size_t linelen)
+{
+ size_t buflen = *n;
+ char *buf = *lineptr;
+
+ if (buflen >= linelen && buf != NULL) {
+ return buf;
+ }
+ if (buf == NULL) {
+ buflen = BT_GETLINE_MINBUFLEN;
+ } else {
+ buflen = buflen << 1;
+ if (buflen < BT_GETLINE_MINBUFLEN) {
+ buflen = BT_GETLINE_MINBUFLEN;
+ }
+ }
+ /* Check below not strictly needed, extra safety. */
+ if (buflen < linelen) {
+ buflen = linelen;
+ }
+ buf = realloc(buf, buflen);
+ if (!buf) {
+ errno = ENOMEM;
+ return NULL;
+ }
+ *n = buflen;
+ *lineptr = buf;
+ return buf;
+}
+
+/*
+ * Returns line length (including possible final \n, excluding final
+ * \0). On end of file, returns -1 with nonzero feof(stream) and errno
+ * set to 0. On error, returns -1 with errno set.
+ *
+ * This interface is similar to the getline(3) man page part of the
+ * Linux man-pages project, release 3.74. One major difference from the
+ * Open Group POSIX specification is that this implementation does not
+ * necessarily set the ferror() flag on error (because it is internal to
+ * libc).
+ */
+static inline
+ssize_t bt_getline(char **lineptr, size_t *n, FILE *stream)
+{
+ size_t linelen = 0;
+ char *buf;
+ int found_eof = 0;
+
+ if (lineptr == NULL || n == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+ for (;;) {
+ char c;
+ int ret;
+
+ ret = fgetc(stream);
+ if (ret == EOF) {
+ if (ferror(stream)) {
+ /* ferror() is set, errno set by fgetc(). */
+ return -1;
+ }
+ assert(feof(stream));
+ found_eof = 1;
+ break;
+ }
+ c = (char) ret;
+ if (linelen == SSIZE_MAX) {
+ errno = EOVERFLOW;
+ return -1;
+ }
+ buf = _bt_getline_bufalloc(lineptr, n, ++linelen);
+ if (!buf) {
+ return -1;
+ }
+ buf[linelen - 1] = c;
+ if (c == '\n') {
+ break;
+ }
+ }
+ if (!linelen && found_eof) {
+ /* feof() is set. */
+ errno = 0;
+ return -1;
+ }
+ buf = _bt_getline_bufalloc(lineptr, n, ++linelen);
+ if (!buf) {
+ return -1;
+ }
+ buf[linelen - 1] = '\0';
+ return linelen - 1; /* Count don't include final \0. */
+}
+
+#endif /* _BABELTRACE_COMPAT_STDIO_H */
+++ /dev/null
-#ifndef _BABELTRACE_COMPAT_STDIO_H
-#define _BABELTRACE_COMPAT_STDIO_H
-
-/*
- * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <stdio.h>
-#include <errno.h>
-#include <assert.h>
-
-#define BT_GETLINE_MINBUFLEN 64
-
-static inline
-char * _bt_getline_bufalloc(char **lineptr, size_t *n, size_t linelen)
-{
- size_t buflen = *n;
- char *buf = *lineptr;
-
- if (buflen >= linelen && buf != NULL) {
- return buf;
- }
- if (buf == NULL) {
- buflen = BT_GETLINE_MINBUFLEN;
- } else {
- buflen = buflen << 1;
- if (buflen < BT_GETLINE_MINBUFLEN) {
- buflen = BT_GETLINE_MINBUFLEN;
- }
- }
- /* Check below not strictly needed, extra safety. */
- if (buflen < linelen) {
- buflen = linelen;
- }
- buf = realloc(buf, buflen);
- if (!buf) {
- errno = ENOMEM;
- return NULL;
- }
- *n = buflen;
- *lineptr = buf;
- return buf;
-}
-
-/*
- * Returns line length (including possible final \n, excluding final
- * \0). On end of file, returns -1 with nonzero feof(stream) and errno
- * set to 0. On error, returns -1 with errno set.
- *
- * This interface is similar to the getline(3) man page part of the
- * Linux man-pages project, release 3.74. One major difference from the
- * Open Group POSIX specification is that this implementation does not
- * necessarily set the ferror() flag on error (because it is internal to
- * libc).
- */
-static inline
-ssize_t bt_getline(char **lineptr, size_t *n, FILE *stream)
-{
- size_t linelen = 0;
- char *buf;
- int found_eof = 0;
-
- if (lineptr == NULL || n == NULL) {
- errno = EINVAL;
- return -1;
- }
- for (;;) {
- char c;
- int ret;
-
- ret = fgetc(stream);
- if (ret == EOF) {
- if (ferror(stream)) {
- /* ferror() is set, errno set by fgetc(). */
- return -1;
- }
- assert(feof(stream));
- found_eof = 1;
- break;
- }
- c = (char) ret;
- if (linelen == SSIZE_MAX) {
- errno = EOVERFLOW;
- return -1;
- }
- buf = _bt_getline_bufalloc(lineptr, n, ++linelen);
- if (!buf) {
- return -1;
- }
- buf[linelen - 1] = c;
- if (c == '\n') {
- break;
- }
- }
- if (!linelen && found_eof) {
- /* feof() is set. */
- errno = 0;
- return -1;
- }
- buf = _bt_getline_bufalloc(lineptr, n, ++linelen);
- if (!buf) {
- return -1;
- }
- buf[linelen - 1] = '\0';
- return linelen - 1; /* Count don't include final \0. */
-}
-
-#endif /* _BABELTRACE_COMPAT_STDIO_H */
--- /dev/null
+#ifndef _BABELTRACE_COMPAT_STDLIB_H
+#define _BABELTRACE_COMPAT_STDLIB_H
+
+/*
+ * babeltrace/compat/stdlib.h
+ *
+ * Copyright (C) 2015 Michael Jeanson <mjeanson@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * This compat wrapper can be removed and replaced by g_mkdtemp() when we bump
+ * the requirement on glib to version 2.30.
+ */
+
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <glib.h>
+
+#ifdef HAVE_MKDTEMP
+
+static inline
+char *bt_mkdtemp(char *template)
+{
+ return mkdtemp(template);
+}
+
+#elif GLIB_CHECK_VERSION(2,30,0)
+
+#include <glib/gstdio.h>
+static inline
+char *bt_mkdtemp(char *template)
+{
+ return g_mkdtemp(template);
+}
+
+#else
+
+static inline
+char *bt_mkdtemp(char *template)
+{
+ char *ret;
+
+ ret = mktemp(template);
+ if (!ret) {
+ goto end;
+ }
+
+ if(mkdir(template, 0700)) {
+ ret = NULL;
+ goto end;
+ }
+
+ ret = template;
+end:
+ return ret;
+}
+
+#endif
+
+#endif /* _BABELTRACE_COMPAT_STDLIB_H */
+++ /dev/null
-#ifndef _BABELTRACE_COMPAT_STDLIB_H
-#define _BABELTRACE_COMPAT_STDLIB_H
-
-/*
- * babeltrace/compat/stdlib.h
- *
- * Copyright (C) 2015 Michael Jeanson <mjeanson@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-/*
- * This compat wrapper can be removed and replaced by g_mkdtemp() when we bump
- * the requirement on glib to version 2.30.
- */
-
-#include <stdlib.h>
-#include <sys/stat.h>
-#include <glib.h>
-
-#ifdef HAVE_MKDTEMP
-
-static inline
-char *bt_mkdtemp(char *template)
-{
- return mkdtemp(template);
-}
-
-#elif GLIB_CHECK_VERSION(2,30,0)
-
-#include <glib/gstdio.h>
-static inline
-char *bt_mkdtemp(char *template)
-{
- return g_mkdtemp(template);
-}
-
-#else
-
-static inline
-char *bt_mkdtemp(char *template)
-{
- char *ret;
-
- ret = mktemp(template);
- if (!ret) {
- goto end;
- }
-
- if(mkdir(template, 0700)) {
- ret = NULL;
- goto end;
- }
-
- ret = template;
-end:
- return ret;
-}
-
-#endif
-
-#endif /* _BABELTRACE_COMPAT_STDLIB_H */
--- /dev/null
+#ifndef _BABELTRACE_COMPAT_STRING_H
+#define _BABELTRACE_COMPAT_STRING_H
+
+/*
+ * Copyright (C) 2013 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <string.h>
+#include <stdlib.h>
+
+#if !defined(__GLIBC__) || ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !defined(_GNU_SOURCE))
+
+/* XSI-compliant strerror_r */
+static inline
+int bt_strerror_r(int errnum, char *buf, size_t buflen)
+{
+ return strerror_r(errnum, buf, buflen);
+}
+
+#else
+
+/* GNU-compliant strerror_r */
+static inline
+int bt_strerror_r(int errnum, char *buf, size_t buflen)
+{
+ char *retbuf;
+
+ retbuf = strerror_r(errnum, buf, buflen);
+ if (retbuf != buf)
+ strncpy(buf, retbuf, buflen);
+ buf[buflen - 1] = '\0';
+ return 0;
+}
+
+#endif
+
+#ifdef HAVE_STRNLEN
+static inline
+size_t bt_strnlen(const char *str, size_t max)
+{
+ return strnlen(str, max);
+}
+#else
+static inline
+size_t bt_strnlen(const char *str, size_t max)
+{
+ size_t ret;
+ const char *end;
+
+ end = memchr(str, 0, max);
+
+ if (end) {
+ ret = (size_t) (end - str);
+ } else {
+ ret = max;
+ }
+
+ return ret;
+}
+#endif /* HAVE_STRNLEN */
+
+#ifdef HAVE_STRNDUP
+static inline
+char *bt_strndup(const char *s, size_t n)
+{
+ return strndup(s, n);
+}
+#else
+static inline
+char *bt_strndup(const char *s, size_t n)
+{
+ char *ret;
+ size_t navail;
+
+ if (!s) {
+ ret = NULL;
+ goto end;
+ }
+
+ /* min() */
+ navail = strlen(s) + 1;
+ if ((n + 1) < navail) {
+ navail = n + 1;
+ }
+
+ ret = malloc(navail);
+ if (!ret) {
+ goto end;
+ }
+
+ memcpy(ret, s, navail);
+ ret[navail - 1] = '\0';
+end:
+ return ret;
+}
+#endif /* HAVE_STRNDUP */
+
+#endif /* _BABELTRACE_COMPAT_STRING_H */
+++ /dev/null
-#ifndef _BABELTRACE_COMPAT_STRING_H
-#define _BABELTRACE_COMPAT_STRING_H
-
-/*
- * Copyright (C) 2013 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <string.h>
-#include <stdlib.h>
-
-#if !defined(__GLIBC__) || ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !defined(_GNU_SOURCE))
-
-/* XSI-compliant strerror_r */
-static inline
-int bt_strerror_r(int errnum, char *buf, size_t buflen)
-{
- return strerror_r(errnum, buf, buflen);
-}
-
-#else
-
-/* GNU-compliant strerror_r */
-static inline
-int bt_strerror_r(int errnum, char *buf, size_t buflen)
-{
- char *retbuf;
-
- retbuf = strerror_r(errnum, buf, buflen);
- if (retbuf != buf)
- strncpy(buf, retbuf, buflen);
- buf[buflen - 1] = '\0';
- return 0;
-}
-
-#endif
-
-#ifdef HAVE_STRNLEN
-static inline
-size_t bt_strnlen(const char *str, size_t max)
-{
- return strnlen(str, max);
-}
-#else
-static inline
-size_t bt_strnlen(const char *str, size_t max)
-{
- size_t ret;
- const char *end;
-
- end = memchr(str, 0, max);
-
- if (end) {
- ret = (size_t) (end - str);
- } else {
- ret = max;
- }
-
- return ret;
-}
-#endif /* HAVE_STRNLEN */
-
-#ifdef HAVE_STRNDUP
-static inline
-char *bt_strndup(const char *s, size_t n)
-{
- return strndup(s, n);
-}
-#else
-static inline
-char *bt_strndup(const char *s, size_t n)
-{
- char *ret;
- size_t navail;
-
- if (!s) {
- ret = NULL;
- goto end;
- }
-
- /* min() */
- navail = strlen(s) + 1;
- if ((n + 1) < navail) {
- navail = n + 1;
- }
-
- ret = malloc(navail);
- if (!ret) {
- goto end;
- }
-
- memcpy(ret, s, navail);
- ret[navail - 1] = '\0';
-end:
- return ret;
-}
-#endif /* HAVE_STRNDUP */
-
-#endif /* _BABELTRACE_COMPAT_STRING_H */
--- /dev/null
+#ifndef _BABELTRACE_UTC_H
+#define _BABELTRACE_UTC_H
+
+/*
+ * Copyright (C) 2011-2013 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <time.h>
+
+/* If set, use GNU or BSD timegm(3) */
+#if defined(_BSD_SOURCE) || defined(_SVID_SOURCE)
+
+static inline
+time_t bt_timegm(struct tm *tm)
+{
+ return timegm(tm);
+}
+
+#else
+
+#include <string.h>
+#include <stdlib.h>
+
+/*
+ * Note: Below implementation of timegm() is not thread safe
+ * as it changes the environment
+ * variable TZ. It is OK as long as it is kept in self-contained program,
+ * but should not be used within thread-safe library code.
+ */
+
+static inline
+time_t bt_timegm(struct tm *tm)
+{
+ time_t ret;
+ char *tz;
+
+ tz = getenv("TZ");
+ /*
+ * Make a temporary copy, as the environment variable will be
+ * modified.
+ */
+ if (tz) {
+ tz = strdup(tz);
+ if (!tz) {
+ /*
+ * Memory allocation error.
+ */
+ return (time_t) -1;
+ }
+ }
+
+ /* Temporarily setting TZ to 1 for UTC */
+ setenv("TZ", "", 1);
+ tzset();
+ ret = mktime(tm);
+ if (tz) {
+ setenv("TZ", tz, 1);
+ free(tz);
+ } else {
+ unsetenv("TZ");
+ }
+ tzset();
+ return ret;
+}
+
+#endif
+
+#endif /* _BABELTRACE_UTC_H */
+++ /dev/null
-#ifndef _BABELTRACE_UTC_H
-#define _BABELTRACE_UTC_H
-
-/*
- * Copyright (C) 2011-2013 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <time.h>
-
-/* If set, use GNU or BSD timegm(3) */
-#if defined(_BSD_SOURCE) || defined(_SVID_SOURCE)
-
-static inline
-time_t bt_timegm(struct tm *tm)
-{
- return timegm(tm);
-}
-
-#else
-
-#include <string.h>
-#include <stdlib.h>
-
-/*
- * Note: Below implementation of timegm() is not thread safe
- * as it changes the environment
- * variable TZ. It is OK as long as it is kept in self-contained program,
- * but should not be used within thread-safe library code.
- */
-
-static inline
-time_t bt_timegm(struct tm *tm)
-{
- time_t ret;
- char *tz;
-
- tz = getenv("TZ");
- /*
- * Make a temporary copy, as the environment variable will be
- * modified.
- */
- if (tz) {
- tz = strdup(tz);
- if (!tz) {
- /*
- * Memory allocation error.
- */
- return (time_t) -1;
- }
- }
-
- /* Temporarily setting TZ to 1 for UTC */
- setenv("TZ", "", 1);
- tzset();
- ret = mktime(tm);
- if (tz) {
- setenv("TZ", tz, 1);
- free(tz);
- } else {
- unsetenv("TZ");
- }
- tzset();
- return ret;
-}
-
-#endif
-
-#endif /* _BABELTRACE_UTC_H */
--- /dev/null
+#ifndef _BABELTRACE_COMPAT_UUID_H
+#define _BABELTRACE_COMPAT_UUID_H
+
+/*
+ * babeltrace/compat/uuid.h
+ *
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/* Includes final \0. */
+#define BABELTRACE_UUID_STR_LEN 37
+#define BABELTRACE_UUID_LEN 16
+
+#ifdef BABELTRACE_HAVE_LIBUUID
+#include <uuid/uuid.h>
+
+static inline
+int bt_uuid_generate(unsigned char *uuid_out)
+{
+ uuid_generate(uuid_out);
+ return 0;
+}
+
+/* Sun's libuuid lacks const qualifiers */
+#if defined(__sun__)
+static inline
+int bt_uuid_unparse(const unsigned char *uuid_in, char *str_out)
+{
+ uuid_unparse((unsigned char *) uuid_in, str_out);
+ return 0;
+}
+
+static inline
+int bt_uuid_parse(const char *str_in, unsigned char *uuid_out)
+{
+ return uuid_parse((char *) str_in, uuid_out);
+}
+
+static inline
+int bt_uuid_compare(const unsigned char *uuid_a,
+ const unsigned char *uuid_b)
+{
+ return uuid_compare((unsigned char *) uuid_a,
+ (unsigned char *) uuid_b);
+}
+#else
+static inline
+int bt_uuid_unparse(const unsigned char *uuid_in, char *str_out)
+{
+ uuid_unparse(uuid_in, str_out);
+ return 0;
+}
+
+static inline
+int bt_uuid_parse(const char *str_in, unsigned char *uuid_out)
+{
+ return uuid_parse(str_in, uuid_out);
+}
+
+static inline
+int bt_uuid_compare(const unsigned char *uuid_a,
+ const unsigned char *uuid_b)
+{
+ return uuid_compare(uuid_a, uuid_b);
+}
+#endif
+
+#elif defined(BABELTRACE_HAVE_LIBC_UUID)
+#include <uuid.h>
+#include <stdint.h>
+#include <string.h>
+#include <stdlib.h>
+
+static inline
+int bt_uuid_generate(unsigned char *uuid_out)
+{
+ uint32_t status;
+
+ uuid_create((uuid_t *) uuid_out, &status);
+ if (status == uuid_s_ok)
+ return 0;
+ else
+ return -1;
+}
+
+static inline
+int bt_uuid_unparse(const unsigned char *uuid_in, char *str_out)
+{
+ uint32_t status;
+ char *alloc_str;
+ int ret;
+
+ uuid_to_string((uuid_t *) uuid_in, &alloc_str, &status);
+ if (status == uuid_s_ok) {
+ strcpy(str_out, alloc_str);
+ ret = 0;
+ } else {
+ ret = -1;
+ }
+ free(alloc_str);
+ return ret;
+}
+
+static inline
+int bt_uuid_parse(const char *str_in, unsigned char *uuid_out)
+{
+ uint32_t status;
+
+ uuid_from_string(str_in, (uuid_t *) uuid_out, &status);
+ if (status == uuid_s_ok)
+ return 0;
+ else
+ return -1;
+}
+
+static inline
+int bt_uuid_compare(const unsigned char *uuid_a,
+ const unsigned char *uuid_b)
+{
+ uint32_t status;
+
+ uuid_compare((uuid_t *) uuid_a, (uuid_t *) uuid_b, &status);
+ if (status == uuid_s_ok)
+ return 0;
+ else
+ return -1;
+}
+
+#elif defined(__MINGW32__)
+
+int bt_uuid_generate(unsigned char *uuid_out);
+int bt_uuid_unparse(const unsigned char *uuid_in, char *str_out);
+int bt_uuid_parse(const char *str_in, unsigned char *uuid_out);
+int bt_uuid_compare(const unsigned char *uuid_a,
+ const unsigned char *uuid_b);
+
+#else
+#error "Babeltrace needs to have a UUID generator configured."
+#endif
+
+#endif /* _BABELTRACE_COMPAT_UUID_H */
+++ /dev/null
-#ifndef _BABELTRACE_COMPAT_UUID_H
-#define _BABELTRACE_COMPAT_UUID_H
-
-/*
- * babeltrace/compat/uuid.h
- *
- * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-/* Includes final \0. */
-#define BABELTRACE_UUID_STR_LEN 37
-#define BABELTRACE_UUID_LEN 16
-
-#ifdef BABELTRACE_HAVE_LIBUUID
-#include <uuid/uuid.h>
-
-static inline
-int bt_uuid_generate(unsigned char *uuid_out)
-{
- uuid_generate(uuid_out);
- return 0;
-}
-
-/* Sun's libuuid lacks const qualifiers */
-#if defined(__sun__)
-static inline
-int bt_uuid_unparse(const unsigned char *uuid_in, char *str_out)
-{
- uuid_unparse((unsigned char *) uuid_in, str_out);
- return 0;
-}
-
-static inline
-int bt_uuid_parse(const char *str_in, unsigned char *uuid_out)
-{
- return uuid_parse((char *) str_in, uuid_out);
-}
-
-static inline
-int bt_uuid_compare(const unsigned char *uuid_a,
- const unsigned char *uuid_b)
-{
- return uuid_compare((unsigned char *) uuid_a,
- (unsigned char *) uuid_b);
-}
-#else
-static inline
-int bt_uuid_unparse(const unsigned char *uuid_in, char *str_out)
-{
- uuid_unparse(uuid_in, str_out);
- return 0;
-}
-
-static inline
-int bt_uuid_parse(const char *str_in, unsigned char *uuid_out)
-{
- return uuid_parse(str_in, uuid_out);
-}
-
-static inline
-int bt_uuid_compare(const unsigned char *uuid_a,
- const unsigned char *uuid_b)
-{
- return uuid_compare(uuid_a, uuid_b);
-}
-#endif
-
-#elif defined(BABELTRACE_HAVE_LIBC_UUID)
-#include <uuid.h>
-#include <stdint.h>
-#include <string.h>
-#include <stdlib.h>
-
-static inline
-int bt_uuid_generate(unsigned char *uuid_out)
-{
- uint32_t status;
-
- uuid_create((uuid_t *) uuid_out, &status);
- if (status == uuid_s_ok)
- return 0;
- else
- return -1;
-}
-
-static inline
-int bt_uuid_unparse(const unsigned char *uuid_in, char *str_out)
-{
- uint32_t status;
- char *alloc_str;
- int ret;
-
- uuid_to_string((uuid_t *) uuid_in, &alloc_str, &status);
- if (status == uuid_s_ok) {
- strcpy(str_out, alloc_str);
- ret = 0;
- } else {
- ret = -1;
- }
- free(alloc_str);
- return ret;
-}
-
-static inline
-int bt_uuid_parse(const char *str_in, unsigned char *uuid_out)
-{
- uint32_t status;
-
- uuid_from_string(str_in, (uuid_t *) uuid_out, &status);
- if (status == uuid_s_ok)
- return 0;
- else
- return -1;
-}
-
-static inline
-int bt_uuid_compare(const unsigned char *uuid_a,
- const unsigned char *uuid_b)
-{
- uint32_t status;
-
- uuid_compare((uuid_t *) uuid_a, (uuid_t *) uuid_b, &status);
- if (status == uuid_s_ok)
- return 0;
- else
- return -1;
-}
-
-#elif defined(__MINGW32__)
-
-int bt_uuid_generate(unsigned char *uuid_out);
-int bt_uuid_unparse(const unsigned char *uuid_in, char *str_out);
-int bt_uuid_parse(const char *str_in, unsigned char *uuid_out);
-int bt_uuid_compare(const unsigned char *uuid_a,
- const unsigned char *uuid_b);
-
-#else
-#error "Babeltrace needs to have a UUID generator configured."
-#endif
-
-#endif /* _BABELTRACE_COMPAT_UUID_H */
--- /dev/null
+#ifndef _BABELTRACE_COMPILER_H
+#define _BABELTRACE_COMPILER_H
+
+/*
+ * compiler.h
+ *
+ * Copyright 2010 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <stddef.h> /* for offsetof */
+
+#define MAYBE_BUILD_BUG_ON(cond) ((void)sizeof(char[1 - 2 * !!(cond)]))
+
+#ifndef container_of
+#define container_of(ptr, type, member) \
+ ({ \
+ const typeof(((type *)NULL)->member) * __ptr = (ptr); \
+ (type *)((char *)__ptr - offsetof(type, member)); \
+ })
+#endif
+
+#define BT_ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
+
+#endif /* _BABELTRACE_COMPILER_H */
+++ /dev/null
-#ifndef _BABELTRACE_COMPILER_H
-#define _BABELTRACE_COMPILER_H
-
-/*
- * compiler.h
- *
- * Copyright 2010 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <stddef.h> /* for offsetof */
-
-#define MAYBE_BUILD_BUG_ON(cond) ((void)sizeof(char[1 - 2 * !!(cond)]))
-
-#ifndef container_of
-#define container_of(ptr, type, member) \
- ({ \
- const typeof(((type *)NULL)->member) * __ptr = (ptr); \
- (type *)((char *)__ptr - offsetof(type, member)); \
- })
-#endif
-
-#define BT_ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
-
-#endif /* _BABELTRACE_COMPILER_H */
#include <babeltrace/object-internal.h>
#include <babeltrace/babeltrace-internal.h>
#include <glib.h>
-#include <babeltrace/compat/uuid.h>
+#include <babeltrace/compat/uuid-internal.h>
struct bt_ctf_clock_class {
struct bt_object base;
#include <babeltrace/object-internal.h>
#include <babeltrace/babeltrace-internal.h>
#include <glib.h>
-#include <babeltrace/compat/uuid.h>
+#include <babeltrace/compat/uuid-internal.h>
struct bt_ctf_clock {
struct bt_object base;
#include <babeltrace/ctf-ir/field-types.h>
#include <babeltrace/ctf-ir/fields.h>
#include <babeltrace/ctf-ir/fields-internal.h>
-#include <babeltrace/align.h>
-#include <babeltrace/mmap-align.h>
+#include <babeltrace/align-internal.h>
+#include <babeltrace/mmap-align-internal.h>
struct bt_ctf_stream_pos {
int fd;
--- /dev/null
+#ifndef _BABELTRACE_ENDIAN_H
+#define _BABELTRACE_ENDIAN_H
+
+/*
+ * babeltrace/endian.h
+ *
+ * Copyright 2012 (c) - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * endian.h compatibility layer.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifdef __FreeBSD__
+#include <machine/endian.h>
+
+#elif defined(__sun__)
+#include <sys/byteorder.h>
+
+#ifndef __BIG_ENDIAN
+#define __BIG_ENDIAN 4321
+#endif
+#ifndef __LITTLE_ENDIAN
+#define __LITTLE_ENDIAN 1234
+#endif
+
+#ifdef _LITTLE_ENDIAN
+#define __BYTE_ORDER __LITTLE_ENDIAN
+#endif
+
+#ifdef _BIG_ENDIAN
+#define __BYTE_ORDER __BIG_ENDIAN
+#endif
+
+#define LITTLE_ENDIAN __LITTLE_ENDIAN
+#define BIG_ENDIAN __BIG_ENDIAN
+#define BYTE_ORDER __BYTE_ORDER
+
+#define betoh16(x) BE_16(x)
+#define letoh16(x) LE_16(x)
+#define betoh32(x) BE_32(x)
+#define letoh32(x) LE_32(x)
+#define betoh64(x) BE_64(x)
+#define letoh64(x) LE_64(x)
+#define htobe16(x) BE_16(x)
+#define be16toh(x) BE_16(x)
+#define htobe32(x) BE_32(x)
+#define be32toh(x) BE_32(x)
+#define htobe64(x) BE_64(x)
+#define be64toh(x) BE_64(x)
+
+#elif defined(__MINGW32__)
+#ifndef __BIG_ENDIAN
+#define __BIG_ENDIAN 4321
+#endif
+#ifndef __LITTLE_ENDIAN
+#define __LITTLE_ENDIAN 1234
+#endif
+
+#ifndef __BYTE_ORDER
+#define __BYTE_ORDER __LITTLE_ENDIAN
+#endif
+
+#define LITTLE_ENDIAN __LITTLE_ENDIAN
+#define BIG_ENDIAN __BIG_ENDIAN
+#define PDP_ENDIAN __PDP_ENDIAN
+#define BYTE_ORDER __BYTE_ORDER
+
+#elif defined(__APPLE__)
+# include <machine/endian.h>
+# include <libkern/OSByteOrder.h>
+
+# if BYTE_ORDER == LITTLE_ENDIAN
+# define htobe16(x) OSSwapConstInt16(x)
+# define htole16(x) (x)
+# define be16toh(x) OSSwapConstInt16(x)
+# define le16toh(x) (x)
+
+# define htobe32(x) OSSwapConstInt32(x)
+# define htole32(x) (x)
+# define be32toh(x) OSSwapConstInt32(x)
+# define le32toh(x) (x)
+
+# define htobe64(x) OSSwapConstInt64(x)
+# define htole64(x) (x)
+# define be64toh(x) OSSwapConstInt64(x)
+# define le64toh(x) (x)
+
+# else /* BYTE_ORDER == LITTLE_ENDIAN */
+# define htobe16(x) (x)
+# define htole16(x) OSSwapConstInt16(x)
+# define be16toh(x) (x)
+# define le16toh(x) OSSwapConstInt16(x)
+
+# define htobe32(x) (x)
+# define htole32(x) OSSwapConstInt32(x)
+# define be32toh(x) (x)
+# define le32toh(x) OSSwapConstInt32(x)
+
+# define htobe64(x) (x)
+# define htole64(x) OSSwapConstInt64(x)
+# define be64toh(x) (x)
+# define le64toh(x) OSSwapConstInt64(x)
+# endif
+
+#else
+#include <endian.h>
+
+/*
+ * htobe/betoh are not defined for glibc < 2.9, so add them explicitly
+ * if they are missing.
+ */
+# ifdef __USE_BSD
+/* Conversion interfaces. */
+# include <byteswap.h>
+
+# if __BYTE_ORDER == __LITTLE_ENDIAN
+# ifndef htobe16
+# define htobe16(x) __bswap_16(x)
+# endif
+# ifndef htole16
+# define htole16(x) (x)
+# endif
+# ifndef be16toh
+# define be16toh(x) __bswap_16(x)
+# endif
+# ifndef le16toh
+# define le16toh(x) (x)
+# endif
+
+# ifndef htobe32
+# define htobe32(x) __bswap_32(x)
+# endif
+# ifndef htole32
+# define htole32(x) (x)
+# endif
+# ifndef be32toh
+# define be32toh(x) __bswap_32(x)
+# endif
+# ifndef le32toh
+# define le32toh(x) (x)
+# endif
+
+# ifndef htobe64
+# define htobe64(x) __bswap_64(x)
+# endif
+# ifndef htole64
+# define htole64(x) (x)
+# endif
+# ifndef be64toh
+# define be64toh(x) __bswap_64(x)
+# endif
+# ifndef le64toh
+# define le64toh(x) (x)
+# endif
+
+# else /* __BYTE_ORDER == __LITTLE_ENDIAN */
+# ifndef htobe16
+# define htobe16(x) (x)
+# endif
+# ifndef htole16
+# define htole16(x) __bswap_16(x)
+# endif
+# ifndef be16toh
+# define be16toh(x) (x)
+# endif
+# ifndef le16toh
+# define le16toh(x) __bswap_16(x)
+# endif
+
+# ifndef htobe32
+# define htobe32(x) (x)
+# endif
+# ifndef htole32
+# define htole32(x) __bswap_32(x)
+# endif
+# ifndef be32toh
+# define be32toh(x) (x)
+# endif
+# ifndef le32toh
+# define le32toh(x) __bswap_32(x)
+# endif
+
+# ifndef htobe64
+# define htobe64(x) (x)
+# endif
+# ifndef htole64
+# define htole64(x) __bswap_64(x)
+# endif
+# ifndef be64toh
+# define be64toh(x) (x)
+# endif
+# ifndef le64toh
+# define le64toh(x) __bswap_64(x)
+# endif
+
+# endif /* __BYTE_ORDER == __LITTLE_ENDIAN */
+# endif /* __USE_BSD */
+#endif /* else -- __FreeBSD__ */
+
+#ifndef FLOAT_WORD_ORDER
+#ifdef __FLOAT_WORD_ORDER
+#define FLOAT_WORD_ORDER __FLOAT_WORD_ORDER
+#else /* __FLOAT_WORD_ORDER */
+#define FLOAT_WORD_ORDER BYTE_ORDER
+#endif /* __FLOAT_WORD_ORDER */
+#endif /* FLOAT_WORD_ORDER */
+
+#if (BYTE_ORDER == BIG_ENDIAN)
+# define BT_CTF_MY_BYTE_ORDER BT_CTF_BYTE_ORDER_BIG_ENDIAN
+#else
+# define BT_CTF_MY_BYTE_ORDER BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
+#endif
+
+#endif /* _BABELTRACE_ENDIAN_H */
+++ /dev/null
-#ifndef _BABELTRACE_ENDIAN_H
-#define _BABELTRACE_ENDIAN_H
-
-/*
- * babeltrace/endian.h
- *
- * Copyright 2012 (c) - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * endian.h compatibility layer.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#ifdef __FreeBSD__
-#include <machine/endian.h>
-
-#elif defined(__sun__)
-#include <sys/byteorder.h>
-
-#ifndef __BIG_ENDIAN
-#define __BIG_ENDIAN 4321
-#endif
-#ifndef __LITTLE_ENDIAN
-#define __LITTLE_ENDIAN 1234
-#endif
-
-#ifdef _LITTLE_ENDIAN
-#define __BYTE_ORDER __LITTLE_ENDIAN
-#endif
-
-#ifdef _BIG_ENDIAN
-#define __BYTE_ORDER __BIG_ENDIAN
-#endif
-
-#define LITTLE_ENDIAN __LITTLE_ENDIAN
-#define BIG_ENDIAN __BIG_ENDIAN
-#define BYTE_ORDER __BYTE_ORDER
-
-#define betoh16(x) BE_16(x)
-#define letoh16(x) LE_16(x)
-#define betoh32(x) BE_32(x)
-#define letoh32(x) LE_32(x)
-#define betoh64(x) BE_64(x)
-#define letoh64(x) LE_64(x)
-#define htobe16(x) BE_16(x)
-#define be16toh(x) BE_16(x)
-#define htobe32(x) BE_32(x)
-#define be32toh(x) BE_32(x)
-#define htobe64(x) BE_64(x)
-#define be64toh(x) BE_64(x)
-
-#elif defined(__MINGW32__)
-#ifndef __BIG_ENDIAN
-#define __BIG_ENDIAN 4321
-#endif
-#ifndef __LITTLE_ENDIAN
-#define __LITTLE_ENDIAN 1234
-#endif
-
-#ifndef __BYTE_ORDER
-#define __BYTE_ORDER __LITTLE_ENDIAN
-#endif
-
-#define LITTLE_ENDIAN __LITTLE_ENDIAN
-#define BIG_ENDIAN __BIG_ENDIAN
-#define PDP_ENDIAN __PDP_ENDIAN
-#define BYTE_ORDER __BYTE_ORDER
-
-#elif defined(__APPLE__)
-# include <machine/endian.h>
-# include <libkern/OSByteOrder.h>
-
-# if BYTE_ORDER == LITTLE_ENDIAN
-# define htobe16(x) OSSwapConstInt16(x)
-# define htole16(x) (x)
-# define be16toh(x) OSSwapConstInt16(x)
-# define le16toh(x) (x)
-
-# define htobe32(x) OSSwapConstInt32(x)
-# define htole32(x) (x)
-# define be32toh(x) OSSwapConstInt32(x)
-# define le32toh(x) (x)
-
-# define htobe64(x) OSSwapConstInt64(x)
-# define htole64(x) (x)
-# define be64toh(x) OSSwapConstInt64(x)
-# define le64toh(x) (x)
-
-# else /* BYTE_ORDER == LITTLE_ENDIAN */
-# define htobe16(x) (x)
-# define htole16(x) OSSwapConstInt16(x)
-# define be16toh(x) (x)
-# define le16toh(x) OSSwapConstInt16(x)
-
-# define htobe32(x) (x)
-# define htole32(x) OSSwapConstInt32(x)
-# define be32toh(x) (x)
-# define le32toh(x) OSSwapConstInt32(x)
-
-# define htobe64(x) (x)
-# define htole64(x) OSSwapConstInt64(x)
-# define be64toh(x) (x)
-# define le64toh(x) OSSwapConstInt64(x)
-# endif
-
-#else
-#include <endian.h>
-
-/*
- * htobe/betoh are not defined for glibc < 2.9, so add them explicitly
- * if they are missing.
- */
-# ifdef __USE_BSD
-/* Conversion interfaces. */
-# include <byteswap.h>
-
-# if __BYTE_ORDER == __LITTLE_ENDIAN
-# ifndef htobe16
-# define htobe16(x) __bswap_16(x)
-# endif
-# ifndef htole16
-# define htole16(x) (x)
-# endif
-# ifndef be16toh
-# define be16toh(x) __bswap_16(x)
-# endif
-# ifndef le16toh
-# define le16toh(x) (x)
-# endif
-
-# ifndef htobe32
-# define htobe32(x) __bswap_32(x)
-# endif
-# ifndef htole32
-# define htole32(x) (x)
-# endif
-# ifndef be32toh
-# define be32toh(x) __bswap_32(x)
-# endif
-# ifndef le32toh
-# define le32toh(x) (x)
-# endif
-
-# ifndef htobe64
-# define htobe64(x) __bswap_64(x)
-# endif
-# ifndef htole64
-# define htole64(x) (x)
-# endif
-# ifndef be64toh
-# define be64toh(x) __bswap_64(x)
-# endif
-# ifndef le64toh
-# define le64toh(x) (x)
-# endif
-
-# else /* __BYTE_ORDER == __LITTLE_ENDIAN */
-# ifndef htobe16
-# define htobe16(x) (x)
-# endif
-# ifndef htole16
-# define htole16(x) __bswap_16(x)
-# endif
-# ifndef be16toh
-# define be16toh(x) (x)
-# endif
-# ifndef le16toh
-# define le16toh(x) __bswap_16(x)
-# endif
-
-# ifndef htobe32
-# define htobe32(x) (x)
-# endif
-# ifndef htole32
-# define htole32(x) __bswap_32(x)
-# endif
-# ifndef be32toh
-# define be32toh(x) (x)
-# endif
-# ifndef le32toh
-# define le32toh(x) __bswap_32(x)
-# endif
-
-# ifndef htobe64
-# define htobe64(x) (x)
-# endif
-# ifndef htole64
-# define htole64(x) __bswap_64(x)
-# endif
-# ifndef be64toh
-# define be64toh(x) (x)
-# endif
-# ifndef le64toh
-# define le64toh(x) __bswap_64(x)
-# endif
-
-# endif /* __BYTE_ORDER == __LITTLE_ENDIAN */
-# endif /* __USE_BSD */
-#endif /* else -- __FreeBSD__ */
-
-#ifndef FLOAT_WORD_ORDER
-#ifdef __FLOAT_WORD_ORDER
-#define FLOAT_WORD_ORDER __FLOAT_WORD_ORDER
-#else /* __FLOAT_WORD_ORDER */
-#define FLOAT_WORD_ORDER BYTE_ORDER
-#endif /* __FLOAT_WORD_ORDER */
-#endif /* FLOAT_WORD_ORDER */
-
-#if (BYTE_ORDER == BIG_ENDIAN)
-# define BT_CTF_MY_BYTE_ORDER BT_CTF_BYTE_ORDER_BIG_ENDIAN
-#else
-# define BT_CTF_MY_BYTE_ORDER BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
-#endif
-
-#endif /* _BABELTRACE_ENDIAN_H */
--- /dev/null
+/*
+ * Copyright (C) 2002 Free Software Foundation, Inc.
+ * This file is part of the GNU C Library.
+ * Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
+ *
+ * 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; only
+ * 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
+ */
+
+#ifndef _BT_LIST_H
+#define _BT_LIST_H 1
+
+/* The definitions of this file are adopted from those which can be
+ found in the Linux kernel headers to enable people familiar with
+ the latter find their way in these sources as well. */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Basic type for the double-link list. */
+struct bt_list_head
+{
+ struct bt_list_head *next;
+ struct bt_list_head *prev;
+};
+
+
+/* Define a variable with the head and tail of the list. */
+#define BT_LIST_HEAD(name) \
+ struct bt_list_head name = { &(name), &(name) }
+
+/* Initialize a new list head. */
+#define BT_INIT_LIST_HEAD(ptr) \
+ (ptr)->next = (ptr)->prev = (ptr)
+
+#define BT_LIST_HEAD_INIT(name) { .prev = &(name), .next = &(name) }
+
+/* Add new element at the head of the list. */
+static inline void
+bt_list_add (struct bt_list_head *newp, struct bt_list_head *head)
+{
+ head->next->prev = newp;
+ newp->next = head->next;
+ newp->prev = head;
+ head->next = newp;
+}
+
+
+/* Add new element at the tail of the list. */
+static inline void
+bt_list_add_tail (struct bt_list_head *newp, struct bt_list_head *head)
+{
+ head->prev->next = newp;
+ newp->next = head;
+ newp->prev = head->prev;
+ head->prev = newp;
+}
+
+
+/* Remove element from list. */
+static inline void
+__bt_list_del (struct bt_list_head *prev, struct bt_list_head *next)
+{
+ next->prev = prev;
+ prev->next = next;
+}
+
+/* Remove element from list. */
+static inline void
+bt_list_del (struct bt_list_head *elem)
+{
+ __bt_list_del (elem->prev, elem->next);
+}
+
+/* delete from list, add to another list as head */
+static inline void
+bt_list_move (struct bt_list_head *elem, struct bt_list_head *head)
+{
+ __bt_list_del (elem->prev, elem->next);
+ bt_list_add (elem, head);
+}
+
+/* replace an old entry.
+ */
+static inline void
+bt_list_replace(struct bt_list_head *old, struct bt_list_head *_new)
+{
+ _new->next = old->next;
+ _new->prev = old->prev;
+ _new->prev->next = _new;
+ _new->next->prev = _new;
+}
+
+/* Join two lists. */
+static inline void
+bt_list_splice (struct bt_list_head *add, struct bt_list_head *head)
+{
+ /* Do nothing if the list which gets added is empty. */
+ if (add != add->next)
+ {
+ add->next->prev = head;
+ add->prev->next = head->next;
+ head->next->prev = add->prev;
+ head->next = add->next;
+ }
+}
+
+
+/* Get typed element from list at a given position. */
+#define bt_list_entry(ptr, type, member) \
+ ((type *) ((char *) (ptr) - (unsigned long) (&((type *) 0)->member)))
+
+
+
+/* Iterate forward over the elements of the list. */
+#define bt_list_for_each(pos, head) \
+ for (pos = (head)->next; pos != (head); pos = pos->next)
+
+
+/* Iterate forward over the elements of the list. */
+#define bt_list_for_each_prev(pos, head) \
+ for (pos = (head)->prev; pos != (head); pos = pos->prev)
+
+
+/* Iterate backwards over the elements list. The list elements can be
+ removed from the list while doing this. */
+#define bt_list_for_each_prev_safe(pos, p, head) \
+ for (pos = (head)->prev, p = pos->prev; \
+ pos != (head); \
+ pos = p, p = pos->prev)
+
+#define bt_list_for_each_entry(pos, head, member) \
+ for (pos = bt_list_entry((head)->next, typeof(*pos), member); \
+ &pos->member != (head); \
+ pos = bt_list_entry(pos->member.next, typeof(*pos), member))
+
+#define bt_list_for_each_entry_reverse(pos, head, member) \
+ for (pos = bt_list_entry((head)->prev, typeof(*pos), member); \
+ &pos->member != (head); \
+ pos = bt_list_entry(pos->member.prev, typeof(*pos), member))
+
+#define bt_list_for_each_entry_safe(pos, p, head, member) \
+ for (pos = bt_list_entry((head)->next, typeof(*pos), member), \
+ p = bt_list_entry(pos->member.next,typeof(*pos), member); \
+ &pos->member != (head); \
+ pos = p, p = bt_list_entry(pos->member.next, typeof(*pos), member))
+
+static inline int bt_list_empty(struct bt_list_head *head)
+{
+ return head == head->next;
+}
+
+static inline void bt_list_replace_init(struct bt_list_head *old,
+ struct bt_list_head *_new)
+{
+ struct bt_list_head *head = old->next;
+ bt_list_del(old);
+ bt_list_add_tail(_new, head);
+ BT_INIT_LIST_HEAD(old);
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _BT_LIST_H */
+++ /dev/null
-/*
- * Copyright (C) 2002 Free Software Foundation, Inc.
- * This file is part of the GNU C Library.
- * Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
- *
- * 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; only
- * 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
- */
-
-#ifndef _BT_LIST_H
-#define _BT_LIST_H 1
-
-/* The definitions of this file are adopted from those which can be
- found in the Linux kernel headers to enable people familiar with
- the latter find their way in these sources as well. */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Basic type for the double-link list. */
-struct bt_list_head
-{
- struct bt_list_head *next;
- struct bt_list_head *prev;
-};
-
-
-/* Define a variable with the head and tail of the list. */
-#define BT_LIST_HEAD(name) \
- struct bt_list_head name = { &(name), &(name) }
-
-/* Initialize a new list head. */
-#define BT_INIT_LIST_HEAD(ptr) \
- (ptr)->next = (ptr)->prev = (ptr)
-
-#define BT_LIST_HEAD_INIT(name) { .prev = &(name), .next = &(name) }
-
-/* Add new element at the head of the list. */
-static inline void
-bt_list_add (struct bt_list_head *newp, struct bt_list_head *head)
-{
- head->next->prev = newp;
- newp->next = head->next;
- newp->prev = head;
- head->next = newp;
-}
-
-
-/* Add new element at the tail of the list. */
-static inline void
-bt_list_add_tail (struct bt_list_head *newp, struct bt_list_head *head)
-{
- head->prev->next = newp;
- newp->next = head;
- newp->prev = head->prev;
- head->prev = newp;
-}
-
-
-/* Remove element from list. */
-static inline void
-__bt_list_del (struct bt_list_head *prev, struct bt_list_head *next)
-{
- next->prev = prev;
- prev->next = next;
-}
-
-/* Remove element from list. */
-static inline void
-bt_list_del (struct bt_list_head *elem)
-{
- __bt_list_del (elem->prev, elem->next);
-}
-
-/* delete from list, add to another list as head */
-static inline void
-bt_list_move (struct bt_list_head *elem, struct bt_list_head *head)
-{
- __bt_list_del (elem->prev, elem->next);
- bt_list_add (elem, head);
-}
-
-/* replace an old entry.
- */
-static inline void
-bt_list_replace(struct bt_list_head *old, struct bt_list_head *_new)
-{
- _new->next = old->next;
- _new->prev = old->prev;
- _new->prev->next = _new;
- _new->next->prev = _new;
-}
-
-/* Join two lists. */
-static inline void
-bt_list_splice (struct bt_list_head *add, struct bt_list_head *head)
-{
- /* Do nothing if the list which gets added is empty. */
- if (add != add->next)
- {
- add->next->prev = head;
- add->prev->next = head->next;
- head->next->prev = add->prev;
- head->next = add->next;
- }
-}
-
-
-/* Get typed element from list at a given position. */
-#define bt_list_entry(ptr, type, member) \
- ((type *) ((char *) (ptr) - (unsigned long) (&((type *) 0)->member)))
-
-
-
-/* Iterate forward over the elements of the list. */
-#define bt_list_for_each(pos, head) \
- for (pos = (head)->next; pos != (head); pos = pos->next)
-
-
-/* Iterate forward over the elements of the list. */
-#define bt_list_for_each_prev(pos, head) \
- for (pos = (head)->prev; pos != (head); pos = pos->prev)
-
-
-/* Iterate backwards over the elements list. The list elements can be
- removed from the list while doing this. */
-#define bt_list_for_each_prev_safe(pos, p, head) \
- for (pos = (head)->prev, p = pos->prev; \
- pos != (head); \
- pos = p, p = pos->prev)
-
-#define bt_list_for_each_entry(pos, head, member) \
- for (pos = bt_list_entry((head)->next, typeof(*pos), member); \
- &pos->member != (head); \
- pos = bt_list_entry(pos->member.next, typeof(*pos), member))
-
-#define bt_list_for_each_entry_reverse(pos, head, member) \
- for (pos = bt_list_entry((head)->prev, typeof(*pos), member); \
- &pos->member != (head); \
- pos = bt_list_entry(pos->member.prev, typeof(*pos), member))
-
-#define bt_list_for_each_entry_safe(pos, p, head, member) \
- for (pos = bt_list_entry((head)->next, typeof(*pos), member), \
- p = bt_list_entry(pos->member.next,typeof(*pos), member); \
- &pos->member != (head); \
- pos = p, p = bt_list_entry(pos->member.next, typeof(*pos), member))
-
-static inline int bt_list_empty(struct bt_list_head *head)
-{
- return head == head->next;
-}
-
-static inline void bt_list_replace_init(struct bt_list_head *old,
- struct bt_list_head *_new)
-{
- struct bt_list_head *head = old->next;
- bt_list_del(old);
- bt_list_add_tail(_new, head);
- BT_INIT_LIST_HEAD(old);
-}
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _BT_LIST_H */
--- /dev/null
+#ifndef _BABELTRACE_MMAP_ALIGN_H
+#define _BABELTRACE_MMAP_ALIGN_H
+
+/*
+ * BabelTrace mmap-align.h - mmap alignment header
+ *
+ * Copyright 2010 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <babeltrace/align-internal.h>
+#include <stdlib.h>
+#include <sys/mman.h>
+
+/*
+ * This header implements a wrapper over mmap (mmap_align) that memory
+ * maps a file region that is not necessarily multiple of the page size.
+ * It returns a structure (instead of a pointer) that contains the mmap
+ * pointer (page-aligned) and a pointer to the offset requested within
+ * that page. Note: in the current implementation, the "addr" parameter
+ * cannot be forced, so we allocate at an address chosen by the OS.
+ */
+
+struct mmap_align {
+ void *page_aligned_addr; /* mmap address, aligned to floor */
+ size_t page_aligned_length; /* mmap length, containing range */
+
+ void *addr; /* virtual mmap address */
+ size_t length; /* virtual mmap length */
+};
+
+static inline
+struct mmap_align *mmap_align(size_t length, int prot,
+ int flags, int fd, off_t offset)
+{
+ struct mmap_align *mma;
+ off_t page_aligned_offset; /* mmap offset, aligned to floor */
+
+ mma = malloc(sizeof(*mma));
+ if (!mma)
+ return MAP_FAILED;
+ mma->length = length;
+ page_aligned_offset = ALIGN_FLOOR(offset, PAGE_SIZE);
+ /*
+ * Page aligned length needs to contain the requested range.
+ * E.g., for a small range that fits within a single page, we might
+ * require a 2 pages page_aligned_length if the range crosses a page
+ * boundary.
+ */
+ mma->page_aligned_length = ALIGN(length + offset - page_aligned_offset, PAGE_SIZE);
+ mma->page_aligned_addr = mmap(NULL, mma->page_aligned_length,
+ prot, flags, fd, page_aligned_offset);
+ if (mma->page_aligned_addr == (void *) -1UL) {
+ free(mma);
+ return MAP_FAILED;
+ }
+ mma->addr = mma->page_aligned_addr + (offset - page_aligned_offset);
+ return mma;
+}
+
+static inline
+int munmap_align(struct mmap_align *mma)
+{
+ void *page_aligned_addr;
+ size_t page_aligned_length;
+
+ page_aligned_addr = mma->page_aligned_addr;
+ page_aligned_length = mma->page_aligned_length;
+ free(mma);
+ return munmap(page_aligned_addr, page_aligned_length);
+}
+
+static inline
+void *mmap_align_addr(struct mmap_align *mma)
+{
+ return mma->addr;
+}
+
+/*
+ * Helper for special-cases, normally unused.
+ */
+static inline
+void mmap_align_set_addr(struct mmap_align *mma, void *addr)
+{
+ mma->addr = addr;
+}
+
+#endif /* _BABELTRACE_MMAP_ALIGN_H */
+++ /dev/null
-#ifndef _BABELTRACE_MMAP_ALIGN_H
-#define _BABELTRACE_MMAP_ALIGN_H
-
-/*
- * BabelTrace mmap-align.h - mmap alignment header
- *
- * Copyright 2010 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <babeltrace/align.h>
-#include <stdlib.h>
-#include <sys/mman.h>
-
-/*
- * This header implements a wrapper over mmap (mmap_align) that memory
- * maps a file region that is not necessarily multiple of the page size.
- * It returns a structure (instead of a pointer) that contains the mmap
- * pointer (page-aligned) and a pointer to the offset requested within
- * that page. Note: in the current implementation, the "addr" parameter
- * cannot be forced, so we allocate at an address chosen by the OS.
- */
-
-struct mmap_align {
- void *page_aligned_addr; /* mmap address, aligned to floor */
- size_t page_aligned_length; /* mmap length, containing range */
-
- void *addr; /* virtual mmap address */
- size_t length; /* virtual mmap length */
-};
-
-static inline
-struct mmap_align *mmap_align(size_t length, int prot,
- int flags, int fd, off_t offset)
-{
- struct mmap_align *mma;
- off_t page_aligned_offset; /* mmap offset, aligned to floor */
-
- mma = malloc(sizeof(*mma));
- if (!mma)
- return MAP_FAILED;
- mma->length = length;
- page_aligned_offset = ALIGN_FLOOR(offset, PAGE_SIZE);
- /*
- * Page aligned length needs to contain the requested range.
- * E.g., for a small range that fits within a single page, we might
- * require a 2 pages page_aligned_length if the range crosses a page
- * boundary.
- */
- mma->page_aligned_length = ALIGN(length + offset - page_aligned_offset, PAGE_SIZE);
- mma->page_aligned_addr = mmap(NULL, mma->page_aligned_length,
- prot, flags, fd, page_aligned_offset);
- if (mma->page_aligned_addr == (void *) -1UL) {
- free(mma);
- return MAP_FAILED;
- }
- mma->addr = mma->page_aligned_addr + (offset - page_aligned_offset);
- return mma;
-}
-
-static inline
-int munmap_align(struct mmap_align *mma)
-{
- void *page_aligned_addr;
- size_t page_aligned_length;
-
- page_aligned_addr = mma->page_aligned_addr;
- page_aligned_length = mma->page_aligned_length;
- free(mma);
- return munmap(page_aligned_addr, page_aligned_length);
-}
-
-static inline
-void *mmap_align_addr(struct mmap_align *mma)
-{
- return mma->addr;
-}
-
-/*
- * Helper for special-cases, normally unused.
- */
-static inline
-void mmap_align_set_addr(struct mmap_align *mma, void *addr)
-{
- mma->addr = addr;
-}
-
-#endif /* _BABELTRACE_MMAP_ALIGN_H */
--- /dev/null
+#ifndef _BABELTRACE_PRIO_HEAP_H
+#define _BABELTRACE_PRIO_HEAP_H
+
+/*
+ * prio_heap.h
+ *
+ * Static-sized priority heap containing pointers. Based on CLRS,
+ * chapter 6.
+ *
+ * Copyright 2011 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <unistd.h>
+#include <babeltrace/babeltrace-internal.h>
+
+struct ptr_heap {
+ size_t len, alloc_len;
+ void **ptrs;
+ int (*gt)(void *a, void *b);
+};
+
+#ifdef DEBUG_HEAP
+void check_heap(const struct ptr_heap *heap);
+#else
+static inline
+void check_heap(const struct ptr_heap *heap)
+{
+}
+#endif
+
+/**
+ * bt_heap_maximum - return the largest element in the heap
+ * @heap: the heap to be operated on
+ *
+ * Returns the largest element in the heap, without performing any modification
+ * to the heap structure. Returns NULL if the heap is empty.
+ */
+static inline void *bt_heap_maximum(const struct ptr_heap *heap)
+{
+ check_heap(heap);
+ return likely(heap->len) ? heap->ptrs[0] : NULL;
+}
+
+/**
+ * bt_heap_init - initialize the heap
+ * @heap: the heap to initialize
+ * @alloc_len: number of elements initially allocated
+ * @gt: function to compare the elements
+ *
+ * Returns -ENOMEM if out of memory.
+ */
+extern int bt_heap_init(struct ptr_heap *heap,
+ size_t alloc_len,
+ int gt(void *a, void *b));
+
+/**
+ * bt_heap_free - free the heap
+ * @heap: the heap to free
+ */
+extern void bt_heap_free(struct ptr_heap *heap);
+
+/**
+ * bt_heap_insert - insert an element into the heap
+ * @heap: the heap to be operated on
+ * @p: the element to add
+ *
+ * Insert an element into the heap.
+ *
+ * Returns -ENOMEM if out of memory.
+ */
+extern int bt_heap_insert(struct ptr_heap *heap, void *p);
+
+/**
+ * bt_heap_remove - remove the largest element from the heap
+ * @heap: the heap to be operated on
+ *
+ * Returns the largest element in the heap. It removes this element from the
+ * heap. Returns NULL if the heap is empty.
+ */
+extern void *bt_heap_remove(struct ptr_heap *heap);
+
+/**
+ * bt_heap_cherrypick - remove a given element from the heap
+ * @heap: the heap to be operated on
+ * @p: the element
+ *
+ * Remove the given element from the heap. Return the element if present, else
+ * return NULL. This algorithm has a complexity of O(n), which is higher than
+ * O(log(n)) provided by the rest of this API.
+ */
+extern void *bt_heap_cherrypick(struct ptr_heap *heap, void *p);
+
+/**
+ * bt_heap_replace_max - replace the the largest element from the heap
+ * @heap: the heap to be operated on
+ * @p: the pointer to be inserted as topmost element replacement
+ *
+ * Returns the largest element in the heap. It removes this element from the
+ * heap. The heap is rebalanced only once after the insertion. Returns NULL if
+ * the heap is empty.
+ *
+ * This is the equivalent of calling bt_heap_remove() and then bt_heap_insert(), but
+ * it only rebalances the heap once. It never allocates memory.
+ */
+extern void *bt_heap_replace_max(struct ptr_heap *heap, void *p);
+
+/**
+ * bt_heap_copy - copy a heap
+ * @dst: the destination heap (must be allocated)
+ * @src: the source heap
+ *
+ * Returns -ENOMEM if out of memory.
+ */
+extern int bt_heap_copy(struct ptr_heap *dst, struct ptr_heap *src);
+
+#endif /* _BABELTRACE_PRIO_HEAP_H */
+++ /dev/null
-#ifndef _BABELTRACE_PRIO_HEAP_H
-#define _BABELTRACE_PRIO_HEAP_H
-
-/*
- * prio_heap.h
- *
- * Static-sized priority heap containing pointers. Based on CLRS,
- * chapter 6.
- *
- * Copyright 2011 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <unistd.h>
-#include <babeltrace/babeltrace-internal.h>
-
-struct ptr_heap {
- size_t len, alloc_len;
- void **ptrs;
- int (*gt)(void *a, void *b);
-};
-
-#ifdef DEBUG_HEAP
-void check_heap(const struct ptr_heap *heap);
-#else
-static inline
-void check_heap(const struct ptr_heap *heap)
-{
-}
-#endif
-
-/**
- * bt_heap_maximum - return the largest element in the heap
- * @heap: the heap to be operated on
- *
- * Returns the largest element in the heap, without performing any modification
- * to the heap structure. Returns NULL if the heap is empty.
- */
-static inline void *bt_heap_maximum(const struct ptr_heap *heap)
-{
- check_heap(heap);
- return likely(heap->len) ? heap->ptrs[0] : NULL;
-}
-
-/**
- * bt_heap_init - initialize the heap
- * @heap: the heap to initialize
- * @alloc_len: number of elements initially allocated
- * @gt: function to compare the elements
- *
- * Returns -ENOMEM if out of memory.
- */
-extern int bt_heap_init(struct ptr_heap *heap,
- size_t alloc_len,
- int gt(void *a, void *b));
-
-/**
- * bt_heap_free - free the heap
- * @heap: the heap to free
- */
-extern void bt_heap_free(struct ptr_heap *heap);
-
-/**
- * bt_heap_insert - insert an element into the heap
- * @heap: the heap to be operated on
- * @p: the element to add
- *
- * Insert an element into the heap.
- *
- * Returns -ENOMEM if out of memory.
- */
-extern int bt_heap_insert(struct ptr_heap *heap, void *p);
-
-/**
- * bt_heap_remove - remove the largest element from the heap
- * @heap: the heap to be operated on
- *
- * Returns the largest element in the heap. It removes this element from the
- * heap. Returns NULL if the heap is empty.
- */
-extern void *bt_heap_remove(struct ptr_heap *heap);
-
-/**
- * bt_heap_cherrypick - remove a given element from the heap
- * @heap: the heap to be operated on
- * @p: the element
- *
- * Remove the given element from the heap. Return the element if present, else
- * return NULL. This algorithm has a complexity of O(n), which is higher than
- * O(log(n)) provided by the rest of this API.
- */
-extern void *bt_heap_cherrypick(struct ptr_heap *heap, void *p);
-
-/**
- * bt_heap_replace_max - replace the the largest element from the heap
- * @heap: the heap to be operated on
- * @p: the pointer to be inserted as topmost element replacement
- *
- * Returns the largest element in the heap. It removes this element from the
- * heap. The heap is rebalanced only once after the insertion. Returns NULL if
- * the heap is empty.
- *
- * This is the equivalent of calling bt_heap_remove() and then bt_heap_insert(), but
- * it only rebalances the heap once. It never allocates memory.
- */
-extern void *bt_heap_replace_max(struct ptr_heap *heap, void *p);
-
-/**
- * bt_heap_copy - copy a heap
- * @dst: the destination heap (must be allocated)
- * @src: the source heap
- *
- * Returns -ENOMEM if out of memory.
- */
-extern int bt_heap_copy(struct ptr_heap *dst, struct ptr_heap *src);
-
-#endif /* _BABELTRACE_PRIO_HEAP_H */
#include <babeltrace/ctf-ir/clock-class.h>
#include <babeltrace/ctf-ir/clock-class-internal.h>
#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/compiler.h>
+#include <babeltrace/compiler-internal.h>
#include <babeltrace/ref.h>
#include <glib.h>
* SOFTWARE.
*/
-#include <babeltrace/compiler.h>
+#include <babeltrace/compiler-internal.h>
#include <babeltrace/graph/component-class-internal.h>
#include <babeltrace/ref.h>
#include <stdbool.h>
#include <babeltrace/graph/notification-iterator-internal.h>
#include <babeltrace/graph/private-notification-iterator.h>
#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/compiler.h>
+#include <babeltrace/compiler-internal.h>
#include <babeltrace/ref.h>
static
#include <babeltrace/graph/graph-internal.h>
#include <babeltrace/graph/port-internal.h>
#include <babeltrace/object-internal.h>
-#include <babeltrace/compiler.h>
+#include <babeltrace/compiler-internal.h>
#include <glib.h>
static
* SOFTWARE.
*/
-#include <babeltrace/compiler.h>
+#include <babeltrace/compiler-internal.h>
#include <babeltrace/values.h>
#include <babeltrace/graph/component-filter-internal.h>
#include <babeltrace/graph/component-internal.h>
#include <babeltrace/graph/component-source.h>
#include <babeltrace/graph/component-filter.h>
#include <babeltrace/graph/port.h>
-#include <babeltrace/compiler.h>
+#include <babeltrace/compiler-internal.h>
#include <unistd.h>
#include <glib.h>
* SOFTWARE.
*/
-#include <babeltrace/compiler.h>
+#include <babeltrace/compiler-internal.h>
#include <babeltrace/ref.h>
#include <babeltrace/graph/component.h>
#include <babeltrace/graph/component-source-internal.h>
* SOFTWARE.
*/
-#include <babeltrace/compiler.h>
+#include <babeltrace/compiler-internal.h>
#include <babeltrace/ctf-ir/event.h>
#include <babeltrace/ctf-ir/event-internal.h>
#include <babeltrace/ctf-ir/event-class.h>
#include <assert.h>
#include <stddef.h>
-#include <babeltrace/compiler.h>
+#include <babeltrace/compiler-internal.h>
#include <babeltrace/graph/notification-heap-internal.h>
#ifdef DEBUG_HEAP
*/
#include <babeltrace/object-internal.h>
-#include <babeltrace/compiler.h>
+#include <babeltrace/compiler-internal.h>
#include <babeltrace/ctf-ir/clock-class.h>
#include <babeltrace/graph/clock-class-priority-map.h>
#include <babeltrace/graph/notification-internal.h>
* SOFTWARE.
*/
-#include <babeltrace/compiler.h>
+#include <babeltrace/compiler-internal.h>
#include <babeltrace/graph/notification-packet-internal.h>
static
* SOFTWARE.
*/
-#include <babeltrace/compiler.h>
+#include <babeltrace/compiler-internal.h>
#include <babeltrace/graph/notification-stream-internal.h>
static
#include <babeltrace/graph/port-internal.h>
#include <babeltrace/graph/connection-internal.h>
#include <babeltrace/object-internal.h>
-#include <babeltrace/compiler.h>
+#include <babeltrace/compiler-internal.h>
static
void bt_port_destroy(struct bt_object *obj)
* SOFTWARE.
*/
-#include <babeltrace/compiler.h>
+#include <babeltrace/compiler-internal.h>
#include <babeltrace/values.h>
#include <babeltrace/graph/component-sink-internal.h>
#include <babeltrace/graph/component-internal.h>
*/
#include <babeltrace/ref.h>
-#include <babeltrace/compiler.h>
+#include <babeltrace/compiler-internal.h>
#include <babeltrace/graph/component-source-internal.h>
#include <babeltrace/graph/component-internal.h>
#include <babeltrace/graph/port-internal.h>
#include <babeltrace/ctf-ir/utils.h>
#include <babeltrace/ref.h>
#include <babeltrace/object-internal.h>
-#include <babeltrace/compiler.h>
+#include <babeltrace/compiler-internal.h>
#include <inttypes.h>
static
#include <babeltrace/ctf-ir/utils.h>
#include <babeltrace/ref.h>
#include <babeltrace/ctf-ir/attributes-internal.h>
-#include <babeltrace/compiler.h>
-#include <babeltrace/endian.h>
+#include <babeltrace/compiler-internal.h>
+#include <babeltrace/endian-internal.h>
#include <inttypes.h>
static
#include <babeltrace/ctf-writer/serialize-internal.h>
#include <babeltrace/ref.h>
#include <babeltrace/ctf-ir/attributes-internal.h>
-#include <babeltrace/compiler.h>
+#include <babeltrace/compiler-internal.h>
static
void bt_ctf_event_destroy(struct bt_object *obj);
#include <babeltrace/ctf-writer/writer-internal.h>
#include <babeltrace/object-internal.h>
#include <babeltrace/ref.h>
-#include <babeltrace/compiler.h>
-#include <babeltrace/endian.h>
+#include <babeltrace/compiler-internal.h>
+#include <babeltrace/endian-internal.h>
#include <float.h>
#include <inttypes.h>
#include <stdlib.h>
#include <babeltrace/ctf-writer/serialize-internal.h>
#include <babeltrace/object-internal.h>
#include <babeltrace/ref.h>
-#include <babeltrace/compiler.h>
-#include <babeltrace/compat/fcntl.h>
-#include <babeltrace/align.h>
+#include <babeltrace/compiler-internal.h>
+#include <babeltrace/compat/fcntl-internal.h>
+#include <babeltrace/align-internal.h>
#define PACKET_LEN_INCREMENT (getpagesize() * 8 * CHAR_BIT)
#include <babeltrace/ctf-writer/functor-internal.h>
#include <babeltrace/ctf-ir/utils.h>
#include <babeltrace/ref.h>
-#include <babeltrace/compiler.h>
-#include <babeltrace/align.h>
-#include <babeltrace/endian.h>
+#include <babeltrace/compiler-internal.h>
+#include <babeltrace/align-internal.h>
+#include <babeltrace/endian-internal.h>
#include <inttypes.h>
static
#include <babeltrace/ctf-writer/writer-internal.h>
#include <babeltrace/ref.h>
#include <babeltrace/ctf-writer/functor-internal.h>
-#include <babeltrace/compiler.h>
-#include <babeltrace/align.h>
+#include <babeltrace/compiler-internal.h>
+#include <babeltrace/align-internal.h>
#include <inttypes.h>
static
#include <babeltrace/ctf-ir/visitor-internal.h>
#include <babeltrace/ctf-ir/utils.h>
#include <babeltrace/graph/notification-schema.h>
-#include <babeltrace/compiler.h>
+#include <babeltrace/compiler-internal.h>
#include <babeltrace/values.h>
#include <babeltrace/ref.h>
-#include <babeltrace/endian.h>
+#include <babeltrace/endian-internal.h>
#include <inttypes.h>
#define DEFAULT_IDENTIFIER_SIZE 128
#include <babeltrace/ctf-ir/utils.h>
#include <babeltrace/ref.h>
#include <babeltrace/object-internal.h>
-#include <babeltrace/compiler.h>
+#include <babeltrace/compiler-internal.h>
#include <inttypes.h>
static
#include <babeltrace/ctf-ir/fields.h>
#include <babeltrace/ctf-ir/fields-internal.h>
#include <babeltrace/ctf-writer/serialize-internal.h>
-#include <babeltrace/align.h>
-#include <babeltrace/mmap-align.h>
-#include <babeltrace/endian.h>
-#include <babeltrace/bitfield.h>
-#include <babeltrace/compat/fcntl.h>
+#include <babeltrace/align-internal.h>
+#include <babeltrace/mmap-align-internal.h>
+#include <babeltrace/endian-internal.h>
+#include <babeltrace/bitfield-internal.h>
+#include <babeltrace/compat/fcntl-internal.h>
#include <glib.h>
#if (FLT_RADIX != 2)
#include <babeltrace/ctf-ir/stream-internal.h>
#include <babeltrace/ctf-ir/trace-internal.h>
#include <babeltrace/ref.h>
-#include <babeltrace/endian.h>
-#include <babeltrace/compiler.h>
+#include <babeltrace/endian-internal.h>
+#include <babeltrace/compiler-internal.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
* SOFTWARE.
*/
-#include <babeltrace/compiler.h>
+#include <babeltrace/compiler-internal.h>
#include <babeltrace/ref.h>
#include <babeltrace/plugin/plugin-internal.h>
#include <babeltrace/plugin/plugin-so-internal.h>
*/
#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/compiler.h>
+#include <babeltrace/compiler-internal.h>
#include <babeltrace/ref.h>
#include <babeltrace/common-internal.h>
#include <babeltrace/plugin/plugin-internal.h>
* SOFTWARE.
*/
-#include <babeltrace/prio_heap.h>
+#include <babeltrace/prio-heap-internal.h>
#include <babeltrace/babeltrace-internal.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <string.h>
-#include <babeltrace/compiler.h>
+#include <babeltrace/compiler-internal.h>
#include <babeltrace/object-internal.h>
#include <babeltrace/ref.h>
#include <babeltrace/values.h>
-#include <babeltrace/compat/glib.h>
+#include <babeltrace/compat/glib-internal.h>
#define BT_VALUE_FROM_CONCRETE(_concrete) ((struct bt_value *) (_concrete))
#define BT_VALUE_TO_BOOL(_base) ((struct bt_value_bool *) (_base))
-SUBDIRS = ctf text muxer utils libctfcopytrace writer
+SUBDIRS = ctf text utils libctfcopytrace writer
if ENABLE_DEBUG_INFO
SUBDIRS += debug-info
#include <stdbool.h>
#include <assert.h>
#include <string.h>
-#include <babeltrace/bitfield.h>
+#include <babeltrace/bitfield-internal.h>
#include <babeltrace/ctf-ir/field-types.h>
#include <babeltrace/ref.h>
-#include <babeltrace/align.h>
+#include <babeltrace/align-internal.h>
#include <glib.h>
#include "btr.h"
#include <stdint.h>
#include <stdio.h>
#include <glib.h>
-#include <babeltrace/list.h>
+#include <babeltrace/list-internal.h>
#include <babeltrace/ctf-ir/trace.h>
#include <babeltrace/babeltrace-internal.h>
#include <stdint.h>
#include <stdlib.h>
#include <assert.h>
-#include <babeltrace/compat/uuid.h>
-#include <babeltrace/compat/memstream.h>
+#include <babeltrace/compat/uuid-internal.h>
+#include <babeltrace/compat/memstream-internal.h>
#include <babeltrace/ctf-ir/trace.h>
#include <glib.h>
*/
#include <stdlib.h>
-#include <babeltrace/list.h>
+#include <babeltrace/list-internal.h>
#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/align.h>
+#include <babeltrace/align-internal.h>
#define OBJSTACK_ALIGN 8 /* Object stack alignment */
#define OBJSTACK_INIT_LEN 128
#include <glib.h>
#include <inttypes.h>
#include <errno.h>
-#include <babeltrace/compat/uuid.h>
-#include <babeltrace/endian.h>
+#include <babeltrace/compat/uuid-internal.h>
+#include <babeltrace/endian-internal.h>
#include <babeltrace/ref.h>
#include <babeltrace/ctf-ir/trace.h>
#include <babeltrace/ctf-ir/stream-class.h>
#include <inttypes.h>
#include <errno.h>
#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/list.h>
+#include <babeltrace/list-internal.h>
#include "scanner.h"
#include "parser.h"
#include "ast.h"
#include <inttypes.h>
#include <errno.h>
#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/list.h>
+#include <babeltrace/list-internal.h>
#include "scanner.h"
#include "parser.h"
#include "ast.h"
#ifndef LTTNG_INDEX_H
#define LTTNG_INDEX_H
-#include <babeltrace/compat/limits.h>
+#include <babeltrace/compat/limits-internal.h>
#define CTF_INDEX_MAGIC 0xC1F1DCC1
#define CTF_INDEX_MAJOR 1
#include <stdbool.h>
#include <assert.h>
#include <glib.h>
-#include <babeltrace/compat/uuid.h>
-#include <babeltrace/compat/memstream.h>
+#include <babeltrace/compat/uuid-internal.h>
+#include <babeltrace/compat/memstream-internal.h>
#define PRINT_ERR_STREAM ctf_fs->error_fp
#define PRINT_PREFIX "ctf-fs-metadata"
#include <babeltrace/ctf-ir/field-types.h>
#include <babeltrace/ctf-ir/fields.h>
#include <babeltrace/ctf-ir/trace.h>
-#include <babeltrace/bitfield.h>
+#include <babeltrace/bitfield-internal.h>
#include <babeltrace/common-internal.h>
#include <inttypes.h>
#include <ctype.h>
#include <babeltrace/graph/notification-iterator.h>
#include <babeltrace/graph/notification-event.h>
#include <babeltrace/values.h>
-#include <babeltrace/compiler.h>
+#include <babeltrace/compiler-internal.h>
#include <babeltrace/common-internal.h>
#include <plugins-common.h>
#include <stdio.h>
*/
#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/compiler.h>
+#include <babeltrace/compiler-internal.h>
#include <babeltrace/ref.h>
#include <babeltrace/plugin/plugin-internal.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
-#include <babeltrace/compat/dirent.h>
-#include <babeltrace/compat/limits.h>
+#include <babeltrace/compat/dirent-internal.h>
+#include <babeltrace/compat/limits-internal.h>
#include <sys/stat.h>
void recursive_rmdir(const char *path)
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#include <babeltrace/bitfield.h>
+#include <babeltrace/bitfield-internal.h>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include "tap/tap.h"
#include <stdbool.h>
#include <stdlib.h>
-#include <babeltrace/compiler.h>
+#include <babeltrace/compiler-internal.h>
#include <babeltrace/ref.h>
#include <babeltrace/graph/notification-heap.h>
#include <babeltrace/graph/notification.h>
#include <babeltrace/ctf-ir/event.h>
#include <babeltrace/ctf-ir/event-class.h>
#include <babeltrace/object-internal.h>
-#include <babeltrace/compat/stdlib.h>
+#include <babeltrace/compat/stdlib-internal.h>
#include <assert.h>
#include "common.h"
#include <babeltrace/ctf/events.h>
#include <babeltrace/values.h>
#include <unistd.h>
-#include <babeltrace/compat/stdlib.h>
+#include <babeltrace/compat/stdlib-internal.h>
#include <stdio.h>
#include <sys/utsname.h>
-#include <babeltrace/compat/limits.h>
-#include <babeltrace/compat/stdio.h>
+#include <babeltrace/compat/limits-internal.h>
+#include <babeltrace/compat/stdio-internal.h>
#include <string.h>
#include <assert.h>
#include <sys/wait.h>
#include <fcntl.h>
-#include <babeltrace/compat/dirent.h>
+#include <babeltrace/compat/dirent-internal.h>
#include "tap/tap.h"
#include <math.h>
#include <float.h>