strlen_user.S 868 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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, 2004 by Ralf Baechle
  7. * Copyright (c) 1999 Silicon Graphics, Inc.
  8. */
  9. #include <asm/asm.h>
  10. #include <asm/asm-offsets.h>
  11. #include <asm/regdef.h>
  12. #define EX(insn,reg,addr,handler) \
  13. 9: insn reg, addr; \
  14. .section __ex_table,"a"; \
  15. PTR 9b, handler; \
  16. .previous
  17. /*
  18. * Return the size of a string (including the ending 0)
  19. *
  20. * Return 0 for error
  21. */
  22. LEAF(__strlen_user_asm)
  23. LONG_L v0, TI_ADDR_LIMIT($28) # pointer ok?
  24. and v0, a0
  25. bnez v0, .Lfault
  26. FEXPORT(__strlen_user_nocheck_asm)
  27. move v0, a0
  28. 1: EX(lb, t0, (v0), .Lfault)
  29. PTR_ADDIU v0, 1
  30. bnez t0, 1b
  31. PTR_SUBU v0, a0
  32. jr ra
  33. END(__strlen_user_asm)
  34. .Lfault: move v0, zero
  35. jr ra