]> git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/sparc/sparc32/strlen.S
Prefer https to http for gnu.org and fsf.org URLs
[thirdparty/glibc.git] / sysdeps / sparc / sparc32 / strlen.S
1 /* Determine the length of a string.
2 For SPARC v7.
3 Copyright (C) 1996-2019 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
5 Contributed by Jakub Jelinek <jj@ultra.linux.cz> and
6 David S. Miller <davem@davemloft.net>.
7
8 The GNU C Library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Lesser General Public
10 License as published by the Free Software Foundation; either
11 version 2.1 of the License, or (at your option) any later version.
12
13 The GNU C Library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public
19 License along with the GNU C Library; if not, see
20 <https://www.gnu.org/licenses/>. */
21
22 #include <sysdep.h>
23
24 .text
25 .align 4
26
27 ENTRY(strlen)
28 mov %o0, %o1
29 andn %o0, 0x3, %o0
30
31 ld [%o0], %o5
32 and %o1, 0x3, %g1
33 mov -1, %g5
34
35 sethi %hi(0x01010101), %o2
36 sll %g1, 3, %g1
37
38 or %o2, %lo(0x01010101), %o2
39 srl %g5, %g1, %g2
40
41 orn %o5, %g2, %o5
42 sll %o2, 7, %o3
43 10: add %o0, 4, %o0
44
45 andn %o3, %o5, %g1
46 sub %o5, %o2, %g2
47
48 andcc %g1, %g2, %g0
49 be,a 10b
50 ld [%o0], %o5
51
52 srl %o5, 24, %g1
53
54 andcc %g1, 0xff, %g0
55 be 90f
56 sub %o0, 4, %o0
57
58 srl %o5, 16, %g2
59
60 andcc %g2, 0xff, %g0
61 be 90f
62 add %o0, 1, %o0
63
64 srl %o5, 8, %g1
65
66 andcc %g1, 0xff, %g0
67 be 90f
68 add %o0, 1, %o0
69
70 add %o0, 1, %o0
71
72 90: retl
73 sub %o0, %o1, %o0
74 END(strlen)
75 libc_hidden_builtin_def (strlen)