Compat layer for gettid
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 21 Feb 2012 02:32:25 +0000 (21:32 -0500)
committerChristian Babeux <christian.babeux@efficios.com>
Tue, 27 Nov 2012 19:55:58 +0000 (14:55 -0500)
commit 49c0da7df5e7bd32c06d69822e9b92120bf4d392 upstream.

[ Edit by Christian Babeux: Resolve includes conflict in
  liblttng-ust/lttng-context-vtid.c ]

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Christian Babeux <christian.babeux@efficios.com>
include/Makefile.am
include/lttng/ust-tid.h [new file with mode: 0644]
include/usterr-signal-safe.h
include/usterr.h
liblttng-ust/lttng-context-vtid.c

index 66b9ab0a043e6798768384d5bfa736e5780a50fe..571e32f92066d4a6f582f448195b8d67e7f623c6 100644 (file)
@@ -25,6 +25,7 @@ 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
new file mode 100644 (file)
index 0000000..c6819f2
--- /dev/null
@@ -0,0 +1,44 @@
+#ifndef _LTTNG_UST_TID_H
+#define _LTTNG_UST_TID_H
+
+/*
+ * lttng/ust-tid.h
+ *
+ * Copyright 2012 (c) - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * 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 <syscall.h>
+#endif
+
+#if defined(_syscall0)
+_syscall0(pid_t, gettid)
+#elif defined(__NR_gettid)
+#include <unistd.h>
+static inline pid_t gettid(void)
+{
+       return syscall(__NR_gettid);
+}
+#else
+#include <sys/types.h>
+#include <unistd.h>
+
+#warning "use pid as tid"
+static inline pid_t gettid(void)
+{
+       return getpid();
+}
+#endif
+
+#endif /* _LTTNG_UST_TID_H */
index 375eff7c569b63d5794a6cc7932de4da81548499..d46b0f6a7af8929fbd9296dfc3bf29d37bdf179d 100644 (file)
@@ -26,8 +26,8 @@
 #include <errno.h>
 #include <stdarg.h>
 #include <stdio.h>
-
 #include <share.h>
+#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) syscall(SYS_gettid),     \
+               (long) gettid(),                \
                ## args, __func__);             \
                fflush(stderr);                 \
        } while(0)
index 35d576ec1815ab755cd80b8a8b2659fbacfe62ee..86c9bf866a256dcff7f2b2ae6bf9893381db702a 100644 (file)
@@ -27,6 +27,7 @@
 #include <stdarg.h>
 #include <stdio.h>
 
+#include "lttng/ust-tid.h"
 #include "share.h"
 
 enum ust_loglevel {
@@ -57,7 +58,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) syscall(SYS_gettid),             \
+                       (long) gettid(),                        \
                        ## args,                                \
                        __func__);                              \
        } while(0)
index d5664c951cf708ff2b7ac6e9be4ca3b61fbbe87b..9aa36c6c55a30e999c9f60fb3fb7dc88392a8139 100644 (file)
@@ -26,6 +26,7 @@
 #include <lttng/ust-tracer.h>
 #include <lttng/ringbuffer-config.h>
 #include "ltt-tracer-core.h"
+#include <lttng/ust-tid.h>
 
 #ifdef __linux__
 #include <syscall.h>
@@ -45,6 +46,7 @@ static inline pid_t gettid(void)
        return getpid();
 }
 #endif
+======= end
 
 /*
  * We cache the result to ensure we don't trigger a system call for
This page took 0.027715 seconds and 4 git commands to generate.