am bc86e156: am 22323f91: Merge "Fix aarch64 futex assembly routines."

* commit 'bc86e156cccb9d1d9bb1b2f1fcbce55fb67c5eb5':
  Fix aarch64 futex assembly routines.
This commit is contained in:
Elliott Hughes 2013-12-21 01:32:27 +00:00 committed by Android Git Automerger
commit 9306d2a21f
8 changed files with 59 additions and 117 deletions

View File

@ -31,97 +31,56 @@
#define FUTEX_WAIT 0
#define FUTEX_WAKE 1
/*
* Syscall interface for fast userspace locks
*
* int __futex_wait(volatile void *ftx, int val, const struct timespec *timeout);
* int __futex_wake(volatile void *ftx, int count);
* int __futex_syscall3(volatile void *ftx, int op, int val);
* int __futex_syscall4(volatile void *ftx, int op, int val, const struct timespec *timeout);
*/
// int __futex_syscall4(volatile void* ftx, int op, int val, const struct timespec* timeout)
ENTRY(__futex_syscall4)
/* create AArch64 PCS frame pointer */
stp x29, x30, [sp, #-16]!
mov x29, sp
/* store x8 */
str x8, [sp, #-16]!
/* syscall No. in x8 */
mov x8, __NR_futex
svc #0
/* restore x8 */
ldr x8, [sp], #16
ldp x29, x30, [sp], #16
/* check if syscall returned successfully */
cmn x0, #(MAX_ERRNO + 1)
cneg x0, x0, hi
b.hi __set_errno
ret
END(__futex_syscall4)
// int __futex_syscall3(volatile void* ftx, int op, int count)
ENTRY(__futex_syscall3)
/* __futex_syscall4 but with fewer arguments */
b __futex_syscall4
END(__futex_syscall3)
// int __futex_wait(volatile void* ftx, int val, const struct timespec* timeout)
ENTRY(__futex_wait)
/* create AArch64 PCS frame pointer */
stp x29, x30, [sp, #-16]!
mov x29, sp
/* store x8 */
str x8, [sp, #-16]!
/* arange arguments as expected in the kernel side */
mov x3, x2
mov w2, w1
mov w1, #FUTEX_WAIT
mov x2, x1
mov x1, #FUTEX_WAIT
/* syscall No. in X8 */
str x8, [sp, #-16]!
mov x8, __NR_futex
svc #0
/* restore x8 */
ldr x8, [sp], #16
ldp x29, x30, [sp], #16
/* check if syscall returned successfully */
cmn x0, #(MAX_ERRNO + 1)
cneg x0, x0, hi
b.hi __set_errno
ret
END(__futex_wait)
// int __futex_wake(volatile void* ftx, int count)
ENTRY(__futex_wake)
/* create AArch64 PCS frame pointer */
stp x29, x30, [sp, #-16]!
mov x29, sp
/* store x8 */
mov x2, x1
mov x1, #FUTEX_WAKE
str x8, [sp, #-16]!
/* arange arguments as expected in the kernel side */
mov w2, w1
mov w1, #FUTEX_WAIT
/* syscall No. in X8 */
mov x8, __NR_futex
svc #0
/* restore x8 */
ldr x8, [sp], #16
ldp x29, x30, [sp], #16
/* check if syscall returned successfully */
cmn x0, #(MAX_ERRNO + 1)
cneg x0, x0, hi
b.hi __set_errno
ret
END(__futex_wake)

View File

@ -26,13 +26,12 @@
* SUCH DAMAGE.
*/
#include <asm/unistd.h>
#include <machine/asm.h>
#include <private/bionic_asm.h>
#define FUTEX_WAIT 0
#define FUTEX_WAKE 1
// __futex_syscall3(*ftx, op, val)
// int __futex_syscall3(volatile void* ftx, int op, int count)
ENTRY(__futex_syscall3)
mov ip, r7
ldr r7, =__NR_futex
@ -41,12 +40,12 @@ ENTRY(__futex_syscall3)
bx lr
END(__futex_syscall3)
// __futex_syscall4(*ftx, op, val, *timespec)
// int __futex_syscall4(volatile void* ftx, int op, int val, const struct timespec* timeout)
ENTRY(__futex_syscall4)
b __futex_syscall3
END(__futex_syscall4)
// __futex_wait(*ftx, val, *timespec)
// int __futex_wait(volatile void* ftx, int val, const struct timespec* timeout)
ENTRY(__futex_wait)
mov ip, r7
mov r3, r2
@ -58,7 +57,7 @@ ENTRY(__futex_wait)
bx lr
END(__futex_wait)
// __futex_wake(*ftx, counter)
// int __futex_wake(volatile void* ftx, int count)
ENTRY(__futex_wake)
mov ip, r7
mov r2, r1

View File

@ -26,15 +26,12 @@
* SUCH DAMAGE.
*/
#include <asm/unistd.h>
#include <private/bionic_asm.h>
#define FUTEX_WAIT 0
#define FUTEX_WAKE 1
/*
* __futex_wait(*ftx, val, *timespec)
* futex_syscall(*ftx, op, val, *timespec, *addr2, val3)
*/
// int __futex_wait(volatile void* ftx, int val, const struct timespec* timeout)
.type __futex_wait, @function
.global __futex_wait
.align 4
@ -59,10 +56,7 @@ __futex_wait:
j $ra
.end __futex_wait
/*
* int __futex_wake(volatile void *ftx, int count)
* int futex_syscall(*ftx, op, val, *timespec, *addr2, val3)
*/
// int __futex_wake(volatile void* ftx, int count)
.type __futex_wake, @function
.globl __futex_wake
.align 4
@ -87,9 +81,7 @@ __futex_wake:
j $ra
.end __futex_wake
/* __futex_syscall3(*ftx, op, val)
* futex_syscall(*ftx, op, val, *timespec, *addr2, val3)
*/
// int __futex_syscall3(volatile void* ftx, int op, int count)
.type __futex_syscall3, @function
.global __futex_syscall3
.align 4
@ -114,9 +106,7 @@ __futex_syscall3:
j $ra
.end __futex_syscall3
/* __futex_syscall4(*ftx, op, val)
* futex_syscall(*ftx, op, val, *timespec, *addr2, val3)
*/
// int __futex_syscall4(volatile void* ftx, int op, int val, const struct timespec* timeout)
.type __futex_syscall4, @function
.global __futex_syscall4
.align 4

View File

@ -1,10 +1,9 @@
#include <asm/unistd.h>
#include <machine/asm.h>
#include <private/bionic_asm.h>
#define FUTEX_WAIT 0
#define FUTEX_WAKE 1
// int __futex_wait(volatile void *ftx, int val, const struct timespec *timeout)
// int __futex_wait(volatile void* ftx, int val, const struct timespec* timeout)
ENTRY(__futex_wait)
pushl %ebx
pushl %esi
@ -19,7 +18,7 @@ ENTRY(__futex_wait)
ret
END(__futex_wait)
// int __futex_wake(volatile void *ftx, int count)
// int __futex_wake(volatile void* ftx, int count)
ENTRY(__futex_wake)
pushl %ebx
mov 8(%esp), %ebx /* ftx */
@ -31,7 +30,7 @@ ENTRY(__futex_wake)
ret
END(__futex_wake)
// int __futex_syscall3(volatile void *ftx, int op, int count)
// int __futex_syscall3(volatile void* ftx, int op, int count)
ENTRY(__futex_syscall3)
pushl %ebx
movl 8(%esp), %ebx /* ftx */
@ -43,7 +42,7 @@ ENTRY(__futex_syscall3)
ret
END(__futex_syscall3)
// int __futex_syscall4(volatile void *ftx, int op, int val, const struct timespec *timeout)
// int __futex_syscall4(volatile void* ftx, int op, int val, const struct timespec* timeout)
ENTRY(__futex_syscall4)
pushl %ebx
pushl %esi

View File

@ -26,15 +26,12 @@
* SUCH DAMAGE.
*/
#include <asm/unistd.h>
#include <machine/asm.h>
#include <private/bionic_asm.h>
#define FUTEX_WAIT 0
#define FUTEX_WAKE 1
/*
* int __futex_wait(volatile void *ftx, int val, const struct timespec *timeout)
*/
// int __futex_wait(volatile void* ftx, int val, const struct timespec* timeout)
ENTRY(__futex_wait)
mov %rdx, %r10 /* timeout */
mov %esi, %edx /* val */
@ -44,8 +41,7 @@ ENTRY(__futex_wait)
ret
END(__futex_wait)
/* int __futex_wake(volatile void *ftx, int count) */
// int __futex_wake(volatile void* ftx, int count)
ENTRY(__futex_wake)
mov %esi, %edx
mov $FUTEX_WAKE, %esi
@ -54,14 +50,14 @@ ENTRY(__futex_wake)
ret
END(__futex_wake)
/* int __futex_syscall3(volatile void *ftx, int op, int count) */
// int __futex_syscall3(volatile void* ftx, int op, int count)
ENTRY(__futex_syscall3)
mov $__NR_futex, %eax
syscall
ret
END(__futex_syscall3)
/* int __futex_syscall4(volatile void *ftx, int op, int val, const struct timespec *timeout) */
// int __futex_syscall4(volatile void* ftx, int op, int val, const struct timespec* timeout)
ENTRY(__futex_syscall4)
mov %rcx, %r10 /* timeout */
mov $__NR_futex, %eax

View File

@ -454,7 +454,7 @@ int __system_property_read(const prop_info *pi, char *name, char *value)
for(;;) {
serial = pi->serial;
while(SERIAL_DIRTY(serial)) {
__futex_wait((volatile void *)&pi->serial, serial, 0);
__futex_wait((volatile void *)&pi->serial, serial, NULL);
serial = pi->serial;
}
len = SERIAL_VALUE_LEN(serial);
@ -572,12 +572,12 @@ int __system_property_wait(const prop_info *pi)
prop_area *pa = __system_property_area__;
n = pa->serial;
do {
__futex_wait(&pa->serial, n, 0);
__futex_wait(&pa->serial, n, NULL);
} while(n == pa->serial);
} else {
n = pi->serial;
do {
__futex_wait((volatile void *)&pi->serial, n, 0);
__futex_wait((volatile void *)&pi->serial, n, NULL);
} while(n == pi->serial);
}
return 0;
@ -635,7 +635,7 @@ unsigned int __system_property_wait_any(unsigned int serial)
prop_area *pa = __system_property_area__;
do {
__futex_wait(&pa->serial, serial, 0);
__futex_wait(&pa->serial, serial, NULL);
} while(pa->serial == serial);
return pa->serial;

View File

@ -101,7 +101,7 @@ int __system_property_read_compat(const prop_info *_pi, char *name, char *value)
for(;;) {
serial = pi->serial;
while(SERIAL_DIRTY(serial)) {
__futex_wait((volatile void *)&pi->serial, serial, 0);
__futex_wait((volatile void *)&pi->serial, serial, NULL);
serial = pi->serial;
}
len = SERIAL_VALUE_LEN(serial);

View File

@ -28,7 +28,6 @@
#ifndef _BIONIC_FUTEX_H
#define _BIONIC_FUTEX_H
#include <linux/compiler.h> /* needed for __user in non-uapi futex.h */
#include <linux/futex.h>
#include <sys/cdefs.h>