]> git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/s390/s390-64/memcpy.S
Update copyright dates with scripts/update-copyrights.
[thirdparty/glibc.git] / sysdeps / s390 / s390-64 / memcpy.S
1 /* memcpy - copy a block from source to destination. 64 bit S/390 version.
2 Copyright (C) 2012-2016 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19
20 #include <sysdep.h>
21 #include "asm-syntax.h"
22
23 /* INPUT PARAMETERS
24 %r2 = address of destination memory area
25 %r3 = address of source memory area
26 %r4 = number of bytes to copy. */
27
28
29 .text
30
31 #ifdef USE_MULTIARCH
32 ENTRY(__memcpy_default)
33 #else
34 ENTRY(memcpy)
35 #endif
36 .machine "z900"
37 ltgr %r4,%r4
38 je .L_Z900_4
39 aghi %r4,-1
40 srlg %r5,%r4,8
41 ltgr %r5,%r5
42 lgr %r1,%r2
43 jne .L_Z900_13
44 .L_Z900_3:
45 larl %r5,.L_Z900_15
46 ex %r4,0(%r5)
47 .L_Z900_4:
48 br %r14
49 .L_Z900_13:
50 chi %r5,4096 # Switch to mvcle for copies >1MB
51 jh __memcpy_mvcle
52 .L_Z900_12:
53 mvc 0(256,%r1),0(%r3)
54 la %r1,256(%r1)
55 la %r3,256(%r3)
56 brctg %r5,.L_Z900_12
57 j .L_Z900_3
58 .L_Z900_15:
59 mvc 0(1,%r1),0(%r3)
60
61 #ifdef USE_MULTIARCH
62 END(__memcpy_default)
63 #else
64 END(memcpy)
65 libc_hidden_builtin_def (memcpy)
66 #endif
67
68 ENTRY(__memcpy_mvcle)
69 # Using as standalone function will result in unexpected
70 # results since the length field is incremented by 1 in order to
71 # compensate the changes already done in the functions above.
72 aghi %r4,1 # length + 1
73 lgr %r5,%r4 # source length
74 lgr %r4,%r3 # source address
75 lgr %r3,%r5 # destination length = source length
76 .L_MVCLE_1:
77 mvcle %r2,%r4,0 # thats it, MVCLE is your friend
78 jo .L_MVCLE_1
79 lgr %r2,%r1 # return destination address
80 br %r14
81 END(__memcpy_mvcle)