Add Aarch64 optimized bzero based on memset
Change-Id: I62cf25bfe23b9d811e00af7307bbd19d89937792 Signed-off-by: Bernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org>
This commit is contained in:
parent
8a405b027a
commit
62d92e1610
@ -34,7 +34,6 @@ libc_common_src_files_arm64 += \
|
|||||||
### CPU specific source files
|
### CPU specific source files
|
||||||
libc_bionic_src_files_arm64 := \
|
libc_bionic_src_files_arm64 := \
|
||||||
arch-arm64/bionic/__bionic_clone.S \
|
arch-arm64/bionic/__bionic_clone.S \
|
||||||
arch-arm64/bionic/bzero_arm64.c \
|
|
||||||
arch-arm64/bionic/_exit_with_stack_teardown.S \
|
arch-arm64/bionic/_exit_with_stack_teardown.S \
|
||||||
arch-arm64/bionic/futex_arm64.S \
|
arch-arm64/bionic/futex_arm64.S \
|
||||||
arch-arm64/bionic/__get_sp.S \
|
arch-arm64/bionic/__get_sp.S \
|
||||||
|
@ -1,33 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2013 The Android Open Source Project
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in
|
|
||||||
* the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
||||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
||||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
||||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
||||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
||||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
||||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
|
||||||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
||||||
* SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
void bzero(void* s, size_t n) {
|
|
||||||
memset(s, '\0', n);
|
|
||||||
}
|
|
30
libc/arch-arm64/generic/bionic/bzero.S
Normal file
30
libc/arch-arm64/generic/bionic/bzero.S
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
/* Copyright (c) 2014, Linaro Limited
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
* Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
* Neither the name of the Linaro nor the
|
||||||
|
names of its contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define BZERO
|
||||||
|
#include "memset.S"
|
||||||
|
#undef BZERO
|
@ -38,15 +38,19 @@
|
|||||||
data blocks more efficiently. In some circumstances this might be
|
data blocks more efficiently. In some circumstances this might be
|
||||||
unsafe, for example in an asymmetric multiprocessor environment with
|
unsafe, for example in an asymmetric multiprocessor environment with
|
||||||
different DC clear lengths (neither the upper nor lower lengths are
|
different DC clear lengths (neither the upper nor lower lengths are
|
||||||
safe to use). The feature can be disabled by defining DONT_USE_DC.
|
safe to use).
|
||||||
|
|
||||||
If code may be run in a virtualized environment, then define
|
If code may be run in a virtualized environment, then define
|
||||||
MAYBE_VIRT. This will cause the code to cache the system register
|
MAYBE_VIRT. This will cause the code to cache the system register
|
||||||
values rather than re-reading them each call. */
|
values rather than re-reading them each call. */
|
||||||
|
|
||||||
#define dstin x0
|
#define dstin x0
|
||||||
#define val w1
|
#ifdef BZERO
|
||||||
|
#define count x1
|
||||||
|
#else
|
||||||
#define count x2
|
#define count x2
|
||||||
|
#endif
|
||||||
|
#define val w1
|
||||||
#define tmp1 x3
|
#define tmp1 x3
|
||||||
#define tmp1w w3
|
#define tmp1w w3
|
||||||
#define tmp2 x4
|
#define tmp2 x4
|
||||||
@ -60,13 +64,18 @@
|
|||||||
#define dst x8
|
#define dst x8
|
||||||
#define tmp3w w9
|
#define tmp3w w9
|
||||||
|
|
||||||
|
#ifdef BZERO
|
||||||
|
ENTRY(bzero)
|
||||||
|
#else
|
||||||
ENTRY(memset)
|
ENTRY(memset)
|
||||||
|
#endif
|
||||||
|
|
||||||
mov dst, dstin /* Preserve return value. */
|
mov dst, dstin /* Preserve return value. */
|
||||||
ands A_lw, val, #255
|
#ifdef BZERO
|
||||||
#ifndef DONT_USE_DC
|
b .Lzero_mem
|
||||||
b.eq .Lzero_mem
|
|
||||||
#endif
|
#endif
|
||||||
|
ands A_lw, val, #255
|
||||||
|
b.eq .Lzero_mem
|
||||||
orr A_lw, A_lw, A_lw, lsl #8
|
orr A_lw, A_lw, A_lw, lsl #8
|
||||||
orr A_lw, A_lw, A_lw, lsl #16
|
orr A_lw, A_lw, A_lw, lsl #16
|
||||||
orr A_l, A_l, A_l, lsl #32
|
orr A_l, A_l, A_l, lsl #32
|
||||||
@ -143,7 +152,6 @@ ENTRY(memset)
|
|||||||
b.ne .Ltail63
|
b.ne .Ltail63
|
||||||
ret
|
ret
|
||||||
|
|
||||||
#ifndef DONT_USE_DC
|
|
||||||
/* For zeroing memory, check to see if we can use the ZVA feature to
|
/* For zeroing memory, check to see if we can use the ZVA feature to
|
||||||
* zero entire 'cache' lines. */
|
* zero entire 'cache' lines. */
|
||||||
.Lzero_mem:
|
.Lzero_mem:
|
||||||
@ -225,7 +233,11 @@ ENTRY(memset)
|
|||||||
ands count, count, zva_bits_x
|
ands count, count, zva_bits_x
|
||||||
b.ne .Ltail_maybe_long
|
b.ne .Ltail_maybe_long
|
||||||
ret
|
ret
|
||||||
|
#ifdef BZERO
|
||||||
|
END(bzero)
|
||||||
|
#else
|
||||||
END(memset)
|
END(memset)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef MAYBE_VIRT
|
#ifdef MAYBE_VIRT
|
||||||
.bss
|
.bss
|
||||||
@ -233,4 +245,3 @@ END(memset)
|
|||||||
.Lcache_clear:
|
.Lcache_clear:
|
||||||
.space 4
|
.space 4
|
||||||
#endif
|
#endif
|
||||||
#endif /* DONT_USE_DC */
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
libc_bionic_src_files_arm64 += \
|
libc_bionic_src_files_arm64 += \
|
||||||
arch-arm64/generic/bionic/bcopy.S \
|
arch-arm64/generic/bionic/bcopy.S \
|
||||||
|
arch-arm64/generic/bionic/bzero.S \
|
||||||
arch-arm64/generic/bionic/memcmp.S \
|
arch-arm64/generic/bionic/memcmp.S \
|
||||||
arch-arm64/generic/bionic/memcpy.S \
|
arch-arm64/generic/bionic/memcpy.S \
|
||||||
arch-arm64/generic/bionic/memmove.S \
|
arch-arm64/generic/bionic/memmove.S \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user