Update copyright dates with scripts/update-copyrights.
[glibc.git] / sysdeps / sh / strlen.S
blob37424a2c1d3481e5fe9c6dd325a465516ec68dd9
1 /* Copyright (C) 1999-2015 Free Software Foundation, Inc.
2    This file is part of the GNU C Library.
3    Contributed by Kazumoto Kojima <kkojima@rr.iij4u.or.jp>
5    The GNU C Library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public
7    License as published by the Free Software Foundation; either
8    version 2.1 of the License, or (at your option) any later version.
10    The GNU C Library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Lesser General Public License for more details.
15    You should have received a copy of the GNU Lesser General Public
16    License along with the GNU C Library; if not, see
17    <http://www.gnu.org/licenses/>.  */
19 #include <sysdep.h>
21 /* size_t strlen (const char *s)  */
23 ENTRY(strlen)
24         mov     r4, r0
25         and     #3, r0
26         tst     r0, r0
27         bt/s    1f
28         mov     #0, r2
30         add     #-1, r0
31         shll2   r0
32         shll    r0
33         braf    r0
34         nop
36         mov.b   @r4+, r1
37         tst     r1, r1
38         bt      8f
39         add     #1, r2
41         mov.b   @r4+, r1
42         tst     r1, r1
43         bt      8f
44         add     #1, r2
46         mov.b   @r4+, r1
47         tst     r1, r1
48         bt      8f
49         add     #1, r2
52         mov     #0, r3
54         mov.l   @r4+, r1
55         cmp/str r3, r1
56         bf/s    2b
57         add     #4, r2
59         add     #-4, r2
60 #ifdef __BIG_ENDIAN__
61         swap.b  r1, r1
62         swap.w  r1, r1
63         swap.b  r1, r1
64 #endif
65         extu.b  r1, r0
66         tst     r0, r0
67         bt/s    8f
68         shlr8   r1
69         add     #1, r2
70         extu.b  r1, r0
71         tst     r0, r0
72         bt/s    8f
73         shlr8   r1
74         add     #1, r2
75         extu.b  r1, r0
76         tst     r0, r0
77         bt      8f
78         add     #1, r2
80         rts
81         mov     r2, r0
82 END(strlen)
83 libc_hidden_builtin_def (strlen)