Move lttng_ust_enum_get_from_desc to libcommon
authorMichael Jeanson <mjeanson@efficios.com>
Thu, 22 Apr 2021 15:31:50 +0000 (11:31 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 23 Apr 2021 19:45:17 +0000 (15:45 -0400)
It is used by both liblttng-ust and liblttng-ust-ctl and contains no
shared state.

Change-Id: I8079e2c81cf72fe2075205608cf5e99aa07f6dfd
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
src/common/Makefile.am
src/common/events.c [new file with mode: 0644]
src/lib/lttng-ust/ust-core.c

index 777764fd7750be3e00d32d3c7a823592d48fd1e4..ce427655fc82dc003cc3daed3ce33a7a22f0ed97 100644 (file)
@@ -139,6 +139,7 @@ libsnprintf_la_SOURCES = \
 libcommon_la_SOURCES = \
        elf.c \
        elf.h \
+       events.c \
        getenv.c \
        getenv.h \
        logging.c \
diff --git a/src/common/events.c b/src/common/events.c
new file mode 100644 (file)
index 0000000..f70a1b4
--- /dev/null
@@ -0,0 +1,27 @@
+
+#include <string.h>
+
+#include "common/events.h"
+#include "common/jhash.h"
+
+/*
+ * Needed by comm layer.
+ */
+struct lttng_enum *lttng_ust_enum_get_from_desc(struct lttng_ust_session *session,
+               const struct lttng_ust_enum_desc *enum_desc)
+{
+       struct lttng_enum *_enum;
+       struct cds_hlist_head *head;
+       struct cds_hlist_node *node;
+       size_t name_len = strlen(enum_desc->name);
+       uint32_t hash;
+
+       hash = jhash(enum_desc->name, name_len, 0);
+       head = &session->priv->enums_ht.table[hash & (LTTNG_UST_ENUM_HT_SIZE - 1)];
+       cds_hlist_for_each_entry(_enum, node, head, hlist) {
+               assert(_enum->desc);
+               if (_enum->desc == enum_desc)
+                       return _enum;
+       }
+       return NULL;
+}
index d070124edf622c68c7215d73418fc31e770dd6cf..e547a4972b2c9f0344973c89a226ce5110a6ea74 100644 (file)
@@ -86,28 +86,6 @@ void lttng_counter_transport_unregister(struct lttng_counter_transport *transpor
        cds_list_del(&transport->node);
 }
 
-/*
- * Needed by comm layer.
- */
-struct lttng_enum *lttng_ust_enum_get_from_desc(struct lttng_ust_session *session,
-               const struct lttng_ust_enum_desc *enum_desc)
-{
-       struct lttng_enum *_enum;
-       struct cds_hlist_head *head;
-       struct cds_hlist_node *node;
-       size_t name_len = strlen(enum_desc->name);
-       uint32_t hash;
-
-       hash = jhash(enum_desc->name, name_len, 0);
-       head = &session->priv->enums_ht.table[hash & (LTTNG_UST_ENUM_HT_SIZE - 1)];
-       cds_hlist_for_each_entry(_enum, node, head, hlist) {
-               assert(_enum->desc);
-               if (_enum->desc == enum_desc)
-                       return _enum;
-       }
-       return NULL;
-}
-
 size_t lttng_ust_dummy_get_size(void *priv __attribute__((unused)),
                struct lttng_ust_probe_ctx *probe_ctx __attribute__((unused)),
                size_t offset)
This page took 0.026884 seconds and 4 git commands to generate.