#include <lttng/ust-events.h>
#include <lttng/ust-tracer.h>
#include <lttng/ringbuffer-config.h>
+#include <urcu/tls-compat.h>
#include <assert.h>
#include "compat.h"
* be set for a thread before the first event is logged within this
* thread.
*/
-static __thread char cached_procname[17];
+typedef char procname_array[17];
+static DEFINE_URCU_TLS(procname_array, cached_procname);
static inline
char *wrapper_getprocname(void)
{
- if (caa_unlikely(!cached_procname[0])) {
- lttng_ust_getprocname(cached_procname);
- cached_procname[LTTNG_UST_PROCNAME_LEN - 1] = '\0';
+ if (caa_unlikely(!URCU_TLS(cached_procname)[0])) {
+ lttng_ust_getprocname(URCU_TLS(cached_procname));
+ URCU_TLS(cached_procname)[LTTNG_UST_PROCNAME_LEN - 1] = '\0';
}
- return cached_procname;
+ return URCU_TLS(cached_procname);
}
void lttng_context_procname_reset(void)
{
- cached_procname[0] = '\0';
+ URCU_TLS(cached_procname)[0] = '\0';
}
static
*/
void lttng_fixup_procname_tls(void)
{
- asm volatile ("" : : "m" (cached_procname[0]));
+ asm volatile ("" : : "m" (URCU_TLS(cached_procname)[0]));
}
#include <lttng/ust-tracer.h>
#include <lttng/ringbuffer-config.h>
#include <lttng/ust-tid.h>
+#include <urcu/tls-compat.h>
#include "lttng-tracer-core.h"
/*
* We cache the result to ensure we don't trigger a system call for
* each event.
*/
-static __thread pid_t cached_vtid;
+static DEFINE_URCU_TLS(pid_t, cached_vtid);
/*
* Upon fork or clone, the TID assigned to our thread is not the same as
*/
void lttng_context_vtid_reset(void)
{
- cached_vtid = 0;
+ URCU_TLS(cached_vtid) = 0;
}
static
struct lttng_ust_lib_ring_buffer_ctx *ctx,
struct lttng_channel *chan)
{
- if (caa_unlikely(!cached_vtid))
- cached_vtid = gettid();
- lib_ring_buffer_align_ctx(ctx, lttng_alignof(cached_vtid));
- chan->ops->event_write(ctx, &cached_vtid, sizeof(cached_vtid));
+ if (caa_unlikely(!URCU_TLS(cached_vtid)))
+ URCU_TLS(cached_vtid) = gettid();
+ lib_ring_buffer_align_ctx(ctx, lttng_alignof(URCU_TLS(cached_vtid)));
+ chan->ops->event_write(ctx, &URCU_TLS(cached_vtid),
+ sizeof(URCU_TLS(cached_vtid)));
}
int lttng_add_vtid_to_ctx(struct lttng_ctx **ctx)
*/
void lttng_fixup_vtid_tls(void)
{
- asm volatile ("" : : "m" (cached_vtid));
+ asm volatile ("" : : "m" (URCU_TLS(cached_vtid)));
}
#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>
* 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.
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
* 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;
sigset_t all_sigs;
int ret;
- if (lttng_ust_nest_count)
+ if (URCU_TLS(lttng_ust_nest_count))
return;
/* Disable signals */
sigfillset(&all_sigs);
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();
*/
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 */
rcu_read_lock();
cpu = lttng_ust_get_cpu();
- nesting = ++lib_ring_buffer_nesting; /* TLS */
+ nesting = ++URCU_TLS(lib_ring_buffer_nesting);
cmm_barrier();
if (caa_unlikely(nesting > 4)) {
WARN_ON_ONCE(1);
- lib_ring_buffer_nesting--; /* TLS */
+ URCU_TLS(lib_ring_buffer_nesting)--;
rcu_read_unlock();
return -EPERM;
} else
void lib_ring_buffer_put_cpu(const struct lttng_ust_lib_ring_buffer_config *config)
{
cmm_barrier();
- lib_ring_buffer_nesting--; /* TLS */
+ URCU_TLS(lib_ring_buffer_nesting)--; /* TLS */
rcu_read_unlock();
}
*/
#include <urcu/compiler.h>
+#include <urcu/tls-compat.h>
#include <signal.h>
#include <pthread.h>
struct lttng_ust_shm_handle *handle);
/* Keep track of trap nesting inside ring buffer code */
-extern __thread unsigned int lib_ring_buffer_nesting;
+extern DECLARE_URCU_TLS(unsigned int, lib_ring_buffer_nesting);
#endif /* _LTTNG_RING_BUFFER_FRONTEND_INTERNAL_H */
#include <fcntl.h>
#include <urcu/compiler.h>
#include <urcu/ref.h>
+#include <urcu/tls-compat.h>
#include <helper.h>
#include "smp.h"
switch_old_end:1;
};
-__thread unsigned int lib_ring_buffer_nesting;
+DEFINE_URCU_TLS(unsigned int, lib_ring_buffer_nesting);
/*
* TODO: this is unused. Errors are saved within the ring buffer.
*/
void lttng_fixup_ringbuffer_tls(void)
{
- asm volatile ("" : : "m" (lib_ring_buffer_nesting));
+ asm volatile ("" : : "m" (URCU_TLS(lib_ring_buffer_nesting)));
}