Re-format new C++ files
[babeltrace.git] / src / plugins / ctf / common / metadata / ctf-meta.hpp
CommitLineData
44c440bc 1/*
0235b0db 2 * SPDX-License-Identifier: MIT
44c440bc 3 *
0235b0db 4 * Copyright 2018 Philippe Proulx <pproulx@efficios.com>
44c440bc
PP
5 */
6
0235b0db
MJ
7#ifndef _CTF_META_H
8#define _CTF_META_H
9
3fadfbc0 10#include <babeltrace2/babeltrace.h>
578e048b 11#include "common/common.h"
6162e6b7 12#include "common/uuid.h"
578e048b 13#include "common/assert.h"
44c440bc 14#include <glib.h>
c4f23e30 15#include <stdbool.h>
44c440bc
PP
16#include <stdint.h>
17#include <string.h>
18
4164020e
SM
19enum ctf_field_class_type
20{
21 CTF_FIELD_CLASS_TYPE_INT,
22 CTF_FIELD_CLASS_TYPE_ENUM,
23 CTF_FIELD_CLASS_TYPE_FLOAT,
24 CTF_FIELD_CLASS_TYPE_STRING,
25 CTF_FIELD_CLASS_TYPE_STRUCT,
26 CTF_FIELD_CLASS_TYPE_ARRAY,
27 CTF_FIELD_CLASS_TYPE_SEQUENCE,
28 CTF_FIELD_CLASS_TYPE_VARIANT,
44c440bc
PP
29};
30
4164020e
SM
31enum ctf_field_class_meaning
32{
33 CTF_FIELD_CLASS_MEANING_NONE,
34 CTF_FIELD_CLASS_MEANING_PACKET_BEGINNING_TIME,
35 CTF_FIELD_CLASS_MEANING_PACKET_END_TIME,
36 CTF_FIELD_CLASS_MEANING_EVENT_CLASS_ID,
37 CTF_FIELD_CLASS_MEANING_STREAM_CLASS_ID,
38 CTF_FIELD_CLASS_MEANING_DATA_STREAM_ID,
39 CTF_FIELD_CLASS_MEANING_MAGIC,
40 CTF_FIELD_CLASS_MEANING_PACKET_COUNTER_SNAPSHOT,
41 CTF_FIELD_CLASS_MEANING_DISC_EV_REC_COUNTER_SNAPSHOT,
42 CTF_FIELD_CLASS_MEANING_EXP_PACKET_TOTAL_SIZE,
43 CTF_FIELD_CLASS_MEANING_EXP_PACKET_CONTENT_SIZE,
44 CTF_FIELD_CLASS_MEANING_UUID,
44c440bc
PP
45};
46
4164020e
SM
47enum ctf_byte_order
48{
49 CTF_BYTE_ORDER_UNKNOWN,
50 CTF_BYTE_ORDER_DEFAULT,
51 CTF_BYTE_ORDER_LITTLE,
52 CTF_BYTE_ORDER_BIG,
44c440bc
PP
53};
54
4164020e
SM
55enum ctf_encoding
56{
57 CTF_ENCODING_NONE,
58 CTF_ENCODING_UTF8,
44c440bc
PP
59};
60
4164020e
SM
61enum ctf_scope
62{
63 CTF_SCOPE_PACKET_UNKNOWN = -1,
64 CTF_SCOPE_PACKET_HEADER = 0,
65 CTF_SCOPE_PACKET_CONTEXT,
66 CTF_SCOPE_EVENT_HEADER,
67 CTF_SCOPE_EVENT_COMMON_CONTEXT,
68 CTF_SCOPE_EVENT_SPECIFIC_CONTEXT,
69 CTF_SCOPE_EVENT_PAYLOAD,
83ebb7f1
PP
70};
71
4164020e
SM
72struct ctf_clock_class
73{
74 GString *name;
75 GString *description;
76 uint64_t frequency;
77 uint64_t precision;
78 int64_t offset_seconds;
79 uint64_t offset_cycles;
80 bt_uuid_t uuid;
81 bool has_uuid;
82 bool is_absolute;
83
84 /* Weak, set during translation */
85 bt_clock_class *ir_cc;
0f2d58c9
PP
86};
87
4164020e
SM
88struct ctf_field_class
89{
90 enum ctf_field_class_type type;
91 unsigned int alignment;
92 bool is_compound;
93 bool in_ir;
44c440bc 94
4164020e
SM
95 /* Weak, set during translation. NULL if `in_ir` is false below. */
96 bt_field_class *ir_fc;
44c440bc
PP
97};
98
4164020e
SM
99struct ctf_field_class_bit_array
100{
101 struct ctf_field_class base;
102 enum ctf_byte_order byte_order;
103 unsigned int size;
44c440bc
PP
104};
105
4164020e
SM
106struct ctf_field_class_int
107{
108 struct ctf_field_class_bit_array base;
109 enum ctf_field_class_meaning meaning;
110 bool is_signed;
111 bt_field_class_integer_preferred_display_base disp_base;
112 enum ctf_encoding encoding;
113 int64_t storing_index;
44c440bc 114
4164020e
SM
115 /* Weak */
116 struct ctf_clock_class *mapped_clock_class;
44c440bc
PP
117};
118
4164020e
SM
119struct ctf_range
120{
121 union
122 {
123 uint64_t u;
124 int64_t i;
125 } lower;
44c440bc 126
4164020e
SM
127 union
128 {
129 uint64_t u;
130 int64_t i;
131 } upper;
44c440bc
PP
132};
133
4164020e
SM
134struct ctf_field_class_enum_mapping
135{
136 GString *label;
45c51519 137
4164020e
SM
138 /* Array of `struct ctf_range` */
139 GArray *ranges;
44c440bc
PP
140};
141
4164020e
SM
142struct ctf_field_class_enum
143{
144 struct ctf_field_class_int base;
44c440bc 145
4164020e
SM
146 /* Array of `struct ctf_field_class_enum_mapping` */
147 GArray *mappings;
44c440bc
PP
148};
149
4164020e
SM
150struct ctf_field_class_float
151{
152 struct ctf_field_class_bit_array base;
44c440bc
PP
153};
154
4164020e
SM
155struct ctf_field_class_string
156{
157 struct ctf_field_class base;
158 enum ctf_encoding encoding;
44c440bc
PP
159};
160
4164020e
SM
161struct ctf_named_field_class
162{
163 /* Original name which can include a leading `_` */
164 GString *orig_name;
45c51519 165
4164020e
SM
166 /* Name as translated to trace IR (leading `_` removed) */
167 GString *name;
44c440bc 168
4164020e
SM
169 /* Owned by this */
170 struct ctf_field_class *fc;
44c440bc
PP
171};
172
4164020e
SM
173struct ctf_field_class_struct
174{
175 struct ctf_field_class base;
44c440bc 176
4164020e
SM
177 /* Array of `struct ctf_named_field_class` */
178 GArray *members;
44c440bc
PP
179};
180
4164020e
SM
181struct ctf_field_path
182{
183 enum ctf_scope root;
44c440bc 184
4164020e
SM
185 /* Array of `int64_t` */
186 GArray *path;
44c440bc
PP
187};
188
4164020e
SM
189struct ctf_field_class_variant_range
190{
191 struct ctf_range range;
192 uint64_t option_index;
44c440bc
PP
193};
194
4164020e
SM
195struct ctf_field_class_variant
196{
197 struct ctf_field_class base;
198 GString *tag_ref;
199 struct ctf_field_path tag_path;
200 uint64_t stored_tag_index;
44c440bc 201
4164020e
SM
202 /* Array of `struct ctf_named_field_class` */
203 GArray *options;
44c440bc 204
4164020e
SM
205 /* Array of `struct ctf_field_class_variant_range` */
206 GArray *ranges;
44c440bc 207
4164020e
SM
208 /* Weak */
209 struct ctf_field_class_enum *tag_fc;
44c440bc
PP
210};
211
4164020e
SM
212struct ctf_field_class_array_base
213{
214 struct ctf_field_class base;
215 struct ctf_field_class *elem_fc;
216 bool is_text;
44c440bc
PP
217};
218
4164020e
SM
219struct ctf_field_class_array
220{
221 struct ctf_field_class_array_base base;
222 enum ctf_field_class_meaning meaning;
223 uint64_t length;
44c440bc
PP
224};
225
4164020e
SM
226struct ctf_field_class_sequence
227{
228 struct ctf_field_class_array_base base;
229 GString *length_ref;
230 struct ctf_field_path length_path;
231 uint64_t stored_length_index;
44c440bc 232
4164020e
SM
233 /* Weak */
234 struct ctf_field_class_int *length_fc;
44c440bc
PP
235};
236
4164020e
SM
237struct ctf_event_class
238{
239 GString *name;
240 uint64_t id;
241 GString *emf_uri;
242 bt_event_class_log_level log_level;
243 bool is_translated;
244 bool is_log_level_set;
44c440bc 245
4164020e
SM
246 /* Owned by this */
247 struct ctf_field_class *spec_context_fc;
44c440bc 248
4164020e
SM
249 /* Owned by this */
250 struct ctf_field_class *payload_fc;
44c440bc 251
4164020e
SM
252 /* Weak, set during translation */
253 bt_event_class *ir_ec;
44c440bc
PP
254};
255
4164020e
SM
256struct ctf_stream_class
257{
258 uint64_t id;
259 bool is_translated;
260 bool packets_have_ts_begin;
261 bool packets_have_ts_end;
262 bool has_discarded_events;
263 bool has_discarded_packets;
264 bool discarded_events_have_default_cs;
265 bool discarded_packets_have_default_cs;
44c440bc 266
4164020e
SM
267 /* Owned by this */
268 struct ctf_field_class *packet_context_fc;
44c440bc 269
4164020e
SM
270 /* Owned by this */
271 struct ctf_field_class *event_header_fc;
44c440bc 272
4164020e
SM
273 /* Owned by this */
274 struct ctf_field_class *event_common_context_fc;
44c440bc 275
4164020e
SM
276 /* Array of `struct ctf_event_class *`, owned by this */
277 GPtrArray *event_classes;
44c440bc 278
4164020e
SM
279 /*
280 * Hash table mapping event class IDs to `struct ctf_event_class *`,
281 * weak.
282 */
283 GHashTable *event_classes_by_id;
44c440bc 284
4164020e
SM
285 /* Weak */
286 struct ctf_clock_class *default_clock_class;
44c440bc 287
4164020e
SM
288 /* Weak, set during translation */
289 bt_stream_class *ir_sc;
44c440bc
PP
290};
291
4164020e
SM
292enum ctf_trace_class_env_entry_type
293{
294 CTF_TRACE_CLASS_ENV_ENTRY_TYPE_INT,
295 CTF_TRACE_CLASS_ENV_ENTRY_TYPE_STR,
44c440bc
PP
296};
297
4164020e
SM
298struct ctf_trace_class_env_entry
299{
300 enum ctf_trace_class_env_entry_type type;
301 GString *name;
44c440bc 302
4164020e
SM
303 struct
304 {
305 int64_t i;
306 GString *str;
307 } value;
44c440bc
PP
308};
309
4164020e
SM
310struct ctf_trace_class
311{
312 unsigned int major;
313 unsigned int minor;
314 bt_uuid_t uuid;
315 bool is_uuid_set;
316 enum ctf_byte_order default_byte_order;
44c440bc 317
4164020e
SM
318 /* Owned by this */
319 struct ctf_field_class *packet_header_fc;
44c440bc 320
4164020e 321 uint64_t stored_value_count;
44c440bc 322
4164020e
SM
323 /* Array of `struct ctf_clock_class *` (owned by this) */
324 GPtrArray *clock_classes;
44c440bc 325
4164020e
SM
326 /* Array of `struct ctf_stream_class *` */
327 GPtrArray *stream_classes;
44c440bc 328
4164020e
SM
329 /* Array of `struct ctf_trace_class_env_entry` */
330 GArray *env_entries;
44c440bc 331
4164020e 332 bool is_translated;
44c440bc 333
4164020e
SM
334 /* Weak, set during translation */
335 bt_trace_class *ir_tc;
5c2e8153 336
4164020e
SM
337 struct
338 {
339 bool lttng_crash;
340 bool lttng_event_after_packet;
341 bool barectf_event_before_packet;
342 } quirks;
44c440bc
PP
343};
344
4164020e 345static inline ctf_field_class_bit_array *ctf_field_class_as_bit_array(ctf_field_class *fc)
087cd0f5 346{
4164020e
SM
347 BT_ASSERT_DBG(!fc ||
348 (fc->type == CTF_FIELD_CLASS_TYPE_INT || fc->type == CTF_FIELD_CLASS_TYPE_ENUM ||
349 fc->type == CTF_FIELD_CLASS_TYPE_FLOAT));
350 return (ctf_field_class_bit_array *) fc;
087cd0f5
SM
351}
352
4164020e 353static inline ctf_field_class_int *ctf_field_class_as_int(ctf_field_class *fc)
087cd0f5 354{
4164020e
SM
355 BT_ASSERT_DBG(!fc ||
356 (fc->type == CTF_FIELD_CLASS_TYPE_INT || fc->type == CTF_FIELD_CLASS_TYPE_ENUM));
357 return (ctf_field_class_int *) fc;
087cd0f5
SM
358}
359
4164020e 360static inline ctf_field_class_enum *ctf_field_class_as_enum(ctf_field_class *fc)
087cd0f5 361{
4164020e
SM
362 BT_ASSERT_DBG(!fc || fc->type == CTF_FIELD_CLASS_TYPE_ENUM);
363 return (ctf_field_class_enum *) fc;
087cd0f5
SM
364}
365
4164020e 366static inline ctf_field_class_float *ctf_field_class_as_float(ctf_field_class *fc)
087cd0f5 367{
4164020e
SM
368 BT_ASSERT_DBG(!fc || fc->type == CTF_FIELD_CLASS_TYPE_FLOAT);
369 return (ctf_field_class_float *) fc;
087cd0f5
SM
370}
371
4164020e 372static inline ctf_field_class_string *ctf_field_class_as_string(ctf_field_class *fc)
087cd0f5 373{
4164020e
SM
374 BT_ASSERT_DBG(!fc || fc->type == CTF_FIELD_CLASS_TYPE_STRING);
375 return (ctf_field_class_string *) fc;
087cd0f5
SM
376}
377
4164020e 378static inline ctf_field_class_struct *ctf_field_class_as_struct(ctf_field_class *fc)
087cd0f5 379{
4164020e
SM
380 BT_ASSERT_DBG(!fc || fc->type == CTF_FIELD_CLASS_TYPE_STRUCT);
381 return (ctf_field_class_struct *) fc;
087cd0f5
SM
382}
383
4164020e 384static inline ctf_field_class_array_base *ctf_field_class_as_array_base(ctf_field_class *fc)
087cd0f5 385{
4164020e
SM
386 BT_ASSERT_DBG(!fc || (fc->type == CTF_FIELD_CLASS_TYPE_ARRAY ||
387 fc->type == CTF_FIELD_CLASS_TYPE_SEQUENCE));
388 return (ctf_field_class_array_base *) fc;
087cd0f5
SM
389}
390
4164020e 391static inline ctf_field_class_array *ctf_field_class_as_array(ctf_field_class *fc)
087cd0f5 392{
4164020e
SM
393 BT_ASSERT_DBG(!fc || fc->type == CTF_FIELD_CLASS_TYPE_ARRAY);
394 return (ctf_field_class_array *) fc;
087cd0f5
SM
395}
396
4164020e 397static inline ctf_field_class_sequence *ctf_field_class_as_sequence(ctf_field_class *fc)
087cd0f5 398{
4164020e
SM
399 BT_ASSERT_DBG(!fc || fc->type == CTF_FIELD_CLASS_TYPE_SEQUENCE);
400 return (ctf_field_class_sequence *) fc;
087cd0f5
SM
401}
402
4164020e 403static inline ctf_field_class_variant *ctf_field_class_as_variant(ctf_field_class *fc)
087cd0f5 404{
4164020e
SM
405 BT_ASSERT_DBG(!fc || fc->type == CTF_FIELD_CLASS_TYPE_VARIANT);
406 return (ctf_field_class_variant *) fc;
087cd0f5
SM
407}
408
4164020e 409static inline void ctf_field_class_destroy(struct ctf_field_class *fc);
087cd0f5 410
4164020e
SM
411static inline void _ctf_field_class_init(struct ctf_field_class *fc, enum ctf_field_class_type type,
412 unsigned int alignment)
44c440bc 413{
4164020e
SM
414 BT_ASSERT(fc);
415 fc->type = type;
416 fc->alignment = alignment;
417 fc->in_ir = false;
44c440bc
PP
418}
419
4164020e
SM
420static inline void _ctf_field_class_bit_array_init(struct ctf_field_class_bit_array *fc,
421 enum ctf_field_class_type type)
44c440bc 422{
4164020e 423 _ctf_field_class_init(&fc->base, type, 1);
44c440bc
PP
424}
425
4164020e
SM
426static inline void _ctf_field_class_int_init(struct ctf_field_class_int *fc,
427 enum ctf_field_class_type type)
44c440bc 428{
4164020e
SM
429 _ctf_field_class_bit_array_init(&fc->base, type);
430 fc->meaning = CTF_FIELD_CLASS_MEANING_NONE;
431 fc->storing_index = -1;
44c440bc
PP
432}
433
4164020e 434static inline void ctf_field_path_init(struct ctf_field_path *field_path)
44c440bc 435{
4164020e
SM
436 BT_ASSERT(field_path);
437 field_path->path = g_array_new(FALSE, TRUE, sizeof(int64_t));
438 BT_ASSERT(field_path->path);
44c440bc
PP
439}
440
4164020e 441static inline void ctf_field_path_fini(struct ctf_field_path *field_path)
44c440bc 442{
4164020e 443 BT_ASSERT(field_path);
44c440bc 444
4164020e
SM
445 if (field_path->path) {
446 g_array_free(field_path->path, TRUE);
447 }
44c440bc
PP
448}
449
4164020e 450static inline void _ctf_named_field_class_init(struct ctf_named_field_class *named_fc)
44c440bc 451{
4164020e
SM
452 BT_ASSERT(named_fc);
453 named_fc->name = g_string_new(NULL);
454 BT_ASSERT(named_fc->name);
455 named_fc->orig_name = g_string_new(NULL);
456 BT_ASSERT(named_fc->orig_name);
44c440bc
PP
457}
458
4164020e 459static inline void _ctf_named_field_class_fini(struct ctf_named_field_class *named_fc)
44c440bc 460{
4164020e 461 BT_ASSERT(named_fc);
44c440bc 462
4164020e
SM
463 if (named_fc->name) {
464 g_string_free(named_fc->name, TRUE);
465 }
44c440bc 466
4164020e
SM
467 if (named_fc->orig_name) {
468 g_string_free(named_fc->orig_name, TRUE);
469 }
45c51519 470
4164020e 471 ctf_field_class_destroy(named_fc->fc);
44c440bc
PP
472}
473
4164020e 474static inline void _ctf_field_class_enum_mapping_init(struct ctf_field_class_enum_mapping *mapping)
44c440bc 475{
4164020e
SM
476 BT_ASSERT(mapping);
477 mapping->label = g_string_new(NULL);
478 BT_ASSERT(mapping->label);
479 mapping->ranges = g_array_new(FALSE, TRUE, sizeof(struct ctf_range));
480 BT_ASSERT(mapping->ranges);
44c440bc
PP
481}
482
4164020e 483static inline void _ctf_field_class_enum_mapping_fini(struct ctf_field_class_enum_mapping *mapping)
44c440bc 484{
4164020e 485 BT_ASSERT(mapping);
44c440bc 486
4164020e
SM
487 if (mapping->label) {
488 g_string_free(mapping->label, TRUE);
489 }
45c51519 490
4164020e
SM
491 if (mapping->ranges) {
492 g_array_free(mapping->ranges, TRUE);
493 }
44c440bc
PP
494}
495
4164020e 496static inline struct ctf_field_class_int *ctf_field_class_int_create(void)
44c440bc 497{
4164020e 498 struct ctf_field_class_int *fc = g_new0(struct ctf_field_class_int, 1);
44c440bc 499
4164020e
SM
500 BT_ASSERT(fc);
501 _ctf_field_class_int_init(fc, CTF_FIELD_CLASS_TYPE_INT);
502 return fc;
44c440bc
PP
503}
504
4164020e 505static inline struct ctf_field_class_float *ctf_field_class_float_create(void)
44c440bc 506{
4164020e 507 struct ctf_field_class_float *fc = g_new0(struct ctf_field_class_float, 1);
44c440bc 508
4164020e
SM
509 BT_ASSERT(fc);
510 _ctf_field_class_bit_array_init(&fc->base, CTF_FIELD_CLASS_TYPE_FLOAT);
511 return fc;
44c440bc
PP
512}
513
4164020e 514static inline struct ctf_field_class_string *ctf_field_class_string_create(void)
44c440bc 515{
4164020e 516 struct ctf_field_class_string *fc = g_new0(struct ctf_field_class_string, 1);
44c440bc 517
4164020e
SM
518 BT_ASSERT(fc);
519 _ctf_field_class_init(&fc->base, CTF_FIELD_CLASS_TYPE_STRING, 8);
520 return fc;
44c440bc
PP
521}
522
4164020e 523static inline struct ctf_field_class_enum *ctf_field_class_enum_create(void)
44c440bc 524{
4164020e 525 struct ctf_field_class_enum *fc = g_new0(struct ctf_field_class_enum, 1);
44c440bc 526
4164020e
SM
527 BT_ASSERT(fc);
528 _ctf_field_class_int_init(&fc->base, CTF_FIELD_CLASS_TYPE_ENUM);
529 fc->mappings = g_array_new(FALSE, TRUE, sizeof(struct ctf_field_class_enum_mapping));
530 BT_ASSERT(fc->mappings);
531 return fc;
44c440bc
PP
532}
533
4164020e 534static inline struct ctf_field_class_struct *ctf_field_class_struct_create(void)
44c440bc 535{
4164020e 536 struct ctf_field_class_struct *fc = g_new0(struct ctf_field_class_struct, 1);
44c440bc 537
4164020e
SM
538 BT_ASSERT(fc);
539 _ctf_field_class_init(&fc->base, CTF_FIELD_CLASS_TYPE_STRUCT, 1);
540 fc->members = g_array_new(FALSE, TRUE, sizeof(struct ctf_named_field_class));
541 BT_ASSERT(fc->members);
542 fc->base.is_compound = true;
543 return fc;
44c440bc
PP
544}
545
4164020e 546static inline struct ctf_field_class_variant *ctf_field_class_variant_create(void)
44c440bc 547{
4164020e 548 struct ctf_field_class_variant *fc = g_new0(struct ctf_field_class_variant, 1);
44c440bc 549
4164020e
SM
550 BT_ASSERT(fc);
551 _ctf_field_class_init(&fc->base, CTF_FIELD_CLASS_TYPE_VARIANT, 1);
552 fc->options = g_array_new(FALSE, TRUE, sizeof(struct ctf_named_field_class));
553 BT_ASSERT(fc->options);
554 fc->ranges = g_array_new(FALSE, TRUE, sizeof(struct ctf_field_class_variant_range));
555 BT_ASSERT(fc->ranges);
556 fc->tag_ref = g_string_new(NULL);
557 BT_ASSERT(fc->tag_ref);
558 ctf_field_path_init(&fc->tag_path);
559 fc->base.is_compound = true;
560 return fc;
44c440bc
PP
561}
562
4164020e 563static inline struct ctf_field_class_array *ctf_field_class_array_create(void)
44c440bc 564{
4164020e 565 struct ctf_field_class_array *fc = g_new0(struct ctf_field_class_array, 1);
44c440bc 566
4164020e
SM
567 BT_ASSERT(fc);
568 _ctf_field_class_init(&fc->base.base, CTF_FIELD_CLASS_TYPE_ARRAY, 1);
569 fc->base.base.is_compound = true;
570 return fc;
44c440bc
PP
571}
572
4164020e 573static inline struct ctf_field_class_sequence *ctf_field_class_sequence_create(void)
44c440bc 574{
4164020e 575 struct ctf_field_class_sequence *fc = g_new0(struct ctf_field_class_sequence, 1);
44c440bc 576
4164020e
SM
577 BT_ASSERT(fc);
578 _ctf_field_class_init(&fc->base.base, CTF_FIELD_CLASS_TYPE_SEQUENCE, 1);
579 fc->length_ref = g_string_new(NULL);
580 BT_ASSERT(fc->length_ref);
581 ctf_field_path_init(&fc->length_path);
582 fc->base.base.is_compound = true;
583 return fc;
44c440bc
PP
584}
585
4164020e 586static inline void _ctf_field_class_int_destroy(struct ctf_field_class_int *fc)
44c440bc 587{
4164020e
SM
588 BT_ASSERT(fc);
589 g_free(fc);
44c440bc
PP
590}
591
4164020e 592static inline void _ctf_field_class_enum_destroy(struct ctf_field_class_enum *fc)
44c440bc 593{
4164020e 594 BT_ASSERT(fc);
44c440bc 595
4164020e
SM
596 if (fc->mappings) {
597 uint64_t i;
44c440bc 598
4164020e
SM
599 for (i = 0; i < fc->mappings->len; i++) {
600 struct ctf_field_class_enum_mapping *mapping =
601 &g_array_index(fc->mappings, struct ctf_field_class_enum_mapping, i);
44c440bc 602
4164020e
SM
603 _ctf_field_class_enum_mapping_fini(mapping);
604 }
44c440bc 605
4164020e
SM
606 g_array_free(fc->mappings, TRUE);
607 }
44c440bc 608
4164020e 609 g_free(fc);
44c440bc
PP
610}
611
4164020e 612static inline void _ctf_field_class_float_destroy(struct ctf_field_class_float *fc)
44c440bc 613{
4164020e
SM
614 BT_ASSERT(fc);
615 g_free(fc);
44c440bc
PP
616}
617
4164020e 618static inline void _ctf_field_class_string_destroy(struct ctf_field_class_string *fc)
44c440bc 619{
4164020e
SM
620 BT_ASSERT(fc);
621 g_free(fc);
44c440bc
PP
622}
623
4164020e 624static inline void _ctf_field_class_struct_destroy(struct ctf_field_class_struct *fc)
44c440bc 625{
4164020e 626 BT_ASSERT(fc);
44c440bc 627
4164020e
SM
628 if (fc->members) {
629 uint64_t i;
44c440bc 630
4164020e
SM
631 for (i = 0; i < fc->members->len; i++) {
632 struct ctf_named_field_class *named_fc =
633 &g_array_index(fc->members, struct ctf_named_field_class, i);
44c440bc 634
4164020e
SM
635 _ctf_named_field_class_fini(named_fc);
636 }
44c440bc 637
4164020e
SM
638 g_array_free(fc->members, TRUE);
639 }
44c440bc 640
4164020e 641 g_free(fc);
44c440bc
PP
642}
643
4164020e 644static inline void _ctf_field_class_array_base_fini(struct ctf_field_class_array_base *fc)
44c440bc 645{
4164020e
SM
646 BT_ASSERT(fc);
647 ctf_field_class_destroy(fc->elem_fc);
44c440bc
PP
648}
649
4164020e 650static inline void _ctf_field_class_array_destroy(struct ctf_field_class_array *fc)
44c440bc 651{
4164020e
SM
652 BT_ASSERT(fc);
653 _ctf_field_class_array_base_fini(&fc->base);
654 g_free(fc);
44c440bc
PP
655}
656
4164020e 657static inline void _ctf_field_class_sequence_destroy(struct ctf_field_class_sequence *fc)
44c440bc 658{
4164020e
SM
659 BT_ASSERT(fc);
660 _ctf_field_class_array_base_fini(&fc->base);
44c440bc 661
4164020e
SM
662 if (fc->length_ref) {
663 g_string_free(fc->length_ref, TRUE);
664 }
44c440bc 665
4164020e
SM
666 ctf_field_path_fini(&fc->length_path);
667 g_free(fc);
44c440bc
PP
668}
669
4164020e 670static inline void _ctf_field_class_variant_destroy(struct ctf_field_class_variant *fc)
44c440bc 671{
4164020e 672 BT_ASSERT(fc);
44c440bc 673
4164020e
SM
674 if (fc->options) {
675 uint64_t i;
44c440bc 676
4164020e
SM
677 for (i = 0; i < fc->options->len; i++) {
678 struct ctf_named_field_class *named_fc =
679 &g_array_index(fc->options, struct ctf_named_field_class, i);
44c440bc 680
4164020e
SM
681 _ctf_named_field_class_fini(named_fc);
682 }
44c440bc 683
4164020e
SM
684 g_array_free(fc->options, TRUE);
685 }
44c440bc 686
4164020e
SM
687 if (fc->ranges) {
688 g_array_free(fc->ranges, TRUE);
689 }
44c440bc 690
4164020e
SM
691 if (fc->tag_ref) {
692 g_string_free(fc->tag_ref, TRUE);
693 }
44c440bc 694
4164020e
SM
695 ctf_field_path_fini(&fc->tag_path);
696 g_free(fc);
44c440bc
PP
697}
698
4164020e 699static inline void ctf_field_class_destroy(struct ctf_field_class *fc)
44c440bc 700{
4164020e
SM
701 if (!fc) {
702 return;
703 }
44c440bc 704
4164020e
SM
705 switch (fc->type) {
706 case CTF_FIELD_CLASS_TYPE_INT:
707 _ctf_field_class_int_destroy(ctf_field_class_as_int(fc));
708 break;
709 case CTF_FIELD_CLASS_TYPE_ENUM:
710 _ctf_field_class_enum_destroy(ctf_field_class_as_enum(fc));
711 break;
712 case CTF_FIELD_CLASS_TYPE_FLOAT:
713 _ctf_field_class_float_destroy(ctf_field_class_as_float(fc));
714 break;
715 case CTF_FIELD_CLASS_TYPE_STRING:
716 _ctf_field_class_string_destroy(ctf_field_class_as_string(fc));
717 break;
718 case CTF_FIELD_CLASS_TYPE_STRUCT:
719 _ctf_field_class_struct_destroy(ctf_field_class_as_struct(fc));
720 break;
721 case CTF_FIELD_CLASS_TYPE_ARRAY:
722 _ctf_field_class_array_destroy(ctf_field_class_as_array(fc));
723 break;
724 case CTF_FIELD_CLASS_TYPE_SEQUENCE:
725 _ctf_field_class_sequence_destroy(ctf_field_class_as_sequence(fc));
726 break;
727 case CTF_FIELD_CLASS_TYPE_VARIANT:
728 _ctf_field_class_variant_destroy(ctf_field_class_as_variant(fc));
729 break;
730 default:
731 bt_common_abort();
732 }
44c440bc
PP
733}
734
4164020e
SM
735static inline struct ctf_range *
736ctf_field_class_enum_mapping_borrow_range_by_index(struct ctf_field_class_enum_mapping *mapping,
737 uint64_t index)
44c440bc 738{
4164020e
SM
739 BT_ASSERT_DBG(mapping);
740 BT_ASSERT_DBG(index < mapping->ranges->len);
741 return &g_array_index(mapping->ranges, struct ctf_range, index);
44c440bc
PP
742}
743
4164020e
SM
744static inline struct ctf_field_class_enum_mapping *
745ctf_field_class_enum_borrow_mapping_by_index(struct ctf_field_class_enum *fc, uint64_t index)
44c440bc 746{
4164020e
SM
747 BT_ASSERT_DBG(fc);
748 BT_ASSERT_DBG(index < fc->mappings->len);
749 return &g_array_index(fc->mappings, struct ctf_field_class_enum_mapping, index);
44c440bc
PP
750}
751
4164020e
SM
752static inline struct ctf_field_class_enum_mapping *
753ctf_field_class_enum_borrow_mapping_by_label(struct ctf_field_class_enum *fc, const char *label)
45c51519 754{
4164020e
SM
755 struct ctf_field_class_enum_mapping *ret_mapping = NULL;
756 uint64_t i;
45c51519 757
4164020e
SM
758 BT_ASSERT_DBG(fc);
759 BT_ASSERT_DBG(label);
45c51519 760
4164020e
SM
761 for (i = 0; i < fc->mappings->len; i++) {
762 struct ctf_field_class_enum_mapping *mapping =
763 ctf_field_class_enum_borrow_mapping_by_index(fc, i);
764
765 if (strcmp(mapping->label->str, label) == 0) {
766 ret_mapping = mapping;
767 goto end;
768 }
769 }
45c51519
PP
770
771end:
4164020e 772 return ret_mapping;
45c51519
PP
773}
774
4164020e
SM
775static inline void ctf_field_class_enum_map_range(struct ctf_field_class_enum *fc,
776 const char *label, uint64_t u_lower,
777 uint64_t u_upper)
45c51519 778{
4164020e
SM
779 struct ctf_field_class_enum_mapping *mapping = NULL;
780 struct ctf_range range = {
781 .lower =
782 {
783 .u = u_lower,
784 },
785 .upper =
786 {
787 .u = u_upper,
788 },
789 };
790 uint64_t i;
45c51519 791
4164020e
SM
792 BT_ASSERT(fc);
793 BT_ASSERT(label);
45c51519 794
4164020e
SM
795 for (i = 0; i < fc->mappings->len; i++) {
796 mapping = ctf_field_class_enum_borrow_mapping_by_index(fc, i);
45c51519 797
4164020e
SM
798 if (strcmp(mapping->label->str, label) == 0) {
799 break;
800 }
801 }
45c51519 802
4164020e
SM
803 if (i == fc->mappings->len) {
804 mapping = NULL;
805 }
45c51519 806
4164020e
SM
807 if (!mapping) {
808 g_array_set_size(fc->mappings, fc->mappings->len + 1);
809 mapping = ctf_field_class_enum_borrow_mapping_by_index(fc, fc->mappings->len - 1);
810 _ctf_field_class_enum_mapping_init(mapping);
811 g_string_assign(mapping->label, label);
812 }
45c51519 813
4164020e 814 g_array_append_val(mapping->ranges, range);
45c51519
PP
815}
816
4164020e
SM
817static inline struct ctf_named_field_class *
818ctf_field_class_struct_borrow_member_by_index(struct ctf_field_class_struct *fc, uint64_t index)
44c440bc 819{
4164020e
SM
820 BT_ASSERT_DBG(fc);
821 BT_ASSERT_DBG(index < fc->members->len);
822 return &g_array_index(fc->members, struct ctf_named_field_class, index);
44c440bc
PP
823}
824
4164020e
SM
825static inline struct ctf_named_field_class *
826ctf_field_class_struct_borrow_member_by_name(struct ctf_field_class_struct *fc, const char *name)
44c440bc 827{
4164020e
SM
828 uint64_t i;
829 struct ctf_named_field_class *ret_named_fc = NULL;
44c440bc 830
4164020e
SM
831 BT_ASSERT_DBG(fc);
832 BT_ASSERT_DBG(name);
44c440bc 833
4164020e
SM
834 for (i = 0; i < fc->members->len; i++) {
835 struct ctf_named_field_class *named_fc =
836 ctf_field_class_struct_borrow_member_by_index(fc, i);
44c440bc 837
4164020e
SM
838 if (strcmp(name, named_fc->name->str) == 0) {
839 ret_named_fc = named_fc;
840 goto end;
841 }
842 }
44c440bc
PP
843
844end:
4164020e 845 return ret_named_fc;
44c440bc
PP
846}
847
4164020e
SM
848static inline struct ctf_field_class *
849ctf_field_class_struct_borrow_member_field_class_by_name(struct ctf_field_class_struct *struct_fc,
850 const char *name)
44c440bc 851{
4164020e
SM
852 struct ctf_named_field_class *named_fc = NULL;
853 struct ctf_field_class *fc = NULL;
44c440bc 854
4164020e
SM
855 if (!struct_fc) {
856 goto end;
857 }
44c440bc 858
4164020e
SM
859 named_fc = ctf_field_class_struct_borrow_member_by_name(struct_fc, name);
860 if (!named_fc) {
861 goto end;
862 }
44c440bc 863
4164020e 864 fc = named_fc->fc;
44c440bc
PP
865
866end:
4164020e 867 return fc;
44c440bc
PP
868}
869
4164020e 870static inline struct ctf_field_class_int *
5cd6d0e5 871ctf_field_class_struct_borrow_member_int_field_class_by_name(
4164020e 872 struct ctf_field_class_struct *struct_fc, const char *name)
44c440bc 873{
4164020e 874 struct ctf_field_class_int *int_fc = NULL;
44c440bc 875
4164020e
SM
876 int_fc = ctf_field_class_as_int(
877 ctf_field_class_struct_borrow_member_field_class_by_name(struct_fc, name));
878 if (!int_fc) {
879 goto end;
880 }
44c440bc 881
4164020e
SM
882 if (int_fc->base.base.type != CTF_FIELD_CLASS_TYPE_INT &&
883 int_fc->base.base.type != CTF_FIELD_CLASS_TYPE_ENUM) {
884 int_fc = NULL;
885 goto end;
886 }
44c440bc
PP
887
888end:
4164020e 889 return int_fc;
44c440bc
PP
890}
891
4164020e 892static inline void _ctf_named_field_class_unescape_orig_name(struct ctf_named_field_class *named_fc)
45c51519 893{
4164020e 894 const char *name = named_fc->orig_name->str;
45c51519 895
4164020e
SM
896 if (name[0] == '_') {
897 name++;
898 }
45c51519 899
4164020e 900 g_string_assign(named_fc->name, name);
45c51519 901}
44c440bc 902
4164020e
SM
903static inline void ctf_field_class_struct_append_member(struct ctf_field_class_struct *fc,
904 const char *orig_name,
905 struct ctf_field_class *member_fc)
44c440bc 906{
4164020e 907 struct ctf_named_field_class *named_fc;
44c440bc 908
4164020e
SM
909 BT_ASSERT(fc);
910 BT_ASSERT(orig_name);
911 g_array_set_size(fc->members, fc->members->len + 1);
44c440bc 912
4164020e
SM
913 named_fc = &g_array_index(fc->members, struct ctf_named_field_class, fc->members->len - 1);
914 _ctf_named_field_class_init(named_fc);
915 g_string_assign(named_fc->orig_name, orig_name);
916 _ctf_named_field_class_unescape_orig_name(named_fc);
917 named_fc->fc = member_fc;
44c440bc 918
4164020e
SM
919 if (member_fc->alignment > fc->base.alignment) {
920 fc->base.alignment = member_fc->alignment;
921 }
44c440bc
PP
922}
923
4164020e
SM
924static inline struct ctf_named_field_class *
925ctf_field_class_variant_borrow_option_by_index(struct ctf_field_class_variant *fc, uint64_t index)
44c440bc 926{
4164020e
SM
927 BT_ASSERT_DBG(fc);
928 BT_ASSERT_DBG(index < fc->options->len);
929 return &g_array_index(fc->options, struct ctf_named_field_class, index);
44c440bc
PP
930}
931
4164020e
SM
932static inline struct ctf_named_field_class *
933ctf_field_class_variant_borrow_option_by_name(struct ctf_field_class_variant *fc, const char *name)
44c440bc 934{
4164020e
SM
935 uint64_t i;
936 struct ctf_named_field_class *ret_named_fc = NULL;
44c440bc 937
4164020e
SM
938 BT_ASSERT_DBG(fc);
939 BT_ASSERT_DBG(name);
44c440bc 940
4164020e
SM
941 for (i = 0; i < fc->options->len; i++) {
942 struct ctf_named_field_class *named_fc =
943 ctf_field_class_variant_borrow_option_by_index(fc, i);
44c440bc 944
4164020e
SM
945 if (strcmp(name, named_fc->name->str) == 0) {
946 ret_named_fc = named_fc;
947 goto end;
948 }
949 }
44c440bc
PP
950
951end:
4164020e
SM
952 return ret_named_fc;
953}
954
955static inline struct ctf_field_class_variant_range *
956ctf_field_class_variant_borrow_range_by_index(struct ctf_field_class_variant *fc, uint64_t index)
957{
958 BT_ASSERT_DBG(fc);
959 BT_ASSERT_DBG(index < fc->ranges->len);
960 return &g_array_index(fc->ranges, struct ctf_field_class_variant_range, index);
961}
962
963static inline void ctf_field_class_variant_append_option(struct ctf_field_class_variant *fc,
964 const char *orig_name,
965 struct ctf_field_class *option_fc)
966{
967 struct ctf_named_field_class *named_fc;
968
969 BT_ASSERT(fc);
970 BT_ASSERT(orig_name);
971 g_array_set_size(fc->options, fc->options->len + 1);
972
973 named_fc = &g_array_index(fc->options, struct ctf_named_field_class, fc->options->len - 1);
974 _ctf_named_field_class_init(named_fc);
975 g_string_assign(named_fc->orig_name, orig_name);
976 _ctf_named_field_class_unescape_orig_name(named_fc);
977 named_fc->fc = option_fc;
978}
979
980static inline void ctf_field_class_variant_set_tag_field_class(struct ctf_field_class_variant *fc,
981 struct ctf_field_class_enum *tag_fc)
982{
983 uint64_t option_i;
984
985 BT_ASSERT(fc);
986 BT_ASSERT(tag_fc);
987 fc->tag_fc = tag_fc;
988
989 for (option_i = 0; option_i < fc->options->len; option_i++) {
990 uint64_t range_i;
991 struct ctf_named_field_class *named_fc =
992 ctf_field_class_variant_borrow_option_by_index(fc, option_i);
993 struct ctf_field_class_enum_mapping *mapping;
994
995 mapping = ctf_field_class_enum_borrow_mapping_by_label(tag_fc, named_fc->orig_name->str);
996 if (!mapping) {
997 continue;
998 }
999
1000 for (range_i = 0; range_i < mapping->ranges->len; range_i++) {
1001 struct ctf_range *range =
1002 ctf_field_class_enum_mapping_borrow_range_by_index(mapping, range_i);
1003 struct ctf_field_class_variant_range var_range;
1004
1005 var_range.range = *range;
1006 var_range.option_index = option_i;
1007 g_array_append_val(fc->ranges, var_range);
1008 }
1009 }
1010}
1011
1012static inline struct ctf_field_class *
1013ctf_field_class_compound_borrow_field_class_by_index(struct ctf_field_class *comp_fc,
1014 uint64_t index)
1015{
1016 struct ctf_field_class *fc = NULL;
1017
1018 switch (comp_fc->type) {
1019 case CTF_FIELD_CLASS_TYPE_STRUCT:
1020 {
1021 struct ctf_named_field_class *named_fc = ctf_field_class_struct_borrow_member_by_index(
1022 (struct ctf_field_class_struct *) comp_fc, index);
1023
1024 BT_ASSERT_DBG(named_fc);
1025 fc = named_fc->fc;
1026 break;
1027 }
1028 case CTF_FIELD_CLASS_TYPE_VARIANT:
1029 {
1030 struct ctf_named_field_class *named_fc = ctf_field_class_variant_borrow_option_by_index(
1031 (struct ctf_field_class_variant *) comp_fc, index);
1032
1033 BT_ASSERT_DBG(named_fc);
1034 fc = named_fc->fc;
1035 break;
1036 }
1037 case CTF_FIELD_CLASS_TYPE_ARRAY:
1038 case CTF_FIELD_CLASS_TYPE_SEQUENCE:
1039 {
1040 struct ctf_field_class_array_base *array_fc = (struct ctf_field_class_array_base *) comp_fc;
1041
1042 fc = array_fc->elem_fc;
1043 break;
1044 }
1045 default:
1046 break;
1047 }
1048
1049 return fc;
1050}
1051
1052static inline uint64_t ctf_field_class_compound_get_field_class_count(struct ctf_field_class *fc)
1053{
1054 uint64_t field_count;
1055
1056 switch (fc->type) {
1057 case CTF_FIELD_CLASS_TYPE_STRUCT:
1058 {
1059 struct ctf_field_class_struct *struct_fc = (struct ctf_field_class_struct *) fc;
1060
1061 field_count = struct_fc->members->len;
1062 break;
1063 }
1064 case CTF_FIELD_CLASS_TYPE_VARIANT:
1065 {
1066 struct ctf_field_class_variant *var_fc = (struct ctf_field_class_variant *) fc;
1067
1068 field_count = var_fc->options->len;
1069 break;
1070 }
1071 case CTF_FIELD_CLASS_TYPE_ARRAY:
1072 case CTF_FIELD_CLASS_TYPE_SEQUENCE:
1073 /*
1074 * Array and sequence types always contain a single
1075 * member (the element type).
1076 */
1077 field_count = 1;
1078 break;
1079 default:
1080 bt_common_abort();
1081 }
1082
1083 return field_count;
1084}
1085
1086static inline int64_t
1087ctf_field_class_compound_get_field_class_index_from_orig_name(struct ctf_field_class *fc,
1088 const char *orig_name)
1089{
1090 int64_t ret_index = -1;
1091 uint64_t i;
1092
1093 switch (fc->type) {
1094 case CTF_FIELD_CLASS_TYPE_STRUCT:
1095 {
1096 struct ctf_field_class_struct *struct_fc = (struct ctf_field_class_struct *) fc;
1097
1098 for (i = 0; i < struct_fc->members->len; i++) {
1099 struct ctf_named_field_class *named_fc =
1100 ctf_field_class_struct_borrow_member_by_index(struct_fc, i);
1101
1102 if (strcmp(orig_name, named_fc->orig_name->str) == 0) {
1103 ret_index = (int64_t) i;
1104 goto end;
1105 }
1106 }
1107
1108 break;
1109 }
1110 case CTF_FIELD_CLASS_TYPE_VARIANT:
1111 {
1112 struct ctf_field_class_variant *var_fc = (struct ctf_field_class_variant *) fc;
1113
1114 for (i = 0; i < var_fc->options->len; i++) {
1115 struct ctf_named_field_class *named_fc =
1116 ctf_field_class_variant_borrow_option_by_index(var_fc, i);
1117
1118 if (strcmp(orig_name, named_fc->orig_name->str) == 0) {
1119 ret_index = (int64_t) i;
1120 goto end;
1121 }
1122 }
1123
1124 break;
1125 }
1126 default:
1127 break;
1128 }
44c440bc
PP
1129
1130end:
4164020e 1131 return ret_index;
44c440bc
PP
1132}
1133
4164020e 1134static inline void ctf_field_path_append_index(struct ctf_field_path *fp, int64_t index)
44c440bc 1135{
4164020e
SM
1136 BT_ASSERT(fp);
1137 g_array_append_val(fp->path, index);
44c440bc
PP
1138}
1139
4164020e
SM
1140static inline int64_t ctf_field_path_borrow_index_by_index(struct ctf_field_path *fp,
1141 uint64_t index)
44c440bc 1142{
4164020e
SM
1143 BT_ASSERT_DBG(fp);
1144 BT_ASSERT_DBG(index < fp->path->len);
1145 return g_array_index(fp->path, int64_t, index);
44c440bc
PP
1146}
1147
4164020e 1148static inline void ctf_field_path_clear(struct ctf_field_path *fp)
44c440bc 1149{
4164020e
SM
1150 BT_ASSERT(fp);
1151 g_array_set_size(fp->path, 0);
44c440bc
PP
1152}
1153
4164020e 1154static inline const char *ctf_scope_string(enum ctf_scope scope)
83ebb7f1 1155{
4164020e
SM
1156 switch (scope) {
1157 case CTF_SCOPE_PACKET_HEADER:
1158 return "PACKET_HEADER";
1159 case CTF_SCOPE_PACKET_CONTEXT:
1160 return "PACKET_CONTEXT";
1161 case CTF_SCOPE_EVENT_HEADER:
1162 return "EVENT_HEADER";
1163 case CTF_SCOPE_EVENT_COMMON_CONTEXT:
1164 return "EVENT_COMMON_CONTEXT";
1165 case CTF_SCOPE_EVENT_SPECIFIC_CONTEXT:
1166 return "EVENT_SPECIFIC_CONTEXT";
1167 case CTF_SCOPE_EVENT_PAYLOAD:
1168 return "EVENT_PAYLOAD";
1169 default:
1170 bt_common_abort();
1171 }
83ebb7f1
PP
1172}
1173
4164020e 1174static inline GString *ctf_field_path_string(struct ctf_field_path *path)
44c440bc 1175{
4164020e
SM
1176 GString *str = g_string_new(NULL);
1177 uint64_t i;
44c440bc 1178
4164020e 1179 BT_ASSERT(path);
44c440bc 1180
4164020e
SM
1181 if (!str) {
1182 goto end;
1183 }
44c440bc 1184
4164020e 1185 g_string_append_printf(str, "[%s", ctf_scope_string(path->root));
44c440bc 1186
4164020e
SM
1187 for (i = 0; i < path->path->len; i++) {
1188 g_string_append_printf(str, ", %" PRId64, ctf_field_path_borrow_index_by_index(path, i));
1189 }
44c440bc 1190
4164020e 1191 g_string_append(str, "]");
44c440bc
PP
1192
1193end:
4164020e
SM
1194 return str;
1195}
1196
1197static inline struct ctf_field_class *
1198ctf_field_path_borrow_field_class(struct ctf_field_path *field_path, struct ctf_trace_class *tc,
1199 struct ctf_stream_class *sc, struct ctf_event_class *ec)
1200{
1201 uint64_t i;
1202 struct ctf_field_class *fc;
1203
1204 switch (field_path->root) {
1205 case CTF_SCOPE_PACKET_HEADER:
1206 fc = tc->packet_header_fc;
1207 break;
1208 case CTF_SCOPE_PACKET_CONTEXT:
1209 fc = sc->packet_context_fc;
1210 break;
1211 case CTF_SCOPE_EVENT_HEADER:
1212 fc = sc->event_header_fc;
1213 break;
1214 case CTF_SCOPE_EVENT_COMMON_CONTEXT:
1215 fc = sc->event_common_context_fc;
1216 break;
1217 case CTF_SCOPE_EVENT_SPECIFIC_CONTEXT:
1218 fc = ec->spec_context_fc;
1219 break;
1220 case CTF_SCOPE_EVENT_PAYLOAD:
1221 fc = ec->payload_fc;
1222 break;
1223 default:
1224 bt_common_abort();
1225 }
1226
1227 BT_ASSERT_DBG(fc);
44c440bc 1228
4164020e
SM
1229 for (i = 0; i < field_path->path->len; i++) {
1230 int64_t child_index = ctf_field_path_borrow_index_by_index(field_path, i);
1231 struct ctf_field_class *child_fc =
1232 ctf_field_class_compound_borrow_field_class_by_index(fc, child_index);
1233 BT_ASSERT_DBG(child_fc);
1234 fc = child_fc;
1235 }
44c440bc 1236
4164020e
SM
1237 BT_ASSERT_DBG(fc);
1238 return fc;
44c440bc
PP
1239}
1240
4164020e 1241static inline struct ctf_field_class *ctf_field_class_copy(struct ctf_field_class *fc);
44c440bc 1242
4164020e
SM
1243static inline void ctf_field_class_bit_array_copy_content(struct ctf_field_class_bit_array *dst_fc,
1244 struct ctf_field_class_bit_array *src_fc)
44c440bc 1245{
4164020e
SM
1246 BT_ASSERT(dst_fc);
1247 BT_ASSERT(src_fc);
1248 dst_fc->byte_order = src_fc->byte_order;
1249 dst_fc->size = src_fc->size;
44c440bc
PP
1250}
1251
4164020e
SM
1252static inline void ctf_field_class_int_copy_content(struct ctf_field_class_int *dst_fc,
1253 struct ctf_field_class_int *src_fc)
44c440bc 1254{
4164020e
SM
1255 ctf_field_class_bit_array_copy_content(&dst_fc->base, &src_fc->base);
1256 dst_fc->meaning = src_fc->meaning;
1257 dst_fc->is_signed = src_fc->is_signed;
1258 dst_fc->disp_base = src_fc->disp_base;
1259 dst_fc->encoding = src_fc->encoding;
1260 dst_fc->mapped_clock_class = src_fc->mapped_clock_class;
1261 dst_fc->storing_index = src_fc->storing_index;
44c440bc
PP
1262}
1263
4164020e 1264static inline struct ctf_field_class_int *_ctf_field_class_int_copy(struct ctf_field_class_int *fc)
44c440bc 1265{
4164020e 1266 struct ctf_field_class_int *copy_fc = ctf_field_class_int_create();
44c440bc 1267
4164020e
SM
1268 BT_ASSERT(copy_fc);
1269 ctf_field_class_int_copy_content(copy_fc, fc);
1270 return copy_fc;
44c440bc
PP
1271}
1272
4164020e
SM
1273static inline struct ctf_field_class_enum *
1274_ctf_field_class_enum_copy(struct ctf_field_class_enum *fc)
44c440bc 1275{
4164020e
SM
1276 struct ctf_field_class_enum *copy_fc = ctf_field_class_enum_create();
1277 uint64_t i;
44c440bc 1278
4164020e
SM
1279 BT_ASSERT(copy_fc);
1280 ctf_field_class_int_copy_content(&copy_fc->base, &fc->base);
44c440bc 1281
4164020e
SM
1282 for (i = 0; i < fc->mappings->len; i++) {
1283 uint64_t range_i;
45c51519 1284
4164020e
SM
1285 struct ctf_field_class_enum_mapping *mapping =
1286 &g_array_index(fc->mappings, struct ctf_field_class_enum_mapping, i);
44c440bc 1287
4164020e
SM
1288 for (range_i = 0; range_i < mapping->ranges->len; range_i++) {
1289 struct ctf_range *range = &g_array_index(mapping->ranges, struct ctf_range, range_i);
45c51519 1290
4164020e
SM
1291 ctf_field_class_enum_map_range(copy_fc, mapping->label->str, range->lower.u,
1292 range->upper.u);
1293 }
1294 }
44c440bc 1295
4164020e 1296 return copy_fc;
44c440bc
PP
1297}
1298
4164020e
SM
1299static inline struct ctf_field_class_float *
1300_ctf_field_class_float_copy(struct ctf_field_class_float *fc)
44c440bc 1301{
4164020e 1302 struct ctf_field_class_float *copy_fc = ctf_field_class_float_create();
44c440bc 1303
4164020e
SM
1304 BT_ASSERT(copy_fc);
1305 ctf_field_class_bit_array_copy_content(&copy_fc->base, &fc->base);
1306 return copy_fc;
44c440bc
PP
1307}
1308
4164020e
SM
1309static inline struct ctf_field_class_string *
1310_ctf_field_class_string_copy(struct ctf_field_class_string *fc)
44c440bc 1311{
4164020e 1312 struct ctf_field_class_string *copy_fc = ctf_field_class_string_create();
44c440bc 1313
4164020e
SM
1314 BT_ASSERT(copy_fc);
1315 return copy_fc;
44c440bc
PP
1316}
1317
4164020e
SM
1318static inline struct ctf_field_class_struct *
1319_ctf_field_class_struct_copy(struct ctf_field_class_struct *fc)
44c440bc 1320{
4164020e
SM
1321 struct ctf_field_class_struct *copy_fc = ctf_field_class_struct_create();
1322 uint64_t i;
44c440bc 1323
4164020e 1324 BT_ASSERT(copy_fc);
44c440bc 1325
4164020e
SM
1326 for (i = 0; i < fc->members->len; i++) {
1327 struct ctf_named_field_class *named_fc =
1328 &g_array_index(fc->members, struct ctf_named_field_class, i);
44c440bc 1329
4164020e
SM
1330 ctf_field_class_struct_append_member(copy_fc, named_fc->name->str,
1331 ctf_field_class_copy(named_fc->fc));
1332 }
44c440bc 1333
4164020e 1334 return copy_fc;
44c440bc
PP
1335}
1336
4164020e
SM
1337static inline void ctf_field_path_copy_content(struct ctf_field_path *dst_fp,
1338 struct ctf_field_path *src_fp)
44c440bc 1339{
4164020e 1340 uint64_t i;
44c440bc 1341
4164020e
SM
1342 BT_ASSERT(dst_fp);
1343 BT_ASSERT(src_fp);
1344 dst_fp->root = src_fp->root;
1345 ctf_field_path_clear(dst_fp);
44c440bc 1346
4164020e
SM
1347 for (i = 0; i < src_fp->path->len; i++) {
1348 int64_t index = ctf_field_path_borrow_index_by_index(src_fp, i);
44c440bc 1349
4164020e
SM
1350 ctf_field_path_append_index(dst_fp, index);
1351 }
44c440bc
PP
1352}
1353
4164020e
SM
1354static inline struct ctf_field_class_variant *
1355_ctf_field_class_variant_copy(struct ctf_field_class_variant *fc)
44c440bc 1356{
4164020e
SM
1357 struct ctf_field_class_variant *copy_fc = ctf_field_class_variant_create();
1358 uint64_t i;
44c440bc 1359
4164020e 1360 BT_ASSERT(copy_fc);
44c440bc 1361
4164020e
SM
1362 for (i = 0; i < fc->options->len; i++) {
1363 struct ctf_named_field_class *named_fc =
1364 &g_array_index(fc->options, struct ctf_named_field_class, i);
44c440bc 1365
4164020e
SM
1366 ctf_field_class_variant_append_option(copy_fc, named_fc->name->str,
1367 ctf_field_class_copy(named_fc->fc));
1368 }
44c440bc 1369
4164020e
SM
1370 for (i = 0; i < fc->ranges->len; i++) {
1371 struct ctf_field_class_variant_range *range =
1372 &g_array_index(fc->ranges, struct ctf_field_class_variant_range, i);
44c440bc 1373
4164020e
SM
1374 g_array_append_val(copy_fc->ranges, *range);
1375 }
44c440bc 1376
4164020e
SM
1377 ctf_field_path_copy_content(&copy_fc->tag_path, &fc->tag_path);
1378 g_string_assign(copy_fc->tag_ref, fc->tag_ref->str);
1379 copy_fc->stored_tag_index = fc->stored_tag_index;
1380 return copy_fc;
44c440bc
PP
1381}
1382
4164020e
SM
1383static inline void
1384ctf_field_class_array_base_copy_content(struct ctf_field_class_array_base *dst_fc,
1385 struct ctf_field_class_array_base *src_fc)
44c440bc 1386{
4164020e
SM
1387 BT_ASSERT(dst_fc);
1388 BT_ASSERT(src_fc);
1389 dst_fc->elem_fc = ctf_field_class_copy(src_fc->elem_fc);
1390 dst_fc->is_text = src_fc->is_text;
44c440bc
PP
1391}
1392
4164020e
SM
1393static inline struct ctf_field_class_array *
1394_ctf_field_class_array_copy(struct ctf_field_class_array *fc)
44c440bc 1395{
4164020e 1396 struct ctf_field_class_array *copy_fc = ctf_field_class_array_create();
44c440bc 1397
4164020e
SM
1398 BT_ASSERT(copy_fc);
1399 ctf_field_class_array_base_copy_content(&copy_fc->base, &fc->base);
1400 copy_fc->length = fc->length;
1401 return copy_fc;
44c440bc
PP
1402}
1403
4164020e
SM
1404static inline struct ctf_field_class_sequence *
1405_ctf_field_class_sequence_copy(struct ctf_field_class_sequence *fc)
44c440bc 1406{
4164020e
SM
1407 struct ctf_field_class_sequence *copy_fc = ctf_field_class_sequence_create();
1408
1409 BT_ASSERT(copy_fc);
1410 ctf_field_class_array_base_copy_content(&copy_fc->base, &fc->base);
1411 ctf_field_path_copy_content(&copy_fc->length_path, &fc->length_path);
1412 g_string_assign(copy_fc->length_ref, fc->length_ref->str);
1413 copy_fc->stored_length_index = fc->stored_length_index;
1414 return copy_fc;
1415}
1416
1417static inline struct ctf_field_class *ctf_field_class_copy(struct ctf_field_class *fc)
1418{
1419 struct ctf_field_class *copy_fc = NULL;
1420
1421 if (!fc) {
1422 goto end;
1423 }
1424
1425 /*
1426 * Translation should not have happened yet.
1427 */
1428 BT_ASSERT(!fc->ir_fc);
44c440bc 1429
4164020e
SM
1430 switch (fc->type) {
1431 case CTF_FIELD_CLASS_TYPE_INT:
1432 copy_fc = &_ctf_field_class_int_copy(ctf_field_class_as_int(fc))->base.base;
1433 break;
1434 case CTF_FIELD_CLASS_TYPE_ENUM:
1435 copy_fc = &_ctf_field_class_enum_copy(ctf_field_class_as_enum(fc))->base.base.base;
1436 break;
1437 case CTF_FIELD_CLASS_TYPE_FLOAT:
1438 copy_fc = &_ctf_field_class_float_copy(ctf_field_class_as_float(fc))->base.base;
1439 break;
1440 case CTF_FIELD_CLASS_TYPE_STRING:
1441 copy_fc = &_ctf_field_class_string_copy(ctf_field_class_as_string(fc))->base;
1442 break;
1443 case CTF_FIELD_CLASS_TYPE_STRUCT:
1444 copy_fc = &_ctf_field_class_struct_copy(ctf_field_class_as_struct(fc))->base;
1445 break;
1446 case CTF_FIELD_CLASS_TYPE_ARRAY:
1447 copy_fc = &_ctf_field_class_array_copy(ctf_field_class_as_array(fc))->base.base;
1448 break;
1449 case CTF_FIELD_CLASS_TYPE_SEQUENCE:
1450 copy_fc = &_ctf_field_class_sequence_copy(ctf_field_class_as_sequence(fc))->base.base;
1451 break;
1452 case CTF_FIELD_CLASS_TYPE_VARIANT:
1453 copy_fc = &_ctf_field_class_variant_copy(ctf_field_class_as_variant(fc))->base;
1454 break;
1455 default:
1456 bt_common_abort();
1457 }
1458
1459 copy_fc->type = fc->type;
1460 copy_fc->alignment = fc->alignment;
1461 copy_fc->in_ir = fc->in_ir;
44c440bc
PP
1462
1463end:
4164020e 1464 return copy_fc;
44c440bc
PP
1465}
1466
4164020e 1467static inline struct ctf_event_class *ctf_event_class_create(void)
44c440bc 1468{
4164020e 1469 struct ctf_event_class *ec = g_new0(struct ctf_event_class, 1);
44c440bc 1470
4164020e
SM
1471 BT_ASSERT(ec);
1472 ec->name = g_string_new(NULL);
1473 BT_ASSERT(ec->name);
1474 ec->emf_uri = g_string_new(NULL);
1475 BT_ASSERT(ec->emf_uri);
1476 ec->is_log_level_set = false;
1477 return ec;
44c440bc
PP
1478}
1479
4164020e
SM
1480static inline void ctf_event_class_set_log_level(struct ctf_event_class *ec,
1481 enum bt_event_class_log_level log_level)
6da709aa 1482{
4164020e
SM
1483 BT_ASSERT(ec);
1484 ec->log_level = log_level;
1485 ec->is_log_level_set = true;
6da709aa
JR
1486}
1487
4164020e 1488static inline void ctf_event_class_destroy(struct ctf_event_class *ec)
44c440bc 1489{
4164020e
SM
1490 if (!ec) {
1491 return;
1492 }
44c440bc 1493
4164020e
SM
1494 if (ec->name) {
1495 g_string_free(ec->name, TRUE);
1496 }
44c440bc 1497
4164020e
SM
1498 if (ec->emf_uri) {
1499 g_string_free(ec->emf_uri, TRUE);
1500 }
44c440bc 1501
4164020e
SM
1502 ctf_field_class_destroy(ec->spec_context_fc);
1503 ctf_field_class_destroy(ec->payload_fc);
1504 g_free(ec);
44c440bc
PP
1505}
1506
4164020e 1507static inline struct ctf_stream_class *ctf_stream_class_create(void)
44c440bc 1508{
4164020e 1509 struct ctf_stream_class *sc = g_new0(struct ctf_stream_class, 1);
44c440bc 1510
4164020e
SM
1511 BT_ASSERT(sc);
1512 sc->event_classes = g_ptr_array_new_with_free_func((GDestroyNotify) ctf_event_class_destroy);
1513 BT_ASSERT(sc->event_classes);
1514 sc->event_classes_by_id = g_hash_table_new(g_direct_hash, g_direct_equal);
1515 BT_ASSERT(sc->event_classes_by_id);
1516 return sc;
44c440bc
PP
1517}
1518
4164020e 1519static inline void ctf_stream_class_destroy(struct ctf_stream_class *sc)
44c440bc 1520{
4164020e
SM
1521 if (!sc) {
1522 return;
1523 }
44c440bc 1524
4164020e
SM
1525 if (sc->event_classes) {
1526 g_ptr_array_free(sc->event_classes, TRUE);
1527 }
44c440bc 1528
4164020e
SM
1529 if (sc->event_classes_by_id) {
1530 g_hash_table_destroy(sc->event_classes_by_id);
1531 }
44c440bc 1532
4164020e
SM
1533 ctf_field_class_destroy(sc->packet_context_fc);
1534 ctf_field_class_destroy(sc->event_header_fc);
1535 ctf_field_class_destroy(sc->event_common_context_fc);
1536 g_free(sc);
44c440bc
PP
1537}
1538
4164020e
SM
1539static inline void ctf_stream_class_append_event_class(struct ctf_stream_class *sc,
1540 struct ctf_event_class *ec)
44c440bc 1541{
4164020e
SM
1542 g_ptr_array_add(sc->event_classes, ec);
1543 g_hash_table_insert(sc->event_classes_by_id, GUINT_TO_POINTER((guint) ec->id), ec);
44c440bc
PP
1544}
1545
4164020e
SM
1546static inline struct ctf_event_class *
1547ctf_stream_class_borrow_event_class_by_id(struct ctf_stream_class *sc, uint64_t type)
44c440bc 1548{
4164020e
SM
1549 BT_ASSERT_DBG(sc);
1550 return (struct ctf_event_class *) g_hash_table_lookup(sc->event_classes_by_id,
1551 GUINT_TO_POINTER((guint) type));
44c440bc
PP
1552}
1553
4164020e 1554static inline void _ctf_trace_class_env_entry_init(struct ctf_trace_class_env_entry *entry)
44c440bc 1555{
4164020e
SM
1556 BT_ASSERT(entry);
1557 entry->name = g_string_new(NULL);
1558 BT_ASSERT(entry->name);
1559 entry->value.str = g_string_new(NULL);
1560 BT_ASSERT(entry->value.str);
44c440bc
PP
1561}
1562
4164020e 1563static inline void _ctf_trace_class_env_entry_fini(struct ctf_trace_class_env_entry *entry)
44c440bc 1564{
4164020e 1565 BT_ASSERT(entry);
44c440bc 1566
4164020e
SM
1567 if (entry->name) {
1568 g_string_free(entry->name, TRUE);
1569 }
44c440bc 1570
4164020e
SM
1571 if (entry->value.str) {
1572 g_string_free(entry->value.str, TRUE);
1573 }
44c440bc
PP
1574}
1575
4164020e 1576static inline struct ctf_clock_class *ctf_clock_class_create(void)
0f2d58c9 1577{
4164020e 1578 struct ctf_clock_class *cc = g_new0(struct ctf_clock_class, 1);
0f2d58c9 1579
4164020e
SM
1580 BT_ASSERT(cc);
1581 cc->name = g_string_new(NULL);
1582 BT_ASSERT(cc->name);
1583 cc->description = g_string_new(NULL);
1584 BT_ASSERT(cc->description);
1585 return cc;
0f2d58c9
PP
1586}
1587
4164020e 1588static inline void ctf_clock_class_destroy(struct ctf_clock_class *cc)
0f2d58c9 1589{
4164020e
SM
1590 if (!cc) {
1591 return;
1592 }
0f2d58c9 1593
4164020e
SM
1594 if (cc->name) {
1595 g_string_free(cc->name, TRUE);
1596 }
0f2d58c9 1597
4164020e
SM
1598 if (cc->description) {
1599 g_string_free(cc->description, TRUE);
1600 }
0f2d58c9 1601
4164020e
SM
1602 bt_clock_class_put_ref(cc->ir_cc);
1603 g_free(cc);
0f2d58c9
PP
1604}
1605
4164020e 1606static inline struct ctf_trace_class *ctf_trace_class_create(void)
44c440bc 1607{
4164020e 1608 struct ctf_trace_class *tc = g_new0(struct ctf_trace_class, 1);
44c440bc 1609
4164020e
SM
1610 BT_ASSERT(tc);
1611 tc->default_byte_order = CTF_BYTE_ORDER_UNKNOWN;
1612 tc->clock_classes = g_ptr_array_new_with_free_func((GDestroyNotify) ctf_clock_class_destroy);
1613 BT_ASSERT(tc->clock_classes);
1614 tc->stream_classes = g_ptr_array_new_with_free_func((GDestroyNotify) ctf_stream_class_destroy);
1615 BT_ASSERT(tc->stream_classes);
1616 tc->env_entries = g_array_new(FALSE, TRUE, sizeof(struct ctf_trace_class_env_entry));
1617 return tc;
44c440bc
PP
1618}
1619
4164020e 1620static inline void ctf_trace_class_destroy(struct ctf_trace_class *tc)
44c440bc 1621{
4164020e
SM
1622 if (!tc) {
1623 return;
1624 }
44c440bc 1625
4164020e 1626 ctf_field_class_destroy(tc->packet_header_fc);
44c440bc 1627
4164020e
SM
1628 if (tc->clock_classes) {
1629 g_ptr_array_free(tc->clock_classes, TRUE);
1630 }
44c440bc 1631
4164020e
SM
1632 if (tc->stream_classes) {
1633 g_ptr_array_free(tc->stream_classes, TRUE);
1634 }
44c440bc 1635
4164020e
SM
1636 if (tc->env_entries) {
1637 uint64_t i;
44c440bc 1638
4164020e
SM
1639 for (i = 0; i < tc->env_entries->len; i++) {
1640 struct ctf_trace_class_env_entry *entry =
1641 &g_array_index(tc->env_entries, struct ctf_trace_class_env_entry, i);
44c440bc 1642
4164020e
SM
1643 _ctf_trace_class_env_entry_fini(entry);
1644 }
44c440bc 1645
4164020e
SM
1646 g_array_free(tc->env_entries, TRUE);
1647 }
44c440bc 1648
4164020e 1649 g_free(tc);
44c440bc
PP
1650}
1651
4164020e
SM
1652static inline void ctf_trace_class_append_env_entry(struct ctf_trace_class *tc, const char *name,
1653 enum ctf_trace_class_env_entry_type type,
1654 const char *str_value, int64_t i_value)
44c440bc 1655{
4164020e 1656 struct ctf_trace_class_env_entry *entry;
44c440bc 1657
4164020e
SM
1658 BT_ASSERT(tc);
1659 BT_ASSERT(name);
1660 g_array_set_size(tc->env_entries, tc->env_entries->len + 1);
44c440bc 1661
4164020e
SM
1662 entry =
1663 &g_array_index(tc->env_entries, struct ctf_trace_class_env_entry, tc->env_entries->len - 1);
1664 entry->type = type;
1665 _ctf_trace_class_env_entry_init(entry);
1666 g_string_assign(entry->name, name);
44c440bc 1667
4164020e
SM
1668 if (str_value) {
1669 g_string_assign(entry->value.str, str_value);
1670 }
44c440bc 1671
4164020e 1672 entry->value.i = i_value;
44c440bc
PP
1673}
1674
4164020e
SM
1675static inline struct ctf_stream_class *
1676ctf_trace_class_borrow_stream_class_by_id(struct ctf_trace_class *tc, uint64_t id)
44c440bc 1677{
4164020e
SM
1678 uint64_t i;
1679 struct ctf_stream_class *ret_sc = NULL;
44c440bc 1680
4164020e 1681 BT_ASSERT_DBG(tc);
44c440bc 1682
4164020e
SM
1683 for (i = 0; i < tc->stream_classes->len; i++) {
1684 struct ctf_stream_class *sc = (struct ctf_stream_class *) tc->stream_classes->pdata[i];
44c440bc 1685
4164020e
SM
1686 if (sc->id == id) {
1687 ret_sc = sc;
1688 goto end;
1689 }
1690 }
44c440bc
PP
1691
1692end:
4164020e 1693 return ret_sc;
44c440bc
PP
1694}
1695
4164020e
SM
1696static inline struct ctf_clock_class *
1697ctf_trace_class_borrow_clock_class_by_name(struct ctf_trace_class *tc, const char *name)
44c440bc 1698{
4164020e
SM
1699 uint64_t i;
1700 struct ctf_clock_class *ret_cc = NULL;
44c440bc 1701
4164020e
SM
1702 BT_ASSERT_DBG(tc);
1703 BT_ASSERT_DBG(name);
44c440bc 1704
4164020e
SM
1705 for (i = 0; i < tc->clock_classes->len; i++) {
1706 struct ctf_clock_class *cc = (struct ctf_clock_class *) tc->clock_classes->pdata[i];
44c440bc 1707
4164020e
SM
1708 BT_ASSERT_DBG(cc->name);
1709 if (strcmp(cc->name->str, name) == 0) {
1710 ret_cc = cc;
1711 goto end;
1712 }
1713 }
44c440bc
PP
1714
1715end:
4164020e 1716 return ret_cc;
44c440bc
PP
1717}
1718
4164020e
SM
1719static inline struct ctf_trace_class_env_entry *
1720ctf_trace_class_borrow_env_entry_by_index(struct ctf_trace_class *tc, uint64_t index)
44c440bc 1721{
4164020e
SM
1722 BT_ASSERT_DBG(tc);
1723 BT_ASSERT_DBG(index < tc->env_entries->len);
1724 return &g_array_index(tc->env_entries, struct ctf_trace_class_env_entry, index);
44c440bc
PP
1725}
1726
4164020e
SM
1727static inline struct ctf_trace_class_env_entry *
1728ctf_trace_class_borrow_env_entry_by_name(struct ctf_trace_class *tc, const char *name)
44c440bc 1729{
4164020e
SM
1730 struct ctf_trace_class_env_entry *ret_entry = NULL;
1731 uint64_t i;
44c440bc 1732
4164020e
SM
1733 BT_ASSERT_DBG(tc);
1734 BT_ASSERT_DBG(name);
44c440bc 1735
4164020e
SM
1736 for (i = 0; i < tc->env_entries->len; i++) {
1737 struct ctf_trace_class_env_entry *env_entry =
1738 ctf_trace_class_borrow_env_entry_by_index(tc, i);
44c440bc 1739
4164020e
SM
1740 if (strcmp(env_entry->name->str, name) == 0) {
1741 ret_entry = env_entry;
1742 goto end;
1743 }
1744 }
44c440bc
PP
1745
1746end:
4164020e 1747 return ret_entry;
44c440bc
PP
1748}
1749
1750#endif /* _CTF_META_H */
This page took 0.162682 seconds and 4 git commands to generate.