Revert "Lose the hand-written futex assembler."
This reverts commit ced906c849704f379d7191822f6d74993d4fa296. Causes issues on art / dalvik due to a broken return value check and other undiagnosed issues. bug: 15195455 Change-Id: I5d6bbb389ecefb0e33a5237421a9d56d32a9317c
This commit is contained in:
parent
ced906c849
commit
75c55ff84e
libc
@ -305,6 +305,8 @@ int eventfd:eventfd2(unsigned int, int) all
|
|||||||
void _exit|_Exit:exit_group(int) all
|
void _exit|_Exit:exit_group(int) all
|
||||||
void __exit:exit(int) all
|
void __exit:exit(int) all
|
||||||
|
|
||||||
|
int futex(void*, int, int, void*, void*, int) all
|
||||||
|
|
||||||
int inotify_init1(int) all
|
int inotify_init1(int) all
|
||||||
int inotify_add_watch(int, const char*, unsigned int) all
|
int inotify_add_watch(int, const char*, unsigned int) all
|
||||||
int inotify_rm_watch(int, unsigned int) all
|
int inotify_rm_watch(int, unsigned int) all
|
||||||
|
@ -53,6 +53,7 @@ libc_bionic_src_files_arm += \
|
|||||||
arch-arm/bionic/__bionic_clone.S \
|
arch-arm/bionic/__bionic_clone.S \
|
||||||
arch-arm/bionic/eabi.c \
|
arch-arm/bionic/eabi.c \
|
||||||
arch-arm/bionic/_exit_with_stack_teardown.S \
|
arch-arm/bionic/_exit_with_stack_teardown.S \
|
||||||
|
arch-arm/bionic/futex_arm.S \
|
||||||
arch-arm/bionic/__get_sp.S \
|
arch-arm/bionic/__get_sp.S \
|
||||||
arch-arm/bionic/libgcc_compat.c \
|
arch-arm/bionic/libgcc_compat.c \
|
||||||
arch-arm/bionic/memcmp16.S \
|
arch-arm/bionic/memcmp16.S \
|
||||||
|
38
libc/arch-arm/bionic/futex_arm.S
Normal file
38
libc/arch-arm/bionic/futex_arm.S
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2008 The Android Open Source Project
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||||
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <private/bionic_asm.h>
|
||||||
|
|
||||||
|
// int __futex_syscall4(volatile void* ftx, int op, int val, const struct timespec* timeout)
|
||||||
|
ENTRY_PRIVATE(__futex_syscall4)
|
||||||
|
mov ip, r7
|
||||||
|
ldr r7, =__NR_futex
|
||||||
|
swi #0
|
||||||
|
mov r7, ip
|
||||||
|
bx lr
|
||||||
|
END(__futex_syscall4)
|
22
libc/arch-arm/syscalls/futex.S
Normal file
22
libc/arch-arm/syscalls/futex.S
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
/* Generated by gensyscalls.py. Do not edit. */
|
||||||
|
|
||||||
|
#include <private/bionic_asm.h>
|
||||||
|
|
||||||
|
ENTRY(futex)
|
||||||
|
mov ip, sp
|
||||||
|
stmfd sp!, {r4, r5, r6, r7}
|
||||||
|
.cfi_def_cfa_offset 16
|
||||||
|
.cfi_rel_offset r4, 0
|
||||||
|
.cfi_rel_offset r5, 4
|
||||||
|
.cfi_rel_offset r6, 8
|
||||||
|
.cfi_rel_offset r7, 12
|
||||||
|
ldmfd ip, {r4, r5, r6}
|
||||||
|
ldr r7, =__NR_futex
|
||||||
|
swi #0
|
||||||
|
ldmfd sp!, {r4, r5, r6, r7}
|
||||||
|
.cfi_def_cfa_offset 0
|
||||||
|
cmn r0, #(MAX_ERRNO + 1)
|
||||||
|
bxls lr
|
||||||
|
neg r0, r0
|
||||||
|
b __set_errno
|
||||||
|
END(futex)
|
@ -37,6 +37,7 @@ libc_bionic_src_files_arm64 := \
|
|||||||
arch-arm64/bionic/__bionic_clone.S \
|
arch-arm64/bionic/__bionic_clone.S \
|
||||||
arch-arm64/bionic/bzero_arm64.c \
|
arch-arm64/bionic/bzero_arm64.c \
|
||||||
arch-arm64/bionic/_exit_with_stack_teardown.S \
|
arch-arm64/bionic/_exit_with_stack_teardown.S \
|
||||||
|
arch-arm64/bionic/futex_arm64.S \
|
||||||
arch-arm64/bionic/__get_sp.S \
|
arch-arm64/bionic/__get_sp.S \
|
||||||
arch-arm64/bionic/__rt_sigreturn.S \
|
arch-arm64/bionic/__rt_sigreturn.S \
|
||||||
arch-arm64/bionic/_setjmp.S \
|
arch-arm64/bionic/_setjmp.S \
|
||||||
|
47
libc/arch-arm64/bionic/futex_arm64.S
Normal file
47
libc/arch-arm64/bionic/futex_arm64.S
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2013 The Android Open Source Project
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||||
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <private/bionic_asm.h>
|
||||||
|
|
||||||
|
// int __futex_syscall4(volatile void* ftx, int op, int val, const struct timespec* timeout)
|
||||||
|
ENTRY_PRIVATE(__futex_syscall4)
|
||||||
|
stp x29, x30, [sp, #-16]!
|
||||||
|
.cfi_def_cfa_offset 16
|
||||||
|
.cfi_rel_offset x29, 0
|
||||||
|
.cfi_rel_offset x30, 8
|
||||||
|
mov x29, sp
|
||||||
|
|
||||||
|
mov x8, __NR_futex
|
||||||
|
svc #0
|
||||||
|
|
||||||
|
ldp x29, x30, [sp], #16
|
||||||
|
.cfi_def_cfa_offset 0
|
||||||
|
.cfi_restore x29
|
||||||
|
.cfi_restore x30
|
||||||
|
ret
|
||||||
|
END(__futex_syscall4)
|
25
libc/arch-arm64/syscalls/futex.S
Normal file
25
libc/arch-arm64/syscalls/futex.S
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
/* Generated by gensyscalls.py. Do not edit. */
|
||||||
|
|
||||||
|
#include <private/bionic_asm.h>
|
||||||
|
|
||||||
|
ENTRY(futex)
|
||||||
|
stp x29, x30, [sp, #-16]!
|
||||||
|
.cfi_def_cfa_offset 16
|
||||||
|
.cfi_rel_offset x29, 0
|
||||||
|
.cfi_rel_offset x30, 8
|
||||||
|
mov x29, sp
|
||||||
|
|
||||||
|
mov x8, __NR_futex
|
||||||
|
svc #0
|
||||||
|
|
||||||
|
ldp x29, x30, [sp], #16
|
||||||
|
.cfi_def_cfa_offset 0
|
||||||
|
.cfi_restore x29
|
||||||
|
.cfi_restore x30
|
||||||
|
|
||||||
|
cmn x0, #(MAX_ERRNO + 1)
|
||||||
|
cneg x0, x0, hi
|
||||||
|
b.hi __set_errno
|
||||||
|
|
||||||
|
ret
|
||||||
|
END(futex)
|
50
libc/arch-mips/bionic/futex_mips.S
Normal file
50
libc/arch-mips/bionic/futex_mips.S
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2008 The Android Open Source Project
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||||
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <private/bionic_asm.h>
|
||||||
|
|
||||||
|
// int __futex_syscall4(volatile void* ftx, int op, int val, const struct timespec* timeout)
|
||||||
|
ENTRY_PRIVATE(__futex_syscall4)
|
||||||
|
subu sp,4*6
|
||||||
|
sw $0,20(sp) /* val3 */
|
||||||
|
sw $0,16(sp) /* addr2 */
|
||||||
|
# move a3,a3 /* timespec */
|
||||||
|
# move a2,a2 /* val */
|
||||||
|
# li a1,a1 /* op */
|
||||||
|
# move a0,a0 /* ftx */
|
||||||
|
li v0,__NR_futex
|
||||||
|
syscall
|
||||||
|
.set noreorder
|
||||||
|
bnez a3, 1f /* Check for error */
|
||||||
|
neg v0 /* Negate error number if it's valid */
|
||||||
|
move v0,$0 /* Otherwise return 0 */
|
||||||
|
1:
|
||||||
|
.set reorder
|
||||||
|
addu sp,4*6
|
||||||
|
j ra
|
||||||
|
END(__futex_syscall4)
|
@ -58,6 +58,7 @@ libc_bionic_src_files_mips += \
|
|||||||
arch-mips/bionic/bzero.S \
|
arch-mips/bionic/bzero.S \
|
||||||
arch-mips/bionic/cacheflush.cpp \
|
arch-mips/bionic/cacheflush.cpp \
|
||||||
arch-mips/bionic/_exit_with_stack_teardown.S \
|
arch-mips/bionic/_exit_with_stack_teardown.S \
|
||||||
|
arch-mips/bionic/futex_mips.S \
|
||||||
arch-mips/bionic/__get_sp.S \
|
arch-mips/bionic/__get_sp.S \
|
||||||
arch-mips/bionic/memcmp16.S \
|
arch-mips/bionic/memcmp16.S \
|
||||||
arch-mips/bionic/_setjmp.S \
|
arch-mips/bionic/_setjmp.S \
|
||||||
|
19
libc/arch-mips/syscalls/futex.S
Normal file
19
libc/arch-mips/syscalls/futex.S
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
/* Generated by gensyscalls.py. Do not edit. */
|
||||||
|
|
||||||
|
#include <private/bionic_asm.h>
|
||||||
|
|
||||||
|
ENTRY(futex)
|
||||||
|
.set noreorder
|
||||||
|
.cpload t9
|
||||||
|
li v0, __NR_futex
|
||||||
|
syscall
|
||||||
|
bnez a3, 1f
|
||||||
|
move a0, v0
|
||||||
|
j ra
|
||||||
|
nop
|
||||||
|
1:
|
||||||
|
la t9,__set_errno
|
||||||
|
j t9
|
||||||
|
nop
|
||||||
|
.set reorder
|
||||||
|
END(futex)
|
64
libc/arch-mips64/bionic/futex_mips.S
Normal file
64
libc/arch-mips64/bionic/futex_mips.S
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2008 The Android Open Source Project
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||||
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <private/bionic_asm.h>
|
||||||
|
|
||||||
|
#if (_MIPS_SIM == _ABIO32) || (_MIPS_SIM == _ABI32)
|
||||||
|
FRAMESZ = MKFSIZ(NARGSAVE+2,0)
|
||||||
|
FRAME_A4 = 4*REGSZ
|
||||||
|
FRAME_A5 = 5*REGSZ
|
||||||
|
#else
|
||||||
|
FRAMESZ = 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// int __futex_syscall4(volatile void* ftx, int op, int val, const struct timespec* timeout)
|
||||||
|
LEAF(__futex_syscall4,FRAMESZ)
|
||||||
|
#if (_MIPS_SIM == _ABIO32) || (_MIPS_SIM == _ABI32)
|
||||||
|
PTR_SUBU sp, FRAMESZ
|
||||||
|
REG_S $0,FRAME_A5(sp) /* val3 */
|
||||||
|
REG_S $0,FRAME_A4(sp) /* addr2 */
|
||||||
|
#else
|
||||||
|
move a5,$0 /* val3 */
|
||||||
|
move a4,$0 /* addr2 */
|
||||||
|
#endif
|
||||||
|
# move a3,a3 /* timespec */
|
||||||
|
# move a2,a2 /* val */
|
||||||
|
# move a1,a1 /* op */
|
||||||
|
# move a0,a0 /* ftx */
|
||||||
|
LI v0,__NR_futex
|
||||||
|
syscall
|
||||||
|
neg v0 /* Negate errno */
|
||||||
|
bnez a3,1f /* Check for error */
|
||||||
|
move v0,$0 /* Return 0 if no error */
|
||||||
|
1:
|
||||||
|
#if (_MIPS_SIM == _ABIO32) || (_MIPS_SIM == _ABI32)
|
||||||
|
PTR_ADDU sp,FRAMESZ
|
||||||
|
#endif
|
||||||
|
j ra
|
||||||
|
END(__futex_syscall4)
|
||||||
|
.hidden __futex_syscall4
|
@ -43,6 +43,7 @@ libc_bionic_src_files_mips64 := \
|
|||||||
arch-mips64/bionic/__bionic_clone.S \
|
arch-mips64/bionic/__bionic_clone.S \
|
||||||
arch-mips64/bionic/bzero.S \
|
arch-mips64/bionic/bzero.S \
|
||||||
arch-mips64/bionic/_exit_with_stack_teardown.S \
|
arch-mips64/bionic/_exit_with_stack_teardown.S \
|
||||||
|
arch-mips64/bionic/futex_mips.S \
|
||||||
arch-mips64/bionic/__get_sp.S \
|
arch-mips64/bionic/__get_sp.S \
|
||||||
arch-mips64/bionic/getdents.cpp \
|
arch-mips64/bionic/getdents.cpp \
|
||||||
arch-mips64/bionic/memcmp16.S \
|
arch-mips64/bionic/memcmp16.S \
|
||||||
|
25
libc/arch-mips64/syscalls/futex.S
Normal file
25
libc/arch-mips64/syscalls/futex.S
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
/* Generated by gensyscalls.py. Do not edit. */
|
||||||
|
|
||||||
|
#include <private/bionic_asm.h>
|
||||||
|
|
||||||
|
ENTRY(futex)
|
||||||
|
.set push
|
||||||
|
.set noreorder
|
||||||
|
li v0, __NR_futex
|
||||||
|
syscall
|
||||||
|
bnez a3, 1f
|
||||||
|
move a0, v0
|
||||||
|
j ra
|
||||||
|
nop
|
||||||
|
1:
|
||||||
|
move t0, ra
|
||||||
|
bal 2f
|
||||||
|
nop
|
||||||
|
2:
|
||||||
|
.cpsetup ra, t1, 2b
|
||||||
|
LA t9,__set_errno
|
||||||
|
.cpreturn
|
||||||
|
j t9
|
||||||
|
move ra, t0
|
||||||
|
.set pop
|
||||||
|
END(futex)
|
16
libc/arch-x86/bionic/futex_x86.S
Normal file
16
libc/arch-x86/bionic/futex_x86.S
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#include <private/bionic_asm.h>
|
||||||
|
|
||||||
|
// 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)
|
42
libc/arch-x86/syscalls/futex.S
Normal file
42
libc/arch-x86/syscalls/futex.S
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
/* Generated by gensyscalls.py. Do not edit. */
|
||||||
|
|
||||||
|
#include <private/bionic_asm.h>
|
||||||
|
|
||||||
|
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)
|
@ -23,6 +23,7 @@ libc_bionic_src_files_x86 := \
|
|||||||
libc_bionic_src_files_x86 += \
|
libc_bionic_src_files_x86 += \
|
||||||
arch-x86/bionic/__bionic_clone.S \
|
arch-x86/bionic/__bionic_clone.S \
|
||||||
arch-x86/bionic/_exit_with_stack_teardown.S \
|
arch-x86/bionic/_exit_with_stack_teardown.S \
|
||||||
|
arch-x86/bionic/futex_x86.S \
|
||||||
arch-x86/bionic/__get_sp.S \
|
arch-x86/bionic/__get_sp.S \
|
||||||
arch-x86/bionic/_setjmp.S \
|
arch-x86/bionic/_setjmp.S \
|
||||||
arch-x86/bionic/setjmp.S \
|
arch-x86/bionic/setjmp.S \
|
||||||
|
37
libc/arch-x86_64/bionic/futex_x86_64.S
Normal file
37
libc/arch-x86_64/bionic/futex_x86_64.S
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2013 The Android Open Source Project
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||||
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <private/bionic_asm.h>
|
||||||
|
|
||||||
|
// int __futex_syscall4(volatile void* ftx, int op, int val, const struct timespec* timeout)
|
||||||
|
ENTRY_PRIVATE(__futex_syscall4)
|
||||||
|
mov %rcx, %r10 /* timeout */
|
||||||
|
mov $__NR_futex, %eax
|
||||||
|
syscall
|
||||||
|
ret
|
||||||
|
END(__futex_syscall4)
|
17
libc/arch-x86_64/syscalls/futex.S
Normal file
17
libc/arch-x86_64/syscalls/futex.S
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
/* Generated by gensyscalls.py. Do not edit. */
|
||||||
|
|
||||||
|
#include <private/bionic_asm.h>
|
||||||
|
|
||||||
|
ENTRY(futex)
|
||||||
|
movq %rcx, %r10
|
||||||
|
movl $__NR_futex, %eax
|
||||||
|
syscall
|
||||||
|
cmpq $-MAX_ERRNO, %rax
|
||||||
|
jb 1f
|
||||||
|
negl %eax
|
||||||
|
movl %eax, %edi
|
||||||
|
call __set_errno
|
||||||
|
orq $-1, %rax
|
||||||
|
1:
|
||||||
|
ret
|
||||||
|
END(futex)
|
@ -30,6 +30,7 @@ libc_common_src_files_x86_64 += \
|
|||||||
libc_bionic_src_files_x86_64 := \
|
libc_bionic_src_files_x86_64 := \
|
||||||
arch-x86_64/bionic/__bionic_clone.S \
|
arch-x86_64/bionic/__bionic_clone.S \
|
||||||
arch-x86_64/bionic/_exit_with_stack_teardown.S \
|
arch-x86_64/bionic/_exit_with_stack_teardown.S \
|
||||||
|
arch-x86_64/bionic/futex_x86_64.S \
|
||||||
arch-x86_64/bionic/__get_sp.S \
|
arch-x86_64/bionic/__get_sp.S \
|
||||||
arch-x86_64/bionic/__rt_sigreturn.S \
|
arch-x86_64/bionic/__rt_sigreturn.S \
|
||||||
arch-x86_64/bionic/_setjmp.S \
|
arch-x86_64/bionic/_setjmp.S \
|
||||||
|
@ -28,42 +28,31 @@
|
|||||||
#ifndef _BIONIC_FUTEX_H
|
#ifndef _BIONIC_FUTEX_H
|
||||||
#define _BIONIC_FUTEX_H
|
#define _BIONIC_FUTEX_H
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
#include <linux/futex.h>
|
#include <linux/futex.h>
|
||||||
|
#include <sys/cdefs.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <sys/cdefs.h>
|
|
||||||
#include <sys/syscall.h>
|
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
|
||||||
struct timespec;
|
struct timespec;
|
||||||
|
|
||||||
static inline int __futex(volatile void* ftx, int op, int value, const struct timespec* timeout) {
|
extern int __futex_syscall4(volatile void* ftx, int op, int value, const struct timespec* timeout);
|
||||||
// Our generated syscall assembler sets errno, but our callers (pthread functions) don't want to.
|
|
||||||
int saved_errno = errno;
|
|
||||||
if (syscall(__NR_futex, ftx, op, value, timeout) == 0) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
int result = -errno;
|
|
||||||
errno = saved_errno;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int __futex_wake(volatile void* ftx, int count) {
|
static inline int __futex_wake(volatile void* ftx, int count) {
|
||||||
return __futex(ftx, FUTEX_WAKE, count, NULL);
|
return __futex_syscall4(ftx, FUTEX_WAKE, count, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int __futex_wake_ex(volatile void* ftx, bool shared, int count) {
|
static inline int __futex_wake_ex(volatile void* ftx, bool shared, int count) {
|
||||||
return __futex(ftx, shared ? FUTEX_WAKE : FUTEX_WAKE_PRIVATE, count, NULL);
|
return __futex_syscall4(ftx, shared ? FUTEX_WAKE : FUTEX_WAKE_PRIVATE, count, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int __futex_wait(volatile void* ftx, int value, const struct timespec* timeout) {
|
static inline int __futex_wait(volatile void* ftx, int value, const struct timespec* timeout) {
|
||||||
return __futex(ftx, FUTEX_WAIT, value, timeout);
|
return __futex_syscall4(ftx, FUTEX_WAIT, value, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int __futex_wait_ex(volatile void* ftx, bool shared, int value, const struct timespec* timeout) {
|
static inline int __futex_wait_ex(volatile void* ftx, bool shared, int value, const struct timespec* timeout) {
|
||||||
return __futex(ftx, shared ? FUTEX_WAIT : FUTEX_WAIT_PRIVATE, value, timeout);
|
return __futex_syscall4(ftx, shared ? FUTEX_WAIT : FUTEX_WAIT_PRIVATE, value, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
__END_DECLS
|
__END_DECLS
|
||||||
|
Loading…
x
Reference in New Issue
Block a user