X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=liblttng-ust%2Flttng-context-vtid.c;h=d5664c951cf708ff2b7ac6e9be4ca3b61fbbe87b;hb=refs%2Fheads%2Fstable-2.0;hp=3fe86405c112307a47e6c1abe0a9c62fe8b2175b;hpb=36e2ba2a19ec6698ed8dfb8c9bde683368334372;p=lttng-ust.git diff --git a/liblttng-ust/lttng-context-vtid.c b/liblttng-ust/lttng-context-vtid.c index 3fe86405..d5664c95 100644 --- a/liblttng-ust/lttng-context-vtid.c +++ b/liblttng-ust/lttng-context-vtid.c @@ -1,10 +1,23 @@ /* - * (C) Copyright 2009-2011 - - * Mathieu Desnoyers + * lttng-context-vtid.c * * LTTng UST vtid context. * - * Dual LGPL v2.1/GPL v2 license. + * Copyright (C) 2009-2012 Mathieu Desnoyers + * + * 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 @@ -12,7 +25,26 @@ #include #include #include -#include +#include "ltt-tracer-core.h" + +#ifdef __linux__ +#include +#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)); +}