mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-30 08:40:07 +00:00
5a82c74822
Also, change sources.redhat.com to sourceware.org. This patch was automatically generated by running the following shell script, which uses GNU sed, and which avoids modifying files imported from upstream: sed -ri ' s,(http|ftp)(://(.*\.)?(gnu|fsf|sourceware)\.org($|[^.]|\.[^a-z])),https\2,g s,(http|ftp)(://(.*\.)?)sources\.redhat\.com($|[^.]|\.[^a-z]),https\2sourceware.org\4,g ' \ $(find $(git ls-files) -prune -type f \ ! -name '*.po' \ ! -name 'ChangeLog*' \ ! -path COPYING ! -path COPYING.LIB \ ! -path manual/fdl-1.3.texi ! -path manual/lgpl-2.1.texi \ ! -path manual/texinfo.tex ! -path scripts/config.guess \ ! -path scripts/config.sub ! -path scripts/install-sh \ ! -path scripts/mkinstalldirs ! -path scripts/move-if-change \ ! -path INSTALL ! -path locale/programs/charmap-kw.h \ ! -path po/libc.pot ! -path sysdeps/gnu/errlist.c \ ! '(' -name configure \ -execdir test -f configure.ac -o -f configure.in ';' ')' \ ! '(' -name preconfigure \ -execdir test -f preconfigure.ac ';' ')' \ -print) and then by running 'make dist-prepare' to regenerate files built from the altered files, and then executing the following to cleanup: chmod a+x sysdeps/unix/sysv/linux/riscv/configure # Omit irrelevant whitespace and comment-only changes, # perhaps from a slightly-different Autoconf version. git checkout -f \ sysdeps/csky/configure \ sysdeps/hppa/configure \ sysdeps/riscv/configure \ sysdeps/unix/sysv/linux/csky/configure # Omit changes that caused a pre-commit check to fail like this: # remote: *** error: sysdeps/powerpc/powerpc64/ppc-mcount.S: trailing lines git checkout -f \ sysdeps/powerpc/powerpc64/ppc-mcount.S \ sysdeps/unix/sysv/linux/s390/s390-64/syscall.S # Omit change that caused a pre-commit check to fail like this: # remote: *** error: sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S: last line does not end in newline git checkout -f sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S
199 lines
3.9 KiB
ArmAsm
199 lines
3.9 KiB
ArmAsm
/* Copyright (C) 1999-2019 Free Software Foundation, Inc.
|
|
This file is part of the GNU C Library.
|
|
Contributed by Kazumoto Kojima <kkojima@rr.iij4u.or.jp>
|
|
Optimized by Toshiyasu Morita <toshiyasu.morita@hsa.hitachi.com>
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU Lesser General Public
|
|
License as published by the Free Software Foundation; either
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
License along with the GNU C Library; if not, see
|
|
<https://www.gnu.org/licenses/>. */
|
|
|
|
#include <sysdep.h>
|
|
|
|
/* void *memcpy(void *dst, const void *src, size_t n);
|
|
No overlap between the memory of DST and of SRC are assumed. */
|
|
|
|
ENTRY(memcpy)
|
|
mov r4,r3 /* Save destination. */
|
|
|
|
/* If less than 11 bytes, just do a byte copy. */
|
|
mov #11,r0
|
|
cmp/gt r6,r0
|
|
bt L_byteloop_init
|
|
|
|
/* Check if we need to word-align source. */
|
|
mov r5,r0
|
|
tst #1,r0
|
|
bt L_wordalign
|
|
|
|
mov.b @r0+,r1 /* Copy one byte. */
|
|
add #-1,r6
|
|
mov.b r1,@r4
|
|
add #1,r4
|
|
|
|
.balignw 4,0x0009
|
|
L_wordalign:
|
|
/* Check if we need to longword-align source. */
|
|
tst #2,r0
|
|
bt L_copy
|
|
|
|
mov.w @r0+,r1 /* Copy one word. */
|
|
add #-2,r6
|
|
#ifdef __BIG_ENDIAN__
|
|
add #1,r4
|
|
mov.b r1,@r4
|
|
shlr8 r1
|
|
mov.b r1,@-r4
|
|
add #2,r4
|
|
#else
|
|
mov.b r1,@r4
|
|
add #1,r4
|
|
shlr8 r1
|
|
mov.b r1,@r4
|
|
add #1,r4
|
|
#endif
|
|
L_copy:
|
|
mov r0,r5
|
|
|
|
/* Calculate the correct routine to handle the destination
|
|
alignment and simultaneously calculate the loop counts for
|
|
both the 2 word copy loop and byte copy loop. */
|
|
mova L_jumptable,r0
|
|
mov r0,r1
|
|
mov r4,r0
|
|
mov r6,r7
|
|
and #3,r0
|
|
shlr2 r7
|
|
shll r0
|
|
shlr r7
|
|
mov.w @(r0,r1),r2
|
|
mov #7,r0
|
|
braf r2
|
|
and r0,r6
|
|
L_base:
|
|
|
|
.balign 4
|
|
L_jumptable:
|
|
.word L_copydest0 - L_base
|
|
.word L_copydest1_or_3 - L_base
|
|
.word L_copydest2 - L_base
|
|
.word L_copydest1_or_3 - L_base
|
|
|
|
.balign 4
|
|
/* Copy routine for (dest mod 4) == 1 or == 3. */
|
|
L_copydest1_or_3:
|
|
add #-1,r4
|
|
.balignw 4,0x0009
|
|
L_copydest1_or_3_loop:
|
|
mov.l @r5+,r0 /* Read first longword. */
|
|
dt r7
|
|
mov.l @r5+,r1 /* Read second longword. */
|
|
#ifdef __BIG_ENDIAN__
|
|
/* Write first longword as byte, word, byte. */
|
|
mov.b r0,@(4,r4)
|
|
shlr8 r0
|
|
mov.w r0,@(2,r4)
|
|
shlr16 r0
|
|
mov.b r0,@(1,r4)
|
|
mov r1,r0
|
|
/* Write second longword as byte, word, byte. */
|
|
mov.b r0,@(8,r4)
|
|
shlr8 r0
|
|
mov.w r0,@(6,r4)
|
|
shlr16 r0
|
|
mov.b r0,@(5,r4)
|
|
#else
|
|
/* Write first longword as byte, word, byte. */
|
|
mov.b r0,@(1,r4)
|
|
shlr8 r0
|
|
mov.w r0,@(2,r4)
|
|
shlr16 r0
|
|
mov.b r0,@(4,r4)
|
|
mov r1,r0
|
|
/* Write second longword as byte, word, byte. */
|
|
mov.b r0,@(5,r4)
|
|
shlr8 r0
|
|
mov.w r0,@(6,r4)
|
|
shlr16 r0
|
|
mov.b r0,@(8,r4)
|
|
#endif
|
|
bf/s L_copydest1_or_3_loop
|
|
add #8,r4
|
|
|
|
bra L_byteloop_init
|
|
add #1,r4
|
|
|
|
.balign 4
|
|
/* Copy routine for (dest mod 4) == 2. */
|
|
L_copydest2:
|
|
L_copydest2_loop:
|
|
mov.l @r5+,r0
|
|
dt r7
|
|
mov.l @r5+,r1
|
|
#ifdef __BIG_ENDIAN__
|
|
mov.w r0,@(2,r4)
|
|
shlr16 r0
|
|
mov.w r0,@r4
|
|
mov r1,r0
|
|
mov.w r0,@(6,r4)
|
|
shlr16 r0
|
|
mov.w r0,@(4,r4)
|
|
#else
|
|
mov.w r0,@r4
|
|
shlr16 r0
|
|
mov.w r0,@(2,r4)
|
|
mov r1,r0
|
|
mov.w r0,@(4,r4)
|
|
shlr16 r0
|
|
mov.w r0,@(6,r4)
|
|
#endif
|
|
bf/s L_copydest2_loop
|
|
add #8,r4
|
|
|
|
bra L_byteloop_init
|
|
nop
|
|
|
|
.balign 4
|
|
/* Copy routine for (dest mod 4) == 0. */
|
|
L_copydest0:
|
|
add #-8,r4
|
|
.balignw 4,0x0009
|
|
L_copydest0_loop:
|
|
mov.l @r5+,r0
|
|
dt r7
|
|
mov.l @r5+,r1
|
|
add #8,r4
|
|
mov.l r0,@r4
|
|
bf/s L_copydest0_loop
|
|
mov.l r1,@(4,r4)
|
|
|
|
add #8,r4 /* Fall through. */
|
|
|
|
L_byteloop_init:
|
|
tst r6,r6
|
|
bt L_exit
|
|
|
|
.balignw 4,0x0009
|
|
/* Copy remaining bytes. */
|
|
L_byteloop:
|
|
mov.b @r5+,r0
|
|
dt r6
|
|
mov.b r0,@r4
|
|
bf/s L_byteloop
|
|
add #1,r4
|
|
|
|
L_exit:
|
|
rts
|
|
mov r3,r0 /* Return destination. */
|
|
END(memcpy)
|
|
libc_hidden_builtin_def (memcpy)
|