OSDN Git Service

Fix aarch64 futex assembly routines.
authorElliott Hughes <enh@google.com>
Sat, 21 Dec 2013 00:58:06 +0000 (16:58 -0800)
committerElliott Hughes <enh@google.com>
Sat, 21 Dec 2013 00:58:06 +0000 (16:58 -0800)
Also make the other architectures more similar to one another,
use NULL instead of 0 in calling code, and remove an unused #define.

Change-Id: I52b874afb6a351c802f201a0625e484df6d093bb

libc/arch-aarch64/bionic/futex_aarch64.S
libc/arch-arm/bionic/futex_arm.S
libc/arch-mips/bionic/futex_mips.S
libc/arch-x86/bionic/futex_x86.S
libc/arch-x86_64/bionic/futex_x86_64.S
libc/bionic/system_properties.c
libc/bionic/system_properties_compat.c
libc/private/bionic_futex.h

index bf7959b..e3ac309 100644 (file)
 #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
+  stp x29, x30, [sp, #-16]!
+  mov x29, sp
 
-    /* check if syscall returned successfully */
-    cmn     x0, #(MAX_ERRNO + 1)
-    cneg    x0, x0, hi
-    b.hi    __set_errno
+  str x8, [sp, #-16]!
+  mov x8, __NR_futex
+  svc #0
+  ldr x8, [sp], #16
 
-    ret
+  ldp x29, x30, [sp], #16
+  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
+  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
+  stp x29, x30, [sp, #-16]!
+  mov x29, sp
 
-    /* store x8 */
-    str    x8,       [sp, #-16]!
+  mov x3, x2
+  mov x2, x1
+  mov x1, #FUTEX_WAIT
 
-    /* arange arguments as expected in the kernel side */
-    mov x3, x2
-    mov w2, w1
-    mov w1, #FUTEX_WAIT
+  str x8, [sp, #-16]!
+  mov x8, __NR_futex
+  svc #0
+  ldr 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
+  ldp x29, x30, [sp], #16
+  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 */
-    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
+  stp x29, x30, [sp, #-16]!
+  mov x29, sp
 
-    /* restore x8 */
-    ldr     x8,       [sp], #16
-    ldp     x29, x30, [sp], #16
+  mov x2, x1
+  mov x1, #FUTEX_WAKE
 
-    /* check if syscall returned successfully */
-    cmn     x0, #(MAX_ERRNO + 1)
-    cneg    x0, x0, hi
-    b.hi    __set_errno
+  str x8, [sp, #-16]!
+  mov x8, __NR_futex
+  svc #0
+  ldr x8, [sp], #16
 
-    ret
+  ldp x29, x30, [sp], #16
+  ret
 END(__futex_wake)
index 4131cdb..0aba278 100644 (file)
  * 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
index 2a953ca..5247b79 100644 (file)
  * 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
index fa33758..8dd2ad0 100644 (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 voidftx, 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 voidftx, 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
index 48a437e..f85d583 100644 (file)
  * 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
index 9fdb6f5..825894f 100644 (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;
index 0326f05..b4c2494 100644 (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);
index 5602af7..bfc3520 100644 (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>