| ... | ... | @@ -196,17 +196,28 @@ pub fn clone() callconv(.naked) u64 { |
| 196 | 196 | // g1 o0, o1, o2, o3, o4 |
| 197 | 197 | asm volatile ( |
| 198 | 198 | \\ save %%sp, -192, %%sp |
| 199 | \\ |
| 200 | \\ // clone() on SPARC can fail with EFAULT if %%sp points to uncommitted memory, so flush |
| 201 | \\ // all register windows up to this point to ensure that the kernel has enough committed |
| 202 | \\ // memory for its stack frame. |
| 203 | \\ save %%sp, -192, %%sp |
| 204 | \\ flushw |
| 205 | \\ restore |
| 206 | \\ |
| 199 | 207 | \\ # Save the func pointer and the arg pointer |
| 200 | 208 | \\ mov %%i0, %%g2 |
| 201 | 209 | \\ mov %%i3, %%g3 |
| 210 | \\ |
| 202 | 211 | \\ # Shuffle the arguments |
| 203 | 212 | \\ mov 217, %%g1 // SYS_clone |
| 204 | 213 | \\ mov %%i2, %%o0 |
| 214 | \\ |
| 205 | 215 | \\ # Add some extra space for the initial frame |
| 206 | | \\ sub %%i1, 176 + 2047, %%o1 |
| 216 | \\ sub %%i1, 192 + 2047, %%o1 |
| 217 | \\ |
| 207 | 218 | \\ mov %%i4, %%o2 |
| 208 | 219 | \\ mov %%i5, %%o3 |
| 209 | | \\ ldx [%%fp + 0x8af], %%o4 |
| 220 | \\ ldx [%%fp + 176 + 2047], %%o4 |
| 210 | 221 | \\ t 0x6d |
| 211 | 222 | \\ bcs,pn %%xcc, 1f |
| 212 | 223 | \\ nop |
| ... | ... | @@ -214,15 +225,18 @@ pub fn clone() callconv(.naked) u64 { |
| 214 | 225 | \\ # process is the child (=1) or the parent (=0). |
| 215 | 226 | \\ brnz %%o1, 2f |
| 216 | 227 | \\ nop |
| 228 | \\ |
| 217 | 229 | \\ # Parent process, return the child pid |
| 218 | 230 | \\ mov %%o0, %%i0 |
| 219 | 231 | \\ ret |
| 220 | 232 | \\ restore |
| 233 | \\ |
| 221 | 234 | \\1: |
| 222 | 235 | \\ # The syscall failed |
| 223 | 236 | \\ sub %%g0, %%o0, %%i0 |
| 224 | 237 | \\ ret |
| 225 | 238 | \\ restore |
| 239 | \\ |
| 226 | 240 | \\2: |
| 227 | 241 | \\ # Child process |
| 228 | 242 | ); |