From b30aff405a220495941f1673b0a5e66c4fa8b84c Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Wed, 28 May 2014 19:35:33 +0000 Subject: Revert "Revert "Lose the hand-written futex assembler."" The problem with the original patch was that using syscall(3) means that errno can be set, but pthread_create(3) was abusing the TLS errno slot as a pthread_mutex_t for the thread startup handshake. There was also a mistake in the check for syscall failures --- it should have checked against -1 instead of 0 (not just because that's the default idiom, but also here because futex(2) can legitimately return values > 0). This patch stops abusing the TLS errno slot and adds a pthread_mutex_t to pthread_internal_t instead. (Note that for LP64 sizeof(pthread_mutex_t) > sizeof(uintptr_t), so we could potentially clobber other TLS slots too.) I've also rewritten the LP32 compatibility stubs to directly reuse the code from the .h file. This reverts commit 75c55ff84ebfa686c7ae2cc8ee431c6a33bd46b4. Bug: 15195455 Change-Id: I6ffb13e5cf6a35d8f59f692d94192aae9ab4593d --- libc/arch-x86/bionic/futex_x86.S | 16 --------------- libc/arch-x86/syscalls/futex.S | 42 ---------------------------------------- libc/arch-x86/x86.mk | 1 - 3 files changed, 59 deletions(-) delete mode 100644 libc/arch-x86/bionic/futex_x86.S delete mode 100644 libc/arch-x86/syscalls/futex.S (limited to 'libc/arch-x86') diff --git a/libc/arch-x86/bionic/futex_x86.S b/libc/arch-x86/bionic/futex_x86.S deleted file mode 100644 index 94647ca..0000000 --- a/libc/arch-x86/bionic/futex_x86.S +++ /dev/null @@ -1,16 +0,0 @@ -#include - -// int __futex_syscall4(volatile void* ftx, int op, int val, const struct timespec* timeout) -ENTRY_PRIVATE(__futex_syscall4) - pushl %ebx - pushl %esi - movl 12(%esp), %ebx /* ftx */ - movl 16(%esp), %ecx /* op */ - movl 20(%esp), %edx /* val */ - movl 24(%esp), %esi /* timeout */ - movl $__NR_futex, %eax - int $0x80 - popl %esi - popl %ebx - ret -END(__futex_syscall4) diff --git a/libc/arch-x86/syscalls/futex.S b/libc/arch-x86/syscalls/futex.S deleted file mode 100644 index 7a52913..0000000 --- a/libc/arch-x86/syscalls/futex.S +++ /dev/null @@ -1,42 +0,0 @@ -/* Generated by gensyscalls.py. Do not edit. */ - -#include - -ENTRY(futex) - pushl %ebx - pushl %ecx - pushl %edx - pushl %esi - pushl %edi - pushl %ebp - .cfi_def_cfa_offset 24 - .cfi_rel_offset ebx, 0 - .cfi_rel_offset ecx, 4 - .cfi_rel_offset edx, 8 - .cfi_rel_offset esi, 12 - .cfi_rel_offset edi, 16 - .cfi_rel_offset ebp, 20 - mov 28(%esp), %ebx - mov 32(%esp), %ecx - mov 36(%esp), %edx - mov 40(%esp), %esi - mov 44(%esp), %edi - mov 48(%esp), %ebp - movl $__NR_futex, %eax - int $0x80 - cmpl $-MAX_ERRNO, %eax - jb 1f - negl %eax - pushl %eax - call __set_errno - addl $4, %esp - orl $-1, %eax -1: - popl %ebp - popl %edi - popl %esi - popl %edx - popl %ecx - popl %ebx - ret -END(futex) diff --git a/libc/arch-x86/x86.mk b/libc/arch-x86/x86.mk index 34da0ce..aa183cb 100644 --- a/libc/arch-x86/x86.mk +++ b/libc/arch-x86/x86.mk @@ -23,7 +23,6 @@ libc_bionic_src_files_x86 := \ libc_bionic_src_files_x86 += \ arch-x86/bionic/__bionic_clone.S \ arch-x86/bionic/_exit_with_stack_teardown.S \ - arch-x86/bionic/futex_x86.S \ arch-x86/bionic/__get_sp.S \ arch-x86/bionic/_setjmp.S \ arch-x86/bionic/setjmp.S \ -- cgit v1.1