diff options
Diffstat (limited to 'nptl/sysdeps/unix/sysv/linux/i386')
-rw-r--r-- | nptl/sysdeps/unix/sysv/linux/i386/pt-vfork.S | 21 | ||||
-rw-r--r-- | nptl/sysdeps/unix/sysv/linux/i386/vfork.S | 8 |
2 files changed, 26 insertions, 3 deletions
diff --git a/nptl/sysdeps/unix/sysv/linux/i386/pt-vfork.S b/nptl/sysdeps/unix/sysv/linux/i386/pt-vfork.S index 6994c0d7fa..24f5a1d292 100644 --- a/nptl/sysdeps/unix/sysv/linux/i386/pt-vfork.S +++ b/nptl/sysdeps/unix/sysv/linux/i386/pt-vfork.S @@ -1,4 +1,4 @@ -/* Copyright (C) 1999, 2002 Free Software Foundation, Inc. +/* Copyright (C) 1999, 2002, 2004 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Andreas Schwab <schwab@gnu.org>. @@ -21,6 +21,21 @@ #define _ERRNO_H 1 #include <bits/errno.h> #include <kernel-features.h> +#include <tcb-offsets.h> + +/* Save the PID value. */ +#define SAVE_PID \ + movl %gs:PID, %edx; \ + movl %edx, %eax; \ + negl %eax; \ + movl %eax, %gs:PID + +/* Restore the old PID value in the parent. */ +#define RESTORE_PID \ + testl %eax, %eax; \ + je 1f; \ + movl %edx, %gs:PID; \ +1: /* Clone the calling process, but without copying the whole address space. The calling process is suspended until the new process exits or is @@ -31,10 +46,14 @@ ENTRY (__vfork) /* Pop the return PC value into ECX. */ popl %ecx + SAVE_PID + /* Stuff the syscall number in EAX and enter into the kernel. */ movl $SYS_ify (vfork), %eax int $0x80 + RESTORE_PID + /* Jump to the return PC. Don't jump directly since this disturbs the branch target cache. Instead push the return address back on the stack. */ diff --git a/nptl/sysdeps/unix/sysv/linux/i386/vfork.S b/nptl/sysdeps/unix/sysv/linux/i386/vfork.S index 2b60a5ea5e..52336102c7 100644 --- a/nptl/sysdeps/unix/sysv/linux/i386/vfork.S +++ b/nptl/sysdeps/unix/sysv/linux/i386/vfork.S @@ -21,9 +21,13 @@ /* Save the PID value. */ #define SAVE_PID \ movl %gs:PID, %edx; \ - movl $-1, %gs:PID + movl %edx, %eax; \ + negl %eax; \ + jne 1f; \ + movl $0x80000000, %eax; \ +1: movl %eax, %gs:PID -/* Restore the old PID value in the parent. In the child store 0. */ +/* Restore the old PID value in the parent. */ #define RESTORE_PID \ testl %eax, %eax; \ je 1f; \ |