From: Sergiu Moga Date: Fri, 7 Feb 2025 09:35:04 +0000 (+0200) Subject: lib/posix-process: Define kernel internal `gettid` X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=4d4217838a6edc930256ac29bc5485a90e203621;p=unikraft%2Funikraft.git lib/posix-process: Define kernel internal `gettid` Add the kernel internal variant of `gettid`, `uk_sys_gettid`. This allows kernel internal code to call this system call's logic without having the syscall shim wrapper logic intervene. Signed-off-by: Sergiu Moga Reviewed-by: Michalis Pappas Reviewed-by: Andrei Tatar Approved-by: Andrei Tatar GitHub-Closes: #1583 --- diff --git a/lib/posix-process/exportsyms.uk b/lib/posix-process/exportsyms.uk index 609452b49..427e2ce55 100644 --- a/lib/posix-process/exportsyms.uk +++ b/lib/posix-process/exportsyms.uk @@ -32,6 +32,7 @@ waitpid waitid getpid getppid +uk_sys_gettid gettid exit exit_group diff --git a/lib/posix-process/include/uk/process.h b/lib/posix-process/include/uk/process.h index 3171fb6f0..e7bdc17cb 100644 --- a/lib/posix-process/include/uk/process.h +++ b/lib/posix-process/include/uk/process.h @@ -38,6 +38,7 @@ #include #include #include +#include /* pid_t */ #if CONFIG_LIBUKSCHED #include #endif @@ -146,6 +147,8 @@ static inline int uk_sys_setrlimit(int resource, const struct rlimit *rlim) DECONST(struct rlimit *, rlim), NULL); } +pid_t uk_sys_gettid(void); + #if CONFIG_LIBUKSCHED int uk_posix_process_create(struct uk_alloc *a, struct uk_thread *thread, diff --git a/lib/posix-process/process.c b/lib/posix-process/process.c index a63cf3ec7..01b20ba71 100644 --- a/lib/posix-process/process.c +++ b/lib/posix-process/process.c @@ -539,7 +539,7 @@ UK_SYSCALL_R_DEFINE(pid_t, getpid) return pthread_self->process->pid; } -UK_SYSCALL_R_DEFINE(pid_t, gettid) +pid_t uk_sys_gettid(void) { if (!pthread_self) return -ENOTSUP; @@ -660,7 +660,7 @@ UK_SYSCALL_R_DEFINE(int, getpid) return UNIKRAFT_PID; } -UK_SYSCALL_R_DEFINE(int, gettid) +pid_t uk_sys_gettid(void) { return UNIKRAFT_TID; } @@ -671,3 +671,8 @@ UK_SYSCALL_R_DEFINE(pid_t, getppid) } #endif /* !CONFIG_LIBPOSIX_PROCESS_PIDS */ + +UK_SYSCALL_R_DEFINE(pid_t, gettid) +{ + return uk_sys_gettid(); +}