strncpy_from_user_32.S 731 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /* strncpy_from_user.S: Sparc strncpy from userspace.
  2. *
  3. * Copyright(C) 1996 David S. Miller
  4. */
  5. #include <linux/linkage.h>
  6. #include <asm/ptrace.h>
  7. #include <asm/errno.h>
  8. .text
  9. /* Must return:
  10. *
  11. * -EFAULT for an exception
  12. * count if we hit the buffer limit
  13. * bytes copied if we hit a null byte
  14. */
  15. ENTRY(__strncpy_from_user)
  16. /* %o0=dest, %o1=src, %o2=count */
  17. mov %o2, %o3
  18. 1:
  19. subcc %o2, 1, %o2
  20. bneg 2f
  21. nop
  22. 10:
  23. ldub [%o1], %o4
  24. add %o0, 1, %o0
  25. cmp %o4, 0
  26. add %o1, 1, %o1
  27. bne 1b
  28. stb %o4, [%o0 - 1]
  29. 2:
  30. add %o2, 1, %o0
  31. retl
  32. sub %o3, %o0, %o0
  33. ENDPROC(__strncpy_from_user)
  34. .section .fixup,#alloc,#execinstr
  35. .align 4
  36. 4:
  37. retl
  38. mov -EFAULT, %o0
  39. .section __ex_table,#alloc
  40. .align 4
  41. .word 10b, 4b