[PATCH 1/3] tools libc_compat: add gettid

From: Riccardo Mancini
Date: Thu Jul 22 2021 - 11:34:27 EST


This patch adds gettid to libc_compat.h, since it was added in glibc
2.30 and is not available in previous versions.
The function is defined only if the HAVE_GETTID is not defined.

Signed-off-by: Riccardo Mancini <rickyman7@xxxxxxxxx>
---
tools/include/tools/libc_compat.h | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/tools/include/tools/libc_compat.h b/tools/include/tools/libc_compat.h
index e907ba6f15e532b6..58762c9c49c22ef1 100644
--- a/tools/include/tools/libc_compat.h
+++ b/tools/include/tools/libc_compat.h
@@ -17,4 +17,11 @@ static inline void *reallocarray(void *ptr, size_t nmemb, size_t size)
return realloc(ptr, bytes);
}
#endif
+
+#ifndef HAVE_GETTID
+static inline pid_t gettid(void)
+{
+ return (pid_t)syscall(__NR_gettid);
+}
+#endif
#endif
--
2.31.1