Rename C++ header files to .hpp
[lttng-tools.git] / src / common / compat / tid.hpp
diff --git a/src/common/compat/tid.hpp b/src/common/compat/tid.hpp
new file mode 100644 (file)
index 0000000..4a6ff74
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2012 (C) Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ */
+
+#ifndef LTTNG_TID_H
+#define LTTNG_TID_H
+
+#ifdef __linux__
+#include <syscall.h>
+#endif
+
+#if defined(__NR_gettid)
+
+#include <unistd.h>
+static inline pid_t lttng_gettid(void)
+{
+       return syscall(__NR_gettid);
+}
+
+#else
+
+#include <sys/types.h>
+#include <unistd.h>
+
+/* Fall-back on getpid for tid if not available. */
+static inline pid_t lttng_gettid(void)
+{
+       return getpid();
+}
+
+#endif
+
+#endif /* LTTNG_TID_H */
This page took 0.024434 seconds and 4 git commands to generate.