diff options
author | Paul Mackerras <paulus@samba.org> | 2012-05-27 23:03:47 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-05-28 00:00:07 -0400 |
commit | 1629372caaaf7ef744d3b983be56b99468a68ff8 (patch) | |
tree | 8d3cc2b69ba7b2626b2fe1b3de3ce2a19e45f524 /arch/powerpc/lib | |
parent | 69ea6405980f217557b6a58f70ff60d8d88519a5 (diff) |
powerpc: Use the new generic strncpy_from_user() and strnlen_user()
This is much the same as for SPARC except that we can do the find_zero()
function more efficiently using the count-leading-zeroes instructions.
Tested on 32-bit and 64-bit PowerPC.
Signed-off-by: Paul Mackerras <paulus@samba.org>
Acked-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/powerpc/lib')
-rw-r--r-- | arch/powerpc/lib/string.S | 45 |
1 files changed, 0 insertions, 45 deletions
diff --git a/arch/powerpc/lib/string.S b/arch/powerpc/lib/string.S index 455881a5563f..093d6316435c 100644 --- a/arch/powerpc/lib/string.S +++ b/arch/powerpc/lib/string.S | |||
@@ -160,48 +160,3 @@ _GLOBAL(__clear_user) | |||
160 | PPC_LONG 1b,91b | 160 | PPC_LONG 1b,91b |
161 | PPC_LONG 8b,92b | 161 | PPC_LONG 8b,92b |
162 | .text | 162 | .text |
163 | |||
164 | _GLOBAL(__strncpy_from_user) | ||
165 | addi r6,r3,-1 | ||
166 | addi r4,r4,-1 | ||
167 | cmpwi 0,r5,0 | ||
168 | beq 2f | ||
169 | mtctr r5 | ||
170 | 1: lbzu r0,1(r4) | ||
171 | cmpwi 0,r0,0 | ||
172 | stbu r0,1(r6) | ||
173 | bdnzf 2,1b /* dec ctr, branch if ctr != 0 && !cr0.eq */ | ||
174 | beq 3f | ||
175 | 2: addi r6,r6,1 | ||
176 | 3: subf r3,r3,r6 | ||
177 | blr | ||
178 | 99: li r3,-EFAULT | ||
179 | blr | ||
180 | |||
181 | .section __ex_table,"a" | ||
182 | PPC_LONG 1b,99b | ||
183 | .text | ||
184 | |||
185 | /* r3 = str, r4 = len (> 0), r5 = top (highest addr) */ | ||
186 | _GLOBAL(__strnlen_user) | ||
187 | addi r7,r3,-1 | ||
188 | subf r6,r7,r5 /* top+1 - str */ | ||
189 | cmplw 0,r4,r6 | ||
190 | bge 0f | ||
191 | mr r6,r4 | ||
192 | 0: mtctr r6 /* ctr = min(len, top - str) */ | ||
193 | 1: lbzu r0,1(r7) /* get next byte */ | ||
194 | cmpwi 0,r0,0 | ||
195 | bdnzf 2,1b /* loop if --ctr != 0 && byte != 0 */ | ||
196 | addi r7,r7,1 | ||
197 | subf r3,r3,r7 /* number of bytes we have looked at */ | ||
198 | beqlr /* return if we found a 0 byte */ | ||
199 | cmpw 0,r3,r4 /* did we look at all len bytes? */ | ||
200 | blt 99f /* if not, must have hit top */ | ||
201 | addi r3,r4,1 /* return len + 1 to indicate no null found */ | ||
202 | blr | ||
203 | 99: li r3,0 /* bad address, return 0 */ | ||
204 | blr | ||
205 | |||
206 | .section __ex_table,"a" | ||
207 | PPC_LONG 1b,99b | ||