From 3f043b0587e8c2bc1f8921438c112e41fa54db8f Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Fri, 27 Jun 2014 13:55:34 -0400 Subject: [PATCH] Move CTF-Writer stream to CTF-IR MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérémie Galarneau --- formats/ctf/ir/Makefile.am | 1 + formats/ctf/ir/stream-class.c | 2 +- formats/ctf/{writer => ir}/stream.c | 6 +- formats/ctf/writer/Makefile.am | 1 - formats/ctf/writer/writer.c | 4 +- include/Makefile.am | 3 +- .../{ctf-writer => ctf-ir}/stream-internal.h | 0 include/babeltrace/ctf-ir/stream.h | 104 ++++++++++++++++++ include/babeltrace/ctf-writer/stream.h | 76 +------------ 9 files changed, 114 insertions(+), 83 deletions(-) rename formats/ctf/{writer => ir}/stream.c (98%) rename include/babeltrace/{ctf-writer => ctf-ir}/stream-internal.h (100%) create mode 100644 include/babeltrace/ctf-ir/stream.h diff --git a/formats/ctf/ir/Makefile.am b/formats/ctf/ir/Makefile.am index 0247445c..295cc809 100644 --- a/formats/ctf/ir/Makefile.am +++ b/formats/ctf/ir/Makefile.am @@ -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 = \ diff --git a/formats/ctf/ir/stream-class.c b/formats/ctf/ir/stream-class.c index 67015978..a1115c22 100644 --- a/formats/ctf/ir/stream-class.c +++ b/formats/ctf/ir/stream-class.c @@ -1,5 +1,5 @@ /* - * stream.c + * stream-class.c * * Babeltrace CTF Writer * diff --git a/formats/ctf/writer/stream.c b/formats/ctf/ir/stream.c similarity index 98% rename from formats/ctf/writer/stream.c rename to formats/ctf/ir/stream.c index 7a2af5ac..4b4e3106 100644 --- a/formats/ctf/writer/stream.c +++ b/formats/ctf/ir/stream.c @@ -26,14 +26,14 @@ * SOFTWARE. */ -#include +#include #include #include #include #include #include -#include -#include +#include +#include #include #include #include diff --git a/formats/ctf/writer/Makefile.am b/formats/ctf/writer/Makefile.am index 6f791f55..1f06c1af 100644 --- a/formats/ctf/writer/Makefile.am +++ b/formats/ctf/writer/Makefile.am @@ -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/writer.c b/formats/ctf/writer/writer.c index 57236bd9..a1605fce 100644 --- a/formats/ctf/writer/writer.c +++ b/formats/ctf/writer/writer.c @@ -34,8 +34,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include diff --git a/include/Makefile.am b/include/Makefile.am index 3e322666..00364dc8 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -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-writer/stream-internal.h b/include/babeltrace/ctf-ir/stream-internal.h similarity index 100% rename from include/babeltrace/ctf-writer/stream-internal.h rename to include/babeltrace/ctf-ir/stream-internal.h diff --git a/include/babeltrace/ctf-ir/stream.h b/include/babeltrace/ctf-ir/stream.h new file mode 100644 index 00000000..0341e78e --- /dev/null +++ b/include/babeltrace/ctf-ir/stream.h @@ -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 + * + * Author: Jérémie Galarneau + * + * 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 + +#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.h b/include/babeltrace/ctf-writer/stream.h index df251fcc..a878cae6 100644 --- a/include/babeltrace/ctf-writer/stream.h +++ b/include/babeltrace/ctf-writer/stream.h @@ -1,6 +1,3 @@ -#ifndef BABELTRACE_CTF_WRITER_STREAM_H -#define BABELTRACE_CTF_WRITER_STREAM_H - /* * BabelTrace - CTF Writer: Stream * @@ -30,75 +27,4 @@ * http://www.efficios.com/ctf */ -#include - -#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 -- 2.34.1