authorgravatar for koachan@protonmail.comKoakuma <koachan@protonmail.com> 2020-11-28 13:24:24+07:00
committergravatar for koachan@protonmail.comKoakuma <koachan@protonmail.com> 2020-11-28 13:24:24+07:00
logf10bff9ffb452eaf22af8dd85412653ac8bd1081
tree45e6dbf7bef661f74716f81627bc40f0bb94382f
parent41c40f4bbec35ac260b6a7af6b0db0dafccb56ca

Add a comment to explain the fork return values on sparc64


1 files changed, 6 insertions(+), 0 deletions(-)

lib/std/os/linux/sparc64.zig+6
......@@ -22,6 +22,11 @@ pub fn syscall_pipe(fd: *[2]i32) usize {
2222}
2323
2424pub fn syscall_fork() usize {
25 // Linux/sparc64 fork() returns two values in %o0 and %o1:
26 // - On the parent's side, %o0 is the child's PID and %o1 is 0.
27 // - On the child's side, %o0 is the parent's PID and %o1 is 1.
28 // We need to clear the child's %o0 so that the return values
29 // conform to the libc convention.
2530 return asm volatile (
2631 \\ t 0x6d
2732 \\ bcc,pt %%xcc, 1f
......@@ -29,6 +34,7 @@ pub fn syscall_fork() usize {
2934 \\ ba 2f
3035 \\ neg %%o0
3136 \\ 1:
37 \\ # Clear the child's %%o0
3238 \\ dec %%o1
3339 \\ and %%o1, %%o0, %%o0
3440 \\ 2: