lkml.org 
[lkml]   [2021]   [Dec]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH rcu 6/6] tools/nolibc: Implement gettid()
Date
From: Mark Brown <broonie@kernel.org>

Allow test programs to determine their thread ID.

Signed-off-by: Mark Brown <broonie@kernel.org>
Cc: Willy Tarreau <w@1wt.eu>
Signed-off-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
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 4988866af0b58..c1c285fe494aa 100644
--- a/tools/include/nolibc/nolibc.h
+++ b/tools/include/nolibc/nolibc.h
@@ -1571,6 +1571,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)
{
@@ -2029,6 +2035,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.31.1.189.g2e36527f23
\
 
 \ /
  Last update: 2021-12-02 01:34    [W:0.622 / U:23.336 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site