]>
Commit | Line | Data |
---|---|---|
2b778ceb | 1 | /* Copyright (C) 2000-2021 Free Software Foundation, Inc. |
9bf55e62 | 2 | Contributed by Richard Henderson (rth@redhat.com) |
9bf55e62 UD |
3 | This file is part of the GNU C Library. |
4 | ||
5 | The GNU C Library is free software; you can redistribute it and/or | |
3214b89b 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. | |
9bf55e62 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 | |
3214b89b | 13 | Lesser General Public License for more details. |
9bf55e62 | 14 | |
3214b89b | 15 | You should have received a copy of the GNU Lesser General Public |
ab84e3ff | 16 | License along with the GNU C Library. If not, see |
5a82c748 | 17 | <https://www.gnu.org/licenses/>. */ |
9bf55e62 | 18 | |
f24a6d08 | 19 | /* Copy no more than N bytes from SRC to DEST, returning the address of |
9bf55e62 UD |
20 | the terminating '\0' in DEST. */ |
21 | ||
22 | #include <sysdep.h> | |
23 | ||
24 | .arch ev6 | |
25 | .set noat | |
26 | .set noreorder | |
27 | .text | |
28 | ||
29 | ENTRY(__stpncpy) | |
30 | ldgp gp, 0(pv) | |
31 | #ifdef PROF | |
32 | lda AT, _mcount | |
33 | jsr AT, (AT), _mcount | |
34 | #endif | |
35 | .prologue 1 | |
36 | ||
37 | mov a0, v0 | |
38 | beq a2, $zerocount | |
39 | ||
40 | .align 4 | |
41 | nop | |
42 | nop | |
43 | jsr t9, __stxncpy # do the work of the copy | |
44 | ||
45 | cttz t8, t4 | |
46 | zapnot t0, t8, t5 | |
47 | andnot a0, 7, a0 | |
48 | bne a2, $multiword # do we have full words left? | |
49 | ||
50 | subq t8, 1, t2 | |
51 | subq t10, 1, t3 | |
52 | cmpult zero, t5, t5 | |
53 | addq a0, t4, v0 | |
54 | ||
55 | or t2, t8, t2 | |
56 | or t3, t10, t3 | |
57 | addq v0, t5, v0 | |
58 | andnot t3, t2, t3 | |
59 | ||
60 | zap t0, t3, t0 | |
61 | nop | |
62 | stq t0, 0(a0) | |
63 | ret | |
64 | ||
65 | $multiword: | |
66 | subq t8, 1, t7 # clear the final bits in the prev word | |
67 | cmpult zero, t5, t5 | |
68 | or t7, t8, t7 | |
69 | zapnot t0, t7, t0 | |
70 | ||
71 | subq a2, 1, a2 | |
72 | stq t0, 0(a0) | |
73 | addq a0, 8, a1 | |
74 | beq a2, 1f # loop over full words remaining | |
75 | ||
76 | nop | |
77 | nop | |
78 | nop | |
79 | blbc a2, 0f | |
80 | ||
81 | stq zero, 0(a1) | |
82 | subq a2, 1, a2 | |
83 | addq a1, 8, a1 | |
84 | beq a2, 1f | |
85 | ||
86 | 0: stq zero, 0(a1) | |
87 | subq a2, 2, a2 | |
88 | nop | |
89 | nop | |
90 | ||
91 | stq zero, 8(a1) | |
92 | addq a1, 16, a1 | |
93 | nop | |
94 | bne a2, 0b | |
95 | ||
96 | 1: ldq t0, 0(a1) # clear the leading bits in the final word | |
97 | subq t10, 1, t7 | |
98 | addq a0, t4, v0 | |
99 | nop | |
100 | ||
101 | or t7, t10, t7 | |
102 | addq v0, t5, v0 | |
103 | zap t0, t7, t0 | |
104 | stq t0, 0(a1) | |
105 | ||
106 | $zerocount: | |
107 | nop | |
108 | nop | |
109 | nop | |
110 | ret | |
111 | ||
112 | END(__stpncpy) | |
113 | ||
d8c656ce | 114 | libc_hidden_def (__stpncpy) |
9bf55e62 | 115 | weak_alias (__stpncpy, stpncpy) |