]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
lib/posix-process: Refactor Kconfig options
authorMichalis Pappas <michalis@unikraft.io>
Wed, 19 Mar 2025 07:14:56 +0000 (08:14 +0100)
committerUnikraft Bot <monkey@unikraft.io>
Wed, 30 Apr 2025 09:42:51 +0000 (09:42 +0000)
Replace CONFIG_LIBPOSIX_PROCESS_PIDS and CONFIG_LIBPOSIX_PROCESS_CLONE
with a single option, CONFIG_LIBPOSIX_PROCESS_MULTITHREADING. This
option enables clone(), _exit(), and exit_group() syscalls as well as
the core logic of libposix-process. Make options previously relevant
to CONFIG_LIBPOSIX_PROCESS_CLONE move to subselection of multithreading.

Without CONFIG_LIBPOSIX_PROCESS_MULTITHREADING the implementation falls
back into stubs. This provides an execution environment for simple
libc-based applications that don't require multithreading, but still
need to execute under a process-like environment. Under this state,
the syscalls involved in multithreading (or multiprocess) return an
error, while others are emulated. Notice that if Unikraft is not configured
to execute main() in a separate uk_thread (i.e. LIBUKBOOT_MAINTHREAD),
_exit() and exit_group() are not available.

Introduce a new config option to enable multiprocess support, namely
CONFIG_LIBPOSIX_PROCESS_MULTIPROCESS. This option replaces the config
option of vfork(), and enforces the selection of multithreading and
execve().

Signed-off-by: Michalis Pappas <michalis@unikraft.io>
Approved-by: Andrei Tatar <andrei@unikraft.io>
Reviewed-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Andrei Tatar <andrei@unikraft.io>
GitHub-Closes: #1627

lib/posix-process/Config.uk
lib/posix-process/Makefile.uk
lib/posix-process/clone.c
lib/posix-process/include/linux/sched.h
lib/posix-process/include/uk/process.h
lib/posix-process/process.c
lib/posix-process/process.h
lib/posix-process/signal/signal.h

index 5117622112e005d9000e6f44aad62863fc13ce1f..b9f7e5e5da0ebee8a0bceaf182bb5eaa823b8bc2 100644 (file)
@@ -4,17 +4,38 @@ menuconfig LIBPOSIX_PROCESS
 
 if LIBPOSIX_PROCESS
 
-menuconfig LIBPOSIX_PROCESS_PIDS
-       bool "Process and thread IDs"
-       select LIBUKSCHED
-
-if LIBPOSIX_PROCESS_PIDS
+menuconfig LIBPOSIX_PROCESS_MULTITHREADING
+       bool "Multithreading support"
 
+if LIBPOSIX_PROCESS_MULTITHREADING
 config LIBPOSIX_PROCESS_MAX_PID
-       int "Largest PID"
+       int "Largest TID"
        range 1 32767
        default 31
 
+config LIBPOSIX_PROCESS_CLONE_PREFER_CHILD
+       bool "Prefer scheduling of child"
+       help
+               If enabled, clone will context switch away from the clone
+               caller. This is necessary for some applications that assume that
+               the new thread does progress while the clone caller is not
+               context switching.
+
+config LIBPOSIX_PROCESS_EXECVE
+       bool "execve() system call"
+       depends on HAVE_VFS
+       select LIBUKBINFMT
+
+endif
+
+menuconfig LIBPOSIX_PROCESS_MULTIPROCESS
+       bool "Multiprocess support"
+       depends on HAVE_VFS
+       select LIBPOSIX_PROCESS_MULTITHREADING
+       select LIBPOSIX_PROCESS_EXECVE
+
+if LIBPOSIX_PROCESS_MULTIPROCESS
+
 config LIBPOSIX_PROCESS_INIT_PIDS
        bool "Assign PID during boot"
 
@@ -22,38 +43,16 @@ endif
 
 config LIBPOSIX_PROCESS_SIGNAL
        bool "POSIX signals (EXPERIMENTAL)"
-       select LIBPOSIX_PROCESS_PIDS
+       select LIBPOSIX_PROCESS_MULTITHREADING
+       select LIBPOSIX_PROCESS_EXECVE
        select LIBSYSCALL_SHIM
        select LIBUKLOCK
 
