diff options
-rw-r--r-- | nptl/ChangeLog | 12 | ||||
-rw-r--r-- | nptl/sysdeps/unix/sysv/linux/i386/pthread_once.S | 8 | ||||
-rw-r--r-- | nptl/sysdeps/unix/sysv/linux/x86_64/fork.c | 31 | ||||
-rw-r--r-- | nptl/sysdeps/unix/sysv/linux/x86_64/pthread_once.S | 38 | ||||
-rw-r--r-- | nptl/sysdeps/x86_64/tls.h | 38 |
5 files changed, 63 insertions, 64 deletions
diff --git a/nptl/ChangeLog b/nptl/ChangeLog index 3d708b6acc..91679b97d3 100644 --- a/nptl/ChangeLog +++ b/nptl/ChangeLog @@ -1,5 +1,17 @@ 2003-03-09 Ulrich Drepper <drepper@redhat.com> + * sysdeps/unix/sysv/linux/x86_64/pthread_once.S: Fix many + leftovers from the ia32 code. + + * sysdeps/unix/sysv/linux/i386/pthread_once.S: Remove unneccessary + memory load. + (clear_once_control): Don't load %esi. + + * sysdeps/x86_64/tls.h: Remove all traces of segment descriptor + handling. + + * sysdeps/unix/sysv/linux/x86_64/fork.c: New file. + * sysdeps/unix/sysv/linux/s390/createthread.c: Moved to... * sysdeps/unix/sysv/linux/createthread.c: ...here. 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 diff --git a/nptl/sysdeps/x86_64/tls.h b/nptl/sysdeps/x86_64/tls.h index 7a6394415c..66e878ef0b 100644 --- a/nptl/sysdeps/x86_64/tls.h +++ b/nptl/sysdeps/x86_64/tls.h @@ -60,30 +60,6 @@ typedef struct /* Get system call information. */ # include <sysdep.h> -/* The old way: using LDT. */ - -/* Structure passed to `modify_ldt', 'set_thread_area', and 'clone' calls. */ -struct user_desc -{ - unsigned int entry_number; - unsigned long int base_addr; - unsigned int limit; - unsigned int seg_32bit:1; - unsigned int contents:2; - unsigned int read_exec_only:1; - unsigned int limit_in_pages:1; - unsigned int seg_not_present:1; - unsigned int useable:1; - unsigned int empty:25; -}; - -/* Initializing bit fields is slow. We speed it up by using a union. */ -union user_desc_init -{ - struct user_desc desc; - unsigned int vals[4]; -}; - /* Get the thread descriptor definition. */ # include <nptl/descr.h> @@ -127,20 +103,6 @@ union user_desc_init __asm ("movl %0, %%fs" :: "q" (val)) -# ifndef __NR_set_thread_area -# define __NR_set_thread_area 205 -# endif -# ifndef TLS_FLAG_WRITABLE -# define TLS_FLAG_WRITABLE 0x00000001 -# endif - -// XXX Enable for the real world. -#if 0 -# ifndef __ASSUME_SET_THREAD_AREA -# error "we need set_thread_area" -# endif -#endif - /* Code to initially initialize the thread pointer. This might need special attention since 'errno' is not yet available and if the operation can cause a failure 'errno' must not be touched. |