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

Linux/Unix编程

开发平台:

Unix_Linux

  1. /* Normally compiler builtins are used, but sometimes the compiler calls out
  2.    of line code. Based on asm-i386/string.h.
  3.  */
  4. #define _STRING_C
  5. #include <linux/string.h>
  6. #undef memmove
  7. void *memmove(void * dest,const void *src,size_t count)
  8. {
  9. if (dest < src) { 
  10. __inline_memcpy(dest,src,count);
  11. } else {
  12. /* Could be more clever and move longs */
  13. unsigned long d0, d1, d2;
  14. __asm__ __volatile__(
  15. "stdnt"
  16. "repnt"
  17. "movsbnt"
  18. "cld"
  19. : "=&c" (d0), "=&S" (d1), "=&D" (d2)
  20. :"0" (count),
  21. "1" (count-1+(const char *)src),
  22. "2" (count-1+(char *)dest)
  23. :"memory");
  24. }
  25. return dest;