mailing list of musl libc
 help / color / mirror / code / Atom feed
* [musl] [PATCH] riscv64: Add vfork
@ 2023-01-03 15:21 Pedro Falcato
  0 siblings, 0 replies; only message in thread
From: Pedro Falcato @ 2023-01-03 15:21 UTC (permalink / raw)
  To: musl; +Cc: Pedro Falcato

Implement vfork() using clone(CLONE_VM | CLONE_VFORK | ...).
---
 src/process/riscv64/vfork.s | 11 +++++++++++
 1 file changed, 11 insertions(+)
 create mode 100644 src/process/riscv64/vfork.s

diff --git a/src/process/riscv64/vfork.s b/src/process/riscv64/vfork.s
new file mode 100644
index 00000000..2f90329d
--- /dev/null
+++ b/src/process/riscv64/vfork.s
@@ -0,0 +1,11 @@
+.global vfork
+.type vfork,@function
+vfork:
+	/* riscv does not have SYS_vfork, so we must use clone instead */
+	/* note: riscv's clone = clone(flags, sp, ptidptr, tls, ctidptr) */
+	li a7, 220
+	li a0, 0x100 | 0x4000 | 17 /* flags = CLONE_VM | CLONE_VFORK | SIGCHLD */
+	mv a1, sp
+	/* the other arguments are ignoreable */
+	ecall
+	j __syscall_ret
-- 
2.39.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-01-03 15:21 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-03 15:21 [musl] [PATCH] riscv64: Add vfork Pedro Falcato

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).