struct test_array *local_ptr;
printf("thread %s, thread id : %lu, pid %lu\n",
- "reader", pthread_self(), getpid());
+ "reader", pthread_self(), (unsigned long)getpid());
sleep(2);
urcu_register_thread();
struct test_array *new, *old;
printf("thread %s, thread id : %lu, pid %lu\n",
- "writer", pthread_self(), getpid());
+ "writer", pthread_self(), (unsigned long)getpid());
sleep(2);
for (i = 0; i < 100000; i++) {
* Return old pointer, OK to free, no more reference exist.
* Called under rcu_write_lock.
*/
-void *urcu_publish_content(void **ptr, void *new)
+void *_urcu_publish_content(void **ptr, void *new)
{
- int ret, prev_parity;
+ int prev_parity;
void *oldptr;
/*
void urcu_unregister_thread(void)
{
- pthread_t self = pthread_self();
rcu_write_lock();
urcu_remove_reader(pthread_self());
rcu_write_unlock();
*
* Copyright February 2009 - Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
*
+ * Credits for Paul e. McKenney <paulmck@linux.vnet.ibm.com>
+ * for inspiration coming from the Linux kernel RCU and rcu-preempt.
+ *
+ * The barrier, mb, rmb, wmb, atomic_inc, smp_read_barrier_depends, ACCESS_ONCE
+ * and rcu_dereference primitives come from the Linux kernel.
+ *
* Distributed under GPLv2
*/
#define rmb() asm volatile("lfence":::"memory")
#define wmb() asm volatile("sfence" ::: "memory")
-
-
-/* x86 32 */
static inline void atomic_inc(int *v)
{
asm volatile("lock; incl %0"
extern void rcu_write_lock(void);
extern void rcu_write_unlock(void);
-extern void *urcu_publish_content(void **ptr, void *new);
+extern void *_urcu_publish_content(void **ptr, void *new);
+
+/*
+ * gcc does not like automatic &struct ... * -> void **.
+ * Remove the warning. (hopefully this is ok)
+ */
+#define urcu_publish_content(ptr, new) _urcu_publish_content((void **)ptr, new)
/*
* Reader thread registration.
*/
extern void urcu_register_thread(void);
-extern void urcu_register_thread(void);
+extern void urcu_unregister_thread(void);
#endif /* _URCU_H */