1 /* Set a block of memory to some byte value. 31/64 bit S/390 version.
2 Copyright (C) 2001-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
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.
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.
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 <https://www.gnu.org/licenses/>. */
21 #include "asm-syntax.h"
22 #include <ifunc-memset.h>
24 /* INPUT PARAMETERS - MEMSET
25 %r2 = address of memory area
26 %r3 = byte to fill memory with
27 %r4 = number of bytes to fill. */
31 #if HAVE_MEMSET_Z900_G5
32 # if defined __s390x__
44 # endif /* ! defined __s390x__ */
52 #endif /* ! defined __s390x__ */
61 larl %r5,.L_Z900_G5_18
63 # define Z900_G5_EX_D 0
67 # define Z900_G5_EX_D .L_Z900_G5_18-.L_Z900_G5_19
70 #endif /* ! defined __s390x__ */
74 ex %r4,Z900_G5_EX_D(%r5)
80 BRCTG %r3,.L_Z900_G5_14
90 #endif /* HAVE_MEMSET_Z900_G5 */
96 .machinemode "zarch_nohighgprs"
97 # if !defined __s390x__
99 # endif /* !defined __s390x__ */
106 cgijlh %r5,0,.L_Z10_15
112 cgfi %r5,163840 # Switch to mvcle for >40MB
116 mvc 1(256,%r1),0(%r1)
123 #endif /* HAVE_MEMSET_Z10 */
129 .machinemode "zarch_nohighgprs"
130 # if !defined __s390x__
132 # endif /* !defined __s390x__ */
134 jl .L_Z196_4 # n == 0
136 je .L_Z196_4 # n == 1
139 risbg %r5,%r4,8,128+63,56 # r5 = n / 256
140 jne .L_Z196_1 # Jump away if r5 != 0
147 jh __memset_mvcle # Switch to mvcle for >256MB
150 mvc 1(255,%r1),0(%r1)
159 #endif /* HAVE_MEMSET_Z196 */
161 #if HAVE_MEMSET_MVCLE
162 ENTRY(__memset_mvcle)
163 aghi %r4,2 # take back the change done by the caller
164 lgr %r0,%r2 # save source address
165 lgr %r1,%r3 # move pad byte to R1
166 lgr %r3,%r4 # move length to r3
167 sgr %r4,%r4 # no source for MVCLE, only a pad byte
169 .L0: mvcle %r2,%r4,0(%r1) # thats it, MVCLE is your friend
171 lgr %r2,%r0 # return value is source address
175 #endif /* HAVE_MEMSET_MVCLE */
177 #if ! HAVE_MEMSET_IFUNC
178 /* If we don't use ifunc, define an alias for memset here.
179 Otherwise see sysdeps/s390/memset.c. */
180 strong_alias (MEMSET_DEFAULT, memset)
183 #if defined SHARED && IS_IN (libc)
184 /* Defines the internal symbol.
185 Compare to libc_hidden_builtin_def (memset) in string/memset.c. */
186 strong_alias (MEMSET_DEFAULT, __GI_memset)