Move urcu_defer_queue to urcu-defer.c
authorMathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Wed, 23 Sep 2009 17:21:45 +0000 (13:21 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Wed, 23 Sep 2009 17:21:45 +0000 (13:21 -0400)
Too big to be inline.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
urcu-defer-static.h
urcu-defer.c
urcu-defer.h

index dd24c61d85d7885d685323757f83c52c2df2f15f..427f3d34d7aa04c5a56db02140815bfd4a1d949b 100644 (file)
@@ -122,72 +122,4 @@ struct defer_queue {
        void **q;
 };
 
-extern struct defer_queue __thread defer_queue;
-
-extern void rcu_defer_barrier_thread(void);
-extern void wake_up_defer(void);
-
-/*
- * not signal-safe.
- */
-static inline void _rcu_defer_queue(void (*fct)(void *p), void *p)
-{
-       unsigned long head, tail;
-
-       /*
-        * Head is only modified by ourself. Tail can be modified by reclamation
-        * thread.
-        */
-       head = defer_queue.head;
-       tail = LOAD_SHARED(defer_queue.tail);
-
-       /*
-        * If queue is full, empty it ourself.
-        * Worse-case: must allow 2 supplementary entries for fct pointer.
-        */
-       if (unlikely(head - tail >= DEFER_QUEUE_SIZE - 2)) {
-               assert(head - tail <= DEFER_QUEUE_SIZE);
-               rcu_defer_barrier_thread();
-               assert(head - LOAD_SHARED(defer_queue.tail) == 0);
-       }
-
-       if (unlikely(defer_queue.last_fct_in != fct)) {
-               defer_queue.last_fct_in = fct;
-               if (unlikely(DQ_IS_FCT_BIT(fct) || fct == DQ_FCT_MARK)) {
-                       /*
-                        * If the function to encode is not aligned or the
-                        * marker, write DQ_FCT_MARK followed by the function
-                        * pointer.
-                        */
-                       _STORE_SHARED(defer_queue.q[head++ & DEFER_QUEUE_MASK],
-                                     DQ_FCT_MARK);
-                       _STORE_SHARED(defer_queue.q[head++ & DEFER_QUEUE_MASK],
-                                     fct);
-               } else {
-                       DQ_SET_FCT_BIT(fct);
-                       _STORE_SHARED(defer_queue.q[head++ & DEFER_QUEUE_MASK],
-                                     fct);
-               }
-       } else {
-               if (unlikely(DQ_IS_FCT_BIT(p) || p == DQ_FCT_MARK)) {
-                       /*
-                        * If the data to encode is not aligned or the marker,
-                        * write DQ_FCT_MARK followed by the function pointer.
-                        */
-                       _STORE_SHARED(defer_queue.q[head++ & DEFER_QUEUE_MASK],
-                                     DQ_FCT_MARK);
-                       _STORE_SHARED(defer_queue.q[head++ & DEFER_QUEUE_MASK],
-                                     fct);
-               }
-       }
-       _STORE_SHARED(defer_queue.q[head++ & DEFER_QUEUE_MASK], p);
-       smp_wmb();      /* Publish new pointer before head */
-                       /* Write q[] before head. */
-       STORE_SHARED(defer_queue.head, head);
-       /*
-        * Wake-up any waiting defer thread.
-        */
-       wake_up_defer();
-}
-
 #endif /* _URCU_DEFER_STATIC_H */
index 5b904f8321a23c2ef3b84752c64c84cc9f9c865a..5e4650ff003b4c8d97ff0fb240a0d14fa4d8660a 100644 (file)
@@ -74,7 +74,7 @@ static pthread_t tid_defer;
 /*
  * Wake-up any waiting defer thread. Called from many concurrent threads.
  */
-void wake_up_defer(void)
+static void wake_up_defer(void)
 {
        if (unlikely(atomic_read(&defer_thread_futex) == -1))
                atomic_set(&defer_thread_futex, 0);
@@ -222,6 +222,69 @@ end:
        internal_urcu_unlock(&urcu_defer_mutex);
 }
 
+/*
+ * _rcu_defer_queue - Queue a RCU callback.
+ */
+void _rcu_defer_queue(void (*fct)(void *p), void *p)
+{
+       unsigned long head, tail;
+
+       /*
+        * Head is only modified by ourself. Tail can be modified by reclamation
+        * thread.
+        */
+       head = defer_queue.head;
+       tail = LOAD_SHARED(defer_queue.tail);
+
+       /*
+        * If queue is full, empty it ourself.
+        * Worse-case: must allow 2 supplementary entries for fct pointer.
+        */
+       if (unlikely(head - tail >= DEFER_QUEUE_SIZE - 2)) {
+               assert(head - tail <= DEFER_QUEUE_SIZE);
+               rcu_defer_barrier_thread();
+               assert(head - LOAD_SHARED(defer_queue.tail) == 0);
+       }
+
+       if (unlikely(defer_queue.last_fct_in != fct)) {
+               defer_queue.last_fct_in = fct;
+               if (unlikely(DQ_IS_FCT_BIT(fct) || fct == DQ_FCT_MARK)) {
+                       /*
+                        * If the function to encode is not aligned or the
+                        * marker, write DQ_FCT_MARK followed by the function
+                        * pointer.
+                        */
+                       _STORE_SHARED(defer_queue.q[head++ & DEFER_QUEUE_MASK],
+                                     DQ_FCT_MARK);
+                       _STORE_SHARED(defer_queue.q[head++ & DEFER_QUEUE_MASK],
+                                     fct);
+               } else {
+                       DQ_SET_FCT_BIT(fct);
+                       _STORE_SHARED(defer_queue.q[head++ & DEFER_QUEUE_MASK],
+                                     fct);
+               }
+       } else {
+               if (unlikely(DQ_IS_FCT_BIT(p) || p == DQ_FCT_MARK)) {
+                       /*
+                        * If the data to encode is not aligned or the marker,
+                        * write DQ_FCT_MARK followed by the function pointer.
+                        */
+                       _STORE_SHARED(defer_queue.q[head++ & DEFER_QUEUE_MASK],
+                                     DQ_FCT_MARK);
+                       _STORE_SHARED(defer_queue.q[head++ & DEFER_QUEUE_MASK],
+                                     fct);
+               }
+       }
+       _STORE_SHARED(defer_queue.q[head++ & DEFER_QUEUE_MASK], p);
+       smp_wmb();      /* Publish new pointer before head */
+                       /* Write q[] before head. */
+       STORE_SHARED(defer_queue.head, head);
+       /*
+        * Wake-up any waiting defer thread.
+        */
+       wake_up_defer();
+}
+
 void *thr_defer(void *args)
 {
        for (;;) {
index 3e04c00fddb09d1cdd8465945eba4acbe385967a..ac2f53b1728c63c4359ab9cc3cc601a63b57cb53 100644 (file)
  * called before the thread exits.
  */
 
-#ifdef _LGPL_SOURCE
-
-#include <urcu-defer-static.h>
-
-/*
- * Mappings for static use of the userspace RCU library.
- * Should only be used in LGPL-compatible code.
- */
-
-#define rcu_defer_queue        _rcu_defer_queue
-
-#else /* !_LGPL_SOURCE */
-
-/*
- * library wrappers to be used by non-LGPL compatible source code.
- */
-
-extern void rcu_defer_queue(void (*fct)(void *p), void *p);
-
-#endif /* !_LGPL_SOURCE */
-
 #define call_rcu               rcu_defer_queue
 #define rcu_reclaim_queue(p)   rcu_defer_queue(free, p)
 
+extern void rcu_defer_queue(void (*fct)(void *p), void *p);
+
 /*
  * Thread registration for reclamation.
  */
This page took 0.028659 seconds and 4 git commands to generate.