SoW-2020-0003: Trace Hit Counters
[lttng-tools.git] / include / lttng / map-key-internal.h
1 /*
2 * Copyright (C) 2021 Francis Deslauriers <francis.deslauriers@efficios.com>
3 *
4 * SPDX-License-Identifier: LGPL-2.1-only
5 *
6 */
7 #ifndef LTTNG_MAP_KEY_INTERNAL_H
8 #define LTTNG_MAP_KEY_INTERNAL_H
9
10 #include <common/dynamic-array.h>
11 #include <common/macros.h>
12 #include <stdbool.h>
13 #include <urcu/ref.h>
14
15 #include <lttng/map-key.h>
16
17 struct lttng_payload;
18 struct lttng_payload_view;
19 struct lttng_map_key_token;
20
21 typedef bool (*map_key_token_equal_cb)(const struct lttng_map_key_token *a,
22 const struct lttng_map_key_token *b);
23
24 enum lttng_map_key_token_type {
25 LTTNG_MAP_KEY_TOKEN_TYPE_STRING,
26 LTTNG_MAP_KEY_TOKEN_TYPE_VARIABLE,
27 };
28
29 struct lttng_map_key_token {
30 enum lttng_map_key_token_type type;
31 map_key_token_equal_cb equal;
32 };
33
34 struct lttng_map_key_token_comm {
35 uint8_t type;
36 };
37
38 struct lttng_map_key_token_string {
39 struct lttng_map_key_token parent;
40 char *string;
41 };
42
43 struct lttng_map_key_token_string_comm {
44 uint8_t parent_type;
45
46 /* Includes null terminator. */
47 uint32_t string_len;
48
49 char payload[];
50 };
51
52 struct lttng_map_key_token_variable {
53 struct lttng_map_key_token parent;
54 enum lttng_map_key_token_variable_type type;
55 };
56
57 struct lttng_map_key_token_variable_comm {
58 uint8_t parent_type;
59 uint8_t var_type;
60 };
61
62 struct lttng_map_key {
63 /* Reference counting is only exposed to internal users*/
64 struct urcu_ref ref;
65 /* Array of `struct lttng_map_key_token` */
66 struct lttng_dynamic_pointer_array tokens;
67 };
68
69 struct lttng_map_key_comm {
70 uint32_t token_count;
71 /* Array of `struct lttng_map_key_token` */
72 char payload[];
73 };
74
75 LTTNG_HIDDEN
76 void lttng_map_key_get(struct lttng_map_key *key);
77
78 LTTNG_HIDDEN
79 void lttng_map_key_put(struct lttng_map_key *key);
80
81 LTTNG_HIDDEN
82 ssize_t lttng_map_key_create_from_payload(struct lttng_payload_view *view,
83 struct lttng_map_key **key);
84
85 LTTNG_HIDDEN
86 int lttng_map_key_serialize(const struct lttng_map_key *key,
87 struct lttng_payload *payload);
88
89 LTTNG_HIDDEN
90 enum lttng_map_key_status lttng_map_key_get_token_count(
91 const struct lttng_map_key *key, unsigned int *count);
92
93 LTTNG_HIDDEN
94 const struct lttng_map_key_token *lttng_map_key_get_token_at_index(
95 const struct lttng_map_key *key, unsigned int index);
96
97 LTTNG_HIDDEN
98 enum lttng_map_key_token_variable_type lttng_map_key_token_variable_get_type(
99 const struct lttng_map_key_token_variable *token);
100
101 LTTNG_HIDDEN
102 const char *lttng_map_key_token_string_get_string(
103 const struct lttng_map_key_token_string *token);
104
105 LTTNG_HIDDEN
106 bool lttng_map_key_is_equal(
107 const struct lttng_map_key *a, const struct lttng_map_key *b);
108
109 LTTNG_HIDDEN
110 void lttng_map_key_get(struct lttng_map_key *key);
111
112 LTTNG_HIDDEN
113 void lttng_map_key_put(struct lttng_map_key *key);
114
115 LTTNG_HIDDEN
116 struct lttng_map_key *lttng_map_key_parse_from_string(const char *key_str);
117
118 #endif /* LTTNG_MAP_KEY_INTERNAL_H */
This page took 0.032504 seconds and 5 git commands to generate.