]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/sh/strlen.S
Update.
[thirdparty/glibc.git] / sysdeps / sh / strlen.S
CommitLineData
85dd1003 1/* Copyright (C) 1999, 2000, 2003 Free Software Foundation, Inc.
3846ef75
UD
2 This file is part of the GNU C Library.
3 Contributed by Kazumoto Kojima <kkojima@rr.iij4u.or.jp>
4
5 The GNU C Library is free software; you can redistribute it and/or
41bdb6e2
AJ
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.
3846ef75
UD
9
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
41bdb6e2 13 Lesser General Public License for more details.
3846ef75 14
41bdb6e2
AJ
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
3846ef75
UD
19
20#include <sysdep.h>
21#include <endian.h>
22
23/* size_t strlen (const char *s) */
24
25ENTRY(strlen)
26 mov r4, r0
27 and #3, r0
28 tst r0, r0
29 bt/s 1f
30 mov #0, r2
31
32 add #-1, r0
33 shll2 r0
34 shll r0
35 braf r0
36 nop
37
38 mov.b @r4+, r1
39 tst r1, r1
40 bt 8f
41 add #1, r2
42
43 mov.b @r4+, r1
44 tst r1, r1
45 bt 8f
46 add #1, r2
47
48 mov.b @r4+, r1
49 tst r1, r1
50 bt 8f
51 add #1, r2
52
531:
54 mov #0, r3
552:
56 mov.l @r4+, r1
57 cmp/str r3, r1
58 bf/s 2b
59 add #4, r2
60
61 add #-4, r2
62#if __BYTE_ORDER == __BIG_ENDIAN
63 swap.b r1, r1
64 swap.w r1, r1
65 swap.b r1, r1
66#endif
67 extu.b r1, r0
68 tst r0, r0
69 bt/s 8f
70 shlr8 r1
71 add #1, r2
72 extu.b r1, r0
73 tst r0, r0
74 bt/s 8f
75 shlr8 r1
76 add #1, r2
77 extu.b r1, r0
78 tst r0, r0
79 bt 8f
80 add #1, r2
818:
82 rts
83 mov r2, r0
84END(strlen)
85dd1003 85libc_hidden_builtin_def (strlen)