mem-memcpy-x86-64-lib.c 647 B

12345678910111213141516171819202122232425
  1. /*
  2. * From code in arch/x86/lib/usercopy_64.c, copied to keep tools/ copy
  3. * of the kernel's arch/x86/lib/memcpy_64.s used in 'perf bench mem memcpy'
  4. * happy.
  5. */
  6. #include <linux/types.h>
  7. unsigned long __memcpy_mcsafe(void *dst, const void *src, size_t cnt);
  8. unsigned long mcsafe_handle_tail(char *to, char *from, unsigned len);
  9. unsigned long mcsafe_handle_tail(char *to, char *from, unsigned len)
  10. {
  11. for (; len; --len, to++, from++) {
  12. /*
  13. * Call the assembly routine back directly since
  14. * memcpy_mcsafe() may silently fallback to memcpy.
  15. */
  16. unsigned long rem = __memcpy_mcsafe(to, from, 1);
  17. if (rem)
  18. break;
  19. }
  20. return len;
  21. }