Fix: move lttng_context_is_app to core file
[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 "lttng-tracer-core.h"
25 #include "jhash.h"
26
27 static CDS_LIST_HEAD(lttng_transport_list);
28
29 struct lttng_transport *lttng_transport_find(const char *name)
30 {
31 struct lttng_transport *transport;
32
33 cds_list_for_each_entry(transport, &lttng_transport_list, node) {
34 if (!strcmp(transport->name, name))
35 return transport;
36 }
37 return NULL;
38 }
39
40 /**
41 * lttng_transport_register - LTT transport registration
42 * @transport: transport structure
43 *
44 * Registers a transport which can be used as output to extract the data out of
45 * LTTng. Called with ust_lock held.
46 */
47 void lttng_transport_register(struct lttng_transport *transport)
48 {
49 cds_list_add_tail(&transport->node, &lttng_transport_list);
50 }
51
52 /**
53 * lttng_transport_unregister - LTT transport unregistration
54 * @transport: transport structure
55 * Called with ust_lock held.
56 */
57 void lttng_transport_unregister(struct lttng_transport *transport)
58 {
59 cds_list_del(&transport->node);
60 }
61
62 /*
63 * Needed by comm layer.
64 */
65 struct lttng_enum *lttng_ust_enum_get(struct lttng_session *session,
66 const char *enum_name)
67 {
68 struct lttng_enum *_enum;
69 struct cds_hlist_head *head;
70 struct cds_hlist_node *node;
71 size_t name_len = strlen(enum_name);
72 uint32_t hash;
73
74 hash = jhash(enum_name, name_len, 0);
75 head = &session->enums_ht.table[hash & (LTTNG_UST_ENUM_HT_SIZE - 1)];
76 cds_hlist_for_each_entry(_enum, node, head, hlist) {
77 assert(_enum->desc);
78 if (!strncmp(_enum->desc->name, enum_name,
79 LTTNG_UST_SYM_NAME_LEN - 1))
80 return _enum;
81 }
82 return NULL;
83 }
84
85 size_t lttng_ust_dummy_get_size(struct lttng_ctx_field *field, size_t offset)
86 {
87 size_t size = 0;
88
89 size += lib_ring_buffer_align(offset, lttng_alignof(char));
90 size += sizeof(char); /* tag */
91 return size;
92 }
93
94 void lttng_ust_dummy_record(struct lttng_ctx_field *field,
95 struct lttng_ust_lib_ring_buffer_ctx *ctx,
96 struct lttng_channel *chan)
97 {
98 char sel_char = (char) LTTNG_UST_DYNAMIC_TYPE_NONE;
99
100 lib_ring_buffer_align_ctx(ctx, lttng_alignof(sel_char));
101 chan->ops->event_write(ctx, &sel_char, sizeof(sel_char));
102 }
103
104 void lttng_ust_dummy_get_value(struct lttng_ctx_field *field,
105 struct lttng_ctx_value *value)
106 {
107 value->sel = LTTNG_UST_DYNAMIC_TYPE_NONE;
108 }
109
110 int lttng_context_is_app(const char *name)
111 {
112 if (strncmp(name, "$app.", strlen("$app.")) != 0) {
113 return 0;
114 }
115 return 1;
116 }
This page took 0.031723 seconds and 5 git commands to generate.