1: /* @(#)vfork.s 0.0 SCCS id keyword */
2: / C library -- vfork
3:
4: / pid = vfork();
5: /
6: / pid == 0 in child process; pid == -1 means error return
7: / in child, parents id is in par_uid if needed
8: /
9: / Since the parent and child share the stack, the return
10: / address for the parent would be overwritten by the child.
11: / Therefore, save the return address in r1 and "return"
12: / by a jump indirect.
13:
14: .globl _vfork, _par_uid
15: .globl __ovno
16: .comm _errno,2
17:
18: _vfork:
19: mov (sp)+,r1 / save return address
20: mov __ovno,savov / save __ovno for parent
21: sys vfork
22: br 1f / child returns here; if no vfork
23: / syscall, parent returns here also.
24:
25: bec 2f / parent returns here
26: 0: mov r0,_errno / vfork failed; can't use cerror
27: mov $-1,r0
28: jmp (r1) / "return" to saved location
29:
30: 1: / child:
31: bes 0b / check error here also
32: / (in case no vfork syscall)
33: mov r0,_par_uid
34: clr r0
35: 2:
36: mov savov,__ovno / restore ovno in case child switched
37: jmp (r1) / "return" to saved location
38:
39: .bss
40: savov: .=.+2
Defined functions
_vfork
declared in line
14; defined in line
18; used 1 times
Defined variables
savov
defined in line
40; used 2 times