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 {...@@ -22,6 +22,11 @@ pub fn syscall_pipe(fd: *[2]i32) usize {
22}22}
2323
24pub fn syscall_fork() usize {24pub 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.
25 return asm volatile (30 return asm volatile (
26 \\ t 0x6d31 \\ t 0x6d
27 \\ bcc,pt %%xcc, 1f32 \\ bcc,pt %%xcc, 1f
...@@ -29,6 +34,7 @@ pub fn syscall_fork() usize {...@@ -29,6 +34,7 @@ pub fn syscall_fork() usize {
29 \\ ba 2f34 \\ ba 2f
30 \\ neg %%o035 \\ neg %%o0
31 \\ 1:36 \\ 1:
37 \\ # Clear the child's %%o0
32 \\ dec %%o138 \\ dec %%o1
33 \\ and %%o1, %%o0, %%o039 \\ and %%o1, %%o0, %%o0
34 \\ 2:40 \\ 2: