Cleanup: apply `include-what-you-use` guideline for `uint*_t`
[lttng-ust.git] / liblttng-ust / ust-core.c
1 /*
2 * ust-core.c
3 *
4 * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; only
9 * version 2.1 of the License.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 #define _LGPL_SOURCE
22 #include <stdint.h>
23 #include <stddef.h>
24 #include <stdlib.h>
25 #include <lttng/ust-events.h>
26 #include <usterr-signal-safe.h>
27 #include "lttng-tracer-core.h"
28 #include "jhash.h"
29
30 static CDS_LIST_HEAD(lttng_transport_list);
31
32 struct lttng_transport *lttng_transport_find(const char *name)
33 {
34 struct lttng_transport *transport;
35
36 cds_list_for_each_entry(transport, &lttng_transport_list, node) {
37 if (!strcmp(transport->name, name))
38 return transport;
39 }
40 return NULL;
41 }
42
43 /**
44 * lttng_transport_register - LTT transport registration
45 * @transport: transport structure
46 *
47 * Registers a transport which can be used as output to extract the data out of
48 * LTTng. Called with ust_lock held.
49 */
50 void lttng_transport_register(struct lttng_transport *transport)
51 {
52 cds_list_add_tail(&transport->node, &lttng_transport_list);
53 }
54
55 /**
56 * lttng_transport_unregister - LTT transport unregistration
57 * @transport: transport structure
58 * Called with ust_lock held.
59 */
60 void lttng_transport_unregister(struct lttng_transport *transport)
61 {
62 cds_list_del(&transport->node);
63 }
64
65 /*
66 * Needed by comm layer.
67 */
68 struct lttng_enum *lttng_ust_enum_get_from_desc(struct lttng_session *session,
69 const struct lttng_enum_desc *enum_desc)
70 {
71 struct lttng_enum *_enum;
72 struct cds_hlist_head *head;
73 struct cds_hlist_node *node;
74 size_t name_len = strlen(enum_desc->name);
75 uint32_t hash;
76
77 hash = jhash(enum_desc->name, name_len, 0);
78 head = &session->enums_ht.table[hash & (LTTNG_UST_ENUM_HT_SIZE - 1)];
79 cds_hlist_for_each_entry(_enum, node, head, hlist) {
80 assert(_enum->desc);
81 if (_enum->desc == enum_desc)
82 return _enum;
83 }
84 return NULL;
85 }
86
87 size_t lttng_ust_dummy_get_size(struct lttng_ctx_field *field, size_t offset)
88 {
89 size_t size = 0;
90
91 size += lib_ring_buffer_align(offset, lttng_alignof(char));
92 size += sizeof(char); /* tag */
93 return size;
94 }
95
96 void lttng_ust_dummy_record(struct lttng_ctx_field *field,
97 struct lttng_ust_lib_ring_buffer_ctx *ctx,
98 struct lttng_channel *chan)
99 {
100 char sel_char = (char) LTTNG_UST_DYNAMIC_TYPE_NONE;
101
102 lib_ring_buffer_align_ctx(ctx, lttng_alignof(sel_char));
103 chan->ops->event_write(ctx, &sel_char, sizeof(sel_char));
104 }
105
106 void lttng_ust_dummy_get_value(struct lttng_ctx_field *field,
107 struct lttng_ctx_value *value)
108 {
109 value->sel = LTTNG_UST_DYNAMIC_TYPE_NONE;
110 }
111
112 int lttng_context_is_app(const char *name)
113 {
114 if (strncmp(name, "$app.", strlen("$app.")) != 0) {
115 return 0;
116 }
117 return 1;
118 }
This page took 0.032228 seconds and 4 git commands to generate.