From: Michael Jeanson Date: Thu, 22 Apr 2021 15:31:50 +0000 (-0400) Subject: Move lttng_ust_enum_get_from_desc to libcommon X-Git-Tag: v2.13.0-rc1~13 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=810185f3a90e717e2a482b4555f90f4d4f6d7bbf;p=lttng-ust.git Move lttng_ust_enum_get_from_desc to libcommon It is used by both liblttng-ust and liblttng-ust-ctl and contains no shared state. Change-Id: I8079e2c81cf72fe2075205608cf5e99aa07f6dfd Signed-off-by: Michael Jeanson Signed-off-by: Mathieu Desnoyers --- diff --git a/src/common/Makefile.am b/src/common/Makefile.am index 777764fd..ce427655 100644 --- a/src/common/Makefile.am +++ b/src/common/Makefile.am @@ -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 index 00000000..f70a1b4b --- /dev/null +++ b/src/common/events.c @@ -0,0 +1,27 @@ + +#include + +#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; +} diff --git a/src/lib/lttng-ust/ust-core.c b/src/lib/lttng-ust/ust-core.c index d070124e..e547a497 100644 --- a/src/lib/lttng-ust/ust-core.c +++ b/src/lib/lttng-ust/ust-core.c @@ -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)