Add `-internal` suffix to all internal header files
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Tue, 4 Apr 2017 18:49:10 +0000 (14:49 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sun, 28 May 2017 16:57:40 +0000 (12:57 -0400)
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
95 files changed:
cli/babeltrace-cfg.h
cli/babeltrace-log.c
compat/compat_uuid.c
include/Makefile.am
include/babeltrace/align-internal.h [new file with mode: 0644]
include/babeltrace/align.h [deleted file]
include/babeltrace/babeltrace-internal.h
include/babeltrace/bitfield-internal.h [new file with mode: 0644]
include/babeltrace/bitfield.h [deleted file]
include/babeltrace/compat/dirent-internal.h [new file with mode: 0644]
include/babeltrace/compat/dirent.h [deleted file]
include/babeltrace/compat/fcntl-internal.h [new file with mode: 0644]
include/babeltrace/compat/fcntl.h [deleted file]
include/babeltrace/compat/glib-internal.h [new file with mode: 0644]
include/babeltrace/compat/glib.h [deleted file]
include/babeltrace/compat/limits-internal.h [new file with mode: 0644]
include/babeltrace/compat/limits.h [deleted file]
include/babeltrace/compat/memstream-internal.h [new file with mode: 0644]
include/babeltrace/compat/memstream.h [deleted file]
include/babeltrace/compat/mman-internal.h [new file with mode: 0644]
include/babeltrace/compat/mman.h [deleted file]
include/babeltrace/compat/send-internal.h [new file with mode: 0644]
include/babeltrace/compat/send.h [deleted file]
include/babeltrace/compat/stdio-internal.h [new file with mode: 0644]
include/babeltrace/compat/stdio.h [deleted file]
include/babeltrace/compat/stdlib-internal.h [new file with mode: 0644]
include/babeltrace/compat/stdlib.h [deleted file]
include/babeltrace/compat/string-internal.h [new file with mode: 0644]
include/babeltrace/compat/string.h [deleted file]
include/babeltrace/compat/utc-internal.h [new file with mode: 0644]
include/babeltrace/compat/utc.h [deleted file]
include/babeltrace/compat/uuid-internal.h [new file with mode: 0644]
include/babeltrace/compat/uuid.h [deleted file]
include/babeltrace/compiler-internal.h [new file with mode: 0644]
include/babeltrace/compiler.h [deleted file]
include/babeltrace/ctf-ir/clock-class-internal.h
include/babeltrace/ctf-ir/event-fields [new file with mode: 0644]
include/babeltrace/ctf-writer/clock-internal.h
include/babeltrace/ctf-writer/serialize-internal.h
include/babeltrace/endian-internal.h [new file with mode: 0644]
include/babeltrace/endian.h [deleted file]
include/babeltrace/list-internal.h [new file with mode: 0644]
include/babeltrace/list.h [deleted file]
include/babeltrace/mmap-align-internal.h [new file with mode: 0644]
include/babeltrace/mmap-align.h [deleted file]
include/babeltrace/prio-heap-internal.h [new file with mode: 0644]
include/babeltrace/prio_heap.h [deleted file]
lib/component/clock-class-priority-map.c
lib/component/component-class.c
lib/component/component.c
lib/component/connection.c
lib/component/filter.c
lib/component/graph.c
lib/component/iterator.c
lib/component/notification/event.c
lib/component/notification/heap.c
lib/component/notification/inactivity.c
lib/component/notification/packet.c
lib/component/notification/stream.c
lib/component/port.c
lib/component/sink.c
lib/component/source.c
lib/ctf-ir/clock-class.c
lib/ctf-ir/event-class.c
lib/ctf-ir/event.c
lib/ctf-ir/field-types.c
lib/ctf-ir/fields.c
lib/ctf-ir/stream-class.c
lib/ctf-ir/stream.c
lib/ctf-ir/trace.c
lib/ctf-writer/clock.c
lib/ctf-writer/serialize.c
lib/ctf-writer/writer.c
lib/plugin/plugin-so.c
lib/plugin/plugin.c
lib/prio_heap/prio_heap.c
lib/values.c
plugins/Makefile.am
plugins/ctf/common/btr/btr.c
plugins/ctf/common/metadata/ast.h
plugins/ctf/common/metadata/decoder.c
plugins/ctf/common/metadata/objstack.c
plugins/ctf/common/metadata/visitor-generate-ir.c
plugins/ctf/common/metadata/visitor-parent-links.c
plugins/ctf/common/metadata/visitor-semantic-validator.c
plugins/ctf/fs/lttng-index.h
plugins/ctf/fs/metadata.c
plugins/text/print.c
plugins/text/text.c
python-plugin-provider/python-plugin-provider.c
tests/lib/common.c
tests/lib/test_bitfield.c
tests/lib/test_bt_notification_heap.c
tests/lib/test_ctf_ir_ref.c
tests/lib/test_ctf_writer.c

index ca2f9950ebbdb6d592173aa0bab49408657d2ce2..508840e4bc64c7dca47265b3eb9d93eb430ebb03 100644 (file)
@@ -30,7 +30,7 @@
 #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>
 
index 38cf8392d47802224f63990d7a80d7055798fff8..27070fc5e90d441d4c62e1f04360028f04a85eb4 100644 (file)
@@ -30,7 +30,7 @@
 #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
index a775da47b5c7f0388602f374c614640ac7b6d88b..03ca167592404add2993d63eb4f5a5c1cc9237a7 100644 (file)
@@ -26,7 +26,7 @@
 
 #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
index ae8d6dcc80fb4f9df73a8ae6bc1bc3bda14854e5..8aef2965458b98e6a45b4d815b63b5ce4b0552ca 100644 (file)
@@ -65,12 +65,12 @@ babeltracegraphinclude_HEADERS = \
        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 \
@@ -91,20 +91,20 @@ noinst_HEADERS = \
        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 \
diff --git a/include/babeltrace/align-internal.h b/include/babeltrace/align-internal.h
new file mode 100644 (file)
index 0000000..a2566c9
--- /dev/null
@@ -0,0 +1,82 @@
+#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 */
diff --git a/include/babeltrace/align.h b/include/babeltrace/align.h
deleted file mode 100644 (file)
index 67ece4d..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-#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 */
index 535f99094970161856927d5adcd6d1fb7753cc0d..367762ab4d9b1d7f42006e4fdbfdd9fe3075a951 100644 (file)
@@ -30,7 +30,7 @@
 #include <stdlib.h>
 #include <errno.h>
 #include <stdbool.h>
-#include <babeltrace/compat/string.h>
+#include <babeltrace/compat/string-internal.h>
 
 #define PERROR_BUFLEN  200
 
diff --git a/include/babeltrace/bitfield-internal.h b/include/babeltrace/bitfield-internal.h
new file mode 100644 (file)
index 0000000..d3609e3
--- /dev/null
@@ -0,0 +1,407 @@
+#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 */
diff --git a/include/babeltrace/bitfield.h b/include/babeltrace/bitfield.h
deleted file mode 100644 (file)
index 6cf804e..0000000
+++ /dev/null
@@ -1,407 +0,0 @@
-#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 */
diff --git a/include/babeltrace/compat/dirent-internal.h b/include/babeltrace/compat/dirent-internal.h
new file mode 100644 (file)
index 0000000..5373c66
--- /dev/null
@@ -0,0 +1,49 @@
+#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 */
diff --git a/include/babeltrace/compat/dirent.h b/include/babeltrace/compat/dirent.h
deleted file mode 100644 (file)
index 5373c66..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-#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 */
diff --git a/include/babeltrace/compat/fcntl-internal.h b/include/babeltrace/compat/fcntl-internal.h
new file mode 100644 (file)
index 0000000..47e5eff
--- /dev/null
@@ -0,0 +1,181 @@
+#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 */
diff --git a/include/babeltrace/compat/fcntl.h b/include/babeltrace/compat/fcntl.h
deleted file mode 100644 (file)
index 47e5eff..0000000
+++ /dev/null
@@ -1,181 +0,0 @@
-#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 */
diff --git a/include/babeltrace/compat/glib-internal.h b/include/babeltrace/compat/glib-internal.h
new file mode 100644 (file)
index 0000000..dd03b19
--- /dev/null
@@ -0,0 +1,83 @@
+#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 */
diff --git a/include/babeltrace/compat/glib.h b/include/babeltrace/compat/glib.h
deleted file mode 100644 (file)
index dd03b19..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-#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 */
diff --git a/include/babeltrace/compat/limits-internal.h b/include/babeltrace/compat/limits-internal.h
new file mode 100644 (file)
index 0000000..b276183
--- /dev/null
@@ -0,0 +1,46 @@
+#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 */
diff --git a/include/babeltrace/compat/limits.h b/include/babeltrace/compat/limits.h
deleted file mode 100644 (file)
index b276183..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-#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 */
diff --git a/include/babeltrace/compat/memstream-internal.h b/include/babeltrace/compat/memstream-internal.h
new file mode 100644 (file)
index 0000000..38b6e3f
--- /dev/null
@@ -0,0 +1,233 @@
+#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 */
diff --git a/include/babeltrace/compat/memstream.h b/include/babeltrace/compat/memstream.h
deleted file mode 100644 (file)
index 38b6e3f..0000000
+++ /dev/null
@@ -1,233 +0,0 @@
-#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 */
diff --git a/include/babeltrace/compat/mman-internal.h b/include/babeltrace/compat/mman-internal.h
new file mode 100644 (file)
index 0000000..061e244
--- /dev/null
@@ -0,0 +1,36 @@
+#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 */
diff --git a/include/babeltrace/compat/mman.h b/include/babeltrace/compat/mman.h
deleted file mode 100644 (file)
index 061e244..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-#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 */
diff --git a/include/babeltrace/compat/send-internal.h b/include/babeltrace/compat/send-internal.h
new file mode 100644 (file)
index 0000000..3998694
--- /dev/null
@@ -0,0 +1,117 @@
+#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 */
diff --git a/include/babeltrace/compat/send.h b/include/babeltrace/compat/send.h
deleted file mode 100644 (file)
index 3998694..0000000
+++ /dev/null
@@ -1,117 +0,0 @@
-#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 */
diff --git a/include/babeltrace/compat/stdio-internal.h b/include/babeltrace/compat/stdio-internal.h
new file mode 100644 (file)
index 0000000..41d1df3
--- /dev/null
@@ -0,0 +1,126 @@
+#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 */
diff --git a/include/babeltrace/compat/stdio.h b/include/babeltrace/compat/stdio.h
deleted file mode 100644 (file)
index 41d1df3..0000000
+++ /dev/null
@@ -1,126 +0,0 @@
-#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 */
diff --git a/include/babeltrace/compat/stdlib-internal.h b/include/babeltrace/compat/stdlib-internal.h
new file mode 100644 (file)
index 0000000..be0518f
--- /dev/null
@@ -0,0 +1,78 @@
+#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 */
diff --git a/include/babeltrace/compat/stdlib.h b/include/babeltrace/compat/stdlib.h
deleted file mode 100644 (file)
index be0518f..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-#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 */
diff --git a/include/babeltrace/compat/string-internal.h b/include/babeltrace/compat/string-internal.h
new file mode 100644 (file)
index 0000000..2aa7bc3
--- /dev/null
@@ -0,0 +1,116 @@
+#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 */
diff --git a/include/babeltrace/compat/string.h b/include/babeltrace/compat/string.h
deleted file mode 100644 (file)
index 2aa7bc3..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-#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 */
diff --git a/include/babeltrace/compat/utc-internal.h b/include/babeltrace/compat/utc-internal.h
new file mode 100644 (file)
index 0000000..fd41f62
--- /dev/null
@@ -0,0 +1,86 @@
+#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 */
diff --git a/include/babeltrace/compat/utc.h b/include/babeltrace/compat/utc.h
deleted file mode 100644 (file)
index fd41f62..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-#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 */
diff --git a/include/babeltrace/compat/uuid-internal.h b/include/babeltrace/compat/uuid-internal.h
new file mode 100644 (file)
index 0000000..4237eb5
--- /dev/null
@@ -0,0 +1,159 @@
+#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 */
diff --git a/include/babeltrace/compat/uuid.h b/include/babeltrace/compat/uuid.h
deleted file mode 100644 (file)
index 4237eb5..0000000
+++ /dev/null
@@ -1,159 +0,0 @@
-#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 */
diff --git a/include/babeltrace/compiler-internal.h b/include/babeltrace/compiler-internal.h
new file mode 100644 (file)
index 0000000..4eaa0e6
--- /dev/null
@@ -0,0 +1,42 @@
+#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 */
diff --git a/include/babeltrace/compiler.h b/include/babeltrace/compiler.h
deleted file mode 100644 (file)
index 4eaa0e6..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-#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 */
index c43f7712475e06eec0536e8d3e75e462889bd43a..0d7d89174c6e1ce9f0532fb62131099dc7723487 100644 (file)
@@ -32,7 +32,7 @@
 #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;
diff --git a/include/babeltrace/ctf-ir/event-fields b/include/babeltrace/ctf-ir/event-fields
new file mode 100644 (file)
index 0000000..8246085
Binary files /dev/null and b/include/babeltrace/ctf-ir/event-fields differ
index 967be1aa28151873133d8d71bcd7183c9acf91e7..b9e524a989e1df0567c29b765c4923e6a7eaa579 100644 (file)
@@ -31,7 +31,7 @@
 #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;
index b04ec36cfd5911f012fef63a64d6fe7da959dcfb..15ced8debe823b0f048b2cf93ff3284eb3e0a098 100644 (file)
@@ -35,8 +35,8 @@
 #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;
diff --git a/include/babeltrace/endian-internal.h b/include/babeltrace/endian-internal.h
new file mode 100644 (file)
index 0000000..55f8d1e
--- /dev/null
@@ -0,0 +1,231 @@
+#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 */
diff --git a/include/babeltrace/endian.h b/include/babeltrace/endian.h
deleted file mode 100644 (file)
index 55f8d1e..0000000
+++ /dev/null
@@ -1,231 +0,0 @@
-#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 */
diff --git a/include/babeltrace/list-internal.h b/include/babeltrace/list-internal.h
new file mode 100644 (file)
index 0000000..ee5d84b
--- /dev/null
@@ -0,0 +1,178 @@
+/*
+ * 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 */
diff --git a/include/babeltrace/list.h b/include/babeltrace/list.h
deleted file mode 100644 (file)
index ee5d84b..0000000
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * 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 */
diff --git a/include/babeltrace/mmap-align-internal.h b/include/babeltrace/mmap-align-internal.h
new file mode 100644 (file)
index 0000000..ccb0e1f
--- /dev/null
@@ -0,0 +1,105 @@
+#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 */
diff --git a/include/babeltrace/mmap-align.h b/include/babeltrace/mmap-align.h
deleted file mode 100644 (file)
index f7c18fa..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-#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 */
diff --git a/include/babeltrace/prio-heap-internal.h b/include/babeltrace/prio-heap-internal.h
new file mode 100644 (file)
index 0000000..52de47c
--- /dev/null
@@ -0,0 +1,134 @@
+#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 */
diff --git a/include/babeltrace/prio_heap.h b/include/babeltrace/prio_heap.h
deleted file mode 100644 (file)
index 52de47c..0000000
+++ /dev/null
@@ -1,134 +0,0 @@
-#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 */
index e917ea5065d888435b2d39fa27e6f22abc853c81..f9055198ab0249b86a1fa3c7ef5432e0f08a8a78 100644 (file)
@@ -27,7 +27,7 @@
 #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>
 
index bdaa2d37d3435f53081d8371593fbff83ce96d08..4585b1f3078153a83575ef5ffa35d9df01499936 100644 (file)
@@ -26,7 +26,7 @@
  * SOFTWARE.
  */
 
-#include <babeltrace/compiler.h>
+#include <babeltrace/compiler-internal.h>
 #include <babeltrace/graph/component-class-internal.h>
 #include <babeltrace/ref.h>
 #include <stdbool.h>
index 47f83c861d3a17b69eb9ca3669a6472b61f85b63..9b996f624bb4e9854412f23b605cc47c37d35b4e 100644 (file)
@@ -39,7 +39,7 @@
 #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
index 1b58c02689e62b01da31e974348ec8b341532e7c..986303ed82a78dba2d09ba16212cc9ccc89f7374 100644 (file)
@@ -35,7 +35,7 @@
 #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
index dd44012022a5429cbec2db4b3d713877bb12a664..5931b3b3f7846c598f6fd334b7449f6ff77652be 100644 (file)
@@ -26,7 +26,7 @@
  * 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>
index a770be30079c112c5318d81b54409e0e9b9bc197..c861fa3c0e049939e88374ddce7416666b923f9d 100644 (file)
@@ -33,7 +33,7 @@
 #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>
 
index ab2783d5b7d258a42bfe7c781ba4cffa67c4afee..29562955dd72e4baa3b8e455df24cefb8098fc04 100644 (file)
@@ -26,7 +26,7 @@
  * 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>
index bae1912fe2b0b885cf3d62e82bc0e8f9104fb144..a9fbf48bd56a6c9c8183f3380e0d100db92fe05a 100644 (file)
@@ -24,7 +24,7 @@
  * 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>
index 897b680b0f1271b04cc007e5eb2fb78b7074399c..fc0bce81b65e5d1c76d080f92aed0a5d743722bb 100644 (file)
@@ -28,7 +28,7 @@
 
 #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
index 9f4cae3fcf8522a09aa9915ce0992b669523b8e6..48073955ee303a443549063340205c637bf1f937 100644 (file)
@@ -21,7 +21,7 @@
  */
 
 #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>
index 393181dab13238c52511409947f1388849e786b5..fa6a0ee335e1b95a96cb30965462d1a2aa1273e2 100644 (file)
@@ -24,7 +24,7 @@
  * SOFTWARE.
  */
 
-#include <babeltrace/compiler.h>
+#include <babeltrace/compiler-internal.h>
 #include <babeltrace/graph/notification-packet-internal.h>
 
 static
index 56062f61222c8e87aec04239957dec162bbe9669..68b9bcdb8b193e2c46375b51f5a29375c8e6ca06 100644 (file)
@@ -24,7 +24,7 @@
  * SOFTWARE.
  */
 
-#include <babeltrace/compiler.h>
+#include <babeltrace/compiler-internal.h>
 #include <babeltrace/graph/notification-stream-internal.h>
 
 static
index bb72b163dd6d64b3dfb4e35ede23dd26a17f2492..c0d5e061d2cd49e271d794de3bbe1e064a67fd5f 100644 (file)
@@ -30,7 +30,7 @@
 #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)
index fbdb3a3e1248ac234c4e0f4af02316b4cff6216a..49bd840249a8f8434d1295af9424345589e65719 100644 (file)
@@ -26,7 +26,7 @@
  * 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>
index 7d43e34c8f154a5d7ede3aad5ad7ac78b4f3abc1..0c4f1817c91e7584efda10238a43d6c47c11dad6 100644 (file)
@@ -27,7 +27,7 @@
  */
 
 #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>
index 66f7f440dd71a0e63228f9acbe27277afbbedd9f..37635ca9763f309ee9d4fca342f73ad01fd41cfe 100644 (file)
@@ -30,7 +30,7 @@
 #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
index 6764d43855e8c18d1d5c97d13de6592b1ac44646..0cef19353f1f972cc7fbb86d5f43c6bb93e12a16 100644 (file)
@@ -37,8 +37,8 @@
 #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
index 5fd732de331b14f613f170467e0c171962324d3a..ff153559ae1962dacf27f562f666112936c4ac89 100644 (file)
@@ -44,7 +44,7 @@
 #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);
index 6b02d4e33df02ab7ca0fa5dd17f3f115eacdddbb..b29d9947d7cc763d118e9b95ca122e297e0536ef 100644 (file)
@@ -35,8 +35,8 @@
 #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>
index ace87de33722c026fae1372993127e5352bba10c..c43b4afa4e57da06a5c0890d2a7a7e514551f23f 100644 (file)
@@ -31,9 +31,9 @@
 #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)
 
index 776ced90a0cd945a2de2fc42b65d0f8b1e45e84f..4fac746800a0646508cc3d14af2044d2c71be3a4 100644 (file)
@@ -41,9 +41,9 @@
 #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
index a06cbbbf64a7844e0878ff533137290ea409c040..7a4d53cee2d3e7dba4a55e2922f6f2f7dc53c86a 100644 (file)
@@ -40,8 +40,8 @@
 #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
index 999270882fbe7a42221e23686f5d4625e2013825..e0ef7b61c90f37f609c469db8a2e11c2082b638c 100644 (file)
 #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
index 84125f2229bd6e4ef6100a9f1c69a7d10f906458..dd070ec95369e833070acecad4e6a88f7a4a45fe 100644 (file)
@@ -33,7 +33,7 @@
 #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
index 0e04229ff22bb7f6289c36736ffd5ea347642b7c..e0239f65e844c77bbe0406566f1fdc1ee81dc837 100644 (file)
 #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)
index c0dbdbb0d5e2b12cfaea0228bc05bf6561d2440d..c7b658fc9a01d7b5d425aeb4ef243a9030f1ef0d 100644 (file)
@@ -35,8 +35,8 @@
 #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>
index bf6f9425dbbc8ebc54c32c297f0bffc923230c38..2e528ea063d7943f6416c97ae7e66a21130df452 100644 (file)
@@ -27,7 +27,7 @@
  * 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>
index 83f628cd8ef79fe387360ba3e55b9fcc1c95c515..90f77cb5a7e7c475e9b82ba1b04ffe8211687c70 100644 (file)
@@ -28,7 +28,7 @@
  */
 
 #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>
index 58e3de68b5f0e93d4260e48841b1a698e3c897bc..cd7098ff045bf09256297d341cb1a1d027dcff1c 100644 (file)
@@ -25,7 +25,7 @@
  * SOFTWARE.
  */
 
-#include <babeltrace/prio_heap.h>
+#include <babeltrace/prio-heap-internal.h>
 #include <babeltrace/babeltrace-internal.h>
 #include <errno.h>
 #include <stdlib.h>
index 1c7902bd73ea10b6c688841ad7dd08f635f20dde..6d08aaeb80d685ad8942e26d95a276a39eb52d3e 100644 (file)
 #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))
index d3fac02d67fc84e0b7d0ae23a3d0d0dd401eead6..d50aac9de44f8dc8480b4b2d5d55d63400cdf0a9 100644 (file)
@@ -1,4 +1,4 @@
-SUBDIRS = ctf text muxer utils libctfcopytrace writer
+SUBDIRS = ctf text utils libctfcopytrace writer
 
 if ENABLE_DEBUG_INFO
 SUBDIRS += debug-info
index 7c48bd0826a848e6a03639e1ba53c0a3363315a2..7e7cf37b956fb3d524a0863f26ea46d73c81c6a5 100644 (file)
 #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"
index 684ea6b84861fe9355f321aa505592aad81cebf5..3ab552aa1966de743ed9b68868d9508581a4c811 100644 (file)
@@ -20,7 +20,7 @@
 #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>
 
index 6dbd81608bcbbb714c92887df50bd17ed1eb5d36..81d6ddef7837e0127efdbd8f3a2e70223fc95941 100644 (file)
@@ -17,8 +17,8 @@
 #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>
 
index 8087722059cd3d28cb66a7241de1ba8d7debca50..de6760166e93f142c33b0f431ed874f01f360d70 100644 (file)
@@ -25,9 +25,9 @@
  */
 
 #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
index e3ca366fba4e26c5dca8cdca1329cb1747b12a97..71f4f12a9b59def00d510b8668a8f535ceeb2210 100644 (file)
@@ -36,8 +36,8 @@
 #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>
index 4a017fc85af804d1fc5843a0e0955aec368d4257..d134d71ceebea58a615c9955d794c54bc1d1d3a3 100644 (file)
@@ -33,7 +33,7 @@
 #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"
index bf00008de5fc293f66d2517840a993d80ed8880c..d94a3bdf4c5947684d638afed3e0d237b942a6a3 100644 (file)
@@ -33,7 +33,7 @@
 #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"
index b26f313271ee9e0577a8802df9d37b85c8f20895..05629f8639d0d02923af2f7a8feb8c562851c638 100644 (file)
@@ -25,7 +25,7 @@
 #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
index a728abbfba6d1b50eaa13e8724798644ec7f78d6..c8e008aa4662a70f7a03a0dc88de65581882255f 100644 (file)
@@ -29,8 +29,8 @@
 #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"
index c155e6fff6e0d4d2e000979016f00e615f074115..3634d0682816cf3ac97b0a09bc1d8257918a01fc 100644 (file)
@@ -36,7 +36,7 @@
 #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>
index 78cdaab666ee9c16a6109c1ffcb0012aea0f4362..bf7201d2391532fb4b6f7f21434d33a1ef14cffd 100644 (file)
@@ -39,7 +39,7 @@
 #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>
index 20892fca139317fe9efbeea30f2ec86c368592eb..c7727f21020cbfddc4977b4c93e9872ee0f78ad6 100644 (file)
@@ -25,7 +25,7 @@
  */
 
 #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>
index 3f418e6d3b9d408fcab6bd2e032c947b0bee131b..a6812b9ffff2d2200a8bd48a68e1aadf200a9cc1 100644 (file)
@@ -21,8 +21,8 @@
 
 #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)
index b14883df873ef574c5d26c83cb2f1a347bdb0d48..efbbc30e15213b51d6dcb18472942a23dc152153 100644 (file)
@@ -19,7 +19,7 @@
  * 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>
index a8c1a42b049e813b2c05e7f9905d8033e1bf1ee4..3bffb71127f47be29c8d12030b4f714de7095bec 100644 (file)
@@ -22,7 +22,7 @@
 #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>
index f6a8253fdc5362c9b36e8ce1a017c780b787923b..f82c31458b97e3f2a59119dd7f52cf9e1b90549c 100644 (file)
@@ -30,7 +30,7 @@
 #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"
 
index 5b256cad222c1f73b1819955def43c8a2f5f4e08..9f76f7b37704bf8ac8d76580eaedb201a0d3c14e 100644 (file)
 #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>
This page took 0.153845 seconds and 4 git commands to generate.