]> git.saurik.com Git - apple/xnu.git/blobdiff - libsyscall/custom/__vfork.s
xnu-2422.90.20.tar.gz
[apple/xnu.git] / libsyscall / custom / __vfork.s
index 073b9084023dab897de56db0a07465d5fd79e5d6..8f5cd224dcf775890b2a4d5ccf030844ae1f290c 100644 (file)
 
 #include "SYS.h"
 
-#if defined(__ppc__) || defined(__ppc64__)
-
-/* We use mode-independent "g" opcodes such as "srgi", and/or
- * mode-independent macros such as MI_GET_ADDRESS.  These expand
- * into word operations when targeting __ppc__, and into doubleword
- * operations when targeting __ppc64__.
- */
-#include <architecture/ppc/mode_independent_asm.h>
-
-/* In vfork(), the child runs in parent's address space.  */
-
-
-MI_ENTRY_POINT(___vfork)
-    MI_GET_ADDRESS(r5,__current_pid)  // get address of __current_pid in r5
-2:
-       lwarx   r6,0,r5                 // don't cache pid across vfork
-       cmpwi   r6,0
-       ble--   3f              // is another vfork in progress
-       li      r6,0                    // if not, erase the stored pid
-3:     
-       addi    r6,r6,-1                // count the parallel vforks in
-       stwcx.  r6,0,r5                 // negative cached pid values
-       bne--   2b
-       
-       li      r0,SYS_vfork
-       sc
-       b       Lbotch                  // error return
-
-       cmpwi   r4,0
-       beq     Lparent                 // parent, since a1 == 0 in parent,
-
-       li      r3,0                    // child
-       blr
-
-Lparent:                    // r3 == child's pid
-       lwarx   r6,0,r5                 // we're back, decrement vfork count
-       addi    r6,r6,1
-       stwcx.  r6,0,r5
-       bne--   Lparent
-       blr                     // return pid
-
-Lbotch:
-       lwarx   r6,0,r5                 // never went, decrement vfork count
-       addi    r6,r6,1
-       stwcx.  r6,0,r5
-       bne--   Lbotch
-
-       MI_BRANCH_EXTERNAL(cerror)
-
-#elif defined(__i386__)
+#if defined(__i386__)
 
 #if defined(__DYNAMIC__)
 #define GET_CURRENT_PID        PICIFY(__current_pid)
@@ -121,7 +72,7 @@ LEAF(___vfork, 0)
        lock
        incl            __current_pid
        pushl           %ecx
-       BRANCH_EXTERN(cerror)
+       BRANCH_EXTERN(tramp_cerror)
 
 L1:
        testl           %edx, %edx              // CF=OF=0,  ZF set if zero result
@@ -157,13 +108,13 @@ LEAF(___vfork, 0)
        popq            %rdi                    // return address in %rdi
        movq            $ SYSCALL_CONSTRUCT_UNIX(SYS_vfork), %rax       // code for vfork -> rax
        UNIX_SYSCALL_TRAP                       // do the system call
-       jnb             L1                                      // jump if CF==0
+       jnb             L1                      // jump if CF==0
        pushq           %rdi                    // put return address back on stack for cerror
        movq            __current_pid@GOTPCREL(%rip), %rcx
        lock
        addq            $1, (%rcx)
-       movq            (%rcx), %rdi
-       BRANCH_EXTERN(cerror)
+       movq            %rax, %rdi
+       BRANCH_EXTERN(_cerror)
 
 L1:
        testl           %edx, %edx              // CF=OF=0,  ZF set if zero result