[lttng-dev] [PATCH lttng-tools 06/24] Fix : Do not redeclare gettid if found

Charles Briere c.briere at samsung.com
Mon Oct 27 16:49:28 EDT 2014


From: Charles Briere <c.briere at samsung.com>

Signed-off-by: Charles Briere <c.briere at samsung.com>
---
 configure.ac            |  2 ++
 src/common/compat/tid.h | 11 +++++++----
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/configure.ac b/configure.ac
index 8703284..3460f98 100644
--- a/configure.ac
+++ b/configure.ac
@@ -213,6 +213,8 @@ AC_CHECK_DECL([cmm_smp_mb__before_uatomic_or], [],
         [AC_MSG_ERROR([liburcu $liburcu_version or newer is needed])], [[#include <urcu.h>]]
 )
 
+AC_CHECK_DECLS([gettid], [], [], [[#include <unistd.h>]])
+
 # Check kmod library
 AC_ARG_WITH(kmod-prefix,
   AS_HELP_STRING([--with-kmod-prefix=PATH],
diff --git a/src/common/compat/tid.h b/src/common/compat/tid.h
index 40f562f..b420914 100644
--- a/src/common/compat/tid.h
+++ b/src/common/compat/tid.h
@@ -29,15 +29,16 @@
 #include <syscall.h>
 #endif
 
-#if defined(_syscall0)
+#if !HAVE_DECL_GETTID
+# if defined(_syscall0)
 _syscall0(pid_t, gettid)
-#elif defined(__NR_gettid)
+# elif defined(__NR_gettid)
 #include <unistd.h>
 static inline pid_t gettid(void)
 {
 	return syscall(__NR_gettid);
 }
-#else
+# else
 #include <sys/types.h>
 #include <unistd.h>
 
@@ -46,6 +47,8 @@ static inline pid_t gettid(void)
 {
 	return getpid();
 }
-#endif
+
+# endif
+#endif /* !HAVE_DECL_GETTID */
 
 #endif /* LTTNG_TID_H */
-- 
2.1.2



More information about the lttng-dev mailing list