Skip to content

Commit b0fe9de

Browse files
brooniepaulmckrcu
authored andcommitted
tools/nolibc: Implement gettid()
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>
1 parent 7bdc0e7 commit b0fe9de

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

tools/include/nolibc/nolibc.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1571,6 +1571,12 @@ pid_t sys_getpid(void)
15711571
return my_syscall0(__NR_getpid);
15721572
}
15731573

1574+
static __attribute__((unused))
1575+
pid_t sys_gettid(void)
1576+
{
1577+
return my_syscall0(__NR_gettid);
1578+
}
1579+
15741580
static __attribute__((unused))
15751581
int sys_gettimeofday(struct timeval *tv, struct timezone *tz)
15761582
{
@@ -2029,6 +2035,18 @@ pid_t getpid(void)
20292035
return ret;
20302036
}
20312037

2038+
static __attribute__((unused))
2039+
pid_t gettid(void)
2040+
{
2041+
pid_t ret = sys_gettid();
2042+
2043+
if (ret < 0) {
2044+
SET_ERRNO(-ret);
2045+
ret = -1;
2046+
}
2047+
return ret;
2048+
}
2049+
20322050
static __attribute__((unused))
20332051
int gettimeofday(struct timeval *tv, struct timezone *tz)
20342052
{

0 commit comments

Comments
 (0)