Update copyright notices with scripts/update-copyrights
[glibc.git] / sysdeps / sparc / sparc32 / strlen.S
blob75a246072fd4e562c405f6974de64742aaf1bb3a
1 /* Determine the length of a string.
2    For SPARC v7.
3    Copyright (C) 1996-2014 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>.
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.
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.
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    <http://www.gnu.org/licenses/>.  */
22 #include <sysdep.h>
24         .text
25         .align          4
27 ENTRY(strlen)
28         mov     %o0, %o1
29         andn    %o0, 0x3, %o0
31         ld      [%o0], %o5
32         and     %o1, 0x3, %g1
33         mov     -1, %g5
35         sethi   %hi(0x01010101), %o2
36         sll     %g1, 3, %g1
38         or      %o2, %lo(0x01010101), %o2
39         srl     %g5, %g1, %g2
41         orn     %o5, %g2, %o5
42         sll     %o2, 7, %o3
43 10:     add     %o0, 4, %o0
45         andn    %o3, %o5, %g1
46         sub     %o5, %o2, %g2
48         andcc   %g1, %g2, %g0
49         be,a    10b
50          ld     [%o0], %o5
52         srl     %o5, 24, %g1
54         andcc   %g1, 0xff, %g0
55         be      90f
56          sub    %o0, 4, %o0
58         srl     %o5, 16, %g2
60         andcc   %g2, 0xff, %g0
61         be      90f
62          add    %o0, 1, %o0
64         srl     %o5, 8, %g1
66         andcc   %g1, 0xff, %g0
67         be      90f
68          add    %o0, 1, %o0
70         add     %o0, 1, %o0
72 90:     retl
73          sub    %o0, %o1, %o0
74 END(strlen)
75 libc_hidden_builtin_def (strlen)