-config LIBPOSIX_PROCESS_CLONE
-       bool "clone() system call"
-       select LIBPOSIX_PROCESS_PIDS
-
 config LIBPOSIX_PROCESS_SIGNALFD
        bool "signalfd4() and signalfd() syscalls"
        depends on LIBPOSIX_PROCESS_SIGNAL
        select LIBUKFILE_POLLED
 
-config LIBPOSIX_PROCESS_CLONE_PREFER_CHILD
-       bool "Prefer scheduling of child"
-       depends on LIBPOSIX_PROCESS_CLONE
-       help
-               If enabled, clone will context switch away from the clone
-               caller. This is necessary for some applications that assume that
-               the new thread does progress while the clone caller is not
-               context switching.
-
-config LIBPOSIX_PROCESS_EXECVE
-       bool "execve() system call"
-       select LIBPOSIX_PROCESS_PIDS
-       select LIBUKBINFMT
-
-config LIBPOSIX_PROCESS_VFORK
-       bool "vfork() system call"
-       select LIBPOSIX_PROCESS_PIDS
-       select LIBPOSIX_PROCESS_CLONE
-
 config LIBPOSIX_PROCESS_DEBUG
        bool "Enable debug messages"
 
index 0b7d0ca8d1aae03cb44f80d016a6a2bafb3bda64..ef5000150aead9158b475ee4b630e6dd1955115f 100644 (file)
@@ -9,16 +9,15 @@ CXXINCLUDES-$(CONFIG_LIBPOSIX_PROCESS) += $(LIBPOSIX_PROCESS_COMMON_INCLUDES-y)
 
 LIBPOSIX_PROCESS_CFLAGS-$(CONFIG_LIBPOSIX_PROCESS_DEBUG) += -DUK_DEBUG
 
-LIBPOSIX_PROCESS_SRCS-$(CONFIG_LIBPOSIX_PROCESS_EXECVE) += $(LIBPOSIX_PROCESS_BASE)/execve.c
-LIBPOSIX_PROCESS_SRCS-$(CONFIG_LIBPOSIX_PROCESS_EXECVE) += $(LIBPOSIX_PROCESS_BASE)/arch/$(CONFIG_UK_ARCH)/execve.c|arch
-
-LIBPOSIX_PROCESS_SRCS-$(CONFIG_LIBPOSIX_PROCESS_VFORK) += $(LIBPOSIX_PROCESS_BASE)/vfork.c
-LIBPOSIX_PROCESS_SRCS-$(CONFIG_LIBPOSIX_PROCESS_VFORK) += $(LIBPOSIX_PROCESS_BASE)/arch/$(CONFIG_UK_ARCH)/vfork.S|arch
-
 LIBPOSIX_PROCESS_SRCS-y += $(LIBPOSIX_PROCESS_BASE)/deprecated.c
 LIBPOSIX_PROCESS_SRCS-y += $(LIBPOSIX_PROCESS_BASE)/process.c
 LIBPOSIX_PROCESS_SRCS-y += $(LIBPOSIX_PROCESS_BASE)/wait.c
 
+LIBPOSIX_PROCESS_SRCS-$(CONFIG_LIBPOSIX_PROCESS_EXECVE) += $(LIBPOSIX_PROCESS_BASE)/arch/$(CONFIG_UK_ARCH)/execve.c|arch
+LIBPOSIX_PROCESS_SRCS-$(CONFIG_LIBPOSIX_PROCESS_EXECVE) += $(LIBPOSIX_PROCESS_BASE)/execve.c
+LIBPOSIX_PROCESS_SRCS-$(CONFIG_LIBPOSIX_PROCESS_MULTIPROCESS) += $(LIBPOSIX_PROCESS_BASE)/arch/$(CONFIG_UK_ARCH)/vfork.S|arch
+LIBPOSIX_PROCESS_SRCS-$(CONFIG_LIBPOSIX_PROCESS_MULTIPROCESS) += $(LIBPOSIX_PROCESS_BASE)/vfork.c
+
 LIBPOSIX_PROCESS_SRCS-$(CONFIG_LIBPOSIX_PROCESS_SIGNAL) += $(LIBPOSIX_PROCESS_BASE)/signal/signal.c
 LIBPOSIX_PROCESS_SRCS-$(CONFIG_LIBPOSIX_PROCESS_SIGNAL) += $(LIBPOSIX_PROCESS_BASE)/signal/sigset.c
 LIBPOSIX_PROCESS_SRCS-$(CONFIG_LIBPOSIX_PROCESS_SIGNAL) += $(LIBPOSIX_PROCESS_BASE)/arch/$(CONFIG_UK_ARCH)/ucontext.c
