#include <common/common.hpp>
#include <common/defaults.hpp>
+#include <common/urcu.hpp>
#include <string.h>
#include <urcu.h>
*/
static int match_str(struct cds_lfht_node *node, const void *key)
{
- struct lttng_ht_node_str *match_node =
- lttng::utils::container_of(node, <tng_ht_node_str::node);
+ auto *match_node = reinterpret_cast<lttng_ht_node_str *>(
+ lttng::utils::container_of(node, <tng_ht_node_str::node));
return hash_match_key_str(match_node->key, (void *) key);
}
*/
static int match_ulong(struct cds_lfht_node *node, const void *key)
{
- struct lttng_ht_node_ulong *match_node =
- lttng::utils::container_of(node, <tng_ht_node_ulong::node);
+ auto *match_node = reinterpret_cast<lttng_ht_node_ulong *>(
+ lttng::utils::container_of(node, <tng_ht_node_ulong::node));
return hash_match_key_ulong((void *) match_node->key, (void *) key);
}
*/
static int match_u64(struct cds_lfht_node *node, const void *key)
{
- struct lttng_ht_node_u64 *match_node =
- lttng::utils::container_of(node, <tng_ht_node_u64::node);
+ auto *match_node = reinterpret_cast<lttng_ht_node_u64 *>(
+ lttng::utils::container_of(node, <tng_ht_node_u64::node));
return hash_match_key_u64(&match_node->key, (void *) key);
}
*/
static int match_two_u64(struct cds_lfht_node *node, const void *key)
{
- struct lttng_ht_node_two_u64 *match_node =
- lttng::utils::container_of(node, <tng_ht_node_two_u64::node);
+ auto *match_node = reinterpret_cast<lttng_ht_node_two_u64 *>(
+ lttng::utils::container_of(node, <tng_ht_node_two_u64::node));
return hash_match_key_two_u64((void *) &match_node->key, (void *) key);
}
LTTNG_ASSERT(node);
/* RCU read lock protects from ABA. */
- rcu_read_lock();
+ const lttng::urcu::read_lock_guard read_lock;
node_ptr = cds_lfht_add_unique(ht->ht,
ht->hash_fct(node->key, lttng_ht_seed),
ht->match_fct,
node->key,
&node->node);
- rcu_read_unlock();
LTTNG_ASSERT(node_ptr == &node->node);
}
LTTNG_ASSERT(node);
/* RCU read lock protects from ABA. */
- rcu_read_lock();
+ const lttng::urcu::read_lock_guard read_lock;
cds_lfht_add(ht->ht, ht->hash_fct(node->key, lttng_ht_seed), &node->node);
- rcu_read_unlock();
}
/*
LTTNG_ASSERT(node);
/* RCU read lock protects from ABA. */
- rcu_read_lock();
+ const lttng::urcu::read_lock_guard read_lock;
cds_lfht_add(ht->ht, ht->hash_fct((void *) node->key, lttng_ht_seed), &node->node);
- rcu_read_unlock();
}
/*
LTTNG_ASSERT(node);
/* RCU read lock protects from ABA. */
- rcu_read_lock();
+ const lttng::urcu::read_lock_guard read_lock;
cds_lfht_add(ht->ht, ht->hash_fct(&node->key, lttng_ht_seed), &node->node);
- rcu_read_unlock();
}
/*
LTTNG_ASSERT(node);
/* RCU read lock protects from ABA. */
- rcu_read_lock();
+ const lttng::urcu::read_lock_guard read_lock;
node_ptr = cds_lfht_add_unique(ht->ht,
ht->hash_fct((void *) node->key, lttng_ht_seed),
ht->match_fct,
(void *) node->key,
&node->node);
- rcu_read_unlock();
LTTNG_ASSERT(node_ptr == &node->node);
}
LTTNG_ASSERT(node);
/* RCU read lock protects from ABA. */
- rcu_read_lock();
+ const lttng::urcu::read_lock_guard read_lock;
node_ptr = cds_lfht_add_unique(ht->ht,
ht->hash_fct(&node->key, lttng_ht_seed),
ht->match_fct,
&node->key,
&node->node);
- rcu_read_unlock();
LTTNG_ASSERT(node_ptr == &node->node);
}
LTTNG_ASSERT(node);
/* RCU read lock protects from ABA. */
- rcu_read_lock();
+ const lttng::urcu::read_lock_guard read_lock;
node_ptr = cds_lfht_add_unique(ht->ht,
ht->hash_fct((void *) &node->key, lttng_ht_seed),
ht->match_fct,
(void *) &node->key,
&node->node);
- rcu_read_unlock();
LTTNG_ASSERT(node_ptr == &node->node);
}
LTTNG_ASSERT(node);
/* RCU read lock protects from ABA. */
- rcu_read_lock();
+ const lttng::urcu::read_lock_guard read_lock;
node_ptr = cds_lfht_add_replace(ht->ht,
ht->hash_fct((void *) node->key, lttng_ht_seed),
ht->match_fct,
(void *) node->key,
&node->node);
- rcu_read_unlock();
if (!node_ptr) {
return nullptr;
} else {
- return lttng::utils::container_of(node_ptr, <tng_ht_node_ulong::node);
+ return reinterpret_cast<lttng_ht_node_ulong *>(
+ lttng::utils::container_of(node_ptr, <tng_ht_node_ulong::node));
}
- LTTNG_ASSERT(node_ptr == &node->node);
}
/*
LTTNG_ASSERT(node);
/* RCU read lock protects from ABA. */
- rcu_read_lock();
+ const lttng::urcu::read_lock_guard read_lock;
node_ptr = cds_lfht_add_replace(ht->ht,
ht->hash_fct(&node->key, lttng_ht_seed),
ht->match_fct,
&node->key,
&node->node);
- rcu_read_unlock();
if (!node_ptr) {
return nullptr;
} else {
- return lttng::utils::container_of(node_ptr, <tng_ht_node_u64::node);
+ LTTNG_ASSERT(node_ptr == &node->node);
+ return reinterpret_cast<lttng_ht_node_u64 *>(
+ lttng::utils::container_of(node_ptr, <tng_ht_node_u64::node));
}
- LTTNG_ASSERT(node_ptr == &node->node);
}
/*
LTTNG_ASSERT(iter);
/* RCU read lock protects from ABA. */
- rcu_read_lock();
+ const lttng::urcu::read_lock_guard read_lock;
ret = cds_lfht_del(ht->ht, iter->iter.node);
- rcu_read_unlock();
return ret;
}
LTTNG_ASSERT(ht->ht);
/* RCU read lock protects from ABA and allows RCU traversal. */
- rcu_read_lock();
+ const lttng::urcu::read_lock_guard read_lock;
cds_lfht_count_nodes(ht->ht, &scb, &count, &sca);
- rcu_read_unlock();
return count;
-}
-
-/*
- * Return lttng ht string node from iterator.
- */
-struct lttng_ht_node_str *lttng_ht_iter_get_node_str(struct lttng_ht_iter *iter)
-{
- struct cds_lfht_node *node;
-
- LTTNG_ASSERT(iter);
- node = cds_lfht_iter_get_node(&iter->iter);
- if (!node) {
- return nullptr;
- }
- return lttng::utils::container_of(node, <tng_ht_node_str::node);
-}
-
-/*
- * Return lttng ht unsigned long node from iterator.
- */
-struct lttng_ht_node_ulong *lttng_ht_iter_get_node_ulong(struct lttng_ht_iter *iter)
-{
- struct cds_lfht_node *node;
-
- LTTNG_ASSERT(iter);
- node = cds_lfht_iter_get_node(&iter->iter);
- if (!node) {
- return nullptr;
- }
- return lttng::utils::container_of(node, <tng_ht_node_ulong::node);
-}
-
-/*
- * Return lttng ht unsigned long node from iterator.
- */
-struct lttng_ht_node_u64 *lttng_ht_iter_get_node_u64(struct lttng_ht_iter *iter)
-{
- struct cds_lfht_node *node;
-
- LTTNG_ASSERT(iter);
- node = cds_lfht_iter_get_node(&iter->iter);
- if (!node) {
- return nullptr;
- }
- return lttng::utils::container_of(node, <tng_ht_node_u64::node);
-}
-
-/*
- * Return lttng ht stream and index id node from iterator.
- */
-struct lttng_ht_node_two_u64 *lttng_ht_iter_get_node_two_u64(struct lttng_ht_iter *iter)
-{
- struct cds_lfht_node *node;
-
- LTTNG_ASSERT(iter);
- node = cds_lfht_iter_get_node(&iter->iter);
- if (!node) {
- return nullptr;
- }
- return lttng::utils::container_of(node, <tng_ht_node_two_u64::node);
-}
+}
\ No newline at end of file