Clean-up: ust-consumer: fix -Wshadow issues in lttng_ustconsumer_recv_cmd
[lttng-tools.git] / include / lttng / event-field-value-internal.h
1 /*
2 * Copyright (C) 2020 Philippe Proulx <pproulx@efficios.com>
3 *
4 * SPDX-License-Identifier: LGPL-2.1-only
5 *
6 */
7
8 #ifndef LTTNG_EVENT_FIELD_VALUE_INTERNAL_H
9 #define LTTNG_EVENT_FIELD_VALUE_INTERNAL_H
10
11 #include <assert.h>
12 #include <stdint.h>
13 #include <lttng/event-field-value.h>
14 #include <common/dynamic-array.h>
15
16 struct lttng_event_field_value {
17 enum lttng_event_field_value_type type;
18 };
19
20 /*
21 * `LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_INT`.
22 */
23 struct lttng_event_field_value_uint {
24 struct lttng_event_field_value parent;
25 uint64_t val;
26 };
27
28 /*
29 * `LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_INT`.
30 */
31 struct lttng_event_field_value_int {
32 struct lttng_event_field_value parent;
33 int64_t val;
34 };
35
36 /*
37 * `LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_ENUM` and
38 * `LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_ENUM` (base).
39 */
40 struct lttng_event_field_value_enum {
41 struct lttng_event_field_value parent;
42
43 /*
44 * Array of `char *` (owned by this).
45 */
46 struct lttng_dynamic_pointer_array labels;
47 };
48
49 /*
50 * `LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_ENUM`.
51 */
52 struct lttng_event_field_value_enum_uint {
53 struct lttng_event_field_value_enum parent;
54 uint64_t val;
55 };
56
57 /*
58 * `LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_ENUM`.
59 */
60 struct lttng_event_field_value_enum_int {
61 struct lttng_event_field_value_enum parent;
62 int64_t val;
63 };
64
65 /* `LTTNG_EVENT_FIELD_VALUE_TYPE_REAL` */
66 struct lttng_event_field_value_real {
67 struct lttng_event_field_value parent;
68 double val;
69 };
70
71 /* `LTTNG_EVENT_FIELD_VALUE_TYPE_STRING` */
72 struct lttng_event_field_value_string {
73 struct lttng_event_field_value parent;
74
75 /* Owned by this */
76 char *val;
77 };
78
79 /* `LTTNG_EVENT_FIELD_VALUE_TYPE_STRING` */
80 struct lttng_event_field_value_array {
81 struct lttng_event_field_value parent;
82
83 /*
84 * Array of `struct lttng_event_field_value *` (owned by this).
85 *
86 * A `NULL` element means it's unavailable
87 * (`LTTNG_EVENT_FIELD_VALUE_STATUS_UNAVAILABLE` status).
88 */
89 struct lttng_dynamic_pointer_array elems;
90 };
91
92 /*
93 * This is internal since the session daemon knows nothing about the
94 * enumeration fields produced by the kernel tracer. Indeed, the kernel tracer
95 * manages its own metadata which remains opaque to the rest of the toolchain.
96 *
97 * Enumerations could be supported for the user space tracer, but it is not the
98 * case right now.
99 */
100
101 /*
102 * Sets `*count` to the number of labels of the enumeration event field
103 * value `field_val`.
104 *
105 * Returns:
106 *
107 * `LTTNG_EVENT_FIELD_VALUE_STATUS_OK`:
108 * Success.
109 *
110 * `LTTNG_EVENT_FIELD_VALUE_STATUS_INVALID`:
111 * * `field_val` is `NULL`.
112 * * The type of `field_val` is not
113 * `LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_ENUM` or
114 * `LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_ENUM`.
115 * * `count` is `NULL`.
116 */
117 LTTNG_HIDDEN
118 enum lttng_event_field_value_status
119 lttng_event_field_value_enum_get_label_count(
120 const struct lttng_event_field_value *field_val,
121 unsigned int *count);
122
123 /*
124 * Returns the label at index `index` of the enumeration event field
125 * value `field_val`, or `NULL` if:
126 *
127 * * `field_val` is `NULL`.
128 * * The type of `field_val` is not
129 * `LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_ENUM` or
130 * `LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_ENUM`.
131 * * `index` is greater than or equal to the label count of `field_val`,
132 * as returned by lttng_event_field_value_enum_get_label_count().
133 */
134 LTTNG_HIDDEN
135 const char *lttng_event_field_value_enum_get_label_at_index(
136 const struct lttng_event_field_value *field_val,
137 unsigned int index);
138
139 LTTNG_HIDDEN
140 struct lttng_event_field_value *lttng_event_field_value_uint_create(
141 uint64_t val);
142
143 LTTNG_HIDDEN
144 struct lttng_event_field_value *lttng_event_field_value_int_create(
145 int64_t val);
146
147 LTTNG_HIDDEN
148 struct lttng_event_field_value *lttng_event_field_value_enum_uint_create(
149 uint64_t val);
150
151 LTTNG_HIDDEN
152 struct lttng_event_field_value *lttng_event_field_value_enum_int_create(
153 int64_t val);
154
155 LTTNG_HIDDEN
156 struct lttng_event_field_value *lttng_event_field_value_real_create(double val);
157
158 LTTNG_HIDDEN
159 struct lttng_event_field_value *lttng_event_field_value_string_create(
160 const char *val);
161
162 LTTNG_HIDDEN
163 struct lttng_event_field_value *lttng_event_field_value_string_create_with_size(
164 const char *val, size_t size);
165
166 LTTNG_HIDDEN
167 struct lttng_event_field_value *lttng_event_field_value_array_create(void);
168
169 LTTNG_HIDDEN
170 int lttng_event_field_value_enum_append_label(
171 struct lttng_event_field_value *field_val, const char *label);
172
173 LTTNG_HIDDEN
174 int lttng_event_field_value_enum_append_label_with_size(
175 struct lttng_event_field_value *field_val, const char *label,
176 size_t size);
177
178 LTTNG_HIDDEN
179 int lttng_event_field_value_array_append(
180 struct lttng_event_field_value *array_field_val,
181 struct lttng_event_field_value *field_val);
182
183 LTTNG_HIDDEN
184 int lttng_event_field_value_array_append_unavailable(
185 struct lttng_event_field_value *array_field_val);
186
187 LTTNG_HIDDEN
188 void lttng_event_field_value_destroy(struct lttng_event_field_value *field_val);
189
190 #endif /* LTTNG_EVENT_FIELD_VALUE_INTERNAL_H */
This page took 0.034777 seconds and 4 git commands to generate.