Fix: re-enable compatibility with autoconf < 2.64
[urcu.git] / urcu-call-rcu-impl.h
index 29c4e28e334a0654f98725392229dbe98b07645a..8ed2ab384f81c0806d7c40a74430eb527ad825de 100644 (file)
@@ -40,6 +40,7 @@
 #include "urcu-pointer.h"
 #include "urcu/list.h"
 #include "urcu/futex.h"
+#include "urcu/tls-compat.h"
 
 /* Data structure that identifies a call_rcu thread. */
 
@@ -62,7 +63,7 @@ CDS_LIST_HEAD(call_rcu_data_list);
 
 /* Link a thread using call_rcu() to its call_rcu thread. */
 
-static __thread struct call_rcu_data *thread_call_rcu_data;
+static DEFINE_URCU_TLS(struct call_rcu_data *, thread_call_rcu_data);
 
 /* Guard call_rcu thread creation. */
 
@@ -204,7 +205,7 @@ static void call_rcu_wake_up(struct call_rcu_data *crdp)
 {
        /* Write to call_rcu list before reading/writing futex */
        cmm_smp_mb();
-       if (unlikely(uatomic_read(&crdp->futex) == -1)) {
+       if (caa_unlikely(uatomic_read(&crdp->futex) == -1)) {
                uatomic_set(&crdp->futex, 0);
                futex_async(&crdp->futex, FUTEX_WAKE, 1,
                      NULL, NULL, 0);
@@ -232,7 +233,7 @@ static void *call_rcu_thread(void *arg)
         */
        rcu_register_thread();
 
-       thread_call_rcu_data = crdp;
+       URCU_TLS(thread_call_rcu_data) = crdp;
        if (!rt) {
                uatomic_dec(&crdp->futex);
                /* Decrement futex before reading call_rcu list */
@@ -396,6 +397,10 @@ struct call_rcu_data *create_call_rcu_data(unsigned long flags,
  * the caller's responsibility to dispose of the removed structure.
  * Use get_cpu_call_rcu_data() to obtain a pointer to the old structure
  * (prior to NULLing it out, of course).
+ *
+ * The caller must wait for a grace-period to pass between return from
+ * set_cpu_call_rcu_data() and call to call_rcu_data_free() passing the
+ * previous call rcu data as argument.
  */
 
 int set_cpu_call_rcu_data(int cpu, struct call_rcu_data *crdp)
@@ -466,8 +471,8 @@ struct call_rcu_data *get_call_rcu_data(void)
 {
        struct call_rcu_data *crd;
 
-       if (thread_call_rcu_data != NULL)
-               return thread_call_rcu_data;
+       if (URCU_TLS(thread_call_rcu_data) != NULL)
+               return URCU_TLS(thread_call_rcu_data);
 
        if (maxcpus > 0) {
                crd = get_cpu_call_rcu_data(sched_getcpu());
@@ -484,7 +489,7 @@ struct call_rcu_data *get_call_rcu_data(void)
 
 struct call_rcu_data *get_thread_call_rcu_data(void)
 {
-       return thread_call_rcu_data;
+       return URCU_TLS(thread_call_rcu_data);
 }
 
 /*
@@ -500,7 +505,7 @@ struct call_rcu_data *get_thread_call_rcu_data(void)
 
 void set_thread_call_rcu_data(struct call_rcu_data *crdp)
 {
-       thread_call_rcu_data = crdp;
+       URCU_TLS(thread_call_rcu_data) = crdp;
 }
 
 /*
@@ -612,6 +617,10 @@ void call_rcu(struct rcu_head *head,
  *
  * We also silently refuse to free NULL pointers.  This simplifies
  * the calling code.
+ *
+ * The caller must wait for a grace-period to pass between return from
+ * set_cpu_call_rcu_data() and call to call_rcu_data_free() passing the
+ * previous call rcu data as argument.
  */
 void call_rcu_data_free(struct call_rcu_data *crdp)
 {
@@ -738,7 +747,7 @@ void call_rcu_after_fork_child(void)
        maxcpus_reset();
        free(per_cpu_call_rcu_data);
        rcu_set_pointer(&per_cpu_call_rcu_data, NULL);
-       thread_call_rcu_data = NULL;
+       URCU_TLS(thread_call_rcu_data) = NULL;
 
        /* Dispose of all of the rest of the call_rcu_data structures. */
        cds_list_for_each_entry_safe(crdp, next, &call_rcu_data_list, list) {
This page took 0.024471 seconds and 4 git commands to generate.