strnlen_user.S
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:1k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. /*
  2.  * This file is subject to the terms and conditions of the GNU General Public
  3.  * License.  See the file "COPYING" in the main directory of this archive
  4.  * for more details.
  5.  *
  6.  * Copyright (c) 1996, 1998, 1999 by Ralf Baechle
  7.  * Copyright (c) 1999 Silicon Graphics, Inc.
  8.  */
  9. #include <asm/asm.h>
  10. #include <asm/offset.h>
  11. #include <asm/regdef.h>
  12. #include <asm/sgidefs.h>
  13. #define EX(insn,reg,addr,handler)
  14. 9: insn reg, addr;
  15. .section __ex_table,"a";
  16. PTR 9b, handler;
  17. .previous
  18. /*
  19.  * Return the size of a string (including the ending 0)
  20.  *
  21.  * Return 0 for error, len of string but at max a1 otherwise
  22.  *
  23.  * Note: for performance reasons we deliberately accept that a user may
  24.  *       make strlen_user and strnlen_user access the first few KSEG0
  25.  *       bytes.  There's nothing secret there ...
  26.  */
  27. LEAF(__strnlen_user_asm)
  28. lw v0, THREAD_CURDS($28) # pointer ok?
  29. and v0, a0
  30. bltz v0, fault
  31. FEXPORT(__strnlen_user_nocheck_asm)
  32. .type __strnlen_user_nocheck_asm,@function
  33. move v0, a0
  34. addu a1, a0 # stop pointer
  35. .set noreorder
  36. 1: beq v0, a1, 1f # limit reached?
  37.  addiu v0, 1
  38. .set reorder
  39. EX(lb, t0, -1(v0), fault)
  40. bnez t0, 1b
  41. 1: subu v0, a0
  42. jr ra
  43. END(__strnlen_user_asm)
  44. fault: move v0, zero
  45. jr ra