Change the prototype to take a descriptor instead of a char *.
Now that provider names can have duplicates enum names are not
necessarily unique.
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
typedef int (*t_statedump_func_ptr)(struct lttng_session *session);
void lttng_handle_pending_statedump(void *owner);
struct cds_list_head *_lttng_get_sessions(void);
-struct lttng_enum *lttng_ust_enum_get(struct lttng_session *session,
- const char *enum_name);
+
+struct lttng_enum *lttng_ust_enum_get_from_desc(struct lttng_session *session,
+ const struct lttng_enum_desc *enum_desc);
void lttng_ust_dl_update(void *ip);
void lttng_ust_fixup_fd_tracker_tls(void);
if (session) {
const struct lttng_enum *_enum;
- _enum = lttng_ust_enum_get(session,
- lbt->enumeration.desc->name);
+ _enum = lttng_ust_enum_get_from_desc(session, lbt->enumeration.desc);
if (!_enum)
return -EINVAL;
ubt->enumeration.id = _enum->id;
const char *enum_name = desc->name;
struct lttng_enum *_enum;
struct cds_hlist_head *head;
- struct cds_hlist_node *node;
int ret = 0;
size_t name_len = strlen(enum_name);
uint32_t hash;
int notify_socket;
+ /* Check if this enum is already registered for this session. */
hash = jhash(enum_name, name_len, 0);
head = &session->enums_ht.table[hash & (LTTNG_UST_ENUM_HT_SIZE - 1)];
- cds_hlist_for_each_entry(_enum, node, head, hlist) {
- assert(_enum->desc);
- if (!strncmp(_enum->desc->name, desc->name,
- LTTNG_UST_SYM_NAME_LEN - 1)) {
- ret = -EEXIST;
- goto exist;
- }
+
+ _enum = lttng_ust_enum_get_from_desc(session, desc);
+ if (_enum) {
+ ret = -EEXIST;
+ goto exist;
}
notify_socket = lttng_get_notify_socket(session->owner);
/*
* Needed by comm layer.
*/
-struct lttng_enum *lttng_ust_enum_get(struct lttng_session *session,
- const char *enum_name)
+struct lttng_enum *lttng_ust_enum_get_from_desc(struct lttng_session *session,
+ const struct lttng_enum_desc *enum_desc)
{
struct lttng_enum *_enum;
struct cds_hlist_head *head;
struct cds_hlist_node *node;
- size_t name_len = strlen(enum_name);
+ size_t name_len = strlen(enum_desc->name);
uint32_t hash;
- hash = jhash(enum_name, name_len, 0);
+ hash = jhash(enum_desc->name, name_len, 0);
head = &session->enums_ht.table[hash & (LTTNG_UST_ENUM_HT_SIZE - 1)];
cds_hlist_for_each_entry(_enum, node, head, hlist) {
assert(_enum->desc);
- if (!strncmp(_enum->desc->name, enum_name,
- LTTNG_UST_SYM_NAME_LEN - 1))
+ if (_enum->desc == enum_desc)
return _enum;
}
return NULL;