0fec6b9d88
__atomic_cmpxchg and other related atomic operations did not provide memory barriers, which can be a problem for non-platform code that links against them when it runs on multi-core devices. This patch does two things to fix this: - It modifies the existing implementation of the functions that are exported by the C library to always provide full memory barriers. We need to keep them exported by the C library to prevent breaking existing application machine code. - It also modifies <sys/atomics.h> to only export always-inlined versions of the functions, to ensure that any application code compiled against the new header will not rely on the platform version of the functions. This ensure that said machine code will run properly on all multi-core devices. This is based on the GCC built-in sync primitives. The end result should be only slightly slower than the previous implementation. Note that the platform code does not use these functions at all. A previous patch completely removed their usage in the pthread and libstdc++ code. + rename arch-arm/bionic/atomics_arm.S to futex_arm.S + rename arch-x86/bionic/atomics_x86.S to futex_x86.S + remove arch-x86/include/sys/atomics.h which already provided inlined functions to the x86 platform. Change-Id: I752a594475090cf37fa926bb38209c2175dda539
75 lines
1.7 KiB
ArmAsm
75 lines
1.7 KiB
ArmAsm
#include <sys/linux-syscalls.h>
|
|
|
|
#define FUTEX_WAIT 0
|
|
#define FUTEX_WAKE 1
|
|
|
|
|
|
/*
|
|
* int __futex_wait(volatile void *ftx, int val, const struct timespec *timeout)
|
|
*/
|
|
.text
|
|
.globl __futex_wait
|
|
.type __futex_wait, @function
|
|
.align 4
|
|
__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
|
|
|
|
|
|
/* int __futex_wake(volatile void *ftx, int count) */
|
|
|
|
.text
|
|
.globl __futex_wake
|
|
.type __futex_wake, @function
|
|
.align 4
|
|
__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
|
|
|
|
/* int __futex_syscall3(volatile void *ftx, int op, int count) */
|
|
.text
|
|
.globl __futex_syscall3
|
|
.type __futex_syscall3, @function
|
|
.align 4
|
|
__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
|
|
|
|
/* int __futex_syscall4(volatile void *ftx, int op, int val, const struct timespec *timeout) */
|
|
.text
|
|
.globl __futex_syscall4
|
|
.type __futex_syscall4, @function
|
|
.align 4
|
|
__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
|