From 5a03acfe371193faace69e5517864ba3b9fc2b9f Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Wed, 12 Mar 2003 05:45:00 +0000 Subject: Update. * sysdeps/unix/sysv/linux/x86_64/lowlevellock.S: Fix asm syntax. * sysdeps/unix/sysv/linux/x86_64/lowlevellock.h: Likewise. * sysdeps/unix/sysv/linux/x86_64/lowlevelmutex.S: Likewise. * sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S: Likewise. * sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S: Likewise. * sysdeps/unix/sysv/linux/x86_64/pthread_once.S: Likewise. * sysdeps/unix/sysv/linux/x86_64/sem_post.S: Likewise. * sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S: Likewise. * sysdeps/unix/sysv/linux/x86_64/sem_trywait.S: Likewise. * sysdeps/unix/sysv/linux/x86_64/sem_wait.S: Likewise. * sysdeps/x86_64/tls.h (THREAD_SELF, THREAD_GETMEM, THREAD_GETMEM_NC, THREAD_SETMEM, THREAD_SETMEM_NC): Correct asm syntax. * allocatestack.c [! TLS_MULTIPLE_THREADS_IN_TCB] (allocate_stack): Initialize *__libc_multiple_threads_ptr not __libc_multiple_threads. * sysdeps/pthread/createthread.c [! TLS_MULTIPLE_THREADS_IN_TCB] (create_thread): Likewise. Define __pthread_multiple_threads and __libc_multiple_threads_ptr. * init.c (__pthread_initialize_minimal_internal): Initialize __libc_multiple_threads_ptr if necessary. * pthreadP.h: Adjust prototype for __libc_pthread_init. Declare __pthread_multiple_threads and __libc_multiple_threads_ptr. * sysdeps/unix/sysv/linux/libc_pthread_init.c: Define __libc_multiple_threads. (__libc_pthread_init): Return pointer to __libc_pthread_init if necessary. * sysdeps/i386/tls.h (THREAD_SETMEM): Fix one-byte variant. (THREAD_SETMEM_NC): Likewise. * sysdeps/x86_64/pthread_spin_trylock.c: Removed. * sysdeps/x86_64/pthread_spin_trylock.S: New file. * sysdeps/x86_64/pthread_spin_unlock.c: Removed. * sysdeps/x86_64/pthread_spin_unlock.S: New file. * sysdeps/i386/i486/pthread_spin_trylock.S (pthread_spin_trylock): Eliminate one entire instruction. --- nptl/sysdeps/x86_64/pthread_spin_trylock.S | 40 ++++++++++++++++++++++++++++++ nptl/sysdeps/x86_64/pthread_spin_trylock.c | 1 - nptl/sysdeps/x86_64/pthread_spin_unlock.S | 31 +++++++++++++++++++++++ nptl/sysdeps/x86_64/pthread_spin_unlock.c | 1 - nptl/sysdeps/x86_64/tls.h | 20 +++++++-------- 5 files changed, 81 insertions(+), 12 deletions(-) create mode 100644 nptl/sysdeps/x86_64/pthread_spin_trylock.S delete mode 100644 nptl/sysdeps/x86_64/pthread_spin_trylock.c create mode 100644 nptl/sysdeps/x86_64/pthread_spin_unlock.S delete mode 100644 nptl/sysdeps/x86_64/pthread_spin_unlock.c (limited to 'nptl/sysdeps/x86_64') diff --git a/nptl/sysdeps/x86_64/pthread_spin_trylock.S b/nptl/sysdeps/x86_64/pthread_spin_trylock.S new file mode 100644 index 0000000000..175714d6b0 --- /dev/null +++ b/nptl/sysdeps/x86_64/pthread_spin_trylock.S @@ -0,0 +1,40 @@ +/* Copyright (C) 2002, 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 2002. + + 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. */ + +#define EBUSY 16 + + +#ifdef UP +# define LOCK +#else +# define LOCK lock +#endif + + .globl pthread_spin_trylock + .type pthread_spin_trylock,@function + .align 16 +pthread_spin_trylock: + movl $1, %eax + xorl %ecx, %ecx + LOCK + cmpxchgl %ecx, (%rdi) + movl $EBUSY, %eax + cmovel %ecx, %eax + retq + .size pthread_spin_trylock,.-pthread_spin_trylock diff --git a/nptl/sysdeps/x86_64/pthread_spin_trylock.c b/nptl/sysdeps/x86_64/pthread_spin_trylock.c deleted file mode 100644 index 7ddb37154b..0000000000 --- a/nptl/sysdeps/x86_64/pthread_spin_trylock.c +++ /dev/null @@ -1 +0,0 @@ -#include "../i386/i686/pthread_spin_trylock.c" diff --git a/nptl/sysdeps/x86_64/pthread_spin_unlock.S b/nptl/sysdeps/x86_64/pthread_spin_unlock.S new file mode 100644 index 0000000000..d3e13bde98 --- /dev/null +++ b/nptl/sysdeps/x86_64/pthread_spin_unlock.S @@ -0,0 +1,31 @@ +/* Copyright (C) 2002, 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 2002. + + 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. */ + + .globl pthread_spin_unlock + .type pthread_spin_unlock,@function + .align 16 +pthread_spin_unlock: + movl $1, (%rdi) + xorl %eax, %eax + retq + .size pthread_spin_unlock,.-pthread_spin_unlock + + /* The implementation of pthread_spin_init is identical. */ + .globl pthread_spin_init +pthread_spin_init = pthread_spin_unlock diff --git a/nptl/sysdeps/x86_64/pthread_spin_unlock.c b/nptl/sysdeps/x86_64/pthread_spin_unlock.c deleted file mode 100644 index b287dc1f5c..0000000000 --- a/nptl/sysdeps/x86_64/pthread_spin_unlock.c +++ /dev/null @@ -1 +0,0 @@ -#include "../i386/pthread_spin_unlock.c" diff --git a/nptl/sysdeps/x86_64/tls.h b/nptl/sysdeps/x86_64/tls.h index 45646e4485..66ae0f3f07 100644 --- a/nptl/sysdeps/x86_64/tls.h +++ b/nptl/sysdeps/x86_64/tls.h @@ -145,7 +145,7 @@ typedef struct do not get optimized away. */ # define THREAD_SELF \ ({ struct pthread *__self; \ - asm ("movq %%fs:%c1,%0" : "=r" (__self) \ + asm ("movq %%fs:%c1,%q0" : "=r" (__self) \ : "i" (offsetof (struct pthread, self))); \ __self;}) @@ -168,7 +168,7 @@ typedef struct 4 or 8. */ \ abort (); \ \ - asm ("movq %%fs:%P1,%0" \ + asm ("movq %%fs:%P1,%q0" \ : "=r" (__value) \ : "i" (offsetof (struct pthread, member))); \ } \ @@ -179,12 +179,12 @@ typedef struct # define THREAD_GETMEM_NC(descr, member, idx) \ ({ __typeof (descr->member[0]) __value; \ if (sizeof (__value) == 1) \ - asm ("movb %%fs:%P2(%3),%b0" \ + asm ("movb %%fs:%P2(%q3),%b0" \ : "=q" (__value) \ : "0" (0), "i" (offsetof (struct pthread, member[0])), \ "r" (idx)); \ else if (sizeof (__value) == 4) \ - asm ("movl %%fs:%P1(,%2,4),%0" \ + asm ("movl %%fs:%P1(,%q2,4),%0" \ : "=r" (__value) \ : "i" (offsetof (struct pthread, member[0])), "r" (idx)); \ else \ @@ -194,7 +194,7 @@ typedef struct 4 or 8. */ \ abort (); \ \ - asm ("movq %%fs:%P1(,%2,8),%0" \ + asm ("movq %%fs:%P1(,%q2,8),%q0" \ : "=r" (__value) \ : "i" (offsetof (struct pthread, member[0])), "r" (idx)); \ } \ @@ -204,7 +204,7 @@ typedef struct /* Same as THREAD_SETMEM, but the member offset can be non-constant. */ # define THREAD_SETMEM(descr, member, value) \ ({ if (sizeof (descr->member) == 1) \ - asm volatile ("movb %0,%%fs:%P1" : \ + asm volatile ("movb %b0,%%fs:%P1" : \ : "iq" (value), \ "i" (offsetof (struct pthread, member))); \ else if (sizeof (descr->member) == 4) \ @@ -218,7 +218,7 @@ typedef struct 4 or 8. */ \ abort (); \ \ - asm volatile ("movq %0,%%fs:%P1" : \ + asm volatile ("movq %q0,%%fs:%P1" : \ : "ir" ((unsigned long int) value), \ "i" (offsetof (struct pthread, member))); \ }}) @@ -227,12 +227,12 @@ typedef struct /* Set member of the thread descriptor directly. */ # define THREAD_SETMEM_NC(descr, member, idx, value) \ ({ if (sizeof (descr->member[0]) == 1) \ - asm volatile ("movb %0,%%fs:%P1(%2)" : \ + asm volatile ("movb %b0,%%fs:%P1(%q2)" : \ : "iq" (value), \ "i" (offsetof (struct pthread, member[0])), \ "r" (idx)); \ else if (sizeof (descr->member[0]) == 4) \ - asm volatile ("movl %0,%%fs:%P1(,%2,4)" : \ + asm volatile ("movl %0,%%fs:%P1(,%q2,4)" : \ : "ir" (value), \ "i" (offsetof (struct pthread, member[0])), \ "r" (idx)); \ @@ -243,7 +243,7 @@ typedef struct 4 or 8. */ \ abort (); \ \ - asm volatile ("movq %0,%%fs:%P1(,%2,8)" : \ + asm volatile ("movq %q0,%%fs:%P1(,%q2,8)" : \ : "r" ((unsigned long int) value), \ "i" (offsetof (struct pthread, member[0])), \ "r" (idx)); \ -- cgit 1.4.1