Update copyright notices with scripts/update-copyrights
[glibc.git] / sysdeps / s390 / s390-64 / multiarch / memset.S
blob3b962696dde817538eaf81ae92b2a6c4470a3cfa
1 /* Set a block of memory to some byte value.  64 bit S/390 version.
2    Copyright (C) 2012-2014 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    <http://www.gnu.org/licenses/>.  */
20 #include "sysdep.h"
21 #include "asm-syntax.h"
23 /* INPUT PARAMETERS
24      %r2 = address of memory area
25      %r3 = byte to fill memory with
26      %r4 = number of bytes to fill.  */
28        .text
30 #ifndef NOT_IN_libc
32 ENTRY(memset_z196)
33         .machine "z196"
34         ltgr    %r4,%r4
35         je      .L_Z196_4
36         stc     %r3,0(%r2)
37         lgr     %r1,%r2
38         cghi    %r4,1
39         je      .L_Z196_4
40         aghi    %r4,-2
41         srlg    %r5,%r4,8
42         ltgr    %r5,%r5
43         jne     .L_Z196_1
44 .L_Z196_3:
45         exrl    %r4,.L_Z196_17
46 .L_Z196_4:
47         br      %r14
48 .L_Z196_1:
49         cgfi    %r5,1048576
50         jh      memset_mvcle       # Switch to mvcle for >256MB
51 .L_Z196_2:
52         pfd     2,1024(%r1)
53         mvc     1(256,%r1),0(%r1)
54         aghi    %r5,-1
55         la      %r1,256(%r1)
56         jne     .L_Z196_2
57         j       .L_Z196_3
58 .L_Z196_17:
59         mvc     1(1,%r1),0(%r1)
60 END(memset_z196)
62 ENTRY(memset_z10)
63         .machine "z10"
64         cgije   %r4,0,.L_Z10_4
65         stc     %r3,0(%r2)
66         lgr     %r1,%r2
67         cgije   %r4,1,.L_Z10_4
68         aghi    %r4,-2
69         srlg    %r5,%r4,8
70         cgijlh  %r5,0,.L_Z10_15
71 .L_Z10_3:
72         exrl    %r4,.L_Z10_18
73 .L_Z10_4:
74         br      %r14
75 .L_Z10_15:
76         cgfi    %r5,163840          # Switch to mvcle for >40MB
77         jh      memset_mvcle
78 .L_Z10_14:
79         pfd     2,1024(%r1)
80         mvc     1(256,%r1),0(%r1)
81         la      %r1,256(%r1)
82         brctg   %r5,.L_Z10_14
83         j       .L_Z10_3
84 .L_Z10_18:
85         mvc     1(1,%r1),0(%r1)
86 END(memset_z10)
88 ENTRY(memset_mvcle)
89         aghi    %r4,2               # take back the change done by the caller
90         lgr     %r0,%r2             # save source address
91         lgr     %r1,%r3             # move pad byte to R1
92         lgr     %r3,%r4             # move length to r3
93         sgr     %r4,%r4             # no source for MVCLE, only a pad byte
94         sgr     %r5,%r5
95 .L0:    mvcle   %r2,%r4,0(%r1)      # thats it, MVCLE is your friend
96         jo      .L0
97         lgr     %r2,%r0             # return value is source address
98 .L1:
99         br      %r14
100 END(memset_mvcle)
102 #endif
104 #include "../memset.S"
106 #ifdef NOT_IN_libc
107 .globl   memset
108 .set     memset,memset_z900
109 #endif