[Glibc-bsd-commits] r4651 - in trunk/glibc-ports/kfreebsd: i386 i386/fbtl x86_64 x86_64/fbtl

Petr Salinger ps-guest at alioth.debian.org
Mon Jul 8 12:48:23 UTC 2013


Author: ps-guest
Date: 2013-06-29 11:41:31 +0000 (Sat, 29 Jun 2013)
New Revision: 4651

Added:
   trunk/glibc-ports/kfreebsd/i386/fbtl/pt-vfork.S
   trunk/glibc-ports/kfreebsd/i386/fbtl/vfork.S
   trunk/glibc-ports/kfreebsd/x86_64/fbtl/pt-vfork.S
   trunk/glibc-ports/kfreebsd/x86_64/fbtl/vfork.S
Removed:
   trunk/glibc-ports/kfreebsd/i386/fbtl/pt-vfork.c
   trunk/glibc-ports/kfreebsd/x86_64/fbtl/pt-vfork.c
Modified:
   trunk/glibc-ports/kfreebsd/i386/vfork.S
   trunk/glibc-ports/kfreebsd/x86_64/vfork.S
Log:
vfork hackery


Added: trunk/glibc-ports/kfreebsd/i386/fbtl/pt-vfork.S
===================================================================
--- trunk/glibc-ports/kfreebsd/i386/fbtl/pt-vfork.S	                        (rev 0)
+++ trunk/glibc-ports/kfreebsd/i386/fbtl/pt-vfork.S	2013-06-29 11:41:31 UTC (rev 4651)
@@ -0,0 +1,36 @@
+/* Copyright (C) 1999-2013 Free Software Foundation, Inc.  This file is part
+   of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+
+#include <tcb-offsets.h>
+
+/* Save the PID value.  */
+#define SAVE_PID \
+	movl	%gs:PID, %edx; 						      \
+	negl	%edx;							      \
+	movl	%edx, %gs:PID
+
+
+/* we do not have spare register during syscall */
+/* Restore the old PID value in the parent.  */
+#define RESTORE_PID_IN_PARENT \
+	movl	%gs:PID, %edx; 						      \
+	negl	%edx;							      \
+	movl	%edx, %gs:PID
+
+#include "../vfork.S"
+

Deleted: trunk/glibc-ports/kfreebsd/i386/fbtl/pt-vfork.c
===================================================================
--- trunk/glibc-ports/kfreebsd/i386/fbtl/pt-vfork.c	2013-06-28 19:23:20 UTC (rev 4650)
+++ trunk/glibc-ports/kfreebsd/i386/fbtl/pt-vfork.c	2013-06-29 11:41:31 UTC (rev 4651)
@@ -1 +0,0 @@
-#warning TODO

Added: trunk/glibc-ports/kfreebsd/i386/fbtl/vfork.S
===================================================================
--- trunk/glibc-ports/kfreebsd/i386/fbtl/vfork.S	                        (rev 0)
+++ trunk/glibc-ports/kfreebsd/i386/fbtl/vfork.S	2013-06-29 11:41:31 UTC (rev 4651)
@@ -0,0 +1,40 @@
+/* Copyright (C) 1999-2013 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+
+#include <tcb-offsets.h>
+
+/* Save the PID value.  */
+#define SAVE_PID \
+	movl	%gs:PID, %edx; 						      \
+	negl	%edx;							      \
+	jne	1f;							      \
+	movl	$0x80000000, %edx;					      \
+1:	movl	%edx, %gs:PID
+
+
+/* we do not have spare register during syscall */
+/* Restore the old PID value in the parent.  */
+#define RESTORE_PID_IN_PARENT \
+	movl	%gs:PID, %edx; 						      \
+	cmpl	$0x80000000, %edx;					      \
+	jne	1f;							      \
+	xorl	%edx, %edx;						      \
+1:	negl	%edx;							      \
+	movl	%edx, %gs:PID
+
+#include "../vfork.S"

Modified: trunk/glibc-ports/kfreebsd/i386/vfork.S
===================================================================
--- trunk/glibc-ports/kfreebsd/i386/vfork.S	2013-06-28 19:23:20 UTC (rev 4650)
+++ trunk/glibc-ports/kfreebsd/i386/vfork.S	2013-06-29 11:41:31 UTC (rev 4651)
@@ -28,7 +28,12 @@
 	/* Pop the return PC value into ECX.  */
 	popl	%ecx
 	cfi_adjust_cfa_offset(-4)
+	cfi_register (%eip, %ecx)
 
+#ifdef SAVE_PID
+        SAVE_PID
+#endif
+
 	/* Perform the system call.  */
 	DO_CALL (vfork, 0)
 	jb	L(error)	/* Branch forward if it failed.  */
@@ -40,6 +45,12 @@
 	decl	%edx
 	andl	%edx, %eax
 
