+#ifndef _URCU_RCULFSTACK_H
+#define _URCU_RCULFSTACK_H
+
/*
* rculfstack.h
*
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#if (!defined(_GNU_SOURCE) && !defined(_LGPL_SOURCE))
#error "Dynamic loader LGPL wrappers not implemented yet"
#endif
void rcu_lfs_push(struct rcu_lfs_stack *s, struct rcu_lfs_node *node)
{
- rcu_read_lock();
for (;;) {
- struct rcu_lfs_node *head = rcu_dereference(s->head);
+ struct rcu_lfs_node *head;
+ rcu_read_lock();
+ head = rcu_dereference(s->head);
node->next = head;
/*
* uatomic_cmpxchg() implicit memory barrier orders earlier
return;
} else {
/* Failure to prepend. Retry. */
+ rcu_read_unlock();
continue;
}
}
/*
* The caller must wait for a grace period to pass before freeing the returned
- * node.
+ * node or modifying the rcu_lfs_node structure.
* Returns NULL if stack is empty.
*/
struct rcu_lfs_node *
rcu_lfs_pop(struct rcu_lfs_stack *s)
{
- rcu_read_lock();
for (;;) {
- struct rcu_lfs_node *head = rcu_dereference(s->head);
+ struct rcu_lfs_node *head;
+ rcu_read_lock();
+ head = rcu_dereference(s->head);
if (head) {
struct rcu_lfs_node *next = rcu_dereference(head->next);
return head;
} else {
/* Concurrent modification. Retry. */
+ rcu_read_unlock();
continue;
}
} else {
}
}
}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _URCU_RCULFSTACK_H */