Path: blob/master/arch/ia64/lib/strncpy_from_user.S
10817 views
/*1* Just like strncpy() except that if a fault occurs during copying,2* -EFAULT is returned.3*4* Inputs:5* in0: address of destination buffer6* in1: address of string to be copied7* in2: length of buffer in bytes8* Outputs:9* r8: -EFAULT in case of fault or number of bytes copied if no fault10*11* Copyright (C) 1998-2001 Hewlett-Packard Co12* Copyright (C) 1998-2001 David Mosberger-Tang <[email protected]>13*14* 00/03/06 D. Mosberger Fixed to return proper return value (bug found by15* by Andreas Schwab <[email protected]>).16*/1718#include <asm/asmmacro.h>1920GLOBAL_ENTRY(__strncpy_from_user)21alloc r2=ar.pfs,3,0,0,022mov r8=023mov r9=in124;;25add r10=in1,in226cmp.eq p6,p0=r0,in227(p6) br.ret.spnt.many rp2829// XXX braindead copy loop---this needs to be optimized30.Loop1:31EX(.Lexit, ld1 r8=[in1],1)32;;33EX(.Lexit, st1 [in0]=r8,1)34cmp.ne p6,p7=r8,r035;;36(p6) cmp.ne.unc p8,p0=in1,r1037(p8) br.cond.dpnt.few .Loop138;;39(p6) mov r8=in2 // buffer filled up---return buffer length40(p7) sub r8=in1,r9,1 // return string length (excluding NUL character)41[.Lexit:]42br.ret.sptk.many rp43END(__strncpy_from_user)444546