Hide most of the private futex functions.

Also hide part of the system properties compatibility code, since
we needed to touch that to keep it building.

I'll remove __futex_syscall4 and futex in a later patch.

Bug: 11156955
Change-Id: Ibbf42414c5bb07fb9f1c4a169922844778e4eeae
This commit is contained in:
Elliott Hughes 2014-05-21 18:27:40 -07:00
parent f97d8713a2
commit d5ed63a6a8
11 changed files with 36 additions and 337 deletions

View File

@ -28,42 +28,11 @@
#include <private/bionic_asm.h>
#define FUTEX_WAIT 0
#define FUTEX_WAKE 1
// int __futex_syscall3(volatile void* ftx, int op, int count)
ENTRY(__futex_syscall3)
mov ip, r7
ldr r7, =__NR_futex
swi #0
mov r7, ip
bx lr
END(__futex_syscall3)
// int __futex_syscall4(volatile void* ftx, int op, int val, const struct timespec* timeout)
ENTRY(__futex_syscall4)
b __futex_syscall3
ENTRY_PRIVATE(__futex_syscall4)
mov ip, r7
ldr r7, =__NR_futex
swi #0
mov r7, ip
bx lr
END(__futex_syscall4)
// int __futex_wait(volatile void* ftx, int val, const struct timespec* timeout)
ENTRY(__futex_wait)
mov ip, r7
mov r3, r2
mov r2, r1
mov r1, #FUTEX_WAIT
ldr r7, =__NR_futex
swi #0
mov r7, ip
bx lr
END(__futex_wait)
// int __futex_wake(volatile void* ftx, int count)
ENTRY(__futex_wake)
mov ip, r7
mov r2, r1
mov r1, #FUTEX_WAKE
ldr r7, =__NR_futex
swi #0
mov r7, ip
bx lr
END(__futex_wake)

View File

