Add CTF enum type support to tracepoint event
[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 #include <stdlib.h>
22 #include <lttng/ust-events.h>
23 #include <usterr-signal-safe.h>
24 #include "jhash.h"
25
26 static CDS_LIST_HEAD(lttng_transport_list);
27
28 struct lttng_transport *lttng_transport_find(const char *name)
29 {
30 struct lttng_transport *transport;
31
32 cds_list_for_each_entry(transport, &lttng_transport_list, node) {
33 if (!strcmp(transport->name, name))
34 return transport;
35 }
36 return NULL;
37 }
38
39 /**
40 * lttng_transport_register - LTT transport registration
41 * @transport: transport structure
42 *
43 * Registers a transport which can be used as output to extract the data out of
44 * LTTng. Called with ust_lock held.
45 */
46 void lttng_transport_register(struct lttng_transport *transport)
47 {
48 cds_list_add_tail(&transport->node, &lttng_transport_list);
49 }
50
51 /**
52 * lttng_transport_unregister - LTT transport unregistration
53 * @transport: transport structure
54 * Called with ust_lock held.
55 */
56 void lttng_transport_unregister(struct lttng_transport *transport)
57 {
58 cds_list_del(&transport->node);
59 }
60
61 /*
62 * Needed by comm layer.
63 */
64 struct lttng_enum *lttng_ust_enum_get(struct lttng_session *session,
65 const char *enum_name)
66 {
67 struct lttng_enum *_enum;
68 struct cds_hlist_head *head;
69 struct cds_hlist_node *node;
70 size_t name_len = strlen(enum_name);
71 uint32_t hash;
72
73 hash = jhash(enum_name, name_len, 0);
74 head = &session->enums_ht.table[hash & (LTTNG_UST_ENUM_HT_SIZE - 1)];
75 cds_hlist_for_each_entry(_enum, node, head, hlist) {
76 assert(_enum->desc);
77 if (!strncmp(_enum->desc->name, enum_name,
78 LTTNG_UST_SYM_NAME_LEN - 1))
79 return _enum;
80 }
81 return NULL;
82 }
This page took 0.031258 seconds and 5 git commands to generate.