Use urcu tls-compat.h
[lttng-ust.git] / liblttng-ust / lttng-ust-comm.c
index bfc9bc5a87f8fc6e02bd5cb3d999f575af1c98dc..a1ebcbe6fc83564a5fc4d9c0c0642403938da35f 100644 (file)
@@ -43,6 +43,7 @@
 #include <lttng/ust.h>
 #include <lttng/ust-error.h>
 #include <lttng/ust-ctl.h>
+#include <urcu/tls-compat.h>
 #include <ust-comm.h>
 #include <usterr-signal-safe.h>
 #include <helper.h>
@@ -85,7 +86,7 @@ static int sem_count = { 2 };
  * Counting nesting within lttng-ust. Used to ensure that calling fork()
  * from liblttng-ust does not execute the pre/post fork handlers.
  */
-static int __thread lttng_ust_nest_count;
+static DEFINE_URCU_TLS(int, lttng_ust_nest_count);
 
 /*
  * Info about socket and associated listener thread.
@@ -183,7 +184,7 @@ extern void lttng_ring_buffer_metadata_client_exit(void);
 static
 void lttng_fixup_nest_count_tls(void)
 {
-       asm volatile ("" : : "m" (lttng_ust_nest_count));
+       asm volatile ("" : : "m" (URCU_TLS(lttng_ust_nest_count)));
 }
 
 static
@@ -621,9 +622,9 @@ int get_wait_shm(struct sock_info *sock_info, size_t mmap_size)
         * If the open failed because the file did not exist, try
         * creating it ourself.
         */
-       lttng_ust_nest_count++;
+       URCU_TLS(lttng_ust_nest_count)++;
        pid = fork();
-       lttng_ust_nest_count--;
+       URCU_TLS(lttng_ust_nest_count)--;
        if (pid > 0) {
                int status;
 
@@ -1213,7 +1214,7 @@ void ust_before_fork(sigset_t *save_sigset)
        sigset_t all_sigs;
        int ret;
 
-       if (lttng_ust_nest_count)
+       if (URCU_TLS(lttng_ust_nest_count))
                return;
        /* Disable signals */
        sigfillset(&all_sigs);
@@ -1240,7 +1241,7 @@ static void ust_after_fork_common(sigset_t *restore_sigset)
 
 void ust_after_fork_parent(sigset_t *restore_sigset)
 {
-       if (lttng_ust_nest_count)
+       if (URCU_TLS(lttng_ust_nest_count))
                return;
        DBG("process %d", getpid());
        rcu_bp_after_fork_parent();
@@ -1259,7 +1260,7 @@ void ust_after_fork_parent(sigset_t *restore_sigset)
  */
 void ust_after_fork_child(sigset_t *restore_sigset)
 {
-       if (lttng_ust_nest_count)
+       if (URCU_TLS(lttng_ust_nest_count))
                return;
        DBG("process %d", getpid());
        /* Release urcu mutexes */
This page took 0.024659 seconds and 4 git commands to generate.