Cleanup: apply `include-what-you-use` guideline for `uint*_t`
[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
3fbec7dc 21#define _LGPL_SOURCE
fb31eb73 22#include <stdint.h>
b4051ad8 23#include <stddef.h>
5e96a467 24#include <stdlib.h>
44c72f10
MD
25#include <lttng/ust-events.h>
26#include <usterr-signal-safe.h>
797b05f6 27#include "lttng-tracer-core.h"
c785c634 28#include "jhash.h"
5e96a467 29
7dd08bec 30static CDS_LIST_HEAD(lttng_transport_list);
c1fca457 31
7dd08bec 32struct lttng_transport *lttng_transport_find(const char *name)
c1fca457 33{
7dd08bec 34 struct lttng_transport *transport;
c1fca457 35
7dd08bec 36 cds_list_for_each_entry(transport, &lttng_transport_list, node) {
c1fca457
MD
37 if (!strcmp(transport->name, name))
38 return transport;
39 }
40 return NULL;
41}
42
43/**
7dd08bec 44 * lttng_transport_register - LTT transport registration
c1fca457
MD
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 */
7dd08bec 50void lttng_transport_register(struct lttng_transport *transport)
c1fca457 51{
7dd08bec 52 cds_list_add_tail(&transport->node, &lttng_transport_list);
c1fca457
MD
53}
54
55/**
7dd08bec 56 * lttng_transport_unregister - LTT transport unregistration
c1fca457
MD
57 * @transport: transport structure
58 * Called with ust_lock held.
59 */
7dd08bec 60void lttng_transport_unregister(struct lttng_transport *transport)
c1fca457
MD
61{
62 cds_list_del(&transport->node);
63}
c785c634
MD
64
65/*
66 * Needed by comm layer.
67 */
b33b46f7
FD
68struct lttng_enum *lttng_ust_enum_get_from_desc(struct lttng_session *session,
69 const struct lttng_enum_desc *enum_desc)
c785c634
MD
70{
71 struct lttng_enum *_enum;
72 struct cds_hlist_head *head;
73 struct cds_hlist_node *node;
b33b46f7 74 size_t name_len = strlen(enum_desc->name);
c785c634
MD
75 uint32_t hash;
76
b33b46f7 77 hash = jhash(enum_desc->name, name_len, 0);
c785c634
MD
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);
b33b46f7 81 if (_enum->desc == enum_desc)
c785c634
MD
82 return _enum;
83 }
84 return NULL;
85}
797b05f6
MD
86
87size_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
96void 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
106void 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}
ce47f5d8
MD
111
112int 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.035082 seconds and 4 git commands to generate.