diff options
author | Carlos O'Donell <carlos@systemhalted.org> | 2015-01-21 00:46:16 -0500 |
---|---|---|
committer | Carlos O'Donell <carlos@systemhalted.org> | 2015-01-21 00:46:16 -0500 |
commit | 042e1521c794a945edc43b5bfa7e69ad70420524 (patch) | |
tree | 74f44d4b065d801cfe6ace654827ca8ef351bff8 /sysdeps/unix/sysv | |
parent | a8db092ec0c6742a9d41e1715946e90d4edfeec1 (diff) | |
download | glibc-042e1521c794a945edc43b5bfa7e69ad70420524.tar.gz glibc-042e1521c794a945edc43b5bfa7e69ad70420524.tar.xz glibc-042e1521c794a945edc43b5bfa7e69ad70420524.zip |
Fix semaphore destruction (bug 12674).
This commit fixes semaphore destruction by either using 64b atomic operations (where available), or by using two separate fields when only 32b atomic operations are available. In the latter case, we keep a conservative estimate of whether there are any waiting threads in one bit of the field that counts the number of available tokens, thus allowing sem_post to atomically both add a token and determine whether it needs to call futex_wake. See: https://sourceware.org/ml/libc-alpha/2014-12/msg00155.html
Diffstat (limited to 'sysdeps/unix/sysv')
18 files changed, 0 insertions, 1793 deletions
diff --git a/sysdeps/unix/sysv/linux/alpha/sem_post.c b/sysdeps/unix/sysv/linux/alpha/sem_post.c deleted file mode 100644 index 9d4495312e..0000000000 --- a/sysdeps/unix/sysv/linux/alpha/sem_post.c +++ /dev/null @@ -1,5 +0,0 @@ -/* ??? This is an ass-backwards way to do this. We should simply define - the acquire/release semantics of atomic_exchange_and_add. And even if - we don't do this, we should be using atomic_full_barrier or otherwise. */ -#define __lll_rel_instr "mb" -#include <nptl/sem_post.c> diff --git a/sysdeps/unix/sysv/linux/i386/i486/sem_post.S b/sysdeps/unix/sysv/linux/i386/i486/sem_post.S deleted file mode 100644 index 7b553bb478..0000000000 --- a/sysdeps/unix/sysv/linux/i386/i486/sem_post.S +++ /dev/null @@ -1,150 +0,0 @@ -/* Copyright (C) 2002-2015 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper <drepper@redhat.com>, 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, see - <http://www.gnu.org/licenses/>. */ - -#include <sysdep.h> -#include <shlib-compat.h> -#include <pthread-errnos.h> -#include <structsem.h> -#include <lowlevellock.h> - - - .text - - .globl __new_sem_post - .type __new_sem_post,@function - .align 16 -__new_sem_post: - cfi_startproc - pushl %ebx - cfi_adjust_cfa_offset(4) - cfi_offset(%ebx, -8) - - movl 8(%esp), %ebx - -#if VALUE == 0 - movl (%ebx), %eax -#else - movl VALUE(%ebx), %eax -#endif -0: cmpl $SEM_VALUE_MAX, %eax - je 3f - leal 1(%eax), %edx - LOCK -#if VALUE == 0 - cmpxchgl %edx, (%ebx) -#else - cmpxchgl %edx, VALUE(%ebx) -#endif - jnz 0b - - cmpl $0, NWAITERS(%ebx) - je 2f - - movl $FUTEX_WAKE, %ecx - orl PRIVATE(%ebx), %ecx - movl $1, %edx - movl $SYS_futex, %eax - ENTER_KERNEL - - testl %eax, %eax - js 1f - -2: xorl %eax, %eax - popl %ebx - cfi_adjust_cfa_offset(-4) - cfi_restore(%ebx) - ret - - cfi_adjust_cfa_offset(4) - cfi_offset(%ebx, -8) -1: -#ifdef PIC - SETUP_PIC_REG(bx) -#else - movl $4f, %ebx -4: -#endif - addl $_GLOBAL_OFFSET_TABLE_, %ebx -#ifdef NO_TLS_DIRECT_SEG_REFS - movl errno@gotntpoff(%ebx), %edx - addl %gs:0, %edx - movl $EINVAL, (%edx) -#else - movl errno@gotntpoff(%ebx), %edx - movl $EINVAL, %gs:(%edx) -#endif - - orl $-1, %eax - popl %ebx - ret - -3: -#ifdef PIC - SETUP_PIC_REG(bx) -#else - movl $5f, %ebx -5: -#endif - addl $_GLOBAL_OFFSET_TABLE_, %ebx -#ifdef NO_TLS_DIRECT_SEG_REFS - movl errno@gotntpoff(%ebx), %edx - addl %gs:0, %edx - movl $EOVERFLOW, (%edx) -#else - movl errno@gotntpoff(%ebx), %edx - movl $EOVERFLOW, %gs:(%edx) -#endif - - orl $-1, %eax - popl %ebx - cfi_adjust_cfa_offset(-4) - cfi_restore(%ebx) - ret - cfi_endproc - .size __new_sem_post,.-__new_sem_post - versioned_symbol(libpthread, __new_sem_post, sem_post, GLIBC_2_1) -#if SHLIB_COMPAT(libpthread, GLIBC_2_0, GLIBC_2_1) - .global __old_sem_post - .type __old_sem_post,@function -__old_sem_post: - cfi_startproc - pushl %ebx - cfi_adjust_cfa_offset(4) - cfi_offset(%ebx, -8) - - movl 8(%esp), %ebx - LOCK - addl $1, (%ebx) - - movl $SYS_futex, %eax - movl $FUTEX_WAKE, %ecx - movl $1, %edx - ENTER_KERNEL - - testl %eax, %eax - js 1b - - xorl %eax, %eax - popl %ebx - cfi_adjust_cfa_offset(-4) - cfi_restore(%ebx) - ret - cfi_endproc - .size __old_sem_post,.-__old_sem_post - compat_symbol(libpthread, __old_sem_post, sem_post, GLIBC_2_0) -#endif diff --git a/sysdeps/unix/sysv/linux/i386/i486/sem_timedwait.S b/sysdeps/unix/sysv/linux/i386/i486/sem_timedwait.S deleted file mode 100644 index a8b9164a9f..0000000000 --- a/sysdeps/unix/sysv/linux/i386/i486/sem_timedwait.S +++ /dev/null @@ -1,327 +0,0 @@ -/* Copyright (C) 2002-2015 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper <drepper@redhat.com>, 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, see - <http://www.gnu.org/licenses/>. */ - -#include <sysdep.h> -#include <shlib-compat.h> -#include <pthread-errnos.h> -#include <structsem.h> -#include <lowlevellock.h> - - -#if VALUE != 0 -# error "code needs to be rewritten for VALUE != 0" -#endif - - - .text - - .globl sem_timedwait - .type sem_timedwait,@function - .align 16 -sem_timedwait: -.LSTARTCODE: - movl 4(%esp), %ecx - - movl (%ecx), %eax -2: testl %eax, %eax - je 1f - - leal -1(%eax), %edx - LOCK - cmpxchgl %edx, (%ecx) - jne 2b - - xorl %eax, %eax - ret - - /* Check whether the timeout value is valid. */ -1: pushl %esi -.Lpush_esi: - pushl %edi -.Lpush_edi: - pushl %ebx -.Lpush_ebx: - subl $12, %esp -.Lsub_esp: - - movl 32(%esp), %edi - - /* Check for invalid nanosecond field. */ - cmpl $1000000000, 4(%edi) - movl $EINVAL, %esi - jae .Lerrno_exit - - LOCK - incl NWAITERS(%ecx) - -7: xorl %ecx, %ecx - movl %esp, %ebx - movl %ecx, %edx - movl $__NR_gettimeofday, %eax - ENTER_KERNEL - - /* Compute relative timeout. */ - movl 4(%esp), %eax - movl $1000, %edx - mul %edx /* Milli seconds to nano seconds. */ - movl (%edi), %ecx - movl 4(%edi), %edx - subl (%esp), %ecx - subl %eax, %edx - jns 5f - addl $1000000000, %edx - subl $1, %ecx -5: testl %ecx, %ecx - movl $ETIMEDOUT, %esi - js 6f /* Time is already up. */ - - movl %ecx, (%esp) /* Store relative timeout. */ - movl %edx, 4(%esp) - -.LcleanupSTART: - call __pthread_enable_asynccancel - movl %eax, 8(%esp) - - movl 28(%esp), %ebx /* Load semaphore address. */ -#if FUTEX_WAIT == 0 - movl PRIVATE(%ebx), %ecx -#else - movl $FUTEX_WAIT, %ecx - orl PRIVATE(%ebx), %ecx -#endif - movl %esp, %esi - xorl %edx, %edx - movl $SYS_futex, %eax - ENTER_KERNEL - movl %eax, %esi - - movl 8(%esp), %eax - call __pthread_disable_asynccancel -.LcleanupEND: - - testl %esi, %esi - je 9f - cmpl $-EWOULDBLOCK, %esi - jne 3f - -9: movl (%ebx), %eax -8: testl %eax, %eax - je 7b - - leal -1(%eax), %ecx - LOCK - cmpxchgl %ecx, (%ebx) - jne 8b - - xorl %eax, %eax - - LOCK - decl NWAITERS(%ebx) - -10: addl $12, %esp -.Ladd_esp: - popl %ebx -.Lpop_ebx: - popl %edi -.Lpop_edi: - popl %esi -.Lpop_esi: - ret - -.Lafter_ret: -3: negl %esi -6: - movl 28(%esp), %ebx /* Load semaphore address. */ - LOCK - decl NWAITERS(%ebx) -.Lerrno_exit: -#ifdef PIC - SETUP_PIC_REG(bx) -#else - movl $4f, %ebx -4: -#endif - addl $_GLOBAL_OFFSET_TABLE_, %ebx -#ifdef NO_TLS_DIRECT_SEG_REFS - movl errno@gotntpoff(%ebx), %edx - addl %gs:0, %edx - movl %esi, (%edx) -#else - movl errno@gotntpoff(%ebx), %edx - movl %esi, %gs:(%edx) -#endif - - orl $-1, %eax - jmp 10b - .size sem_timedwait,.-sem_timedwait - - - .type sem_wait_cleanup,@function -sem_wait_cleanup: - LOCK - decl NWAITERS(%ebx) - movl %eax, (%esp) -.LcallUR: - call _Unwind_Resume@PLT - hlt -.LENDCODE: - .size sem_wait_cleanup,.-sem_wait_cleanup - - - .section .gcc_except_table,"a",@progbits -.LexceptSTART: - .byte 0xff # @LPStart format (omit) - .byte 0xff # @TType format (omit) - .byte 0x01 # call-site format - # DW_EH_PE_uleb128 - .uleb128 .Lcstend-.Lcstbegin -.Lcstbegin: - .uleb128 .LcleanupSTART-.LSTARTCODE - .uleb128 .LcleanupEND-.LcleanupSTART - .uleb128 sem_wait_cleanup-.LSTARTCODE - .uleb128 0 - .uleb128 .LcallUR-.LSTARTCODE - .uleb128 .LENDCODE-.LcallUR - .uleb128 0 - .uleb128 0 -.Lcstend: - - - .section .eh_frame,"a",@progbits -.LSTARTFRAME: - .long .LENDCIE-.LSTARTCIE # Length of the CIE. -.LSTARTCIE: - .long 0 # CIE ID. - .byte 1 # Version number. -#ifdef SHARED - .string "zPLR" # NUL-terminated augmentation - # string. -#else - .string "zPL" # NUL-terminated augmentation - # string. -#endif - .uleb128 1 # Code alignment factor. - .sleb128 -4 # Data alignment factor. - .byte 8 # Return address register - # column. -#ifdef SHARED - .uleb128 7 # Augmentation value length. - .byte 0x9b # Personality: DW_EH_PE_pcrel - # + DW_EH_PE_sdata4 - # + DW_EH_PE_indirect - .long DW.ref.__gcc_personality_v0-. - .byte 0x1b # LSDA Encoding: DW_EH_PE_pcrel - # + DW_EH_PE_sdata4. - .byte 0x1b # FDE Encoding: DW_EH_PE_pcrel - # + DW_EH_PE_sdata4. -#else - .uleb128 6 # Augmentation value length. - .byte 0x0 # Personality: absolute - .long __gcc_personality_v0 - .byte 0x0 # LSDA Encoding: absolute -#endif - .byte 0x0c # DW_CFA_def_cfa - .uleb128 4 - .uleb128 4 - .byte 0x88 # DW_CFA_offset, column 0x10 - .uleb128 1 - .align 4 -.LENDCIE: - - .long .LENDFDE-.LSTARTFDE # Length of the FDE. -.LSTARTFDE: - .long .LSTARTFDE-.LSTARTFRAME # CIE pointer. -#ifdef SHARED - .long .LSTARTCODE-. # PC-relative start address - # of the code. -#else - .long .LSTARTCODE # Start address of the code. -#endif - .long .LENDCODE-.LSTARTCODE # Length of the code. - .uleb128 4 # Augmentation size -#ifdef SHARED - .long .LexceptSTART-. -#else - .long .LexceptSTART -#endif - - .byte 4 # DW_CFA_advance_loc4 - .long .Lpush_esi-.LSTARTCODE - .byte 14 # DW_CFA_def_cfa_offset - .uleb128 8 - .byte 0x86 # DW_CFA_offset %esi - .uleb128 2 - .byte 4 # DW_CFA_advance_loc4 - .long .Lpush_edi-.Lpush_esi - .byte 14 # DW_CFA_def_cfa_offset - .uleb128 12 - .byte 0x87 # DW_CFA_offset %edi - .uleb128 3 - .byte 4 # DW_CFA_advance_loc4 - .long .Lpush_ebx-.Lpush_edi - .byte 14 # DW_CFA_def_cfa_offset - .uleb128 16 - .byte 0x83 # DW_CFA_offset %ebx - .uleb128 4 - .byte 4 # DW_CFA_advance_loc4 - .long .Lsub_esp-.Lpush_ebx - .byte 14 # DW_CFA_def_cfa_offset - .uleb128 28 - .byte 4 # DW_CFA_advance_loc4 - .long .Ladd_esp-.Lsub_esp - .byte 14 # DW_CFA_def_cfa_offset - .uleb128 16 - .byte 4 # DW_CFA_advance_loc4 - .long .Lpop_ebx-.Ladd_esp - .byte 14 # DW_CFA_def_cfa_offset - .uleb128 12 - .byte 0xc3 # DW_CFA_restore %ebx - .byte 4 # DW_CFA_advance_loc4 - .long .Lpop_edi-.Lpop_ebx - .byte 14 # DW_CFA_def_cfa_offset - .uleb128 8 - .byte 0xc7 # DW_CFA_restore %edi - .byte 4 # DW_CFA_advance_loc4 - .long .Lpop_esi-.Lpop_edi - .byte 14 # DW_CFA_def_cfa_offset - .uleb128 4 - .byte 0xc6 # DW_CFA_restore %esi - .byte 4 # DW_CFA_advance_loc4 - .long .Lafter_ret-.Lpop_esi - .byte 14 # DW_CFA_def_cfa_offset - .uleb128 28 - .byte 0x86 # DW_CFA_offset %esi - .uleb128 2 - .byte 0x87 # DW_CFA_offset %edi - .uleb128 3 - .byte 0x83 # DW_CFA_offset %ebx - .uleb128 4 - .align 4 -.LENDFDE: - - -#ifdef SHARED - .hidden DW.ref.__gcc_personality_v0 - .weak DW.ref.__gcc_personality_v0 - .section .gnu.linkonce.d.DW.ref.__gcc_personality_v0,"aw",@progbits - .align 4 - .type DW.ref.__gcc_personality_v0, @object - .size DW.ref.__gcc_personality_v0, 4 -DW.ref.__gcc_personality_v0: - .long __gcc_personality_v0 -#endif diff --git a/sysdeps/unix/sysv/linux/i386/i486/sem_trywait.S b/sysdeps/unix/sysv/linux/i386/i486/sem_trywait.S deleted file mode 100644 index 2524d96aea..0000000000 --- a/sysdeps/unix/sysv/linux/i386/i486/sem_trywait.S +++ /dev/null @@ -1,67 +0,0 @@ -/* Copyright (C) 2002-2015 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper <drepper@redhat.com>, 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, see - <http://www.gnu.org/licenses/>. */ - -#include <sysdep.h> -#include <shlib-compat.h> -#include <pthread-errnos.h> -#include <lowlevellock.h> - - .text - - .globl __new_sem_trywait - .type __new_sem_trywait,@function - .align 16 -__new_sem_trywait: - movl 4(%esp), %ecx - - movl (%ecx), %eax -2: testl %eax, %eax - jz 1f - - leal -1(%eax), %edx - LOCK - cmpxchgl %edx, (%ecx) - jne 2b - xorl %eax, %eax - ret - -1: -#ifdef PIC - SETUP_PIC_REG(cx) -#else - movl $3f, %ecx -3: -#endif - addl $_GLOBAL_OFFSET_TABLE_, %ecx -#ifdef NO_TLS_DIRECT_SEG_REFS - movl errno@gotntpoff(%ecx), %edx - addl %gs:0, %edx - movl $EAGAIN, (%edx) -#else - movl errno@gotntpoff(%ecx), %edx - movl $EAGAIN, %gs:(%edx) -#endif - orl $-1, %eax - ret - .size __new_sem_trywait,.-__new_sem_trywait - versioned_symbol(libpthread, __new_sem_trywait, sem_trywait, GLIBC_2_1) -#if SHLIB_COMPAT(libpthread, GLIBC_2_0, GLIBC_2_1) - .global __old_sem_trywait -__old_sem_trywait = __new_sem_trywait - compat_symbol(libpthread, __old_sem_trywait, sem_trywait, GLIBC_2_0) -#endif diff --git a/sysdeps/unix/sysv/linux/i386/i486/sem_wait.S b/sysdeps/unix/sysv/linux/i386/i486/sem_wait.S deleted file mode 100644 index 9121041ecc..0000000000 --- a/sysdeps/unix/sysv/linux/i386/i486/sem_wait.S +++ /dev/null @@ -1,343 +0,0 @@ -/* Copyright (C) 2002-2015 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper <drepper@redhat.com>, 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, see - <http://www.gnu.org/licenses/>. */ - -#include <sysdep.h> -#include <shlib-compat.h> -#include <pthread-errnos.h> -#include <structsem.h> -#include <lowlevellock.h> - - -#if VALUE != 0 -# error "code needs to be rewritten for VALUE != 0" -#endif - - .text - - .globl __new_sem_wait - .type __new_sem_wait,@function - .align 16 -__new_sem_wait: -.LSTARTCODE: - pushl %ebx -.Lpush_ebx: - pushl %esi -.Lpush_esi: - subl $4, %esp -.Lsub_esp: - - movl 16(%esp), %ebx - - movl (%ebx), %eax -2: testl %eax, %eax - je 1f - - leal -1(%eax), %edx - LOCK - cmpxchgl %edx, (%ebx) - jne 2b -7: xorl %eax, %eax - -9: movl 4(%esp), %esi - movl 8(%esp), %ebx - addl $12, %esp -.Ladd_esp: - ret - -.Lafter_ret: -1: LOCK - incl NWAITERS(%ebx) - -.LcleanupSTART: -6: call __pthread_enable_asynccancel - movl %eax, (%esp) - -#if FUTEX_WAIT == 0 - movl PRIVATE(%ebx), %ecx -#else - movl $FUTEX_WAIT, %ecx - orl PRIVATE(%ebx), %ecx -#endif - xorl %esi, %esi - xorl %edx, %edx - movl $SYS_futex, %eax - ENTER_KERNEL - movl %eax, %esi - - movl (%esp), %eax - call __pthread_disable_asynccancel -.LcleanupEND: - - testl %esi, %esi - je 3f - cmpl $-EWOULDBLOCK, %esi - jne 4f - -3: - movl (%ebx), %eax -5: testl %eax, %eax - je 6b - - leal -1(%eax), %edx - LOCK - cmpxchgl %edx, (%ebx) - jne 5b - - LOCK - decl NWAITERS(%ebx) - jmp 7b - -4: LOCK - decl NWAITERS(%ebx) - - negl %esi -#ifdef PIC - SETUP_PIC_REG(bx) -#else - movl $8f, %ebx -8: -#endif - addl $_GLOBAL_OFFSET_TABLE_, %ebx -#ifdef NO_TLS_DIRECT_SEG_REFS - movl errno@gotntpoff(%ebx), %edx - addl %gs:0, %edx - movl %esi, (%edx) -#else - movl errno@gotntpoff(%ebx), %edx - movl %esi, %gs:(%edx) -#endif - orl $-1, %eax - - jmp 9b - .size __new_sem_wait,.-__new_sem_wait - versioned_symbol(libpthread, __new_sem_wait, sem_wait, GLIBC_2_1) - - - .type sem_wait_cleanup,@function -sem_wait_cleanup: - LOCK - decl NWAITERS(%ebx) - movl %eax, (%esp) -.LcallUR: - call _Unwind_Resume@PLT - hlt -.LENDCODE: - .size sem_wait_cleanup,.-sem_wait_cleanup - - - .section .gcc_except_table,"a",@progbits -.LexceptSTART: - .byte 0xff # @LPStart format (omit) - .byte 0xff # @TType format (omit) - .byte 0x01 # call-site format - # DW_EH_PE_uleb128 - .uleb128 .Lcstend-.Lcstbegin -.Lcstbegin: - .uleb128 .LcleanupSTART-.LSTARTCODE - .uleb128 .LcleanupEND-.LcleanupSTART - .uleb128 sem_wait_cleanup-.LSTARTCODE - .uleb128 0 - .uleb128 .LcallUR-.LSTARTCODE - .uleb128 .LENDCODE-.LcallUR - .uleb128 0 - .uleb128 0 -.Lcstend: - - - .section .eh_frame,"a",@progbits -.LSTARTFRAME: - .long .LENDCIE-.LSTARTCIE # Length of the CIE. -.LSTARTCIE: - .long 0 # CIE ID. - .byte 1 # Version number. -#ifdef SHARED - .string "zPLR" # NUL-terminated augmentation - # string. -#else - .string "zPL" # NUL-terminated augmentation - # string. -#endif - .uleb128 1 # Code alignment factor. - .sleb128 -4 # Data alignment factor. - .byte 8 # Return address register - # column. -#ifdef SHARED - .uleb128 7 # Augmentation value length. - .byte 0x9b # Personality: DW_EH_PE_pcrel - # + DW_EH_PE_sdata4 - # + DW_EH_PE_indirect - .long DW.ref.__gcc_personality_v0-. - .byte 0x1b # LSDA Encoding: DW_EH_PE_pcrel - # + DW_EH_PE_sdata4. - .byte 0x1b # FDE Encoding: DW_EH_PE_pcrel - # + DW_EH_PE_sdata4. -#else - .uleb128 6 # Augmentation value length. - .byte 0x0 # Personality: absolute - .long __gcc_personality_v0 - .byte 0x0 # LSDA Encoding: absolute -#endif - .byte 0x0c # DW_CFA_def_cfa - .uleb128 4 - .uleb128 4 - .byte 0x88 # DW_CFA_offset, column 0x10 - .uleb128 1 - .align 4 -.LENDCIE: - - .long .LENDFDE-.LSTARTFDE # Length of the FDE. -.LSTARTFDE: - .long .LSTARTFDE-.LSTARTFRAME # CIE pointer. -#ifdef SHARED - .long .LSTARTCODE-. # PC-relative start address - # of the code. -#else - .long .LSTARTCODE # Start address of the code. -#endif - .long .LENDCODE-.LSTARTCODE # Length of the code. - .uleb128 4 # Augmentation size -#ifdef SHARED - .long .LexceptSTART-. -#else - .long .LexceptSTART -#endif - - .byte 4 # DW_CFA_advance_loc4 - .long .Lpush_ebx-.LSTARTCODE - .byte 14 # DW_CFA_def_cfa_offset - .uleb128 8 - .byte 0x83 # DW_CFA_offset %ebx - .uleb128 2 - .byte 4 # DW_CFA_advance_loc4 - .long .Lpush_esi-.Lpush_ebx - .byte 14 # DW_CFA_def_cfa_offset - .uleb128 12 - .byte 0x86 # DW_CFA_offset %esi - .uleb128 3 - .byte 4 # DW_CFA_advance_loc4 - .long .Lsub_esp-.Lpush_esi - .byte 14 # DW_CFA_def_cfa_offset - .uleb128 16 - .byte 4 # DW_CFA_advance_loc4 - .long .Ladd_esp-.Lsub_esp - .byte 14 # DW_CFA_def_cfa_offset - .uleb128 4 - .byte 0xc3 # DW_CFA_restore %ebx - .byte 0xc6 # DW_CFA_restore %esi - .byte 4 # DW_CFA_advance_loc4 - .long .Lafter_ret-.Ladd_esp - .byte 14 # DW_CFA_def_cfa_offset - .uleb128 16 - .byte 0x83 # DW_CFA_offset %ebx - .uleb128 2 - .byte 0x86 # DW_CFA_offset %esi - .uleb128 3 - .align 4 -.LENDFDE: - - -#ifdef SHARED - .hidden DW.ref.__gcc_personality_v0 - .weak DW.ref.__gcc_personality_v0 - .section .gnu.linkonce.d.DW.ref.__gcc_personality_v0,"aw",@progbits - .align 4 - .type DW.ref.__gcc_personality_v0, @object - .size DW.ref.__gcc_personality_v0, 4 -DW.ref.__gcc_personality_v0: - .long __gcc_personality_v0 -#endif - - -#if SHLIB_COMPAT(libpthread, GLIBC_2_0, GLIBC_2_1) - .section ".text.compat", "ax" - .global __old_sem_wait - .type __old_sem_wait,@function - .align 16 - cfi_startproc -__old_sem_wait: - pushl %ebx - cfi_adjust_cfa_offset(4) - pushl %esi - cfi_adjust_cfa_offset(4) - subl $4, %esp - cfi_adjust_cfa_offset(4) - - movl 16(%esp), %ebx - cfi_offset(ebx, -8) - - cfi_offset(esi, -12) -3: movl (%ebx), %eax -2: testl %eax, %eax - je 1f - - leal -1(%eax), %edx - LOCK - cmpxchgl %edx, (%ebx) - jne 2b - xorl %eax, %eax - -5: movl 4(%esp), %esi - movl 8(%esp), %ebx - addl $12, %esp - cfi_restore(ebx) - cfi_restore(esi) - cfi_adjust_cfa_offset(-12) - ret - - cfi_adjust_cfa_offset(12) - cfi_offset(ebx, -8) - cfi_offset(esi, -12) -1: call __pthread_enable_asynccancel - movl %eax, (%esp) - - xorl %esi, %esi - movl $SYS_futex, %eax - movl %esi, %ecx - movl %esi, %edx - ENTER_KERNEL - movl %eax, %esi - - movl (%esp), %eax - call __pthread_disable_asynccancel - - testl %esi, %esi - je 3b - cmpl $-EWOULDBLOCK, %esi - je 3b - negl %esi -#ifdef PIC - SETUP_PIC_REG(bx) -#else - movl $4f, %ebx -4: -#endif - addl $_GLOBAL_OFFSET_TABLE_, %ebx -#ifdef NO_TLS_DIRECT_SEG_REFS - movl errno@gotntpoff(%ebx), %edx - addl %gs:0, %edx - movl %esi, (%edx) -#else - movl errno@gotntpoff(%ebx), %edx - movl %esi, %gs:(%edx) -#endif - orl $-1, %eax - jmp 5b - cfi_endproc - .size __old_sem_wait,.-__old_sem_wait - compat_symbol(libpthread, __old_sem_wait, sem_wait, GLIBC_2_0) -#endif diff --git a/sysdeps/unix/sysv/linux/i386/i586/sem_post.S b/sysdeps/unix/sysv/linux/i386/i586/sem_post.S deleted file mode 100644 index 4534d567d8..0000000000 --- a/sysdeps/unix/sysv/linux/i386/i586/sem_post.S +++ /dev/null @@ -1,19 +0,0 @@ -/* Copyright (C) 2003-2015 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, see - <http://www.gnu.org/licenses/>. */ - -#include "../i486/sem_post.S" diff --git a/sysdeps/unix/sysv/linux/i386/i586/sem_timedwait.S b/sysdeps/unix/sysv/linux/i386/i586/sem_timedwait.S deleted file mode 100644 index fa4ad496e5..0000000000 --- a/sysdeps/unix/sysv/linux/i386/i586/sem_timedwait.S +++ /dev/null @@ -1,19 +0,0 @@ -/* Copyright (C) 2003-2015 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, see - <http://www.gnu.org/licenses/>. */ - -#include "../i486/sem_timedwait.S" diff --git a/sysdeps/unix/sysv/linux/i386/i586/sem_trywait.S b/sysdeps/unix/sysv/linux/i386/i586/sem_trywait.S deleted file mode 100644 index 6f3a690d77..0000000000 --- a/sysdeps/unix/sysv/linux/i386/i586/sem_trywait.S +++ /dev/null @@ -1,19 +0,0 @@ -/* Copyright (C) 2003-2015 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, see - <http://www.gnu.org/licenses/>. */ - -#include "../i486/sem_trywait.S" diff --git a/sysdeps/unix/sysv/linux/i386/i586/sem_wait.S b/sysdeps/unix/sysv/linux/i386/i586/sem_wait.S deleted file mode 100644 index 718d50d680..0000000000 --- a/sysdeps/unix/sysv/linux/i386/i586/sem_wait.S +++ /dev/null @@ -1,19 +0,0 @@ -/* Copyright (C) 2003-2015 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, see - <http://www.gnu.org/licenses/>. */ - -#include "../i486/sem_wait.S" diff --git a/sysdeps/unix/sysv/linux/i386/i686/sem_post.S b/sysdeps/unix/sysv/linux/i386/i686/sem_post.S deleted file mode 100644 index 4534d567d8..0000000000 --- a/sysdeps/unix/sysv/linux/i386/i686/sem_post.S +++ /dev/null @@ -1,19 +0,0 @@ -/* Copyright (C) 2003-2015 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, see - <http://www.gnu.org/licenses/>. */ - -#include "../i486/sem_post.S" diff --git a/sysdeps/unix/sysv/linux/i386/i686/sem_timedwait.S b/sysdeps/unix/sysv/linux/i386/i686/sem_timedwait.S deleted file mode 100644 index fa4ad496e5..0000000000 --- a/sysdeps/unix/sysv/linux/i386/i686/sem_timedwait.S +++ /dev/null @@ -1,19 +0,0 @@ -/* Copyright (C) 2003-2015 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, see - <http://www.gnu.org/licenses/>. */ - -#include "../i486/sem_timedwait.S" diff --git a/sysdeps/unix/sysv/linux/i386/i686/sem_trywait.S b/sysdeps/unix/sysv/linux/i386/i686/sem_trywait.S deleted file mode 100644 index 6f3a690d77..0000000000 --- a/sysdeps/unix/sysv/linux/i386/i686/sem_trywait.S +++ /dev/null @@ -1,19 +0,0 @@ -/* Copyright (C) 2003-2015 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, see - <http://www.gnu.org/licenses/>. */ - -#include "../i486/sem_trywait.S" diff --git a/sysdeps/unix/sysv/linux/i386/i686/sem_wait.S b/sysdeps/unix/sysv/linux/i386/i686/sem_wait.S deleted file mode 100644 index 718d50d680..0000000000 --- a/sysdeps/unix/sysv/linux/i386/i686/sem_wait.S +++ /dev/null @@ -1,19 +0,0 @@ -/* Copyright (C) 2003-2015 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, see - <http://www.gnu.org/licenses/>. */ - -#include "../i486/sem_wait.S" diff --git a/sysdeps/unix/sysv/linux/powerpc/sem_post.c b/sysdeps/unix/sysv/linux/powerpc/sem_post.c deleted file mode 100644 index 6a4e46fb9d..0000000000 --- a/sysdeps/unix/sysv/linux/powerpc/sem_post.c +++ /dev/null @@ -1,71 +0,0 @@ -/* sem_post -- post to a POSIX semaphore. Powerpc version. - Copyright (C) 2003-2015 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Paul Mackerras <paulus@au.ibm.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, see - <http://www.gnu.org/licenses/>. */ - -#include <errno.h> -#include <sysdep.h> -#include <lowlevellock.h> -#include <internaltypes.h> -#include <semaphore.h> - -#include <shlib-compat.h> - -int -__new_sem_post (sem_t *sem) -{ - struct new_sem *isem = (struct new_sem *) sem; - - __asm __volatile (__ARCH_REL_INSTR ::: "memory"); - atomic_increment (&isem->value); - __asm __volatile (__ARCH_ACQ_INSTR ::: "memory"); - if (isem->nwaiters > 0) - { - int err = lll_futex_wake (&isem->value, 1, - isem->private ^ FUTEX_PRIVATE_FLAG); - if (__builtin_expect (err, 0) < 0) - { - __set_errno (-err); - return -1; - } - } - return 0; -} -versioned_symbol (libpthread, __new_sem_post, sem_post, GLIBC_2_1); - -#if SHLIB_COMPAT (libpthread, GLIBC_2_0, GLIBC_2_1) - -int -attribute_compat_text_section -__old_sem_post (sem_t *sem) -{ - int *futex = (int *) sem; - - __asm __volatile (__ARCH_REL_INSTR ::: "memory"); - (void) atomic_increment_val (futex); - /* We always have to assume it is a shared semaphore. */ - int err = lll_futex_wake (futex, 1, LLL_SHARED); - if (__builtin_expect (err, 0) < 0) - { - __set_errno (-err); - return -1; - } - return 0; -} - -compat_symbol (libpthread, __old_sem_post, sem_post, GLIBC_2_0); -#endif diff --git a/sysdeps/unix/sysv/linux/x86_64/sem_post.S b/sysdeps/unix/sysv/linux/x86_64/sem_post.S deleted file mode 100644 index f5dfb0536e..0000000000 --- a/sysdeps/unix/sysv/linux/x86_64/sem_post.S +++ /dev/null @@ -1,75 +0,0 @@ -/* Copyright (C) 2002-2015 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper <drepper@redhat.com>, 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, see - <http://www.gnu.org/licenses/>. */ - -#include <sysdep.h> -#include <lowlevellock.h> -#include <shlib-compat.h> -#include <pthread-errnos.h> -#include <structsem.h> - - - .text - - .globl sem_post - .type sem_post,@function - .align 16 -sem_post: -#if VALUE == 0 - movl (%rdi), %eax -#else - movl VALUE(%rdi), %eax -#endif -0: cmpl $SEM_VALUE_MAX, %eax - je 3f - leal 1(%rax), %esi - LOCK -#if VALUE == 0 - cmpxchgl %esi, (%rdi) -#else - cmpxchgl %esi, VALUE(%rdi) -#endif - jnz 0b - - LP_OP(cmp) $0, NWAITERS(%rdi) - je 2f - - movl $SYS_futex, %eax - movl $FUTEX_WAKE, %esi - orl PRIVATE(%rdi), %esi - movl $1, %edx - syscall - - testq %rax, %rax - js 1f - -2: xorl %eax, %eax - retq - -1: - movl $EINVAL, %eax - jmp 4f - -3: - movl $EOVERFLOW, %eax - -4: - movq errno@gottpoff(%rip), %rdx - movl %eax, %fs:(%rdx) - orl $-1, %eax - retq - .size sem_post,.-sem_post diff --git a/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S b/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S deleted file mode 100644 index 091b2411b4..0000000000 --- a/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S +++ /dev/null @@ -1,380 +0,0 @@ -/* Copyright (C) 2002-2015 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper <drepper@redhat.com>, 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, see - <http://www.gnu.org/licenses/>. */ - -#include <sysdep.h> -#include <kernel-features.h> -#include <lowlevellock.h> -#include <shlib-compat.h> -#include <pthread-errnos.h> -#include <structsem.h> - - .text - - .globl sem_timedwait - .type sem_timedwait,@function - .align 16 -sem_timedwait: -.LSTARTCODE: - cfi_startproc -#ifdef SHARED - cfi_personality(DW_EH_PE_pcrel | DW_EH_PE_sdata4 | DW_EH_PE_indirect, - DW.ref.__gcc_personality_v0) - cfi_lsda(DW_EH_PE_pcrel | DW_EH_PE_sdata4, .LexceptSTART) -#else - cfi_personality(DW_EH_PE_udata4, __gcc_personality_v0) - cfi_lsda(DW_EH_PE_udata4, .LexceptSTART) -#endif -#if VALUE == 0 - movl (%rdi), %eax -#else - movl VALUE(%rdi), %eax -#endif -2: testl %eax, %eax - je 1f - - leaq -1(%rax), %rdx - LOCK -#if VALUE == 0 - cmpxchgl %edx, (%rdi) -#else - cmpxchgl %edx, VALUE(%rdi) -#endif - jne 2b - - xorl %eax, %eax - retq - - /* Check whether the timeout value is valid. */ -1: cmpq $1000000000, 8(%rsi) - jae 6f - -#ifndef __ASSUME_FUTEX_CLOCK_REALTIME -# ifdef PIC - cmpl $0, __have_futex_clock_realtime(%rip) -# else - cmpl $0, __have_futex_clock_realtime -# endif - je .Lreltmo -#endif - - cmpq $0, (%rsi) - js 16f - - /* This push is only needed to store the sem_t pointer for the - exception handler. */ - pushq %rdi - cfi_adjust_cfa_offset(8) - - movq %rsi, %r10 - - LOCK - LP_OP(add) $1, NWAITERS(%rdi) - -.LcleanupSTART: -13: call __pthread_enable_asynccancel - movl %eax, %r8d - -#if VALUE != 0 - leaq VALUE(%rdi), %rdi -#endif - movl $0xffffffff, %r9d - movl $FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME, %esi - orl PRIVATE(%rdi), %esi - movl $SYS_futex, %eax - xorl %edx, %edx - syscall - movq %rax, %r9 -#if VALUE != 0 - leaq -VALUE(%rdi), %rdi -#endif - - xchgq %r8, %rdi - call __pthread_disable_asynccancel -.LcleanupEND: - movq %r8, %rdi - - testq %r9, %r9 - je 11f - cmpq $-EWOULDBLOCK, %r9 - jne 3f - -11: -#if VALUE == 0 - movl (%rdi), %eax -#else - movl VALUE(%rdi), %eax -#endif -14: testl %eax, %eax - je 13b - - leaq -1(%rax), %rcx - LOCK -#if VALUE == 0 - cmpxchgl %ecx, (%rdi) -#else - cmpxchgl %ecx, VALUE(%rdi) -#endif - jne 14b - - xorl %eax, %eax - -15: LOCK - LP_OP(sub) $1, NWAITERS(%rdi) - - leaq 8(%rsp), %rsp - cfi_adjust_cfa_offset(-8) - retq - - cfi_adjust_cfa_offset(8) -3: negq %r9 - movq errno@gottpoff(%rip), %rdx - movl %r9d, %fs:(%rdx) - - orl $-1, %eax - jmp 15b - - cfi_adjust_cfa_offset(-8) -6: - movq errno@gottpoff(%rip), %rdx - movl $EINVAL, %fs:(%rdx) - - orl $-1, %eax - - retq - -16: - movq errno@gottpoff(%rip), %rdx - movl $ETIMEDOUT, %fs:(%rdx) - - orl $-1, %eax - - retq - -#ifndef __ASSUME_FUTEX_CLOCK_REALTIME -.Lreltmo: - pushq %r12 - cfi_adjust_cfa_offset(8) - cfi_rel_offset(%r12, 0) - pushq %r13 - cfi_adjust_cfa_offset(8) - cfi_rel_offset(%r13, 0) - pushq %r14 - cfi_adjust_cfa_offset(8) - cfi_rel_offset(%r14, 0) - -#ifdef __ASSUME_FUTEX_CLOCK_REALTIME -# define STACKFRAME 8 -#else -# define STACKFRAME 24 -#endif - subq $STACKFRAME, %rsp - cfi_adjust_cfa_offset(STACKFRAME) - - movq %rdi, %r12 - movq %rsi, %r13 - - LOCK - LP_OP(add) $1, NWAITERS(%r12) - -7: xorl %esi, %esi - movq %rsp,%rdi - /* This call works because we directly jump to a system call entry - which preserves all the registers. */ - call JUMPTARGET(__gettimeofday) - - /* Compute relative timeout. */ - movq 8(%rsp), %rax - movl $1000, %edi - mul %rdi /* Milli seconds to nano seconds. */ - movq (%r13), %rdi - movq 8(%r13), %rsi - subq (%rsp), %rdi - subq %rax, %rsi - jns 5f - addq $1000000000, %rsi - decq %rdi -5: testq %rdi, %rdi - movl $ETIMEDOUT, %r14d - js 36f /* Time is already up. */ - - movq %rdi, (%rsp) /* Store relative timeout. */ - movq %rsi, 8(%rsp) - -.LcleanupSTART2: - call __pthread_enable_asynccancel - movl %eax, 16(%rsp) - - movq %rsp, %r10 -# if VALUE == 0 - movq %r12, %rdi -# else - leaq VALUE(%r12), %rdi -# endif -# if FUTEX_WAIT == 0 - movl PRIVATE(%rdi), %esi -# else - movl $FUTEX_WAIT, %esi - orl PRIVATE(%rdi), %esi -# endif - movl $SYS_futex, %eax - xorl %edx, %edx - syscall - movq %rax, %r14 - - movl 16(%rsp), %edi - call __pthread_disable_asynccancel -.LcleanupEND2: - - testq %r14, %r14 - je 9f - cmpq $-EWOULDBLOCK, %r14 - jne 33f - -9: -# if VALUE == 0 - movl (%r12), %eax -# else - movl VALUE(%r12), %eax -# endif -8: testl %eax, %eax - je 7b - - leaq -1(%rax), %rcx - LOCK -# if VALUE == 0 - cmpxchgl %ecx, (%r12) -# else - cmpxchgl %ecx, VALUE(%r12) -# endif - jne 8b - - xorl %eax, %eax - -45: LOCK - LP_OP(sub) $1, NWAITERS(%r12) - - addq $STACKFRAME, %rsp - cfi_adjust_cfa_offset(-STACKFRAME) - popq %r14 - cfi_adjust_cfa_offset(-8) - cfi_restore(%r14) - popq %r13 - cfi_adjust_cfa_offset(-8) - cfi_restore(%r13) - popq %r12 - cfi_adjust_cfa_offset(-8) - cfi_restore(%r12) - retq - - cfi_adjust_cfa_offset(STACKFRAME + 3 * 8) - cfi_rel_offset(%r12, STACKFRAME + 2 * 8) - cfi_rel_offset(%r13, STACKFRAME + 1 * 8) - cfi_rel_offset(%r14, STACKFRAME) -33: negq %r14 -36: - movq errno@gottpoff(%rip), %rdx - movl %r14d, %fs:(%rdx) - - orl $-1, %eax - jmp 45b -#endif - cfi_endproc - .size sem_timedwait,.-sem_timedwait - - - .type sem_timedwait_cleanup,@function -sem_timedwait_cleanup: - cfi_startproc - cfi_adjust_cfa_offset(8) - - movq (%rsp), %rdi - LOCK - LP_OP(sub) $1, NWAITERS(%rdi) - movq %rax, %rdi -.LcallUR: - call _Unwind_Resume@PLT - hlt -.LENDCODE: - cfi_endproc - .size sem_timedwait_cleanup,.-sem_timedwait_cleanup - - -#ifndef __ASSUME_FUTEX_CLOCK_REALTIME - .type sem_timedwait_cleanup2,@function -sem_timedwait_cleanup2: - cfi_startproc - cfi_adjust_cfa_offset(STACKFRAME + 3 * 8) - cfi_rel_offset(%r12, STACKFRAME + 2 * 8) - cfi_rel_offset(%r13, STACKFRAME + 1 * 8) - cfi_rel_offset(%r14, STACKFRAME) - - LOCK - LP_OP(sub) $1, NWAITERS(%r12) - movq %rax, %rdi - movq STACKFRAME(%rsp), %r14 - movq STACKFRAME+8(%rsp), %r13 - movq STACKFRAME+16(%rsp), %r12 -.LcallUR2: - call _Unwind_Resume@PLT - hlt -.LENDCODE2: - cfi_endproc - .size sem_timedwait_cleanup2,.-sem_timedwait_cleanup2 -#endif - - - .section .gcc_except_table,"a",@progbits -.LexceptSTART: - .byte DW_EH_PE_omit # @LPStart format - .byte DW_EH_PE_omit # @TType format - .byte DW_EH_PE_uleb128 # call-site format - .uleb128 .Lcstend-.Lcstbegin -.Lcstbegin: - .uleb128 .LcleanupSTART-.LSTARTCODE - .uleb128 .LcleanupEND-.LcleanupSTART - .uleb128 sem_timedwait_cleanup-.LSTARTCODE - .uleb128 0 -#ifndef __ASSUME_FUTEX_CLOCK_REALTIME - .uleb128 .LcleanupSTART2-.LSTARTCODE - .uleb128 .LcleanupEND2-.LcleanupSTART2 - .uleb128 sem_timedwait_cleanup2-.LSTARTCODE - .uleb128 0 -#endif - .uleb128 .LcallUR-.LSTARTCODE - .uleb128 .LENDCODE-.LcallUR - .uleb128 0 - .uleb128 0 -#ifndef __ASSUME_FUTEX_CLOCK_REALTIME - .uleb128 .LcallUR2-.LSTARTCODE - .uleb128 .LENDCODE2-.LcallUR2 - .uleb128 0 - .uleb128 0 -#endif -.Lcstend: - - -#ifdef SHARED - .hidden DW.ref.__gcc_personality_v0 - .weak DW.ref.__gcc_personality_v0 - .section .gnu.linkonce.d.DW.ref.__gcc_personality_v0,"aw",@progbits - .align LP_SIZE - .type DW.ref.__gcc_personality_v0, @object - .size DW.ref.__gcc_personality_v0, LP_SIZE -DW.ref.__gcc_personality_v0: - ASM_ADDR __gcc_personality_v0 -#endif diff --git a/sysdeps/unix/sysv/linux/x86_64/sem_trywait.S b/sysdeps/unix/sysv/linux/x86_64/sem_trywait.S deleted file mode 100644 index 1838e96223..0000000000 --- a/sysdeps/unix/sysv/linux/x86_64/sem_trywait.S +++ /dev/null @@ -1,47 +0,0 @@ -/* Copyright (C) 2002-2015 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper <drepper@redhat.com>, 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, see - <http://www.gnu.org/licenses/>. */ - -#include <sysdep.h> -#include <lowlevellock.h> -#include <shlib-compat.h> -#include <pthread-errnos.h> - - .text - - .globl sem_trywait - .type sem_trywait,@function - .align 16 -sem_trywait: - movl (%rdi), %eax -2: testl %eax, %eax - jz 1f - - leal -1(%rax), %edx - LOCK - cmpxchgl %edx, (%rdi) - jne 2b - - xorl %eax, %eax - retq - -1: - movq errno@gottpoff(%rip), %rdx - movl $EAGAIN, %fs:(%rdx) - orl $-1, %eax - retq - .size sem_trywait,.-sem_trywait diff --git a/sysdeps/unix/sysv/linux/x86_64/sem_wait.S b/sysdeps/unix/sysv/linux/x86_64/sem_wait.S deleted file mode 100644 index 2e7b131923..0000000000 --- a/sysdeps/unix/sysv/linux/x86_64/sem_wait.S +++ /dev/null @@ -1,176 +0,0 @@ -/* Copyright (C) 2002-2015 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper <drepper@redhat.com>, 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, see - <http://www.gnu.org/licenses/>. */ - -#include <sysdep.h> -#include <lowlevellock.h> -#include <shlib-compat.h> -#include <pthread-errnos.h> -#include <structsem.h> - - - .text - - .globl sem_wait - .type sem_wait,@function - .align 16 -sem_wait: -.LSTARTCODE: - cfi_startproc -#ifdef SHARED - cfi_personality(DW_EH_PE_pcrel | DW_EH_PE_sdata4 | DW_EH_PE_indirect, - DW.ref.__gcc_personality_v0) - cfi_lsda(DW_EH_PE_pcrel | DW_EH_PE_sdata4, .LexceptSTART) -#else - cfi_personality(DW_EH_PE_udata4, __gcc_personality_v0) - cfi_lsda(DW_EH_PE_udata4, .LexceptSTART) -#endif - -#if VALUE == 0 - movl (%rdi), %eax -#else - movl VALUE(%rdi), %eax -#endif -2: testl %eax, %eax - je 1f - - leal -1(%rax), %edx - LOCK -#if VALUE == 0 - cmpxchgl %edx, (%rdi) -#else - cmpxchgl %edx, VALUE(%rdi) -#endif - jne 2b - - xorl %eax, %eax - retq - - /* This push is only needed to store the sem_t pointer for the - exception handler. */ -1: pushq %rdi - cfi_adjust_cfa_offset(8) - - LOCK - LP_OP(add) $1, NWAITERS(%rdi) - -.LcleanupSTART: -6: call __pthread_enable_asynccancel - movl %eax, %r8d - - xorq %r10, %r10 - movl $SYS_futex, %eax -#if FUTEX_WAIT == 0 - movl PRIVATE(%rdi), %esi -#else - movl $FUTEX_WAIT, %esi - orl PRIVATE(%rdi), %esi -#endif - xorl %edx, %edx - syscall - movq %rax, %rcx - - xchgq %r8, %rdi - call __pthread_disable_asynccancel -.LcleanupEND: - movq %r8, %rdi - - testq %rcx, %rcx - je 3f - cmpq $-EWOULDBLOCK, %rcx - jne 4f - -3: -#if VALUE == 0 - movl (%rdi), %eax -#else - movl VALUE(%rdi), %eax -#endif -5: testl %eax, %eax - je 6b - - leal -1(%rax), %edx - LOCK -#if VALUE == 0 - cmpxchgl %edx, (%rdi) -#else - cmpxchgl %edx, VALUE(%rdi) -#endif - jne 5b - - xorl %eax, %eax - -9: LOCK - LP_OP(sub) $1, NWAITERS(%rdi) - - leaq 8(%rsp), %rsp - cfi_adjust_cfa_offset(-8) - - retq - - cfi_adjust_cfa_offset(8) -4: negq %rcx - movq errno@gottpoff(%rip), %rdx - movl %ecx, %fs:(%rdx) - orl $-1, %eax - - jmp 9b - .size sem_wait,.-sem_wait - - - .type sem_wait_cleanup,@function -sem_wait_cleanup: - movq (%rsp), %rdi - LOCK - LP_OP(sub) $1, NWAITERS(%rdi) - movq %rax, %rdi -.LcallUR: - call _Unwind_Resume@PLT - hlt -.LENDCODE: - cfi_endproc - .size sem_wait_cleanup,.-sem_wait_cleanup - - - .section .gcc_except_table,"a",@progbits -.LexceptSTART: - .byte DW_EH_PE_omit # @LPStart format - .byte DW_EH_PE_omit # @TType format - .byte DW_EH_PE_uleb128 # call-site format - .uleb128 .Lcstend-.Lcstbegin -.Lcstbegin: - .uleb128 .LcleanupSTART-.LSTARTCODE - .uleb128 .LcleanupEND-.LcleanupSTART - .uleb128 sem_wait_cleanup-.LSTARTCODE - .uleb128 0 - .uleb128 .LcallUR-.LSTARTCODE - .uleb128 .LENDCODE-.LcallUR - .uleb128 0 - .uleb128 0 -.Lcstend: - - -#ifdef SHARED - .hidden DW.ref.__gcc_personality_v0 - .weak DW.ref.__gcc_personality_v0 - .section .gnu.linkonce.d.DW.ref.__gcc_personality_v0,"aw",@progbits - .align LP_SIZE - .type DW.ref.__gcc_personality_v0, @object - .size DW.ref.__gcc_personality_v0, LP_SIZE -DW.ref.__gcc_personality_v0: - ASM_ADDR __gcc_personality_v0 -#endif |