about summary refs log tree commit diff
path: root/nptl/sysdeps/unix/sysv
diff options
context:
space:
mode:
Diffstat (limited to 'nptl/sysdeps/unix/sysv')
-rw-r--r--nptl/sysdeps/unix/sysv/linux/i386/pthread_once.S8
-rw-r--r--nptl/sysdeps/unix/sysv/linux/x86_64/fork.c31
-rw-r--r--nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S38
3 files changed, 51 insertions, 26 deletions
diff --git a/nptl/sysdeps/unix/sysv/linux/i386/pthread_once.S b/nptl/sysdeps/unix/sysv/linux/i386/pthread_once.S
index abab62ff1e..8d3deb88f8 100644
--- a/nptl/sysdeps/unix/sysv/linux/i386/pthread_once.S
+++ b/nptl/sysdeps/unix/sysv/linux/i386/pthread_once.S
@@ -105,8 +105,7 @@ __pthread_once:
 	pushl	%edx
 	call	__pthread_cleanup_push	/* Note: no @PLT.  */
 
-	movl	44(%esp), %eax
-	call	*%eax
+	call	*44(%esp)
 
 	/* Pop the cleanup handler.  This code depends on the once
 	   handler and _pthread_cleanup_push not touch the content
@@ -144,20 +143,17 @@ pthread_once = __pthread_once
 	.type	clear_once_control,@function
 	.align	16
 clear_once_control:
-	pushl	%esi
 	pushl	%ebx
 
-	movl	12(%esp), %ebx
+	movl	8(%esp), %ebx
 	movl	$0, (%ebx)
 
-	xorl	%esi, %esi
 	movl	$0x7fffffff, %edx
 	movl	$FUTEX_WAKE, %ecx
 	movl	$SYS_futex, %eax
 	ENTER_KERNEL
 
 	popl	%ebx
-	popl	%esi
 	ret
 	.size	clear_once_control,.-clear_once_control
 
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/fork.c b/nptl/sysdeps/unix/sysv/linux/x86_64/fork.c
new file mode 100644
index 0000000000..c828e158d9
--- /dev/null
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/fork.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <sched.h>
+#include <signal.h>
+#include <sysdep.h>
+#include <tls.h>
+
+
+#define ARCH_FORK() \
+  INLINE_SYSCALL (clone, 4,						      \
+		  CLONE_CHILD_SETTID | CLONE_CHILD_CLEARTID | SIGCHLD, 0,     \
+		  NULL, &THREAD_SELF->tid)
+
+#include "../fork.c"
diff --git a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S
index 3871c0e1a2..43eadcf40a 100644
--- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S
+++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S
@@ -38,18 +38,20 @@ __pthread_once:
 	testl	$2, (%rdi)
 	jz	1f
 	xorl	%eax, %eax
-0:	ret
+	retq
 
-1:	xorq	%rsi, %rsi
+	/* Preserve the function pointer.  */
+1:	pushq	%rsi
+	xorq	%r10, %r10
 
 	/* Not yet initialized or initialization in progress.
 	   Get the fork generation counter now.  */
 6:	movl	(%rdi), %eax
 
-5:	movq	%rax, %rdx
+5:	movl	%eax, %edx
 
 	testl	$2, %eax
-	jnz	0b
+	jnz	4f
 
 	andl	$3, %edx
 	orl	__fork_generation(%rip), %edx
@@ -70,8 +72,8 @@ __pthread_once:
 	jnz	3f	/* Different for generation -> run initializer.  */
 
 	/* Somebody else got here first.  Wait.  */
-	movq	%rsi, %rcx		/* movl $FUTEX_WAIT, %ecx */
-	movl	$SYS_futex, %eax
+	movq	%r10, %rsi		/* movl $FUTEX_WAIT, %ecx */
+	movq	$SYS_futex, %eax
 	syscall
 	jmp	6b
 
@@ -88,14 +90,11 @@ __pthread_once:
 	movq	%rsp, %rdi
 	call	__pthread_cleanup_push	/* Note: no @PLT.  */
 
-	movq	48(%rsp), %rax
-	call	*%rax
+	call	*40(%rsp)
 
-	/* Pop the cleanup handler.  This code depends on the once
-	   handler and _pthread_cleanup_push not touch the content
-	   of the stack.  Otherwise the first parameter would have
-	   to be reloaded.  */
-	xorq	%rdi, %rdi
+	/* Pop the cleanup handler.  */
+	movq	%rsp, %rdi
+	xorq	%rsi, %rsi
 	call	__pthread_cleanup_pop	/* Note: no @PLT.  */
 
 	addq	$32, %rsp
@@ -110,12 +109,12 @@ __pthread_once:
 	/* Wake up all other threads.  */
 	movl	$0x7fffffff, %edx
 	movl	$FUTEX_WAKE, %esi
-	xorq	%rcx, %rcx
-	movl	$SYS_futex, %eax
+	movq	$SYS_futex, %rax
 	syscall
 
-4:	xorq	%rax, %rax
-	ret
+4:	addq	$4, %rsp
+	xorq	%rax, %rax
+	retq
 
 	.size	__pthread_once,.-__pthread_once
 
@@ -128,11 +127,10 @@ pthread_once = __pthread_once
 clear_once_control:
 	movl	$0, (%rdi)
 
-	xorq	%rcx, %rcx
 	movl	$0x7fffffff, %edx
 	movl	$FUTEX_WAKE, %esi
-	movl	$SYS_futex, %eax
+	movq	$SYS_futex, %rax
 	syscall
 
-	ret
+	retq
 	.size	clear_once_control,.-clear_once_control