Version 2.0.8
[lttng-ust.git] / liblttng-ust / lttng-context-vtid.c
index 3fe86405c112307a47e6c1abe0a9c62fe8b2175b..d5664c951cf708ff2b7ac6e9be4ca3b61fbbe87b 100644 (file)
@@ -1,10 +1,23 @@
 /*
- * (C) Copyright       2009-2011 -
- *             Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * lttng-context-vtid.c
  *
  * LTTng UST vtid context.
  *
- * Dual LGPL v2.1/GPL v2 license.
+ * Copyright (C) 2009-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #include <sys/types.h>
 #include <lttng/ust-events.h>
 #include <lttng/ust-tracer.h>
 #include <lttng/ringbuffer-config.h>
-#include <lttng/ust-tid.h>
+#include "ltt-tracer-core.h"
+
+#ifdef __linux__
+#include <syscall.h>
+#endif
+
+#if defined(_syscall0)
+_syscall0(pid_t, gettid)
+#elif defined(__NR_gettid)
+static inline pid_t gettid(void)
+{
+       return syscall(__NR_gettid);
+}
+#else
+#warning "use pid as tid"
+static inline pid_t gettid(void)
+{
+       return getpid();
+}
+#endif
 
 /*
  * We cache the result to ensure we don't trigger a system call for
@@ -74,3 +106,11 @@ int lttng_add_vtid_to_ctx(struct lttng_ctx **ctx)
        field->record = vtid_record;
        return 0;
 }
+
+/*
+ * Force a read (imply TLS fixup for dlopen) of TLS variables.
+ */
+void lttng_fixup_vtid_tls(void)
+{
+       asm volatile ("" : : "m" (cached_vtid));
+}
This page took 0.026687 seconds and 4 git commands to generate.