]>
Commit | Line | Data |
---|---|---|
ae6b8730 | 1 | /* Determine the length of a string. For SPARC v9. |
04277e02 | 2 | Copyright (C) 1998-2019 Free Software Foundation, Inc. |
41bdb6e2 | 3 | This file is part of the GNU C Library. |
462a5227 DM |
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>. | |
ae6b8730 RH |
7 | |
8 | The GNU C Library is free software; you can redistribute it and/or | |
41bdb6e2 AJ |
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. | |
ae6b8730 RH |
12 | |
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 | |
41bdb6e2 | 16 | Lesser General Public License for more details. |
ae6b8730 | 17 | |
41bdb6e2 | 18 | You should have received a copy of the GNU Lesser General Public |
59ba27a6 PE |
19 | License along with the GNU C Library; if not, see |
20 | <http://www.gnu.org/licenses/>. */ | |
ae6b8730 RH |
21 | |
22 | #include <sysdep.h> | |
462a5227 DM |
23 | |
24 | .register %g2, #scratch | |
25 | .register %g3, #scratch | |
ae6b8730 RH |
26 | |
27 | .text | |
28 | .align 32 | |
29 | ENTRY(strlen) | |
462a5227 DM |
30 | mov %o0, %o1 |
31 | andn %o0, 0x7, %o0 | |
32 | ||
33 | ldx [%o0], %o5 | |
34 | and %o1, 0x7, %g1 | |
35 | mov -1, %g5 | |
36 | ||
37 | sethi %hi(0x01010101), %o2 | |
38 | sll %g1, 3, %g1 | |
39 | ||
40 | or %o2, %lo(0x01010101), %o2 | |
41 | srlx %g5, %g1, %o3 | |
42 | ||
43 | sllx %o2, 32, %g1 | |
44 | sethi %hi(0x0000ff00), %g5 | |
45 | ||
46 | orn %o5, %o3, %o5 | |
47 | or %o2, %g1, %o2 | |
48 | ||
49 | sllx %o2, 7, %o3 | |
50 | 10: add %o0, 8, %o0 | |
51 | ||
52 | andn %o3, %o5, %g1 | |
53 | sub %o5, %o2, %g2 | |
54 | ||
55 | andcc %g1, %g2, %g0 | |
56 | be,a,pt %xcc, 10b | |
57 | ldx [%o0], %o5 | |
58 | srlx %o5, 32, %g1 | |
59 | ||
60 | andn %o3, %g1, %o4 | |
61 | sub %g1, %o2, %g2 | |
62 | ||
63 | add %o0, 4, %g3 | |
64 | andcc %o4, %g2, %g0 | |
65 | movne %icc, %g1, %o5 | |
66 | ||
67 | move %icc, %g3, %o0 | |
68 | or %g5, %lo(0x0000ff00), %g5 | |
69 | mov 3 - 8, %g2 | |
70 | ||
71 | andcc %o5, %g5, %g0 | |
72 | srlx %o5, 16, %g1 | |
73 | move %icc, 2 - 8, %g2 | |
74 | ||
75 | andcc %g1, 0xff, %g0 | |
76 | srl %o5, 24, %o5 | |
77 | move %icc, 1 - 8, %g2 | |
78 | ||
79 | movrz %o5, 0 - 8, %g2 | |
80 | sub %o0, %o1, %o0 | |
81 | ||
82 | retl | |
83 | add %o0, %g2, %o0 | |
ae6b8730 | 84 | END(strlen) |
85dd1003 | 85 | libc_hidden_builtin_def (strlen) |