summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux/kvx/vfork.S
diff options
context:
space:
mode:
Diffstat (limited to 'libc/sysdeps/linux/kvx/vfork.S')
-rw-r--r--libc/sysdeps/linux/kvx/vfork.S47
1 files changed, 47 insertions, 0 deletions
diff --git a/libc/sysdeps/linux/kvx/vfork.S b/libc/sysdeps/linux/kvx/vfork.S
new file mode 100644
index 000000000..7c6a17133
--- /dev/null
+++ b/libc/sysdeps/linux/kvx/vfork.S
@@ -0,0 +1,47 @@
+/*
+ * This file is subject to the terms and conditions of the LGPL V2.1
+ * License. See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2018 Kalray Inc.
+ */
+
+#include <sys/syscall.h>
+#include <sysdep.h>
+
+/* We do not want COMPAT to be enabled in our kernel, hence vfork
+ * is not available. Use clone to do the same job with appropriate flags */
+#define _SIGNAL_H
+#include <bits/signum.h> /* For SIGCHLD */
+
+#define CLONE_VM 0x00000100
+#define CLONE_VFORK 0x00004000
+#define CLONE_FLAGS_FOR_VFORK (CLONE_VM|CLONE_VFORK|SIGCHLD)
+
+ENTRY(__vfork)
+ make $r0 = CLONE_FLAGS_FOR_VFORK
+ /* Not sure if needed to zero-out other parameters but better
+ * be safe than sorry */
+ make $r1 = 0
+ make $r2 = 0
+ ;;
+ make $r3 = 0
+ make $r4 = 0
+ ;;
+ scall SYS_ify(clone)
+ ;;
+ /* If PID < 0 then it's an error, else, simply return */
+ cb.dltz $r0 ? err
+ ;;
+ ret
+ ;;
+L(err):
+ goto __syscall_error
+ ;;
+ /* Never return */
+ errop
+ ;;
+END(__vfork)
+
+weak_alias(__vfork,vfork)
+libc_hidden_def(vfork)