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