| ... | @@ -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 | } |
| 23 | | 23 | |
| 24 | pub fn syscall_fork() usize { | 24 | pub 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 0x6d | 31 | \\ t 0x6d |
| 27 | \\ bcc,pt %%xcc, 1f | 32 | \\ bcc,pt %%xcc, 1f |
| ... | @@ -29,6 +34,7 @@ pub fn syscall_fork() usize { | ... | @@ -29,6 +34,7 @@ pub fn syscall_fork() usize { |
| 29 | \\ ba 2f | 34 | \\ ba 2f |
| 30 | \\ neg %%o0 | 35 | \\ neg %%o0 |
| 31 | \\ 1: | 36 | \\ 1: |
| | 37 | \\ # Clear the child's %%o0 |
| 32 | \\ dec %%o1 | 38 | \\ dec %%o1 |
| 33 | \\ and %%o1, %%o0, %%o0 | 39 | \\ and %%o1, %%o0, %%o0 |
| 34 | \\ 2: | 40 | \\ 2: |