From aab17bfec51be0eb306ff1197a38d8acc5e877a3 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Wed, 22 Feb 2012 17:10:29 -0500 Subject: [PATCH] Revert "Compat layer for gettid" This reverts commit 36e2ba2a19ec6698ed8dfb8c9bde683368334372. Signed-off-by: Mathieu Desnoyers --- include/Makefile.am | 1 - include/lttng/ust-tid.h | 44 ------------------------------- include/usterr-signal-safe.h | 4 +-- include/usterr.h | 3 +-- liblttng-ust/lttng-context-vtid.c | 20 +++++++++++++- 5 files changed, 22 insertions(+), 50 deletions(-) delete mode 100644 include/lttng/ust-tid.h diff --git a/include/Makefile.am b/include/Makefile.am index 571e32f9..66b9ab0a 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -25,7 +25,6 @@ noinst_HEADERS = \ usterr-signal-safe.h \ ust_snprintf.h \ ust-comm.h \ - lttng/ust-tid.h \ lttng/bitfield.h \ helper.h \ share.h diff --git a/include/lttng/ust-tid.h b/include/lttng/ust-tid.h deleted file mode 100644 index c6819f25..00000000 --- a/include/lttng/ust-tid.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef _LTTNG_UST_TID_H -#define _LTTNG_UST_TID_H - -/* - * lttng/ust-tid.h - * - * Copyright 2012 (c) - Mathieu Desnoyers - * - * gettid compatibility layer. - * - * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED - * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. - * - * Permission is hereby granted to use or copy this program - * for any purpose, provided the above notices are retained on all copies. - * Permission to modify the code and to distribute modified code is granted, - * provided the above notices are retained, and a notice that the code was - * modified is included with the above copyright notice. - */ - -#ifdef __linux__ -#include -#endif - -#if defined(_syscall0) -_syscall0(pid_t, gettid) -#elif defined(__NR_gettid) -#include -static inline pid_t gettid(void) -{ - return syscall(__NR_gettid); -} -#else -#include -#include - -#warning "use pid as tid" -static inline pid_t gettid(void) -{ - return getpid(); -} -#endif - -#endif /* _LTTNG_UST_TID_H */ diff --git a/include/usterr-signal-safe.h b/include/usterr-signal-safe.h index d46b0f6a..375eff7c 100644 --- a/include/usterr-signal-safe.h +++ b/include/usterr-signal-safe.h @@ -26,8 +26,8 @@ #include #include #include + #include -#include "lttng/ust-tid.h" enum ust_loglevel { UST_LOGLEVEL_UNKNOWN = 0, @@ -85,7 +85,7 @@ do { \ do { \ sigsafe_print_err(UST_STR_COMPONENT "[%ld/%ld]: " fmt " (in %s() at " __FILE__ ":" UST_XSTR(__LINE__) ")\n", \ (long) getpid(), \ - (long) gettid(), \ + (long) syscall(SYS_gettid), \ ## args, __func__); \ fflush(stderr); \ } while(0) diff --git a/include/usterr.h b/include/usterr.h index 86c9bf86..35d576ec 100644 --- a/include/usterr.h +++ b/include/usterr.h @@ -27,7 +27,6 @@ #include #include -#include "lttng/ust-tid.h" #include "share.h" enum ust_loglevel { @@ -58,7 +57,7 @@ static inline int ust_debug(void) do { \ fprintf(stderr, UST_STR_COMPONENT "[%ld/%ld]: " fmt " (in %s() at " __FILE__ ":" XSTR(__LINE__) ")\n", \ (long) getpid(), \ - (long) gettid(), \ + (long) syscall(SYS_gettid), \ ## args, \ __func__); \ } while(0) diff --git a/liblttng-ust/lttng-context-vtid.c b/liblttng-ust/lttng-context-vtid.c index 3fe86405..6f7e078d 100644 --- a/liblttng-ust/lttng-context-vtid.c +++ b/liblttng-ust/lttng-context-vtid.c @@ -12,7 +12,25 @@ #include #include #include -#include + +#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 -- 2.34.1