2 * Just like strncpy() except that if a fault occurs during copying,
6 * in0: address of destination buffer
7 * in1: address of string to be copied
8 * in2: length of buffer in bytes
10 * r8: -EFAULT in case of fault or number of bytes copied if no fault
12 * Copyright (C) 1998-2001 Hewlett-Packard Co
13 * Copyright (C) 1998-2001 David Mosberger-Tang <davidm@hpl.hp.com>
15 * 00/03/06 D. Mosberger Fixed to return proper return value (bug found by
16 * by Andreas Schwab <schwab@suse.de>).
19 #include <asm/asmmacro.h>
21 GLOBAL_ENTRY(__strncpy_from_user)
22 alloc r2=ar.pfs,3,0,0,0
28 (p6) br.ret.spnt.many rp
30 // XXX braindead copy loop---this needs to be optimized
32 EX(.Lexit, ld1 r8=[in1],1)
34 EX(.Lexit, st1 [in0]=r8,1)
37 (p6) cmp.ne.unc p8,p0=in1,r10
38 (p8) br.cond.dpnt.few .Loop1
40 (p6) mov r8=in2 // buffer filled up---return buffer length
41 (p7) sub r8=in1,r9,1 // return string length (excluding NUL character)
44 END(__strncpy_from_user)