@@ -39,21 +38,19 @@ LIBPOSIX_PROCESS_SRCS-y += $(LIBPOSIX_PROCESS_BASE)/signal/kill.c
 LIBPOSIX_PROCESS_SRCS-y += $(LIBPOSIX_PROCESS_BASE)/signal/tgkill.c
 LIBPOSIX_PROCESS_SRCS-y += $(LIBPOSIX_PROCESS_BASE)/signal/tkill.c
 
-LIBPOSIX_PROCESS_SRCS-$(CONFIG_LIBPOSIX_PROCESS_CLONE) += $(LIBPOSIX_PROCESS_BASE)/signal/clone.c|signal
-LIBPOSIX_PROCESS_SRCS-$(CONFIG_LIBPOSIX_PROCESS_CLONE) += $(LIBPOSIX_PROCESS_BASE)/clone.c
-LIBPOSIX_PROCESS_SRCS-$(CONFIG_LIBPOSIX_PROCESS_CLONE) += $(LIBPOSIX_PROCESS_BASE)/arch/$(CONFIG_UK_ARCH)/clone.S|arch
-LIBPOSIX_PROCESS_SRCS-$(CONFIG_LIBPOSIX_PROCESS_CLONE) += $(LIBPOSIX_PROCESS_BASE)/clonetab.ld
-LIBPOSIX_PROCESS_SRCS-$(CONFIG_LIBPOSIX_PROCESS_CLONE) += $(LIBPOSIX_PROCESS_BASE)/arch/$(CONFIG_UK_ARCH)/clone.c|$(CONFIG_UK_ARCH)
-CFLAGS-$(CONFIG_LIBPOSIX_PROCESS_PIDS) += -fno-builtin-exit -fno-builtin-exit-group
-CXXFLAGS-$(CONFIG_LIBPOSIX_PROCESS_PIDS) += -fno-builtin-exit -fno-builtin-exit-group
+LIBPOSIX_PROCESS_SRCS-$(CONFIG_LIBPOSIX_PROCESS_MULTITHREADING) += $(LIBPOSIX_PROCESS_BASE)/signal/clone.c|signal
+LIBPOSIX_PROCESS_SRCS-$(CONFIG_LIBPOSIX_PROCESS_MULTITHREADING) += $(LIBPOSIX_PROCESS_BASE)/clone.c
+LIBPOSIX_PROCESS_SRCS-$(CONFIG_LIBPOSIX_PROCESS_MULTITHREADING) += $(LIBPOSIX_PROCESS_BASE)/clonetab.ld
+LIBPOSIX_PROCESS_SRCS-$(CONFIG_LIBPOSIX_PROCESS_MULTITHREADING) += $(LIBPOSIX_PROCESS_BASE)/arch/$(CONFIG_UK_ARCH)/clone.c|$(CONFIG_UK_ARCH)
+LIBPOSIX_PROCESS_SRCS-$(CONFIG_LIBPOSIX_PROCESS_MULTITHREADING) += $(LIBPOSIX_PROCESS_BASE)/arch/$(CONFIG_UK_ARCH)/clone.S|arch
+CFLAGS-$(CONFIG_LIBPOSIX_PROCESS_MULTITHREADING) += -fno-builtin-exit -fno-builtin-exit-group
+CXXFLAGS-$(CONFIG_LIBPOSIX_PROCESS_MULTITHREADING) += -fno-builtin-exit -fno-builtin-exit-group
 
 LIBPOSIX_PROCESS_CINCLUDES-y += -I$(UK_PLAT_COMMON_BASE)/include
 LIBPOSIX_PROCESS_ASINCLUDES-y += -I$(UK_PLAT_COMMON_BASE)/include
 LIBPOSIX_PROCESS_CXXINCLUDES-y += -I$(UK_PLAT_COMMON_BASE)/include
 
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBPOSIX_PROCESS) += alarm-1
-UK_PROVIDED_SYSCALLS-$(CONFIG_LIBPOSIX_PROCESS_CLONE) += clone-5e
-UK_PROVIDED_SYSCALLS-$(CONFIG_LIBPOSIX_PROCESS_EXECVE) += execve-3e
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBPOSIX_PROCESS) += pause-0
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBPOSIX_PROCESS) += sigaltstack-2
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBPOSIX_PROCESS) += rt_sigpending-2
@@ -68,7 +65,6 @@ UK_PROVIDED_SYSCALLS-$(CONFIG_LIBPOSIX_PROCESS_SIGNALFD) += signalfd-3
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBPOSIX_PROCESS) += kill-2
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBPOSIX_PROCESS) += tgkill-3
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBPOSIX_PROCESS) += tkill-2
-UK_PROVIDED_SYSCALLS-$(CONFIG_LIBPOSIX_PROCESS_VFORK) += vfork-0e
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBPOSIX_PROCESS) += wait4-4 waitid-4
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBPOSIX_PROCESS) += getpgid-1
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBPOSIX_PROCESS) += setpgid-2
@@ -82,4 +78,7 @@ UK_PROVIDED_SYSCALLS-$(CONFIG_LIBPOSIX_PROCESS) += prlimit64-4
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBPOSIX_PROCESS) += getrlimit-2 setrlimit-2
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBPOSIX_PROCESS) += getrusage-2
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBPOSIX_PROCESS) += prctl-5
-UK_PROVIDED_SYSCALLS-$(CONFIG_LIBPOSIX_PROCESS_PIDS) += exit-1 exit_group-1
+UK_PROVIDED_SYSCALLS-$(CONFIG_LIBPOSIX_PROCESS_EXECVE) += execve-3e
+UK_PROVIDED_SYSCALLS-$(CONFIG_LIBPOSIX_PROCESS_MULTIPROCESS) += vfork-0e
+UK_PROVIDED_SYSCALLS-$(CONFIG_LIBPOSIX_PROCESS_MULTITHREADING) += clone-5e
+UK_PROVIDED_SYSCALLS-$(CONFIG_LIBPOSIX_PROCESS_MULTITHREADING) += exit-1 exit_group-1
index 01f7e490ffa2ced42301f7dc539ea23a7f3b7a39..e74f80decf68553dff02821bf96f7ffc87448040 100644 (file)
@@ -324,6 +324,7 @@ static void _clone_child_gc(struct uk_thread *t)
 int uk_clone(struct clone_args *cl_args, size_t cl_args_len,
             struct ukarch_execenv *execenv)
 {
+       struct posix_process *pprocess;
        struct posix_thread *pthread;
        struct uk_thread *child = NULL;
        struct uk_thread *t;
@@ -398,6 +399,13 @@ int uk_clone(struct clone_args *cl_args, size_t cl_args_len,
        uk_pr_debug(")\n");
 #endif /* UK_DEBUG */
 
+#if !CONFIG_LIBPOSIX_PROCESS_MULTIPROCESS
+       if (unlikely(flags & !CLONE_THREAD)) {
+               uk_pr_err("Multiprocess support not enabled\n");
+               return -ENOTSUP;
+       }
+#endif /* !CONFIG_LIBPOSIX_PROCESS_MULTIPROCESS */
+
        /* CLONE_VM requires that the child operates on the same memory
         * space as the parent.
         *
@@ -478,6 +486,7 @@ int uk_clone(struct clone_args *cl_args, size_t cl_args_len,
 #endif /* CONFIG_LIBUKDEBUG_ENABLE_ASSERT */
 
        if (flags & CLONE_VFORK) {
+#if CONFIG_LIBPOSIX_PROCESS_MULTIPROCESS
                /* We will be blocking the parent and pass control to the child
                 * via the scheduler. Therefore we need to set the child's TLS
                 * pointer the Unikraft TLS.
@@ -492,6 +501,10 @@ int uk_clone(struct clone_args *cl_args, size_t cl_args_len,
 
                /* Also inherit the parent's stack allocator */
                child->_mem.stack_a = t->_mem.stack_a;
+#else /* CONFIG_LIBPOSIX_PROCESS_MULTIPROCESS */
+               ret = -ENOTSUP;
+               goto err_free_child;
+#endif /* CONFIG_LIBPOSIX_PROCESS_MULTIPROCESS */
        } else  {
                /* CLONE_SETTLS: Instead of just activating the Unikraft TLS
                 * we activate the passed TLS pointer as soon as the child
@@ -508,13 +521,27 @@ int uk_clone(struct clone_args *cl_args, size_t cl_args_len,
                    (void *) child->tlsp,
                    (child->tlsp != child->uktlsp) ? "custom" : "Unikraft");
 
-       if (!(cl_args->flags & CLONE_THREAD)) {
-               uk_pr_debug("Creating new process for child\n");
-               ret = uk_posix_process_create(uk_alloc_get_default(), child, t);
+       if (cl_args->flags & CLONE_THREAD) {
+               pprocess = uk_pprocess_current();
+               UK_ASSERT(pprocess);
+
+               pthread = pprocess_create_pthread(pprocess, child);
+               if (unlikely(PTRISERR(pthread))) {
+                       ret = PTR2ERR(pthread);
+                       uk_pr_err("Could not create pthread (%d)\n", ret);
+                       goto err_free_child;
+               }
+       } else {
+#if CONFIG_LIBPOSIX_PROCESS_MULTIPROCESS
+               ret = pprocess_create(uk_alloc_get_default(), child, t);
                if (unlikely(ret)) {
-                       uk_pr_err("Could not create child process\n");
+                       uk_pr_err("Could not create process (%d)\n", ret);
                        goto err_free_child;
                }
+#else /* CONFIG_LIBPOSIX_PROCESS_MULTIPROCESS */
+               ret = -ENOTSUP;
+               goto err_free_child;
+#endif /* CONFIG_LIBPOSIX_PROCESS_MULTIPROCESS */
        }
 
        /* Call clone handler table but treat CLONE_SETTLS as handled */
index f8ee0fb92bdb1809a81a632f51445d0ca11f6d87..5d0fd23ee022ee379abf00a4cffe036d8d4625b4 100644 (file)
@@ -42,7 +42,7 @@
 extern "C" {
 #endif
 
-#if CONFIG_LIBPOSIX_PROCESS_CLONE
+#if CONFIG_LIBPOSIX_PROCESS_MULTITHREADING
 /* Clone arguments for SYS_clone3
  * long syscall(SYS_clone3, struct clone_args *cl_args, size_t size);
  */
@@ -65,7 +65,7 @@ struct clone_args {
                             * of child (since Linux 5.7)
                             */
 };
-#endif /* CONFIG_LIBPOSIX_PROCESS_CLONE */
+#endif /* CONFIG_LIBPOSIX_PROCESS_MULTITHREADING */
 
 #ifdef __cplusplus
 }
index 63e926daa0a05c9fcada1f71294428bae99a658d..d7968166ff7fb8771e55decd4fb1159504a4d869 100644 (file)
 #ifndef __UK_PROCESS_H__
 #define __UK_PROCESS_H__
 
-#include <arch/clone.h>
-#include <uk/config.h>
 #include <stdbool.h>
+#include <stddef.h> /* NULL */
 #include <sys/resource.h>
 #include <sys/types.h> /* pid_t */
-#if CONFIG_LIBUKSCHED
-#include <uk/thread.h>
-#endif
-#include <uk/prio.h>
-#if CONFIG_LIBPOSIX_PROCESS_CLONE
+
+#include <uk/config.h>
+#include <uk/essentials.h>
+
+#if CONFIG_LIBPOSIX_PROCESS_MULTITHREADING
 #ifndef _GNU_SOURCE
 #define _GNU_SOURCE
 #endif
 #include <sched.h>       /* CLONE_* constants */
 #include <linux/sched.h> /* struct clone_args */
 
+#include <arch/clone.h>
+#include <uk/event.h>
+#include <uk/prio.h>
+#include <uk/thread.h>
+
 /* In case a libC is defining only a subset of our currently supported clone
  * flags, we provide here a completion of the list
  */
 #ifndef CLONE_CLEAR_SIGHAND
 #define CLONE_CLEAR_SIGHAND    0x100000000ULL
 #endif
-#endif /* CONFIG_LIBPOSIX_PROCESS_CLONE */
+#endif /* CONFIG_LIBPOSIX_PROCESS_MULTITHREADING */
 
 int uk_sys_prlimit64(int pid, unsigned int resource,
                     struct rlimit *new_limit, struct rlimit *old_limit);
@@ -151,14 +155,14 @@ pid_t uk_sys_gettid(void);
 pid_t uk_sys_getppid(void);
 pid_t uk_sys_getpid(void);
 
-#if CONFIG_LIBUKSCHED
+#if CONFIG_LIBPOSIX_PROCESS_MULTIPROCESS
 int uk_posix_process_create(struct uk_alloc *a,
                            struct uk_thread *thread,
                            struct uk_thread *parent);
 void uk_posix_process_kill(struct uk_thread *thread);
-#endif /* CONFIG_LIBUKSCHED */
+#endif /* CONFIG_LIBPOSIX_PROCESS_MULTIPROCESS */
 
-#if CONFIG_LIBPOSIX_PROCESS_CLONE
+#if CONFIG_LIBPOSIX_PROCESS_MULTITHREADING
 typedef int  (*uk_posix_clone_init_func_t)(const struct clone_args *cl_args,
                                           size_t cl_args_len,
                                           struct uk_thread *child,
@@ -218,7 +222,7 @@ struct uk_posix_clonetab_entry {
        _UK_POSIX_CLONETAB_ENTRY(flags_mask, presence_only, init_fn, term_fn,  \
                                 UK_PRIO_LATEST)
 
-#endif /* CONFIG_LIBPOSIX_PROCESS_CLONE */
+#endif /* CONFIG_LIBPOSIX_PROCESS_MULTITHREADING */
 
 #if CONFIG_LIBPOSIX_PROCESS_EXECVE
 
index 1f303a076b01fead891a3c04f08e04b13789721f..0e421b0533d7b2aa797d227ef49619ff4b62a492 100644 (file)
@@ -43,7 +43,7 @@
 
 struct uk_thread *pprocess_thread_main;
 
-#if CONFIG_LIBPOSIX_PROCESS_PIDS
+#if CONFIG_LIBPOSIX_PROCESS_MULTITHREADING
 #include <uk/bitmap.h>
 #include <uk/list.h>
 #include <uk/alloc.h>
@@ -52,9 +52,7 @@ struct uk_thread *pprocess_thread_main;
 #include <uk/init.h>
 #include <uk/errptr.h>
 #include <uk/essentials.h>
-#if CONFIG_LIBPOSIX_PROCESS_CLONE
 #include <uk/process.h>
-#endif /* CONFIG_LIBPOSIX_PROCESS_CLONE */
 
 #if CONFIG_LIBPOSIX_PROCESS_SIGNAL
 #include "signal/signal.h"
@@ -485,7 +483,6 @@ void uk_posix_process_kill(struct uk_thread *thread)
        pprocess_kill(pprocess);
 }
 
-#if CONFIG_LIBPOSIX_PROCESS_INIT_PIDS
 static int posix_process_init(struct uk_init_ctx *ictx)
 {
        struct uk_thread *t;
@@ -509,7 +506,6 @@ static int posix_process_init(struct uk_init_ctx *ictx)
 }
 
 uk_late_initcall(posix_process_init, 0x0);
-#endif /* CONFIG_LIBPOSIX_PROCESS_INIT_PIDS */
 
 /* Thread initialization: Assign posix thread only if parent is part of a
  * process
@@ -712,7 +708,6 @@ __noreturn void exit_group(int status)
 }
 #endif /* UK_LIBC_SYSCALLS */
 
-#if CONFIG_LIBPOSIX_PROCESS_CLONE
 /* Store child PID at given location for parent */
 static int pprocess_parent_settid(const struct clone_args *cl_args,
                                  size_t cl_args_len __unused,
@@ -759,8 +754,7 @@ static int pprocess_clone_thread(const struct clone_args *cl_args __unused,
        return 0;
 }
 UK_POSIX_CLONE_HANDLER(CLONE_THREAD, false, pprocess_clone_thread, 0x0);
-#endif /* CONFIG_LIBPOSIX_PROCESS_CLONE */
-#else  /* !CONFIG_LIBPOSIX_PROCESS_PIDS */
+#else  /* !CONFIG_LIBPOSIX_PROCESS_MULTITHREADING */
 
 #define UNIKRAFT_PID      1
 #define UNIKRAFT_TID      1
@@ -781,7 +775,7 @@ pid_t uk_sys_getppid(void)
        return UNIKRAFT_PPID;
 }
 
-#endif /* !CONFIG_LIBPOSIX_PROCESS_PIDS */
+#endif /* !CONFIG_LIBPOSIX_PROCESS_MULTITHREADING */
 
 UK_SYSCALL_R_DEFINE(pid_t, gettid)
 {
index 10ae276aa8e0f67302602e186d9af5a3e493d69e..c2dbb4cfc3d0176b43566beeb0e6ae444a581185 100644 (file)
 #ifndef __PROCESS_H_INTERNAL__
 #define __PROCESS_H_INTERNAL__
 
-#include <uk/config.h>
 #include <sys/types.h>
+#include <uk/config.h>
 
-#if CONFIG_LIBPOSIX_PROCESS_CLONE
+#if CONFIG_LIBPOSIX_PROCESS_MULTITHREADING
 #include <linux/sched.h>
 #include <uk/arch/ctx.h>
-#endif /* CONFIG_LIBPOSIX_PROCESS_CLONE */
-
-#if CONFIG_LIBPOSIX_PROCESS_PIDS
 #include <uk/thread.h>
-
-#define TIDMAP_SIZE (CONFIG_LIBPOSIX_PROCESS_MAX_PID + 1)
+#endif /* CONFIG_LIBPOSIX_PROCESS_MULTITHREADING */
 
 extern struct uk_thread *pprocess_thread_main;
 
+#if CONFIG_LIBPOSIX_PROCESS_MULTITHREADING
+
+#define TIDMAP_SIZE (CONFIG_LIBPOSIX_PROCESS_MAX_PID + 1)
+
 /* Notice: The RUNNING state is not necessarily in sync with the state
  * of the underlying uk_thread (may be blocked by the scheduler).
  * On the other hand, the BLOCKED state implies that the underlying
@@ -120,11 +120,9 @@ pid_t ukthread2tid(struct uk_thread *thread);
 pid_t ukthread2pid(struct uk_thread *thread);
 
 void pprocess_kill_siblings(struct uk_thread *thread);
-#endif /* CONFIG_LIBPOSIX_PROCESS_PIDS */
 
-#if CONFIG_LIBPOSIX_PROCESS_CLONE
 int uk_clone(struct clone_args *cl_args, size_t cl_args_len,
             struct ukarch_execenv *execenv);
-#endif /* CONFIG_LIBPOSIX_PROCESS_CLONE */
+#endif /* CONFIG_LIBPOSIX_PROCESS_MULTITHREADING */
 
 #endif /* __PROCESS_H_INTERNAL__ */
index 0f59c44743f8ba238dd4c506dd474c992641e1c3..c00291a008327d2d16fd959dd00ebcd989902a83 100644 (file)
@@ -103,7 +103,7 @@ struct uk_sigaction {
        __atomic refcnt;
 };
 
-#if CONFIG_LIBPOSIX_PROCESS_PIDS
+#if CONFIG_LIBPOSIX_PROCESS_MULTITHREADING
 
 /* Descriptor of a pending signal.
  *
@@ -364,6 +364,6 @@ bool pprocess_signal_should_drop(struct posix_process *pproc, int signum)
 #endif /* !CONFIG_LIBPOSIX_PROCESS_SIGNALFD */
 #endif /* CONFIG_LIBPOSIX_PROCESS_SIGNAL */
 
-#endif /* CONFIG_LIBPOSIX_PROCESS_PIDS */
+#endif /* CONFIG_LIBPOSIX_PROCESS_MULTITHREADING */
 
 #endif /* __UK_PROCESS_SIGNAL_H__ */