add acknowledgements, fix gcc warnings
authorMathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Fri, 6 Feb 2009 02:41:04 +0000 (21:41 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Fri, 6 Feb 2009 02:41:04 +0000 (21:41 -0500)
test_urcu.c
urcu.c
urcu.h

index 10d4d9961292d3149d04fe88417a7247de3c8ad8..2b34798986ae14fc6b80ff6a749f6c800516816d 100644 (file)
@@ -37,7 +37,7 @@ void *thr_reader(void *arg)
        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();
@@ -67,7 +67,7 @@ void *thr_writer(void *arg)
        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++) {
diff --git a/urcu.c b/urcu.c
index 232a57bb718fbf12be651cebd6a808b01976c924..e258d96fab4e730d42fc22c4a3e58870e42bda4e 100644 (file)
--- a/urcu.c
+++ b/urcu.c
@@ -117,9 +117,9 @@ void wait_for_quiescent_state(int parity)
  * 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;
 
        /*
@@ -207,7 +207,6 @@ void urcu_register_thread(void)
 
 void urcu_unregister_thread(void)
 {
-       pthread_t self = pthread_self();
        rcu_write_lock();
        urcu_remove_reader(pthread_self());
        rcu_write_unlock();
diff --git a/urcu.h b/urcu.h
index 673f7952c3f254b79f6f157188b8b812f569fd41..3c5b178d1a8254adb37331fea6b61698a58c459c 100644 (file)
--- a/urcu.h
+++ b/urcu.h
@@ -8,6 +8,12 @@
  *
  * 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
  */
 
@@ -19,9 +25,6 @@
 #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"
@@ -101,12 +104,18 @@ static inline void rcu_read_unlock(int urcu_parity)
 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 */
This page took 0.029148 seconds and 4 git commands to generate.