diff options
author | 2021-10-24 19:43:23 +0200 | |
---|---|---|
committer | 2021-11-30 17:26:42 -0800 | |
commit | b0fe9dec66370cef23e9c281d229f4c44f84cfa2 (patch) | |
tree | 6cf6cd5e4ec636be2f9ee563cf806b59e7536edb /tools/include | |
parent | tools/nolibc: x86-64: Use `mov $60,%eax` instead of `mov $60,%rax` (diff) | |
download | linux-b0fe9dec66370cef23e9c281d229f4c44f84cfa2.tar.gz linux-b0fe9dec66370cef23e9c281d229f4c44f84cfa2.tar.bz2 linux-b0fe9dec66370cef23e9c281d229f4c44f84cfa2.zip |
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>
Diffstat (limited to 'tools/include')
-rw-r--r-- | tools/include/nolibc/nolibc.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tools/include/nolibc/nolibc.h b/tools/include/nolibc/nolibc.h index 4988866af0b5..c1c285fe494a 100644 --- a/tools/include/nolibc/nolibc.h +++ b/tools/include/nolibc/nolibc.h @@ -1572,6 +1572,12 @@ pid_t sys_getpid(void) } 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) { return my_syscall2(__NR_gettimeofday, tv, tz); @@ -2030,6 +2036,18 @@ pid_t getpid(void) } 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) { int ret = sys_gettimeofday(tv, tz); |