Compat layer for gettid
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 21 Feb 2012 02:32:25 +0000 (21:32 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 21 Feb 2012 02:32:25 +0000 (21:32 -0500)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@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 6f7e078d22d2910072748adfd0ee59b8c9a695b4..3fe86405c112307a47e6c1abe0a9c62fe8b2175b 100644 (file)
 #include <lttng/ust-events.h>
 #include <lttng/ust-tracer.h>
 #include <lttng/ringbuffer-config.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
+#include <lttng/ust-tid.h>
 
 /*
  * We cache the result to ensure we don't trigger a system call for
This page took 0.028123 seconds and 4 git commands to generate.