From 18a8907c4efb82f839959cce3cec442a96d87f8e Mon Sep 17 00:00:00 2001 From: Brent DeGraaf Date: Tue, 8 Jul 2014 16:59:13 -0400 Subject: bionic: update memmove for 32 bits atomic When src/dst are 32bits aligned, the updated memmove will guarantee 32bits atomic. Change-Id: I21cb77451270d061b32e3e2d2fda22e7e373b7ff --- libc/arch-arm/krait/bionic/memmove.S | 94 ++++++++++++++++++++++++------------ 1 file changed, 63 insertions(+), 31 deletions(-) diff --git a/libc/arch-arm/krait/bionic/memmove.S b/libc/arch-arm/krait/bionic/memmove.S index b7b77ce..24fcec2 100644 --- a/libc/arch-arm/krait/bionic/memmove.S +++ b/libc/arch-arm/krait/bionic/memmove.S @@ -1,5 +1,5 @@ /*************************************************************************** - Copyright (c) 2009-2013 The Linux Foundation. All rights reserved. + Copyright (c) 2009-2014 The Linux Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -84,7 +84,7 @@ _memmove_words: .save {r0, lr} cmp r2, #0 it ne - subsne r12, r0, r1 + subsne r12, r0, r1 // Warning: do not combine these "it" blocks it eq bxeq lr // memmove only if r1 < r0 < r1+r2 @@ -94,15 +94,28 @@ _memmove_words: cmpge r12, r0 it le ble memcpy - cmp r2, #63 - ble .Lneon_b2f_smallcopy + cmp r2, #4 + it le + ble .Lneon_b2f_smallcopy_loop push {r0, lr} add r0, r0, r2 add r1, r1, r2 + cmp r2, #64 + it ge + bge .Lneon_b2f_copy_64 + cmp r2, #32 + it ge + bge .Lneon_b2f_copy_32 + cmp r2, #8 + it ge + bge .Lneon_b2f_copy_8 + b .Lneon_b2f_copy_1 +.Lneon_b2f_copy_64: mov r12, r2, lsr #6 add r0, r0, #32 add r1, r1, #32 cmp r12, #PLDTHRESH + it le ble .Lneon_b2f_copy_64_loop_nopld sub r12, #PLDOFFS sub lr, r1, #(PLDOFFS)*PLDSIZE @@ -116,6 +129,7 @@ _memmove_words: subs r12, r12, #1 vst1.32 {q0, q1}, [r0]! vst1.32 {q2, q3}, [r0] + it ne bne .Lneon_b2f_copy_64_loop_outer mov r12, #PLDOFFS .Lneon_b2f_copy_64_loop_nopld: @@ -126,12 +140,15 @@ _memmove_words: subs r12, r12, #1 vst1.32 {q8, q9}, [r0]! vst1.32 {q10, q11}, [r0] + it ne bne .Lneon_b2f_copy_64_loop_nopld ands r2, r2, #0x3f + it eq beq .Lneon_memmove_done sub r1, r1, #32 sub r0, r0, #32 cmp r2, #32 + it lt blt .Lneon_b2f_copy_8 .Lneon_b2f_copy_32: sub r1, r1, #32 @@ -139,9 +156,11 @@ _memmove_words: vld1.32 {q0, q1}, [r1] vst1.32 {q0, q1}, [r0] ands r2, r2, #0x1f + it eq beq .Lneon_memmove_done .Lneon_b2f_copy_8: movs r12, r2, lsr #0x3 + it eq beq .Lneon_b2f_copy_1 .Lneon_b2f_copy_8_loop: sub r1, r1, #8 @@ -149,39 +168,52 @@ _memmove_words: vld1.32 {d0}, [r1] subs r12, r12, #1 vst1.32 {d0}, [r0] + it ne bne .Lneon_b2f_copy_8_loop ands r2, r2, #0x7 beq .Lneon_memmove_done .Lneon_b2f_copy_1: - sub r1, r1, r2 - sub r0, r0, r2 - ands r12, r2, #1 - beq .Lneon_b2f_copy_halfword_loop - subs r2, r2, #1 - ldrb r3, [r1, r2] - strb r3, [r0, r2] - beq .Lneon_memmove_done -.Lneon_b2f_copy_halfword_loop: - subs r2, r2, #2 - ldrh r3, [r1, r2] - strh r3, [r0, r2] - bne .Lneon_b2f_copy_halfword_loop + movs r12, r2, lsl #29 + itttt mi + submi r1, r1, #4 + submi r0, r0, #4 + ldrmi r3, [r1] + strmi r3, [r0] + movs r2, r2, lsl #31 + itttt cs + subcs r1, r1, #2 + subcs r0, r0, #2 + ldrhcs r3, [r1] + strhcs r3, [r0] + itttt mi + submi r1, r1, #1 + submi r0, r0, #1 + ldrbmi r12, [r1] + strbmi r12, [r0] .Lneon_memmove_done: pop {r0, pc} -.Lneon_b2f_smallcopy: - ands r12, r2, #1 - beq .Lneon_b2f_halfword_small_loop - subs r2, r2, #1 - ldrb r3, [r1, r2] - strb r3, [r0, r2] - it eq - bxeq lr -.Lneon_b2f_halfword_small_loop: - subs r2, r2, #2 - ldrh r3, [r1, r2] - strh r3, [r0, r2] - bne .Lneon_b2f_halfword_small_loop +.Lneon_b2f_smallcopy_loop: + // 4 bytes or less + add r1, r1, r2 + add r0, r0, r2 + movs r12, r2, lsl #29 + itttt mi + submi r1, r1, #4 + submi r0, r0, #4 + ldrmi r3, [r1] + strmi r3, [r0] + movs r2, r2, lsl #31 + itttt cs + subcs r1, r1, #2 + subcs r0, r0, #2 + ldrhcs r3, [r1] + strhcs r3, [r0] + itttt mi + submi r1, r1, #1 + submi r0, r0, #1 + ldrbmi r12, [r1] + strbmi r12, [r0] bx lr - .cfi_endproc + .cfi_endproc END(memmove) -- cgit v1.1 From edb901356a0cf5015dd2c96cec22eaf6776d3e12 Mon Sep 17 00:00:00 2001 From: HazouPH Date: Tue, 19 Aug 2014 16:32:38 +0200 Subject: Fix build for x86. Remove duplicate mcmchr from Android.mk. Other implemented in arch-x86/x86.mk Change-Id: I90a562960b214dd02b015d3e2715f711907ae9e8 --- libc/Android.mk | 2 -- 1 file changed, 2 deletions(-) diff --git a/libc/Android.mk b/libc/Android.mk index 1b02b78..da193fb 100644 --- a/libc/Android.mk +++ b/libc/Android.mk @@ -411,8 +411,6 @@ libc_static_common_src_files += \ bionic/pthread_create.cpp \ bionic/pthread_key.cpp \ -libc_common_src_files += \ - bionic/memchr.c endif # x86 ifeq ($(TARGET_ARCH),mips) -- cgit v1.1 From a6ec766e03030feb1c3fbb0579e30419c26361c5 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Fri, 8 Nov 2013 14:38:12 -0800 Subject: Remove the dependency on the non-uapi __kernel_nlink_t. The kernel doesn't have an nlink_t; it just uses the equivalent of uint32_t. We already had a usable __nlink_t in the C library, so let's just define our nlink_t in terms of __nlink_t, which is what __nlink_t was meant for anyway. Note that our struct stat just follows the kernel, and doesn't refer to nlink_t anyway. Change-Id: I6f51188d188fab975e286d6f8945fe746200b8d4 --- libc/include/sys/types.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libc/include/sys/types.h b/libc/include/sys/types.h index a0ce405..bee1329 100644 --- a/libc/include/sys/types.h +++ b/libc/include/sys/types.h @@ -59,7 +59,6 @@ typedef __kernel_id_t id_t; typedef __kernel_ino_t ino_t; typedef __kernel_key_t key_t; typedef __kernel_mode_t mode_t; -typedef __kernel_nlink_t nlink_t; #ifndef _OFF_T_DEFINED_ #define _OFF_T_DEFINED_ typedef __kernel_off_t off_t; @@ -69,6 +68,8 @@ typedef loff_t off64_t; /* GLibc-specific */ typedef __kernel_pid_t pid_t; +typedef __nlink_t nlink_t; + /* while POSIX wants these in , we * declare then in instead */ #if 0 -- cgit v1.1