Skip to content

Commit

Permalink
tools/nolibc: Implement gettid()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
broonie authored and paulmckrcu committed Dec 1, 2021
1 parent 7bdc0e7 commit b0fe9de
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tools/include/nolibc/nolibc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
{
Expand Down

0 comments on commit b0fe9de

Please sign in to comment.