Update copyright notices with scripts/update-copyrights.
[glibc.git] / sysdeps / sparc / sparc64 / strlen.S
blobe2701703572ba821bf263ac88da3ecd465fbe277
1 /* Determine the length of a string.  For SPARC v9.
2    Copyright (C) 1998-2013 Free Software Foundation, Inc.
3    This file is part of the GNU C Library.
4    Contributed by Jan Vondrak <jvon4518@ss1000.ms.mff.cuni.cz>,
5                   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         .register       %g2, #scratch
25         .register       %g3, #scratch
27         .text
28         .align          32
29 ENTRY(strlen)
30         mov     %o0, %o1
31         andn    %o0, 0x7, %o0
33         ldx     [%o0], %o5
34         and     %o1, 0x7, %g1
35         mov     -1, %g5
37         sethi   %hi(0x01010101), %o2
38         sll     %g1, 3, %g1
40         or      %o2, %lo(0x01010101), %o2
41         srlx    %g5, %g1, %o3
43         sllx    %o2, 32, %g1
44         sethi   %hi(0x0000ff00), %g5
46         orn     %o5, %o3, %o5
47         or      %o2, %g1, %o2
49         sllx    %o2, 7, %o3
50 10:     add     %o0, 8, %o0
52         andn    %o3, %o5, %g1
53         sub     %o5, %o2, %g2
55         andcc   %g1, %g2, %g0
56         be,a,pt %xcc, 10b
57          ldx    [%o0], %o5
58         srlx    %o5, 32, %g1
60         andn    %o3, %g1, %o4
61         sub     %g1, %o2, %g2
63         add     %o0, 4, %g3
64         andcc   %o4, %g2, %g0
65         movne   %icc, %g1, %o5
67         move    %icc, %g3, %o0
68         or      %g5, %lo(0x0000ff00), %g5
69         mov     3 - 8, %g2
71         andcc   %o5, %g5, %g0
72         srlx    %o5, 16, %g1
73         move    %icc, 2 - 8, %g2
75         andcc   %g1, 0xff, %g0
76         srl     %o5, 24, %o5
77         move    %icc, 1 - 8, %g2
79         movrz   %o5, 0 - 8, %g2
80         sub     %o0, %o1, %o0
82         retl
83          add    %o0, %g2, %o0
84 END(strlen)
85 libc_hidden_builtin_def (strlen)