Fix: handle backward probe compatibility for application contexts
[lttng-ust.git] / liblttng-ust / ust-core.c
CommitLineData
5e96a467
MD
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
5e96a467 21#include <stdlib.h>
44c72f10
MD
22#include <lttng/ust-events.h>
23#include <usterr-signal-safe.h>
c785c634 24#include "jhash.h"
5e96a467 25
7dd08bec 26static CDS_LIST_HEAD(lttng_transport_list);
c1fca457 27
7dd08bec 28struct lttng_transport *lttng_transport_find(const char *name)
c1fca457 29{
7dd08bec 30 struct lttng_transport *transport;
c1fca457 31
7dd08bec 32 cds_list_for_each_entry(transport, &lttng_transport_list, node) {
c1fca457
MD
33 if (!strcmp(transport->name, name))
34 return transport;
35 }
36 return NULL;
37}
38
39/**
7dd08bec 40 * lttng_transport_register - LTT transport registration
c1fca457
MD
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 */
7dd08bec 46void lttng_transport_register(struct lttng_transport *transport)
c1fca457 47{
7dd08bec 48 cds_list_add_tail(&transport->node, &lttng_transport_list);
c1fca457
MD
49}
50
51/**
7dd08bec 52 * lttng_transport_unregister - LTT transport unregistration
c1fca457
MD
53 * @transport: transport structure
54 * Called with ust_lock held.
55 */
7dd08bec 56void lttng_transport_unregister(struct lttng_transport *transport)
c1fca457
MD
57{
58 cds_list_del(&transport->node);
59}
c785c634
MD
60
61/*
62 * Needed by comm layer.
63 */
64struct 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.031752 seconds and 4 git commands to generate.