2 * String handling functions for PowerPC.
4 * Copyright (C) 1996 Paul Mackerras.
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
11 #include <linux/config.h>
12 #include <asm/processor.h>
13 #include <asm/errno.h>
14 #include <asm/ppc_asm.h>
17 .stabs "arch/powerpc/lib/",N_SO,0,0,0f
18 .stabs "string.S",N_SO,0,0,0f
21 .section __ex_table,"a"
40 /* This clears out any unused part of the destination buffer,
41 just as the libc version does. -- paulus */
51 bdnzf 2,1b /* dec ctr, branch if ctr != 0 && !cr0.eq */
52 bnelr /* if we didn't hit a null char, we're done */
54 cmpwi 0,r5,0 /* any space left in destination buffer? */
55 beqlr /* we know r0 == 0 here */
56 2: stbu r0,1(r6) /* clear it out if so */
118 _GLOBAL(__clear_user)
124 /* clear a single word */
127 /* clear word sized chunks */
137 /* clear byte sized chunks */
154 .section __ex_table,"a"
160 _GLOBAL(__strncpy_from_user)
169 bdnzf 2,1b /* dec ctr, branch if ctr != 0 && !cr0.eq */
177 .section __ex_table,"a"
181 /* r3 = str, r4 = len (> 0), r5 = top (highest addr) */
182 _GLOBAL(__strnlen_user)
184 subf r6,r7,r5 /* top+1 - str */
188 0: mtctr r6 /* ctr = min(len, top - str) */
189 1: lbzu r0,1(r7) /* get next byte */
191 bdnzf 2,1b /* loop if --ctr != 0 && byte != 0 */
193 subf r3,r3,r7 /* number of bytes we have looked at */
194 beqlr /* return if we found a 0 byte */
195 cmpw 0,r3,r4 /* did we look at all len bytes? */
196 blt 99f /* if not, must have hit top */
197 addi r3,r4,1 /* return len + 1 to indicate no null found */
199 99: li r3,0 /* bad address, return 0 */
202 .section __ex_table,"a"