@ -28,11 +28,8 @@
#include <private/bionic_asm.h>
#define FUTEX_WAIT 0
#define FUTEX_WAKE 1
// int __futex_syscall4(volatile void* ftx, int op, int val, const struct timespec* timeout)
ENTRY(__futex_syscall4)
ENTRY_PRIVATE(__futex_syscall4)
stp x29, x30, [sp, #-16]!
.cfi_def_cfa_offset 16
.cfi_rel_offset x29, 0
@ -48,51 +45,3 @@ ENTRY(__futex_syscall4)
.cfi_restore x30
ret
END(__futex_syscall4)
// int __futex_syscall3(volatile void* ftx, int op, int count)
ENTRY(__futex_syscall3)
b __futex_syscall4
END(__futex_syscall3)
// int __futex_wait(volatile void* ftx, int val, const struct timespec* timeout)
ENTRY_PRIVATE(__futex_wait)
stp x29, x30, [sp, #-16]!
.cfi_def_cfa_offset 16
.cfi_rel_offset x29, 0
.cfi_rel_offset x30, 8
mov x29, sp
mov x3, x2
mov x2, x1
mov x1, #FUTEX_WAIT
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_wait)
// int __futex_wake(volatile void* ftx, int count)
ENTRY_PRIVATE(__futex_wake)
stp x29, x30, [sp, #-16]!
.cfi_def_cfa_offset 16
.cfi_rel_offset x29, 0
.cfi_rel_offset x30, 8
mov x29, sp
mov x2, x1
mov x1, #FUTEX_WAKE
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_wake)

View File

@ -28,74 +28,8 @@
#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)
ENTRY(__futex_wait)
subu sp,4*6
sw $0,20(sp) /* val3 */
sw $0,16(sp) /* addr2 */
move a3,a2 /* timespec */
move a2,a1 /* val */
li a1,FUTEX_WAIT /* 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_wait)
// int __futex_wake(volatile void* ftx, int count)
ENTRY(__futex_wake)
subu sp,4*6
sw $0,20(sp) /* val3 */
sw $0,16(sp) /* addr2 */
move a3,$0 /* timespec */
move a2,a1 /* val */
li a1,FUTEX_WAKE /* 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_wake)
// int __futex_syscall3(volatile void* ftx, int op, int count)
ENTRY(__futex_syscall3)
subu sp,4*6
sw $0,20(sp) /* val3 */
sw $0,16(sp) /* addr2 */
move a3,$0 /* 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_syscall3)
// int __futex_syscall4(volatile void* ftx, int op, int val, const struct timespec* timeout)
ENTRY(__futex_syscall4)
ENTRY_PRIVATE(__futex_syscall4)
subu sp,4*6
sw $0,20(sp) /* val3 */
sw $0,16(sp) /* addr2 */

View File

@ -28,9 +28,6 @@
#include <private/bionic_asm.h>
#define FUTEX_WAIT 0
#define FUTEX_WAKE 1
#if (_MIPS_SIM == _ABIO32) || (_MIPS_SIM == _ABI32)
FRAMESZ = MKFSIZ(NARGSAVE+2,0)
FRAME_A4 = 4*REGSZ
@ -39,84 +36,6 @@ FRAME_A5 = 5*REGSZ
FRAMESZ = 0
#endif
// int __futex_wait(volatile void* ftx, int val, const struct timespec* timeout)
LEAF(__futex_wait, 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,a2 /* timespec */
move a2,a1 /* val */
LI a1,FUTEX_WAIT /* 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_wait)
// int __futex_wake(volatile void* ftx, int count)
LEAF(__futex_wake,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,$0 /* timespec */
move a2,a1 /* val */
LI a1,FUTEX_WAKE /* 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_wake)
// int __futex_syscall3(volatile void* ftx, int op, int count)
LEAF(__futex_syscall3,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,$0 /* 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_syscall3)
// 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)
@ -142,3 +61,4 @@ LEAF(__futex_syscall4,FRAMESZ)
#endif
j ra
END(__futex_syscall4)
.hidden __futex_syscall4

View File

@ -1,49 +1,7 @@
#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)
ENTRY(__futex_wait)
pushl %ebx
pushl %esi
mov 12(%esp), %ebx /* ftx */
movl $FUTEX_WAIT, %ecx
mov 16(%esp), %edx /* val */
mov 20(%esp), %esi /* timeout */
movl $__NR_futex, %eax
int $0x80
popl %esi
popl %ebx
ret
END(__futex_wait)
// int __futex_wake(volatile void* ftx, int count)
ENTRY(__futex_wake)
pushl %ebx
mov 8(%esp), %ebx /* ftx */
movl $FUTEX_WAKE, %ecx
mov 12(%esp), %edx /* count */
movl $__NR_futex, %eax
int $0x80
popl %ebx
ret
END(__futex_wake)
// int __futex_syscall3(volatile void* ftx, int op, int count)
ENTRY(__futex_syscall3)
pushl %ebx
movl 8(%esp), %ebx /* ftx */
movl 12(%esp), %ecx /* op */
movl 16(%esp), %edx /* value */
movl $__NR_futex, %eax
int $0x80
popl %ebx
ret
END(__futex_syscall3)
// int __futex_syscall4(volatile void* ftx, int op, int val, const struct timespec* timeout)
ENTRY(__futex_syscall4)
ENTRY_PRIVATE(__futex_syscall4)
pushl %ebx
pushl %esi
movl 12(%esp), %ebx /* ftx */

View File

@ -28,37 +28,8 @@
#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)
ENTRY_PRIVATE(__futex_wait)
mov %rdx, %r10 /* timeout */
mov %esi, %edx /* val */
mov $FUTEX_WAIT, %esi /* op */
mov $__NR_futex, %eax
syscall
ret
END(__futex_wait)
// int __futex_wake(volatile void* ftx, int count)
ENTRY_PRIVATE(__futex_wake)
mov %esi, %edx
mov $FUTEX_WAKE, %esi
mov $__NR_futex, %eax
syscall
ret
END(__futex_wake)
// 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)
ENTRY(__futex_syscall4)
ENTRY_PRIVATE(__futex_syscall4)
mov %rcx, %r10 /* timeout */
mov $__NR_futex, %eax
syscall

View File

@ -88,11 +88,3 @@ int __timespec_from_absolute(timespec* ts, const timespec* abstime, clockid_t cl
}
return 0;
}
int __futex_wake_ex(volatile void* ftx, int pshared, int val) {
return __futex_syscall3(ftx, pshared ? FUTEX_WAKE : FUTEX_WAKE_PRIVATE, val);
}
int __futex_wait_ex(volatile void* ftx, int pshared, int val, const timespec* timeout) {
return __futex_syscall4(ftx, pshared ? FUTEX_WAIT : FUTEX_WAIT_PRIVATE, val, timeout);
}

View File

@ -51,9 +51,8 @@
#include <sys/_system_properties.h>
#include <sys/system_properties.h>
#include <sys/atomics.h>
#include "private/bionic_atomic_inline.h"
#include "private/bionic_futex.h"
#include "private/bionic_macros.h"
#define ALIGN(x, a) (((x) + (a - 1)) & ~(a - 1))

View File

@ -35,7 +35,8 @@
*/
#include <string.h>
#include <sys/atomics.h>
#include "private/bionic_futex.h"
#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
#include <sys/_system_properties.h>
@ -67,7 +68,7 @@ typedef struct prop_info_compat prop_info_compat;
extern prop_area *__system_property_area__;
const prop_info *__system_property_find_compat(const char *name)
__LIBC_HIDDEN__ const prop_info *__system_property_find_compat(const char *name)
{
prop_area_compat *pa = (prop_area_compat *)__system_property_area__;
unsigned count = pa->count;
@ -93,7 +94,7 @@ const prop_info *__system_property_find_compat(const char *name)
return 0;
}
int __system_property_read_compat(const prop_info *_pi, char *name, char *value)
__LIBC_HIDDEN__ int __system_property_read_compat(const prop_info *_pi, char *name, char *value)
{
unsigned serial, len;
const prop_info_compat *pi = (const prop_info_compat *)_pi;
@ -115,7 +116,7 @@ int __system_property_read_compat(const prop_info *_pi, char *name, char *value)
}
}
int __system_property_foreach_compat(
__LIBC_HIDDEN__ int __system_property_foreach_compat(
void (*propfn)(const prop_info *pi, void *cookie),
void *cookie)
{

View File

@ -75,10 +75,6 @@ __atomic_inc(volatile int *ptr)
return __sync_fetch_and_add (ptr, 1);
}
int __futex_wait(volatile void *ftx, int val, const struct timespec *timeout);
int __futex_wake(volatile void *ftx, int count);
__END_DECLS
#endif /* _SYS_ATOMICS_H */

View File

@ -30,20 +30,30 @@
#include <linux/futex.h>
#include <sys/cdefs.h>
#include <stdbool.h>
#include <stddef.h>
__BEGIN_DECLS
extern int __futex_wait(volatile void *ftx, int val, const struct timespec *timeout);
extern int __futex_wake(volatile void *ftx, int count);
struct timespec;
extern int __futex_syscall3(volatile void *ftx, int op, int val);
extern int __futex_syscall4(volatile void *ftx, int op, int val, const struct timespec *timeout);
extern int __futex_syscall4(volatile void* ftx, int op, int value, const struct timespec* timeout);
/* Like __futex_wait/wake, but take an additional 'pshared' argument.
* when non-0, this will use normal futexes. Otherwise, private futexes.
*/
__LIBC_HIDDEN__ int __futex_wake_ex(volatile void* ftx, int pshared, int val);
__LIBC_HIDDEN__ int __futex_wait_ex(volatile void* ftx, int pshared, int val, const struct timespec* timeout);
static inline int __futex_wake(volatile void* ftx, int count) {
return __futex_syscall4(ftx, FUTEX_WAKE, count, NULL);
}
static inline int __futex_wake_ex(volatile void* ftx, bool shared, int count) {
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) {
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) {
return __futex_syscall4(ftx, shared ? FUTEX_WAIT : FUTEX_WAIT_PRIVATE, value, timeout);
}
__END_DECLS