+#ifdef RESTORE_PID_IN_PARENT
+        jz L(norestore)
+        RESTORE_PID_IN_PARENT
+L(norestore):
+#endif
+
 	/* Jump to the return PC.  */
 	jmp	*%ecx
 
@@ -48,6 +59,10 @@
 	pushl	%ecx
 	cfi_adjust_cfa_offset(4)
 
+#ifdef RESTORE_PID_IN_PARENT
+        RESTORE_PID_IN_PARENT
+#endif
+
 	/* Branch to the error handler, hidden in PSEUDO_END.  */
 	jmp	SYSCALL_ERROR_LABEL
 L(pseudo_end):

Added: trunk/glibc-ports/kfreebsd/x86_64/fbtl/pt-vfork.S
===================================================================
--- trunk/glibc-ports/kfreebsd/x86_64/fbtl/pt-vfork.S	                        (rev 0)
+++ trunk/glibc-ports/kfreebsd/x86_64/fbtl/pt-vfork.S	2013-06-29 11:41:31 UTC (rev 4651)
@@ -0,0 +1,29 @@
+/* Copyright (C) 2004-2013 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <tcb-offsets.h>
+
+#define SAVE_PID \
+	movl	%fs:PID, %esi;						      \
+	movl	%esi, %edx;						      \
+	negl	%edx;							      \
+	movl	%edx, %fs:PID
+
+#define RESTORE_PID_IN_PARENT \
+	movl	%esi, %fs:PID;						      \
+
+#include "../vfork.S"

Deleted: trunk/glibc-ports/kfreebsd/x86_64/fbtl/pt-vfork.c
===================================================================
--- trunk/glibc-ports/kfreebsd/x86_64/fbtl/pt-vfork.c	2013-06-28 19:23:20 UTC (rev 4650)
+++ trunk/glibc-ports/kfreebsd/x86_64/fbtl/pt-vfork.c	2013-06-29 11:41:31 UTC (rev 4651)
@@ -1 +0,0 @@
-#warning TODO

Added: trunk/glibc-ports/kfreebsd/x86_64/fbtl/vfork.S
===================================================================
--- trunk/glibc-ports/kfreebsd/x86_64/fbtl/vfork.S	                        (rev 0)
+++ trunk/glibc-ports/kfreebsd/x86_64/fbtl/vfork.S	2013-06-29 11:41:31 UTC (rev 4651)
@@ -0,0 +1,31 @@
+/* Copyright (C) 2004-2013 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <tcb-offsets.h>
+
+#define SAVE_PID \
+	movl	%fs:PID, %esi;						      \
+	movl	$0x80000000, %ecx;					      \
+	movl	%esi, %edx;						      \
+	negl	%edx;							      \
+	cmove	%ecx, %edx;						      \
+	movl	%edx, %fs:PID
+
+#define RESTORE_PID_IN_PARENT \
+	movl	%esi, %fs:PID;						      \
+
+#include "../vfork.S"

Modified: trunk/glibc-ports/kfreebsd/x86_64/vfork.S
===================================================================
--- trunk/glibc-ports/kfreebsd/x86_64/vfork.S	2013-06-28 19:23:20 UTC (rev 4650)
+++ trunk/glibc-ports/kfreebsd/x86_64/vfork.S	2013-06-29 11:41:31 UTC (rev 4651)
@@ -25,10 +25,14 @@
 
 ENTRY (__vfork)
 
-	/* Pop the return PC value into ESI.  */
-	popq	%rsi
+	/* Pop the return PC value into RDI.  */
+	popq	%rdi
 	cfi_adjust_cfa_offset(-8)
+	cfi_register(%rip, %rdi)
 
+#ifdef SAVE_PID
+        SAVE_PID
+#endif
 	/* Perform the system call.  */
 	DO_CALL (vfork, 0)
 	jb	L(error)	/* Branch forward if it failed.  */
@@ -40,14 +44,22 @@
 	decq	%rdx
 	andq	%rdx, %rax
 
+#ifdef RESTORE_PID_IN_PARENT
+	jz L(norestore)
+        RESTORE_PID_IN_PARENT
+L(norestore):
+#endif
+
 	/* Jump to the return PC.  */
-	jmp	*%rsi
+	jmp	*%rdi
 
 L(error):
 	/* Push back the return PC.  */
-	pushq	%rsi
+	pushq	%rdi
 	cfi_adjust_cfa_offset(8)
-
+#ifdef RESTORE_PID_IN_PARENT
+        RESTORE_PID_IN_PARENT
+#endif
 	/* Branch to the error handler, hidden in PSEUDO_END.  */
 	jmp	SYSCALL_ERROR_LABEL
 L(pseudo_end):




More information about the Glibc-bsd-commits mailing list