[PATCH v7 08/37] tools/nolibc: Implement gettid()
Mark Brown
broonie at kernel.org
Fri Dec 10 10:41:04 PST 2021
Allow test programs to determine their thread ID.
Signed-off-by: Mark Brown <broonie at kernel.org>
Cc: Willy Tarreau <w at 1wt.eu>
---
tools/include/nolibc/nolibc.h | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/tools/include/nolibc/nolibc.h b/tools/include/nolibc/nolibc.h
index 3430667b0d24..fea8aace0119 100644
--- a/tools/include/nolibc/nolibc.h
+++ b/tools/include/nolibc/nolibc.h
@@ -1555,6 +1555,12 @@ pid_t sys_getpid(void)
return my_syscall0(__NR_getpid);
}
+static __attribute__((unused))
+pid_t sys_gettid(void)
+{
+ return my_syscall0(__NR_gettid);
+}
+
static __attribute__((unused))
int sys_gettimeofday(struct timeval *tv, struct timezone *tz)
{
@@ -2013,6 +2019,18 @@ pid_t getpid(void)
return ret;
}
+static __attribute__((unused))
+pid_t gettid(void)
+{
+ pid_t ret = sys_gettid();
+
+ if (ret < 0) {
+ SET_ERRNO(-ret);
+ ret = -1;
+ }
+ return ret;
+}
+
static __attribute__((unused))
int gettimeofday(struct timeval *tv, struct timezone *tz)
{
--
2.30.2
More information about the linux-arm-kernel
mailing list