[sys/linux]: Remove clone syscall and call it directly in fork on arm64

This commit is contained in:
PucklaJ
2024-04-28 11:56:19 +02:00
parent 7f301790d0
commit d1a205e2cf
+2 -20
View File
@@ -729,32 +729,14 @@ getsockopt :: proc {
getsockopt_base, getsockopt_base,
} }
/*
Creates a new ("child") process, in a manner similar to fork.
Available since Linux 1.0? (<2.4)
Note(flysand): this syscall is not documented, but the bottom 8 bits of flags
are for exit signal
*/
clone :: proc "contextless" (flags: u64, stack: rawptr, parent_tid, child_tid: ^i32, tls: u64) -> (i64, Errno) {
when ODIN_ARCH == .amd64 {
ret := syscall(SYS_clone, flags, stack, parent_tid, child_tid, tls)
return errno_unwrap(ret, i64)
} else {
ret := syscall(SYS_clone, flags, stack, parent_tid, tls, child_tid)
return errno_unwrap(ret, i64)
}
}
/* /*
Creates a copy of the running process. Creates a copy of the running process.
Available since Linux 1.0. Available since Linux 1.0.
*/ */
fork :: proc "contextless" () -> (Pid, Errno) { fork :: proc "contextless" () -> (Pid, Errno) {
when ODIN_ARCH == .arm64 { when ODIN_ARCH == .arm64 {
ret, err := clone(u64(Signal.SIGCHLD), nil, nil, nil, 0) ret := syscall(SYS_clone, u64(Signal.SIGCHLD), cast(rawptr) nil, cast(rawptr) nil, cast(rawptr) nil, u64(0))
if err != .NONE do return Pid(ret), err return errno_unwrap(ret, Pid)
return Pid(ret), err
} else { } else {
ret := syscall(SYS_fork) ret := syscall(SYS_fork)
return errno_unwrap(ret, Pid) return errno_unwrap(ret, Pid)