|
Packit |
6c4009 |
/* strncpy - copy at most n characters from a string from source to
|
|
Packit |
6c4009 |
destination. 64 bit S/390 version
|
|
Packit |
6c4009 |
Copyright (C) 2001-2018 Free Software Foundation, Inc.
|
|
Packit |
6c4009 |
Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
|
|
Packit |
6c4009 |
This file is part of the GNU C Library.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
The GNU C Library is free software; you can redistribute it and/or
|
|
Packit |
6c4009 |
modify it under the terms of the GNU Lesser General Public
|
|
Packit |
6c4009 |
License as published by the Free Software Foundation; either
|
|
Packit |
6c4009 |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit |
6c4009 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
6c4009 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
6c4009 |
Lesser General Public License for more details.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
You should have received a copy of the GNU Lesser General Public
|
|
Packit |
6c4009 |
License along with the GNU C Library; if not, see
|
|
Packit |
6c4009 |
<http://www.gnu.org/licenses/>. */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* INPUT PARAMETERS
|
|
Packit |
6c4009 |
%r2 = address of destination (dst)
|
|
Packit |
6c4009 |
%r3 = address of source (src)
|
|
Packit |
6c4009 |
%r4 = max of bytes to copy. */
|
|
Packit |
6c4009 |
|
|
Packit |
1e4663 |
#include <ifunc-strncpy.h>
|
|
Packit |
6c4009 |
#include "sysdep.h"
|
|
Packit |
6c4009 |
#include "asm-syntax.h"
|
|
Packit |
6c4009 |
|
|
Packit |
1e4663 |
#if HAVE_STRNCPY_Z900_G5
|
|
Packit |
1e4663 |
ENTRY(STRNCPY_Z900_G5)
|
|
Packit |
6c4009 |
.text
|
|
Packit |
6c4009 |
stg %r2,48(%r15) # save dst pointer
|
|
Packit |
6c4009 |
slgr %r2,%r3 # %r3 points to src, %r2+%r3 to dst
|
|
Packit |
6c4009 |
lghi %r1,7
|
|
Packit |
6c4009 |
ngr %r1,%r4 # last 3 bits of # bytes
|
|
Packit |
6c4009 |
srlg %r4,%r4,3
|
|
Packit |
6c4009 |
ltgr %r4,%r4 # less than 8 bytes to copy ?
|
|
Packit |
6c4009 |
jz .L1
|
|
Packit |
6c4009 |
bras %r5,.L0 # enter loop & load address of a 0
|
|
Packit |
6c4009 |
.long 0
|
|
Packit |
6c4009 |
.L0: icmh %r0,8,0(%r3) # first byte
|
|
Packit |
6c4009 |
jz .L3
|
|
Packit |
6c4009 |
icmh %r0,4,1(%r3) # second byte
|
|
Packit |
6c4009 |
jz .L4
|
|
Packit |
6c4009 |
icmh %r0,2,2(%r3) # third byte
|
|
Packit |
6c4009 |
jz .L5
|
|
Packit |
6c4009 |
icmh %r0,1,3(%r3) # fourth byte
|
|
Packit |
6c4009 |
jz .L6
|
|
Packit |
6c4009 |
icm %r0,8,4(%r3) # fifth byte
|
|
Packit |
6c4009 |
jz .L7
|
|
Packit |
6c4009 |
icm %r0,4,5(%r3) # sixth byte
|
|
Packit |
6c4009 |
jz .L8
|
|
Packit |
6c4009 |
icm %r0,2,6(%r3) # seventh byte
|
|
Packit |
6c4009 |
jz .L9
|
|
Packit |
6c4009 |
icm %r0,1,7(%r3) # eigth byte
|
|
Packit |
6c4009 |
jz .L10
|
|
Packit |
6c4009 |
stg %r0,0(%r2,%r3) # store all eight to dest.
|
|
Packit |
6c4009 |
la %r3,8(%r3)
|
|
Packit |
6c4009 |
brct %r4,.L0
|
|
Packit |
6c4009 |
.L1: ltgr %r1,%r1
|
|
Packit |
6c4009 |
jz .Lexit
|
|
Packit |
6c4009 |
.L2: icm %r0,1,0(%r3)
|
|
Packit |
6c4009 |
stc %r0,0(%r2,%r3)
|
|
Packit |
6c4009 |
la %r3,1(%r3)
|
|
Packit |
6c4009 |
jz .L11
|
|
Packit |
6c4009 |
brct %r1,.L2
|
|
Packit |
6c4009 |
j .Lexit
|
|
Packit |
6c4009 |
.L3: icmh %r0,4,0(%r5)
|
|
Packit |
6c4009 |
.L4: icmh %r0,2,0(%r5)
|
|
Packit |
6c4009 |
.L5: icmh %r0,1,0(%r5)
|
|
Packit |
6c4009 |
.L6: icm %r0,8,0(%r5)
|
|
Packit |
6c4009 |
.L7: icm %r0,4,0(%r5)
|
|
Packit |
6c4009 |
.L8: icm %r0,2,0(%r5)
|
|
Packit |
6c4009 |
.L9: icm %r0,1,0(%r5)
|
|
Packit |
6c4009 |
.L10: stg %r0,0(%r2,%r3)
|
|
Packit |
6c4009 |
la %r3,8(%r3)
|
|
Packit |
6c4009 |
aghi %r4,-1
|
|
Packit |
6c4009 |
j .L12
|
|
Packit |
6c4009 |
.L11: aghi %r1,-1
|
|
Packit |
6c4009 |
.L12: sllg %r4,%r4,3
|
|
Packit |
6c4009 |
algr %r4,%r1
|
|
Packit |
6c4009 |
algr %r2,%r3 # start of dst area to be zeroed
|
|
Packit |
6c4009 |
lgr %r3,%r4
|
|
Packit |
6c4009 |
slgr %r4,%r4
|
|
Packit |
6c4009 |
slgr %r5,%r5
|
|
Packit |
6c4009 |
.L13: mvcle %r2,%r4,0 # pad dst with zeroes
|
|
Packit |
6c4009 |
jo .L13
|
|
Packit |
6c4009 |
.Lexit: lg %r2,48(%r15) # return dst pointer
|
|
Packit |
6c4009 |
br %r14
|
|
Packit |
1e4663 |
END(STRNCPY_Z900_G5)
|
|
Packit |
1e4663 |
|
|
Packit |
1e4663 |
# if ! HAVE_STRNCPY_IFUNC
|
|
Packit |
1e4663 |
strong_alias (STRNCPY_Z900_G5, strncpy)
|
|
Packit |
1e4663 |
# endif
|
|
Packit |
1e4663 |
|
|
Packit |
1e4663 |
# if defined SHARED && IS_IN (libc)
|
|
Packit |
1e4663 |
strong_alias (STRNCPY_Z900_G5, __GI_strncpy)
|
|
Packit |
1e4663 |
# endif
|
|
Packit |
1e4663 |
#endif
|