OSDN Git Service

Remove as many hard-coded constants from the MIPS vfork.S as possible.
authorElliott Hughes <enh@google.com>
Thu, 2 Jan 2014 23:41:33 +0000 (15:41 -0800)
committerElliott Hughes <enh@google.com>
Fri, 3 Jan 2014 22:27:17 +0000 (14:27 -0800)
We could do better, but not without MIPS cleaning up their kernel headers.

Change-Id: Ib4d4ce5d720ce8ca27a3f9a1ae07a9a277675af9

libc/arch-mips/bionic/vfork.S

index 2e2e4ff..414caaf 100644 (file)
  */
 
 #include <asm/unistd.h>
+#include <linux/sched.h>
 
-       .text
+// TODO: mips' uapi signal.h is missing #ifndef __ASSEMBLY__.
+// #include <asm/signal.h>
+#define SIGCHLD 18
 
-/* int vfork() implemented using clone() */
+       .text
 
        .type   vfork, @function
        .global vfork
@@ -40,17 +43,22 @@ vfork:
        .set    noreorder
        .cpload $t9
 
-       li      $a0, 0x4112        /* CLONE_VM | CLONE_VFORK | SIGCHLD */
-       move    $a1, $sp
+       li      $a0, (CLONE_VM | CLONE_VFORK | SIGCHLD)
+       li      $a1, 0
+       li      $a2, 0
+       li      $a3, 0
+       subu    $sp, 8
+       sw      $0, 16($sp)
        li      $v0, __NR_clone
        syscall
-       bnez    $a3,1f
-        nop
+       addu    $sp, 8
+       bnez    $a3, 1f
+        move   $a0, $v0
 
        j       $ra
         nop
 1:
-       la      $t9,__set_errno
+       la      $t9, __set_errno
        j       $t9
-        move   $a0,$v0
+        nop
        .end    vfork