X-Git-Url: https://git.liburcu.org/?p=urcu.git;a=blobdiff_plain;f=urcu-defer-static.h;h=dd875ca66b75cdac02f21a9a6eba5a4ce9693796;hp=dd24c61d85d7885d685323757f83c52c2df2f15f;hb=ec4e58a3aba2084440012f8ccac3a31eb6101183;hpb=4ce9e4f28aa6de3f3443066c7a64d12156904d6b diff --git a/urcu-defer-static.h b/urcu-defer-static.h index dd24c61..dd875ca 100644 --- a/urcu-defer-static.h +++ b/urcu-defer-static.h @@ -32,8 +32,8 @@ #include #include -#include -#include +#include +#include /* @@ -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 */