Fix: handle sys_futex() FUTEX_WAIT interrupted by signal
[urcu.git] / urcu / rculfstack.h
index f43c9d8c1e679c344bdb289b445fdd99ed0c466d..c7e5599d07fa12f13573c6dd877432be08a120e9 100644 (file)
@@ -1,3 +1,6 @@
+#ifndef _URCU_RCULFSTACK_H
+#define _URCU_RCULFSTACK_H
+
 /*
  * rculfstack.h
  *
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#if (!defined(_GNU_SOURCE) && !defined(_LGPL_SOURCE))
-#error "Dynamic loader LGPL wrappers not implemented yet"
+#include <urcu/compiler.h>
+
+#ifdef __cplusplus
+extern "C" {
 #endif
 
-struct rcu_lfs_node {
-       struct rcu_lfs_node *next;
+#ifndef CDS_LFS_RCU_DEPRECATED
+#define CDS_LFS_RCU_DEPRECATED \
+       CDS_DEPRECATED("urcu/rculfstack.h is deprecated. Please use urcu/lfstack.h instead.")
+#endif
+
+struct cds_lfs_node_rcu {
+       struct cds_lfs_node_rcu *next;
 };
 
-struct rcu_lfs_stack {
-       struct rcu_lfs_node *head;
+struct cds_lfs_stack_rcu {
+       struct cds_lfs_node_rcu *head;
 };
 
-void rcu_lfs_node_init(struct rcu_lfs_node *node)
+#ifdef _LGPL_SOURCE
+
+#include <urcu/static/rculfstack.h>
+
+static inline CDS_LFS_RCU_DEPRECATED
+void cds_lfs_node_init_rcu(struct cds_lfs_node_rcu *node)
 {
+       _cds_lfs_node_init_rcu(node);
 }
 
-void rcu_lfs_init(struct rcu_lfs_stack *s)
+static inline
+void cds_lfs_init_rcu(struct cds_lfs_stack_rcu *s)
 {
-       s->head = NULL;
+       _cds_lfs_init_rcu(s);
 }
 
-void rcu_lfs_push(struct rcu_lfs_stack *s, struct rcu_lfs_node *node)
+static inline CDS_LFS_RCU_DEPRECATED
+int cds_lfs_push_rcu(struct cds_lfs_stack_rcu *s,
+                       struct cds_lfs_node_rcu *node)
 {
-       rcu_read_lock();
-       for (;;) {
-               struct rcu_lfs_node *head = rcu_dereference(s->head);
-
-               node->next = head;
-               /*
-                * uatomic_cmpxchg() implicit memory barrier orders earlier
-                * stores to node before publication.
-                */
-               if (uatomic_cmpxchg(&s->head, head, node) == head) {
-                       rcu_read_unlock();
-                       return;
-               } else {
-                       /* Failure to prepend. Retry. */
-                       continue;
-               }
-       }
+       return _cds_lfs_push_rcu(s, node);
 }
 
-struct rcu_lfs_node *
-rcu_lfs_pop(struct rcu_lfs_stack *s)
+static inline CDS_LFS_RCU_DEPRECATED
+struct cds_lfs_node_rcu *cds_lfs_pop_rcu(struct cds_lfs_stack_rcu *s)
 {
-       rcu_read_lock();
-       for (;;) {
-               struct rcu_lfs_node *head = rcu_dereference(s->head);
-
-               if (head) {
-                       struct rcu_lfs_node *next = rcu_dereference(head->next);
-
-                       if (uatomic_cmpxchg(&s->head, head, next) == head) {
-                               rcu_read_unlock();
-                               return head;
-                       } else {
-                               /* Concurrent modification. Retry. */
-                               continue;
-                       }
-               } else {
-                       /* Empty stack */
-                       rcu_read_unlock();
-                       return NULL;
-               }
-       }
+       return _cds_lfs_pop_rcu(s);
 }
+
+#else /* !_LGPL_SOURCE */
+
+extern CDS_LFS_RCU_DEPRECATED
+void cds_lfs_node_init_rcu(struct cds_lfs_node_rcu *node);
+extern CDS_LFS_RCU_DEPRECATED
+void cds_lfs_init_rcu(struct cds_lfs_stack_rcu *s);
+extern CDS_LFS_RCU_DEPRECATED
+int cds_lfs_push_rcu(struct cds_lfs_stack_rcu *s,
+                       struct cds_lfs_node_rcu *node);
+
+/*
+ * Should be called under rcu read lock critical section.
+ *
+ * The caller must wait for a grace period to pass before freeing the returned
+ * node or modifying the cds_lfs_node_rcu structure.
+ * Returns NULL if stack is empty.
+ */
+extern CDS_LFS_RCU_DEPRECATED
+struct cds_lfs_node_rcu *cds_lfs_pop_rcu(struct cds_lfs_stack_rcu *s);
+
+#endif /* !_LGPL_SOURCE */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _URCU_RCULFSTACK_H */
This page took 0.024204 seconds and 4 git commands to generate.