]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
lib/posix-process: Add helpers for current process and thread
authorMichalis Pappas <michalis@unikraft.io>
Mon, 13 Nov 2023 18:21:12 +0000 (19:21 +0100)
committerUnikraft Bot <monkey@unikraft.io>
Wed, 26 Mar 2025 08:05:34 +0000 (08:05 +0000)
Add uk_pprocess_current() uk_pthread_current() helpers. For now
these are part of the private API.

Checkpatch-Ignore: GLOBAL_INITIALISERS
Signed-off-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Ioan-Teodor Teugea <ioan_teodor.teugea@stud.acs.upb.ro>
Reviewed-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Andrei Tatar <andrei@unikraft.io>
Approved-by: Andrei Tatar <andrei@unikraft.io>
GitHub-Closes: #1248

lib/posix-process/process.c
lib/posix-process/process.h

index 14ae6eda26fb441a4711021b420ff26491a6b1f2..12a19c33cba608c13dee4c8efc11ebbfbd54a215 100644 (file)
@@ -70,7 +70,7 @@ struct posix_process *pid_process[TIDMAP_SIZE];
 /**
  * Thread-local posix_thread reference
  */
-static __uk_tls struct posix_thread *pthread_self = NULL;
+__uk_tls struct posix_thread *pthread_self = NULL;
 
 /**
  * Helpers to find and reserve a `pid_t`
index 8816ec262673e3f1891a39bffd4830aed24a7a0f..44c2c07f8447c28e333250ba9887c33bc41f10a2 100644 (file)
@@ -89,6 +89,8 @@ struct posix_thread {
 
 extern struct posix_process *pid_process[TIDMAP_SIZE];
 
+extern __uk_tls struct posix_thread *pthread_self;
+
 #define uk_pprocess_foreach(_p)                                                \
        for (int _j = 1, _i = 0; _i != ARRAY_SIZE(pid_process);         \
                _j = !_j, _i++)                                         \
@@ -99,6 +101,12 @@ extern struct posix_process *pid_process[TIDMAP_SIZE];
        uk_list_for_each_entry_safe((_pthread), (_pthreadn),            \
                                    &(_proc)->threads, thread_list_entry)
 
+#define uk_pthread_current()                                           \
+       uk_thread_uktls_var(uk_thread_current(), pthread_self)
+
+#define uk_pprocess_current()                                          \
+       uk_pthread_current()->process
+
 #if CONFIG_LIBPOSIX_PROCESS_PIDS
 struct posix_process *pid2pprocess(pid_t pid);
 struct uk_thread *tid2ukthread(pid_t tid);