]> git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/s390/s390-32/multiarch/memset-s390.S
Update copyright dates with scripts/update-copyrights.
[thirdparty/glibc.git] / sysdeps / s390 / s390-32 / multiarch / memset-s390.S
1 /* Set a block of memory to some byte value. 32 bit S/390 version.
2 Copyright (C) 2012-2017 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 memory area
25 %r3 = byte to fill memory with
26 %r4 = number of bytes to fill. */
27
28 .text
29
30 #if IS_IN (libc)
31
32 ENTRY(__memset_z196)
33 .machine "z196"
34 .machinemode "zarch_nohighgprs"
35 llgfr %r4,%r4
36 ltgr %r4,%r4
37 je .L_Z196_4
38 stc %r3,0(%r2)
39 lr %r1,%r2
40 cghi %r4,1
41 je .L_Z196_4
42 aghi %r4,-2
43 srlg %r5,%r4,8
44 ltgr %r5,%r5
45 jne .L_Z196_1
46 .L_Z196_3:
47 exrl %r4,.L_Z196_17
48 .L_Z196_4:
49 br %r14
50 .L_Z196_1:
51 cgfi %r5,1048576
52 jh __memset_mvcle # Switch to mvcle for >256MB
53 .L_Z196_2:
54 pfd 2,1024(%r1)
55 mvc 1(256,%r1),0(%r1)
56 aghi %r5,-1
57 la %r1,256(%r1)
58 jne .L_Z196_2
59 j .L_Z196_3
60 .L_Z196_17:
61 mvc 1(1,%r1),0(%r1)
62 END(__memset_z196)
63
64 ENTRY(__memset_z10)
65 .machine "z10"
66 .machinemode "zarch_nohighgprs"
67 llgfr %r4,%r4
68 cgije %r4,0,.L_Z10_4
69 stc %r3,0(%r2)
70 lr %r1,%r2
71 cgije %r4,1,.L_Z10_4
72 aghi %r4,-2
73 srlg %r5,%r4,8
74 cgijlh %r5,0,.L_Z10_15
75 .L_Z10_3:
76 exrl %r4,.L_Z10_18
77 .L_Z10_4:
78 br %r14
79 .L_Z10_15:
80 cgfi %r5,163840 # Switch to mvcle for >40MB
81 jh __memset_mvcle
82 .L_Z10_14:
83 pfd 2,1024(%r1)
84 mvc 1(256,%r1),0(%r1)
85 la %r1,256(%r1)
86 brctg %r5,.L_Z10_14
87 j .L_Z10_3
88 .L_Z10_18:
89 mvc 1(1,%r1),0(%r1)
90 END(__memset_z10)
91
92 ENTRY(__memset_mvcle)
93 ahi %r4,2 # take back the change done by the caller
94 lr %r0,%r2 # save source address
95 lr %r1,%r3 # move pad byte to R1
96 lr %r3,%r4
97 sr %r4,%r4 # no source for MVCLE, only a pad byte
98 sr %r5,%r5
99 .L0: mvcle %r2,%r4,0(%r1) # thats it, MVCLE is your friend
100 jo .L0
101 lr %r2,%r0 # return value is source address
102 .L1:
103 br %r14
104 END(__memset_mvcle)
105
106 #endif /* IS_IN (libc) */
107
108 #include "../memset.S"
109
110 #if !IS_IN (libc)
111 .globl memset
112 .set memset,__memset_default
113 #elif defined SHARED && IS_IN (libc)
114 .globl __GI_memset
115 .set __GI_memset,__memset_default
116 #endif