event.c \
event-fields.c \
event-types.c \
+ stream.c \
stream-class.c
libctf_ir_la_LIBADD = \
/*
- * stream.c
+ * stream-class.c
*
* Babeltrace CTF Writer
*
--- /dev/null
+/*
+ * stream.c
+ *
+ * Babeltrace CTF Writer
+ *
+ * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Author: 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 <babeltrace/ctf-ir/clock.h>
+#include <babeltrace/ctf-ir/clock-internal.h>
+#include <babeltrace/ctf-writer/event.h>
+#include <babeltrace/ctf-ir/event-internal.h>
+#include <babeltrace/ctf-ir/event-types-internal.h>
+#include <babeltrace/ctf-ir/event-fields-internal.h>
+#include <babeltrace/ctf-ir/stream.h>
+#include <babeltrace/ctf-ir/stream-internal.h>
+#include <babeltrace/ctf-ir/stream-class-internal.h>
+#include <babeltrace/ctf-writer/functor-internal.h>
+#include <babeltrace/compiler.h>
+#include <babeltrace/align.h>
+
+static
+void bt_ctf_stream_destroy(struct bt_ctf_ref *ref);
+static
+int set_structure_field_integer(struct bt_ctf_field *, char *, uint64_t);
+
+BT_HIDDEN
+struct bt_ctf_stream *bt_ctf_stream_create(
+ struct bt_ctf_stream_class *stream_class)
+{
+ struct bt_ctf_stream *stream = NULL;
+
+ if (!stream_class) {
+ goto end;
+ }
+
+ stream = g_new0(struct bt_ctf_stream, 1);
+ if (!stream) {
+ goto end;
+ }
+
+ bt_ctf_ref_init(&stream->ref_count);
+ stream->pos.fd = -1;
+ stream->id = stream_class->next_stream_id++;
+ stream->stream_class = stream_class;
+ bt_ctf_stream_class_get(stream_class);
+ bt_ctf_stream_class_freeze(stream_class);
+ stream->events = g_ptr_array_new_with_free_func(
+ (GDestroyNotify)bt_ctf_event_put);
+end:
+ return stream;
+}
+
+BT_HIDDEN
+int bt_ctf_stream_set_flush_callback(struct bt_ctf_stream *stream,
+ flush_func callback, void *data)
+{
+ int ret = stream ? 0 : -1;
+
+ if (!stream) {
+ goto end;
+ }
+
+ stream->flush.func = callback;
+ stream->flush.data = data;
+end:
+ return ret;
+}
+
+BT_HIDDEN
+int bt_ctf_stream_set_fd(struct bt_ctf_stream *stream, int fd)
+{
+ int ret = 0;
+
+ if (stream->pos.fd != -1) {
+ ret = -1;
+ goto end;
+ }
+
+ ctf_init_pos(&stream->pos, NULL, fd, O_RDWR);
+ stream->pos.fd = fd;
+end:
+ return ret;
+}
+
+void bt_ctf_stream_append_discarded_events(struct bt_ctf_stream *stream,
+ uint64_t event_count)
+{
+ if (!stream) {
+ return;
+ }
+
+ stream->events_discarded += event_count;
+}
+
+int bt_ctf_stream_append_event(struct bt_ctf_stream *stream,
+ struct bt_ctf_event *event)
+{
+ int ret = 0;
+ uint64_t timestamp;
+
+ if (!stream || !event) {
+ ret = -1;
+ goto end;
+ }
+
+ ret = bt_ctf_event_validate(event);
+ if (ret) {
+ goto end;
+ }
+
+ timestamp = bt_ctf_clock_get_time(stream->stream_class->clock);
+ ret = bt_ctf_event_set_timestamp(event, timestamp);
+ if (ret) {
+ goto end;
+ }
+
+ bt_ctf_event_get(event);
+ g_ptr_array_add(stream->events, event);
+end:
+ return ret;
+}
+
+int bt_ctf_stream_flush(struct bt_ctf_stream *stream)
+{
+ int ret = 0;
+ size_t i;
+ uint64_t timestamp_begin, timestamp_end;
+ struct bt_ctf_stream_class *stream_class;
+ struct bt_ctf_field *integer = NULL;
+ struct ctf_stream_pos packet_context_pos;
+
+ if (!stream) {
+ ret = -1;
+ goto end;
+ }
+
+ if (!stream->events->len) {
+ goto end;
+ }
+
+ if (stream->flush.func) {
+ stream->flush.func(stream, stream->flush.data);
+ }
+
+ stream_class = stream->stream_class;
+ timestamp_begin = ((struct bt_ctf_event *) g_ptr_array_index(
+ stream->events, 0))->timestamp;
+ timestamp_end = ((struct bt_ctf_event *) g_ptr_array_index(
+ stream->events, stream->events->len - 1))->timestamp;
+ ret = set_structure_field_integer(stream_class->packet_context,
+ "timestamp_begin", timestamp_begin);
+ if (ret) {
+ goto end;
+ }
+
+ ret = set_structure_field_integer(stream_class->packet_context,
+ "timestamp_end", timestamp_end);
+ if (ret) {
+ goto end;
+ }
+
+ ret = set_structure_field_integer(stream_class->packet_context,
+ "events_discarded", stream->events_discarded);
+ if (ret) {
+ goto end;
+ }
+
+ ret = set_structure_field_integer(stream_class->packet_context,
+ "content_size", UINT64_MAX);
+ if (ret) {
+ goto end;
+ }
+
+ ret = set_structure_field_integer(stream_class->packet_context,
+ "packet_size", UINT64_MAX);
+ if (ret) {
+ goto end;
+ }
+
+ /* Write packet context */
+ memcpy(&packet_context_pos, &stream->pos,
+ sizeof(struct ctf_stream_pos));
+ ret = bt_ctf_field_serialize(stream_class->packet_context,
+ &stream->pos);
+ if (ret) {
+ goto end;
+ }
+
+ for (i = 0; i < stream->events->len; i++) {
+ struct bt_ctf_event *event = g_ptr_array_index(
+ stream->events, i);
+ uint32_t event_id = bt_ctf_event_class_get_id(
+ event->event_class);
+ uint64_t timestamp = bt_ctf_event_get_timestamp(event);
+
+ ret = set_structure_field_integer(stream_class->event_header,
+ "id", event_id);
+ if (ret) {
+ goto end;
+ }
+ ret = set_structure_field_integer(stream_class->event_header,
+ "timestamp", timestamp);
+ if (ret) {
+ goto end;
+ }
+
+ /* Write event header */
+ ret = bt_ctf_field_serialize(stream_class->event_header,
+ &stream->pos);
+ if (ret) {
+ goto end;
+ }
+
+ /* Write event content */
+ ret = bt_ctf_event_serialize(event, &stream->pos);
+ if (ret) {
+ goto end;
+ }
+ }
+
+ /*
+ * Update the packet total size and content size and overwrite the
+ * packet context.
+ * Copy base_mma as the packet may have been remapped (e.g. when a
+ * packet is resized).
+ */
+ packet_context_pos.base_mma = stream->pos.base_mma;
+ ret = set_structure_field_integer(stream_class->packet_context,
+ "content_size", stream->pos.offset);
+ if (ret) {
+ goto end;
+ }
+
+ ret = set_structure_field_integer(stream_class->packet_context,
+ "packet_size", stream->pos.packet_size);
+ if (ret) {
+ goto end;
+ }
+
+ ret = bt_ctf_field_serialize(stream_class->packet_context,
+ &packet_context_pos);
+ if (ret) {
+ goto end;
+ }
+
+ g_ptr_array_set_size(stream->events, 0);
+ stream->flushed_packet_count++;
+end:
+ bt_ctf_field_put(integer);
+ return ret;
+}
+
+void bt_ctf_stream_get(struct bt_ctf_stream *stream)
+{
+ if (!stream) {
+ return;
+ }
+
+ bt_ctf_ref_get(&stream->ref_count);
+}
+
+void bt_ctf_stream_put(struct bt_ctf_stream *stream)
+{
+ if (!stream) {
+ return;
+ }
+
+ bt_ctf_ref_put(&stream->ref_count, bt_ctf_stream_destroy);
+}
+
+static
+void bt_ctf_stream_destroy(struct bt_ctf_ref *ref)
+{
+ struct bt_ctf_stream *stream;
+
+ if (!ref) {
+ return;
+ }
+
+ stream = container_of(ref, struct bt_ctf_stream, ref_count);
+ ctf_fini_pos(&stream->pos);
+ if (close(stream->pos.fd)) {
+ perror("close");
+ }
+ bt_ctf_stream_class_put(stream->stream_class);
+ g_ptr_array_free(stream->events, TRUE);
+ g_free(stream);
+}
+
+static
+int set_structure_field_integer(struct bt_ctf_field *structure, char *name,
+ uint64_t value)
+{
+ int ret = 0;
+
+ struct bt_ctf_field *integer =
+ bt_ctf_field_structure_get_field(structure, name);
+ if (!integer) {
+ ret = -1;
+ goto end;
+ }
+
+ ret = bt_ctf_field_unsigned_integer_set_value(integer, value);
+end:
+ bt_ctf_field_put(integer);
+ return ret;
+}
libctf_writer_la_SOURCES = \
writer.c \
- stream.c \
functor.c
libctf_writer_la_LIBADD = \
+++ /dev/null
-/*
- * stream.c
- *
- * Babeltrace CTF Writer
- *
- * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * Author: 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 <babeltrace/ctf-writer/clock.h>
-#include <babeltrace/ctf-ir/clock-internal.h>
-#include <babeltrace/ctf-writer/event.h>
-#include <babeltrace/ctf-ir/event-internal.h>
-#include <babeltrace/ctf-ir/event-types-internal.h>
-#include <babeltrace/ctf-ir/event-fields-internal.h>
-#include <babeltrace/ctf-writer/stream.h>
-#include <babeltrace/ctf-writer/stream-internal.h>
-#include <babeltrace/ctf-ir/stream-class-internal.h>
-#include <babeltrace/ctf-writer/functor-internal.h>
-#include <babeltrace/compiler.h>
-#include <babeltrace/align.h>
-
-static
-void bt_ctf_stream_destroy(struct bt_ctf_ref *ref);
-static
-int set_structure_field_integer(struct bt_ctf_field *, char *, uint64_t);
-
-BT_HIDDEN
-struct bt_ctf_stream *bt_ctf_stream_create(
- struct bt_ctf_stream_class *stream_class)
-{
- struct bt_ctf_stream *stream = NULL;
-
- if (!stream_class) {
- goto end;
- }
-
- stream = g_new0(struct bt_ctf_stream, 1);
- if (!stream) {
- goto end;
- }
-
- bt_ctf_ref_init(&stream->ref_count);
- stream->pos.fd = -1;
- stream->id = stream_class->next_stream_id++;
- stream->stream_class = stream_class;
- bt_ctf_stream_class_get(stream_class);
- bt_ctf_stream_class_freeze(stream_class);
- stream->events = g_ptr_array_new_with_free_func(
- (GDestroyNotify)bt_ctf_event_put);
-end:
- return stream;
-}
-
-BT_HIDDEN
-int bt_ctf_stream_set_flush_callback(struct bt_ctf_stream *stream,
- flush_func callback, void *data)
-{
- int ret = stream ? 0 : -1;
-
- if (!stream) {
- goto end;
- }
-
- stream->flush.func = callback;
- stream->flush.data = data;
-end:
- return ret;
-}
-
-BT_HIDDEN
-int bt_ctf_stream_set_fd(struct bt_ctf_stream *stream, int fd)
-{
- int ret = 0;
-
- if (stream->pos.fd != -1) {
- ret = -1;
- goto end;
- }
-
- ctf_init_pos(&stream->pos, NULL, fd, O_RDWR);
- stream->pos.fd = fd;
-end:
- return ret;
-}
-
-void bt_ctf_stream_append_discarded_events(struct bt_ctf_stream *stream,
- uint64_t event_count)
-{
- if (!stream) {
- return;
- }
-
- stream->events_discarded += event_count;
-}
-
-int bt_ctf_stream_append_event(struct bt_ctf_stream *stream,
- struct bt_ctf_event *event)
-{
- int ret = 0;
- uint64_t timestamp;
-
- if (!stream || !event) {
- ret = -1;
- goto end;
- }
-
- ret = bt_ctf_event_validate(event);
- if (ret) {
- goto end;
- }
-
- timestamp = bt_ctf_clock_get_time(stream->stream_class->clock);
- ret = bt_ctf_event_set_timestamp(event, timestamp);
- if (ret) {
- goto end;
- }
-
- bt_ctf_event_get(event);
- g_ptr_array_add(stream->events, event);
-end:
- return ret;
-}
-
-int bt_ctf_stream_flush(struct bt_ctf_stream *stream)
-{
- int ret = 0;
- size_t i;
- uint64_t timestamp_begin, timestamp_end;
- struct bt_ctf_stream_class *stream_class;
- struct bt_ctf_field *integer = NULL;
- struct ctf_stream_pos packet_context_pos;
-
- if (!stream) {
- ret = -1;
- goto end;
- }
-
- if (!stream->events->len) {
- goto end;
- }
-
- if (stream->flush.func) {
- stream->flush.func(stream, stream->flush.data);
- }
-
- stream_class = stream->stream_class;
- timestamp_begin = ((struct bt_ctf_event *) g_ptr_array_index(
- stream->events, 0))->timestamp;
- timestamp_end = ((struct bt_ctf_event *) g_ptr_array_index(
- stream->events, stream->events->len - 1))->timestamp;
- ret = set_structure_field_integer(stream_class->packet_context,
- "timestamp_begin", timestamp_begin);
- if (ret) {
- goto end;
- }
-
- ret = set_structure_field_integer(stream_class->packet_context,
- "timestamp_end", timestamp_end);
- if (ret) {
- goto end;
- }
-
- ret = set_structure_field_integer(stream_class->packet_context,
- "events_discarded", stream->events_discarded);
- if (ret) {
- goto end;
- }
-
- ret = set_structure_field_integer(stream_class->packet_context,
- "content_size", UINT64_MAX);
- if (ret) {
- goto end;
- }
-
- ret = set_structure_field_integer(stream_class->packet_context,
- "packet_size", UINT64_MAX);
- if (ret) {
- goto end;
- }
-
- /* Write packet context */
- memcpy(&packet_context_pos, &stream->pos,
- sizeof(struct ctf_stream_pos));
- ret = bt_ctf_field_serialize(stream_class->packet_context,
- &stream->pos);
- if (ret) {
- goto end;
- }
-
- for (i = 0; i < stream->events->len; i++) {
- struct bt_ctf_event *event = g_ptr_array_index(
- stream->events, i);
- uint32_t event_id = bt_ctf_event_class_get_id(
- event->event_class);
- uint64_t timestamp = bt_ctf_event_get_timestamp(event);
-
- ret = set_structure_field_integer(stream_class->event_header,
- "id", event_id);
- if (ret) {
- goto end;
- }
- ret = set_structure_field_integer(stream_class->event_header,
- "timestamp", timestamp);
- if (ret) {
- goto end;
- }
-
- /* Write event header */
- ret = bt_ctf_field_serialize(stream_class->event_header,
- &stream->pos);
- if (ret) {
- goto end;
- }
-
- /* Write event content */
- ret = bt_ctf_event_serialize(event, &stream->pos);
- if (ret) {
- goto end;
- }
- }
-
- /*
- * Update the packet total size and content size and overwrite the
- * packet context.
- * Copy base_mma as the packet may have been remapped (e.g. when a
- * packet is resized).
- */
- packet_context_pos.base_mma = stream->pos.base_mma;
- ret = set_structure_field_integer(stream_class->packet_context,
- "content_size", stream->pos.offset);
- if (ret) {
- goto end;
- }
-
- ret = set_structure_field_integer(stream_class->packet_context,
- "packet_size", stream->pos.packet_size);
- if (ret) {
- goto end;
- }
-
- ret = bt_ctf_field_serialize(stream_class->packet_context,
- &packet_context_pos);
- if (ret) {
- goto end;
- }
-
- g_ptr_array_set_size(stream->events, 0);
- stream->flushed_packet_count++;
-end:
- bt_ctf_field_put(integer);
- return ret;
-}
-
-void bt_ctf_stream_get(struct bt_ctf_stream *stream)
-{
- if (!stream) {
- return;
- }
-
- bt_ctf_ref_get(&stream->ref_count);
-}
-
-void bt_ctf_stream_put(struct bt_ctf_stream *stream)
-{
- if (!stream) {
- return;
- }
-
- bt_ctf_ref_put(&stream->ref_count, bt_ctf_stream_destroy);
-}
-
-static
-void bt_ctf_stream_destroy(struct bt_ctf_ref *ref)
-{
- struct bt_ctf_stream *stream;
-
- if (!ref) {
- return;
- }
-
- stream = container_of(ref, struct bt_ctf_stream, ref_count);
- ctf_fini_pos(&stream->pos);
- if (close(stream->pos.fd)) {
- perror("close");
- }
- bt_ctf_stream_class_put(stream->stream_class);
- g_ptr_array_free(stream->events, TRUE);
- g_free(stream);
-}
-
-static
-int set_structure_field_integer(struct bt_ctf_field *structure, char *name,
- uint64_t value)
-{
- int ret = 0;
-
- struct bt_ctf_field *integer =
- bt_ctf_field_structure_get_field(structure, name);
- if (!integer) {
- ret = -1;
- goto end;
- }
-
- ret = bt_ctf_field_unsigned_integer_set_value(integer, value);
-end:
- bt_ctf_field_put(integer);
- return ret;
-}
#include <babeltrace/ctf-ir/event-fields-internal.h>
#include <babeltrace/ctf-writer/functor-internal.h>
#include <babeltrace/ctf-ir/stream-class-internal.h>
-#include <babeltrace/ctf-writer/stream-internal.h>
-#include <babeltrace/ctf-writer/stream.h>
+#include <babeltrace/ctf-ir/stream-internal.h>
+#include <babeltrace/ctf-ir/stream.h>
#include <babeltrace/compiler.h>
#include <stdio.h>
#include <stdlib.h>
babeltrace/ctf-ir/event-fields.h \
babeltrace/ctf-ir/event-types.h \
babeltrace/ctf-ir/event.h \
+ babeltrace/ctf-ir/stream.h \
babeltrace/ctf-ir/stream-class.h
noinst_HEADERS = \
babeltrace/ctf-ir/event-internal.h \
babeltrace/ctf-ir/clock-internal.h \
babeltrace/ctf-ir/stream-class-internal.h \
- babeltrace/ctf-writer/stream-internal.h \
+ babeltrace/ctf-ir/stream-internal.h \
babeltrace/ctf-writer/functor-internal.h \
babeltrace/trace-handle-internal.h \
babeltrace/compat/uuid.h \
--- /dev/null
+#ifndef BABELTRACE_CTF_WRITER_STREAM_INTERNAL_H
+#define BABELTRACE_CTF_WRITER_STREAM_INTERNAL_H
+
+/*
+ * BabelTrace - CTF Writer: Stream internal
+ *
+ * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Author: 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 <babeltrace/ctf-writer/ref-internal.h>
+#include <babeltrace/ctf-writer/clock.h>
+#include <babeltrace/ctf-writer/event-fields.h>
+#include <babeltrace/ctf-writer/event-types.h>
+#include <babeltrace/babeltrace-internal.h>
+#include <babeltrace/ctf/types.h>
+#include <glib.h>
+
+typedef void(*flush_func)(struct bt_ctf_stream *, void *);
+
+struct flush_callback {
+ flush_func func;
+ void *data;
+};
+
+struct bt_ctf_stream {
+ struct bt_ctf_ref ref_count;
+ uint32_t id;
+ struct bt_ctf_stream_class *stream_class;
+ struct flush_callback flush;
+ /* Array of pointers to bt_ctf_event for the current packet */
+ GPtrArray *events;
+ struct ctf_stream_pos pos;
+ unsigned int flushed_packet_count;
+ uint64_t events_discarded;
+};
+
+BT_HIDDEN
+struct bt_ctf_stream *bt_ctf_stream_create(
+ struct bt_ctf_stream_class *stream_class);
+
+BT_HIDDEN
+int bt_ctf_stream_set_flush_callback(struct bt_ctf_stream *stream,
+ flush_func callback, void *data);
+
+BT_HIDDEN
+int bt_ctf_stream_set_fd(struct bt_ctf_stream *stream, int fd);
+
+#endif /* BABELTRACE_CTF_WRITER_STREAM_INTERNAL_H */
--- /dev/null
+#ifndef BABELTRACE_CTF_IR_STREAM_H
+#define BABELTRACE_CTF_IR_STREAM_H
+
+/*
+ * BabelTrace - CTF IR: Stream
+ *
+ * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Author: 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.
+ *
+ * The Common Trace Format (CTF) Specification is available at
+ * http://www.efficios.com/ctf
+ */
+
+#include <babeltrace/ctf-ir/stream-class.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct bt_ctf_event;
+struct bt_ctf_stream;
+
+/*
+ * bt_ctf_stream_append_discarded_events: increment discarded events count.
+ *
+ * Increase the current packet's discarded event count.
+ *
+ * @param stream Stream instance.
+ * @param event_count Number of discarded events to add to the stream's current
+ * packet.
+ */
+extern void bt_ctf_stream_append_discarded_events(struct bt_ctf_stream *stream,
+ uint64_t event_count);
+
+/*
+ * bt_ctf_stream_append_event: append an event to the stream.
+ *
+ * Append "event" to the stream's current packet. The stream's associated clock
+ * will be sampled during this call. The event shall not be modified after
+ * being appended to a stream. The stream will share the event's ownership by
+ * incrementing its reference count. The current packet is not flushed to disk
+ * until the next call to bt_ctf_stream_flush.
+ *
+ * @param stream Stream instance.
+ * @param event Event instance to append to the stream's current packet.
+ *
+ * Returns 0 on success, a negative value on error.
+ */
+extern int bt_ctf_stream_append_event(struct bt_ctf_stream *stream,
+ struct bt_ctf_event *event);
+
+/*
+ * bt_ctf_stream_flush: flush a stream.
+ *
+ * The stream's current packet's events will be flushed to disk. Events
+ * subsequently appended to the stream will be added to a new packet.
+ *
+ * @param stream Stream instance.
+ *
+ * Returns 0 on success, a negative value on error.
+ */
+extern int bt_ctf_stream_flush(struct bt_ctf_stream *stream);
+
+/*
+ * bt_ctf_stream_get and bt_ctf_stream_put: increment and decrement the
+ * stream's reference count.
+ *
+ * These functions ensure that the stream won't be destroyed while it
+ * is in use. The same number of get and put (plus one extra put to
+ * release the initial reference done at creation) have to be done to
+ * destroy a stream.
+ *
+ * When the stream's reference count is decremented to 0 by a
+ * bt_ctf_stream_put, the stream is freed.
+ *
+ * @param stream Stream instance.
+ */
+extern void bt_ctf_stream_get(struct bt_ctf_stream *stream);
+extern void bt_ctf_stream_put(struct bt_ctf_stream *stream);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_CTF_IR_STREAM_H */
+++ /dev/null
-#ifndef BABELTRACE_CTF_WRITER_STREAM_INTERNAL_H
-#define BABELTRACE_CTF_WRITER_STREAM_INTERNAL_H
-
-/*
- * BabelTrace - CTF Writer: Stream internal
- *
- * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * Author: 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 <babeltrace/ctf-writer/ref-internal.h>
-#include <babeltrace/ctf-writer/clock.h>
-#include <babeltrace/ctf-writer/event-fields.h>
-#include <babeltrace/ctf-writer/event-types.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/ctf/types.h>
-#include <glib.h>
-
-typedef void(*flush_func)(struct bt_ctf_stream *, void *);
-
-struct flush_callback {
- flush_func func;
- void *data;
-};
-
-struct bt_ctf_stream {
- struct bt_ctf_ref ref_count;
- uint32_t id;
- struct bt_ctf_stream_class *stream_class;
- struct flush_callback flush;
- /* Array of pointers to bt_ctf_event for the current packet */
- GPtrArray *events;
- struct ctf_stream_pos pos;
- unsigned int flushed_packet_count;
- uint64_t events_discarded;
-};
-
-BT_HIDDEN
-struct bt_ctf_stream *bt_ctf_stream_create(
- struct bt_ctf_stream_class *stream_class);
-
-BT_HIDDEN
-int bt_ctf_stream_set_flush_callback(struct bt_ctf_stream *stream,
- flush_func callback, void *data);
-
-BT_HIDDEN
-int bt_ctf_stream_set_fd(struct bt_ctf_stream *stream, int fd);
-
-#endif /* BABELTRACE_CTF_WRITER_STREAM_INTERNAL_H */
-#ifndef BABELTRACE_CTF_WRITER_STREAM_H
-#define BABELTRACE_CTF_WRITER_STREAM_H
-
/*
* BabelTrace - CTF Writer: Stream
*
* http://www.efficios.com/ctf
*/
-#include <babeltrace/ctf-writer/stream-class.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct bt_ctf_event;
-struct bt_ctf_stream;
-
-/*
- * bt_ctf_stream_append_discarded_events: increment discarded events count.
- *
- * Increase the current packet's discarded event count.
- *
- * @param stream Stream instance.
- * @param event_count Number of discarded events to add to the stream's current
- * packet.
- */
-extern void bt_ctf_stream_append_discarded_events(struct bt_ctf_stream *stream,
- uint64_t event_count);
-
-/*
- * bt_ctf_stream_append_event: append an event to the stream.
- *
- * Append "event" to the stream's current packet. The stream's associated clock
- * will be sampled during this call. The event shall not be modified after
- * being appended to a stream. The stream will share the event's ownership by
- * incrementing its reference count. The current packet is not flushed to disk
- * until the next call to bt_ctf_stream_flush.
- *
- * @param stream Stream instance.
- * @param event Event instance to append to the stream's current packet.
- *
- * Returns 0 on success, a negative value on error.
- */
-extern int bt_ctf_stream_append_event(struct bt_ctf_stream *stream,
- struct bt_ctf_event *event);
-
-/*
- * bt_ctf_stream_flush: flush a stream.
- *
- * The stream's current packet's events will be flushed to disk. Events
- * subsequently appended to the stream will be added to a new packet.
- *
- * @param stream Stream instance.
- *
- * Returns 0 on success, a negative value on error.
- */
-extern int bt_ctf_stream_flush(struct bt_ctf_stream *stream);
-
-/*
- * bt_ctf_stream_get and bt_ctf_stream_put: increment and decrement the
- * stream's reference count.
- *
- * These functions ensure that the stream won't be destroyed while it
- * is in use. The same number of get and put (plus one extra put to
- * release the initial reference done at creation) have to be done to
- * destroy a stream.
- *
- * When the stream's reference count is decremented to 0 by a
- * bt_ctf_stream_put, the stream is freed.
- *
- * @param stream Stream instance.
- */
-extern void bt_ctf_stream_get(struct bt_ctf_stream *stream);
-extern void bt_ctf_stream_put(struct bt_ctf_stream *stream);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_CTF_WRITER_STREAM_H */
+#include <babeltrace/ctf-ir/stream.h>