root/arch/ia64/lib/strncpy_from_user.S

/* [<][>][^][v][top][bottom][index][help] */
   1 /* SPDX-License-Identifier: GPL-2.0 */
   2 /*
   3  * Just like strncpy() except that if a fault occurs during copying,
   4  * -EFAULT is returned.
   5  *
   6  * Inputs:
   7  *      in0:    address of destination buffer
   8  *      in1:    address of string to be copied
   9  *      in2:    length of buffer in bytes
  10  * Outputs:
  11  *      r8:     -EFAULT in case of fault or number of bytes copied if no fault
  12  *
  13  * Copyright (C) 1998-2001 Hewlett-Packard Co
  14  * Copyright (C) 1998-2001 David Mosberger-Tang <davidm@hpl.hp.com>
  15  *
  16  * 00/03/06 D. Mosberger Fixed to return proper return value (bug found by
  17  *                       by Andreas Schwab <schwab@suse.de>).
  18  */
  19 
  20 #include <asm/asmmacro.h>
  21 #include <asm/export.h>
  22 
  23 GLOBAL_ENTRY(__strncpy_from_user)
  24         alloc r2=ar.pfs,3,0,0,0
  25         mov r8=0
  26         mov r9=in1
  27         ;;
  28         add r10=in1,in2
  29         cmp.eq p6,p0=r0,in2
  30 (p6)    br.ret.spnt.many rp
  31 
  32         // XXX braindead copy loop---this needs to be optimized
  33 .Loop1:
  34         EX(.Lexit, ld1 r8=[in1],1)
  35         ;;
  36         EX(.Lexit, st1 [in0]=r8,1)
  37         cmp.ne p6,p7=r8,r0
  38         ;;
  39 (p6)    cmp.ne.unc p8,p0=in1,r10
  40 (p8)    br.cond.dpnt.few .Loop1
  41         ;;
  42 (p6)    mov r8=in2              // buffer filled up---return buffer length
  43 (p7)    sub r8=in1,r9,1         // return string length (excluding NUL character)
  44 [.Lexit:]
  45         br.ret.sptk.many rp
  46 END(__strncpy_from_user)
  47 EXPORT_SYMBOL(__strncpy_from_user)

/* [<][>][^][v][top][bottom][index][help] */