]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
lib/posix-process: Define kernel internal `gettid`
authorSergiu Moga <sergiu@unikraft.io>
Fri, 7 Feb 2025 09:35:04 +0000 (11:35 +0200)
committerUnikraft Bot <monkey@unikraft.io>
Fri, 14 Feb 2025 14:16:47 +0000 (14:16 +0000)
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 <sergiu@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Andrei Tatar <andrei@unikraft.io>
Approved-by: Andrei Tatar <andrei@unikraft.io>
GitHub-Closes: #1583

lib/posix-process/exportsyms.uk
lib/posix-process/include/uk/process.h
lib/posix-process/process.c

index 609452b49f89a8988fdd7ed6df6f8a6bec834544..427e2ce55fdc817750e08ba754dbd0d664a4b34a 100644 (file)
@@ -32,6 +32,7 @@ waitpid
 waitid
 getpid
 getppid
+uk_sys_gettid
 gettid
 exit
 exit_group
index 3171fb6f063d038a966d1f149bead0a74afea03b..e7bdc17cbc4de191f7784d52bea14814357453d5 100644 (file)
@@ -38,6 +38,7 @@
 #include <uk/config.h>
 #include <stdbool.h>
 #include <sys/resource.h>
+#include <sys/types.h> /* pid_t */
 #if CONFIG_LIBUKSCHED
 #include <uk/thread.h>
 #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,
index a63cf3ec7666fcfa92748eaa6b9e6743f2b2a9b4..01b20ba716fa00619f859d385a3164c7986da839 100644 (file)
@@ -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();
+}