Import 2.3.9pre5
[davej-history.git] / arch / mips / lib / strlen_user.S
blob6e22269c728a6d4587e630623e8b4a139441a900
1 /*
2  * arch/mips/lib/strlen_user.S
3  *
4  * This file is subject to the terms and conditions of the GNU General Public
5  * License.  See the file "COPYING" in the main directory of this archive
6  * for more details.
7  *
8  * Copyright (c) 1996, 1998 by Ralf Baechle
9  *
10  * $Id: strlen_user.S,v 1.2 1998/05/04 09:12:54 ralf Exp $
11  */
12 #include <asm/asm.h>
13 #include <asm/offset.h>
14 #include <asm/regdef.h>
15 #include <asm/sgidefs.h>
17 #define EX(insn,reg,addr,handler)                       \
18 9:      insn    reg, addr;                              \
19         .section __ex_table,"a";                        \
20         PTR     9b, handler;                            \
21         .previous
24  * Return the size of a string (including the ending 0)
25  *
26  * Return 0 for error
27  */
28 LEAF(__strlen_user_nocheck_asm)
29         lw      v0, THREAD_CURDS($28)                   # pointer ok?
30         subu    v0, zero, v0
31         and     v0, a0
32         nor     v0, zero, v0
33         beqz    v0, fault
34 EXPORT(__strlen_user_asm)
35         move            v0, a0
36 1:      EX(lb, t0, (v0), fault)
37         LONG_ADDIU      v0, 1
38         bnez            t0, 1b
39         LONG_SUBU       v0, a0
40         jr              ra
41         END(__strlen_user_nocheck_asm)
43         .section        __ex_table,"a"
44         PTR             1b, fault
45         .previous
47 fault:  move            v0, zero
48         jr              ra