]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/sparc/sparc32/stpcpy.S
Update copyright notices with scripts/update-copyrights
[thirdparty/glibc.git] / sysdeps / sparc / sparc32 / stpcpy.S
CommitLineData
ae6b8730
RH
1/* Copy SRC to DEST returning the address of the terminating '\0' in DEST.
2 For SPARC v7.
d4697bc9 3 Copyright (C) 1996-2014 Free Software Foundation, Inc.
ae6b8730
RH
4 This file is part of the GNU C Library.
5 Contributed by Jakub Jelinek <jj@ultra.linux.cz>.
6
7 The GNU C Library is free software; you can redistribute it and/or
41bdb6e2
AJ
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
ae6b8730
RH
11
12 The GNU C Library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
41bdb6e2 15 Lesser General Public License for more details.
ae6b8730 16
41bdb6e2 17 You should have received a copy of the GNU Lesser General Public
59ba27a6
PE
18 License along with the GNU C Library; if not, see
19 <http://www.gnu.org/licenses/>. */
ae6b8730
RH
20
21#include <sysdep.h>
22
23 /* Normally, this uses ((xword - 0x01010101) & 0x80808080) test
24 to find out if any byte in xword could be zero. This is fast, but
25 also gives false alarm for any byte in range 0x81-0xff. It does
26 not matter for correctness, as if this test tells us there could
27 be some zero byte, we check it byte by byte, but if bytes with
28 high bits set are common in the strings, then this will give poor
29 performance. You can #define EIGHTBIT_NOT_RARE and the algorithm
30 will use one tick slower, but more precise test
31 ((xword - 0x01010101) & (~xword) & 0x80808080),
32 which does not give any false alarms (but if some bits are set,
33 one cannot assume from it which bytes are zero and which are not).
34 It is yet to be measured, what is the correct default for glibc
35 in these days for an average user.
36 */
37
38 .text
39 .align 4
043cee37
RM
40
41ENTRY(__stpcpy)
42 andcc %o1, 3, %g0
43 be 20f
44 sethi %hi(0x80808080), %o4
45
46 ldub [%o1], %o5
ae6b8730
RH
47 stb %o5, [%o0]
48 cmp %o5, 0
49 add %o0, 1, %o0
50 be 1f
51 add %o1, 1, %o1
52 andcc %o1, 3, %g0
53 be 4f
54 or %o4, %lo(0x80808080), %o3
55 ldub [%o1], %o5
56 stb %o5, [%o0]
57 cmp %o5, 0
58 add %o0, 1, %o0
59 be 1f
60 add %o1, 1, %o1
61 andcc %o1, 3, %g0
62 be 5f
63 sethi %hi(0x01010101), %o4
64 ldub [%o1], %o5
65 stb %o5, [%o0]
66 cmp %o5, 0
67 add %o0, 1, %o0
68 be 1f
69 add %o1, 1, %o1
70 b 6f
71 or %o4, %lo(0x01010101), %o2
721: retl
73 add %o0, -1, %o0
74
043cee37 7520: or %o4, %lo(0x80808080), %o3
ae6b8730
RH
764: sethi %hi(0x01010101), %o4
775: or %o4, %lo(0x01010101), %o2
786: andcc %o0, 3, %g0
79 bne 16f
80 sub %g0, 4, %g1
6111cd0e 81
ae6b8730
RH
8211: add %g1, 4, %g1
83 ld [%o1 + %g1], %o5
84 sub %o5, %o2, %o4
85#ifdef EIGHTBIT_NOT_RARE
86 andn %o4, %o5, %o4
87#endif
88 andcc %o4, %o3, %g0
89 be,a 11b
90 st %o5, [%o0 + %g1]
91
92 /* Check every byte. */
93 srl %o5, 24, %g5
94 andcc %g5, 0xff, %g0
95 be 14f
96 srl %o5, 16, %g5
97 andcc %g5, 0xff, %g0
98 be 13f
99 srl %o5, 8, %g5
100 andcc %g5, 0xff, %g0
101 be 12f
102 andcc %o5, 0xff, %g0
103 bne 11b
104 st %o5, [%o0 + %g1]
105 add %o0, %g1, %o0
106 retl
107 add %o0, 3, %o0
10812: srl %o5, 16, %o5
109 sth %o5, [%o0 + %g1]
110 add %g1, 2, %g1
111 stb %g0, [%o0 + %g1]
112 retl
113 add %o0, %g1, %o0
11413: srl %o5, 16, %o5
115 sth %o5, [%o0 + %g1]
116 add %g1, 1, %g1
117 retl
118 add %o0, %g1, %o0
11914: stb %g0, [%o0 + %g1]
120 retl
121 add %o0, %g1, %o0
122
12315: srl %o5, 24, %o4
124 srl %o5, 16, %g1
125 stb %o4, [%o0]
126 srl %o5, 8, %g4
127 stb %g1, [%o0 + 1]
128 stb %g4, [%o0 + 2]
129 stb %o5, [%o0 + 3]
130 add %o0, 4, %o0
13116: ld [%o1], %o5
132 sub %o5, %o2, %o4
133 andcc %o4, %o3, %g0
134 be 15b
135 add %o1, 4, %o1
136
137 /* Check every byte. */
138 srl %o5, 24, %g5
139 andcc %g5, 0xff, %g4
140 be 19f
141 stb %g4, [%o0]
142 srl %o5, 16, %g5
143 andcc %g5, 0xff, %g4
144 be 18f
145 stb %g4, [%o0 + 1]
146 srl %o5, 8, %g5
147 andcc %g5, 0xff, %g4
148 be 17f
149 stb %g4, [%o0 + 2]
150 andcc %o5, 0xff, %g4
151 stb %g4, [%o0 + 3]
152 bne 16b
153 add %o0, 4, %o0
154 retl
155 sub %o0, 1, %o0
15617: retl
157 add %o0, 2, %o0
15818: retl
159 add %o0, 1, %o0
16019: retl
161 nop
162END(__stpcpy)
163
1ab18a5b 164weak_alias (__stpcpy, stpcpy)
6111cd0e 165libc_hidden_def (__stpcpy)
3dbfd811 166libc_hidden_builtin_def (stpcpy)