]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
tools/nolibc: Implement gettid()
authorMark Brown <broonie@kernel.org>
Sun, 24 Oct 2021 17:43:23 +0000 (19:43 +0200)
committerPaul E. McKenney <paulmck@kernel.org>
Wed, 1 Dec 2021 01:26:42 +0000 (17:26 -0800)
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

index 4988866af0b5890b2d4e1ffe57509ee0f08335b2..c1c285fe494aa6ca1f334a1130889a80ec8330b0 100644 (file)
@@ -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)
 {