Move CTF-Writer stream to CTF-IR
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 27 Jun 2014 17:55:34 +0000 (13:55 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sat, 28 Jun 2014 21:13:06 +0000 (17:13 -0400)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
formats/ctf/ir/Makefile.am
formats/ctf/ir/stream-class.c
formats/ctf/ir/stream.c [new file with mode: 0644]
formats/ctf/writer/Makefile.am
formats/ctf/writer/stream.c [deleted file]
formats/ctf/writer/writer.c
include/Makefile.am
include/babeltrace/ctf-ir/stream-internal.h [new file with mode: 0644]
include/babeltrace/ctf-ir/stream.h [new file with mode: 0644]
include/babeltrace/ctf-writer/stream-internal.h [deleted file]
include/babeltrace/ctf-writer/stream.h

index 0247445c561c993179ab925bde85693654a0e5c9..295cc809c659860c427d2157a6eefb7cde0de61c 100644 (file)
@@ -7,6 +7,7 @@ libctf_ir_la_SOURCES = \
        event.c \
        event-fields.c \
        event-types.c \
+       stream.c \
        stream-class.c
 
 libctf_ir_la_LIBADD = \
index 67015978399eb35e2e13b354412d4bb9279ef57d..a1115c221b6620877e676e3f9adcd5a9872b7d16 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * stream.c
+ * stream-class.c
  *
  * Babeltrace CTF Writer
  *
diff --git a/formats/ctf/ir/stream.c b/formats/ctf/ir/stream.c
new file mode 100644 (file)
index 0000000..4b4e310
--- /dev/null
@@ -0,0 +1,328 @@
+/*
+ * 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;
+}
index 6f791f555c888f324a3c7b77030a3812a4f36f1a..1f06c1afb5e56e528c038740ecd0b1417caa7d53 100644 (file)
@@ -4,7 +4,6 @@ noinst_LTLIBRARIES = libctf-writer.la
 
 libctf_writer_la_SOURCES = \
        writer.c \
-       stream.c \
        functor.c
 
 libctf_writer_la_LIBADD = \
diff --git a/formats/ctf/writer/stream.c b/formats/ctf/writer/stream.c
deleted file mode 100644 (file)
index 7a2af5a..0000000
+++ /dev/null
@@ -1,328 +0,0 @@
-/*
- * 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;
-}
index 57236bd94186baa0c3e562cb1a49834191b39971..a1605fcee198fd2561fb9d0ec1f4d5c7c9908a45 100644 (file)
@@ -34,8 +34,8 @@
 #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>
index 3e322666ed385b6348a65dd9aa99100ea8015ca0..00364dc830236fb0e06cad4766f1622672ef2f53 100644 (file)
@@ -26,6 +26,7 @@ babeltracectfirinclude_HEADERS = \
        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 = \
@@ -54,7 +55,7 @@ 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 \
diff --git a/include/babeltrace/ctf-ir/stream-internal.h b/include/babeltrace/ctf-ir/stream-internal.h
new file mode 100644 (file)
index 0000000..daaa430
--- /dev/null
@@ -0,0 +1,68 @@
+#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 */
diff --git a/include/babeltrace/ctf-ir/stream.h b/include/babeltrace/ctf-ir/stream.h
new file mode 100644 (file)
index 0000000..0341e78
--- /dev/null
@@ -0,0 +1,104 @@
+#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 */
diff --git a/include/babeltrace/ctf-writer/stream-internal.h b/include/babeltrace/ctf-writer/stream-internal.h
deleted file mode 100644 (file)
index daaa430..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-#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 */
index df251fcc092a6f3f7f9ba19c3a3cdc3a6fcd6c8c..a878cae63e53834f21d83ea408f4b45597923855 100644 (file)
@@ -1,6 +1,3 @@
-#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>
This page took 0.036275 seconds and 4 git commands to generate.