#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>
+#include <stdint.h>
static
void bt_ctf_stream_class_destroy(struct bt_object *obj);
int64_t ret;
if (!stream_class || !stream_class->id_set) {
- ret = -1;
+ ret = (int64_t) -1;
goto end;
}
- ret = (int64_t) stream_class->id;
+ ret = stream_class->id;
end:
return ret;
}
BT_HIDDEN
int _bt_ctf_stream_class_set_id(
- struct bt_ctf_stream_class *stream_class, uint32_t id)
+ struct bt_ctf_stream_class *stream_class, int64_t id)
{
stream_class->id = id;
stream_class->id_set = 1;
return 0;
}
-struct event_class_set_stream_id_data {
- uint32_t stream_id;
+struct event_class_set_stream_class_id_data {
+ int64_t stream_class_id;
int ret;
};
static
void event_class_set_stream_id(gpointer event_class, gpointer data)
{
- struct event_class_set_stream_id_data *typed_data = data;
+ struct event_class_set_stream_class_id_data *typed_data = data;
typed_data->ret |= bt_ctf_event_class_set_stream_id(event_class,
- typed_data->stream_id);
+ typed_data->stream_class_id);
}
BT_HIDDEN
int bt_ctf_stream_class_set_id_no_check(
- struct bt_ctf_stream_class *stream_class, uint32_t id)
+ struct bt_ctf_stream_class *stream_class, int64_t id)
{
int ret = 0;
- struct event_class_set_stream_id_data data =
- { .stream_id = id, .ret = 0 };
+ struct event_class_set_stream_class_id_data data =
+ { .stream_class_id = id, .ret = 0 };
/*
* Make sure all event classes have their "stream_id" attribute
}
int bt_ctf_stream_class_set_id(struct bt_ctf_stream_class *stream_class,
- uint32_t id)
+ uint64_t id_param)
{
int ret = 0;
+ int64_t id = (int64_t) id_param;
- if (!stream_class || stream_class->frozen) {
+ if (!stream_class || stream_class->frozen || id < 0) {
ret = -1;
goto end;
}
goto end;
}
- /*
- * Two event classes cannot share the same name in a given
- * stream class.
- */
- if (!strcmp(bt_ctf_event_class_get_name(event_class_a),
- bt_ctf_event_class_get_name(event_class_b))) {
- search_query->found = 1;
- goto end;
- }
-
/*
* Two event classes cannot share the same ID in a given
* stream class.
goto end;
}
+ trace = bt_ctf_stream_class_get_trace(stream_class);
+ if (trace && trace->is_static) {
+ ret = -1;
+ goto end;
+ }
+
event_id = g_new(int64_t, 1);
if (!event_id) {
ret = -1;
goto end;
}
- trace = bt_ctf_stream_class_get_trace(stream_class);
if (trace) {
/*
* If the stream class is associated with a trace, then
return ret;
}
-int bt_ctf_stream_class_get_event_class_count(
+int64_t bt_ctf_stream_class_get_event_class_count(
struct bt_ctf_stream_class *stream_class)
{
- int ret;
+ int64_t ret;
if (!stream_class) {
- ret = -1;
+ ret = (int64_t) -1;
goto end;
}
- ret = (int) stream_class->event_classes->len;
+ ret = (int64_t) stream_class->event_classes->len;
end:
return ret;
}
-struct bt_ctf_event_class *bt_ctf_stream_class_get_event_class(
- struct bt_ctf_stream_class *stream_class, int index)
+struct bt_ctf_event_class *bt_ctf_stream_class_get_event_class_by_index(
+ struct bt_ctf_stream_class *stream_class, uint64_t index)
{
struct bt_ctf_event_class *event_class = NULL;
- if (!stream_class || index < 0 ||
- index >= stream_class->event_classes->len) {
+ if (!stream_class || index >= stream_class->event_classes->len) {
goto end;
}
return event_class;
}
-struct bt_ctf_event_class *bt_ctf_stream_class_get_event_class_by_name(
- struct bt_ctf_stream_class *stream_class, const char *name)
-{
- size_t i;
- struct bt_ctf_event_class *event_class = NULL;
-
- if (!stream_class || !name) {
- goto end;
- }
-
- for (i = 0; i < stream_class->event_classes->len; i++) {
- struct bt_ctf_event_class *cur_event_class =
- g_ptr_array_index(stream_class->event_classes, i);
- const char *cur_event_class_name =
- bt_ctf_event_class_get_name(cur_event_class);
-
- if (!strcmp(name, cur_event_class_name)) {
- event_class = cur_event_class;
- bt_get(event_class);
- goto end;
- }
- }
-end:
- return event_class;
-}
-
struct bt_ctf_event_class *bt_ctf_stream_class_get_event_class_by_id(
- struct bt_ctf_stream_class *stream_class, uint32_t id)
+ struct bt_ctf_stream_class *stream_class, uint64_t id)
{
- int64_t id_key = id;
+ int64_t id_key = (int64_t) id;
struct bt_ctf_event_class *event_class = NULL;
- if (!stream_class) {
+ if (!stream_class || id_key < 0) {
goto end;
}
if (packet_context_type &&
bt_ctf_field_type_get_type_id(packet_context_type) !=
- BT_CTF_TYPE_ID_STRUCT) {
+ BT_CTF_FIELD_TYPE_ID_STRUCT) {
/* A packet context must be a structure. */
ret = -1;
goto end;
if (event_header_type &&
bt_ctf_field_type_get_type_id(event_header_type) !=
- BT_CTF_TYPE_ID_STRUCT) {
+ BT_CTF_FIELD_TYPE_ID_STRUCT) {
/* An event header must be a structure. */
ret = -1;
goto end;
if (event_context_type &&
bt_ctf_field_type_get_type_id(event_context_type) !=
- BT_CTF_TYPE_ID_STRUCT) {
+ BT_CTF_FIELD_TYPE_ID_STRUCT) {
/* A packet context must be a structure. */
ret = -1;
goto end;
}
static
-int get_event_class_count(void *element)
+int64_t get_event_class_count(void *element)
{
return bt_ctf_stream_class_get_event_class_count(
(struct bt_ctf_stream_class *) element);
static
void *get_event_class(void *element, int i)
{
- return bt_ctf_stream_class_get_event_class(
+ return bt_ctf_stream_class_get_event_class_by_index(
(struct bt_ctf_stream_class *) element, i);
}
int bt_ctf_stream_class_serialize(struct bt_ctf_stream_class *stream_class,
struct metadata_context *context)
{
- int64_t ret = 0;
+ int ret = 0;
size_t i;
g_string_assign(context->field_name, "");
}
g_string_append_printf(context->string,
- "stream {\n\tid = %" PRIu32 ";\n\tevent.header := ",
+ "stream {\n\tid = %" PRId64 ";\n\tevent.header := ",
stream_class->id);
ret = bt_ctf_field_type_serialize(stream_class->event_header_type,
context);