LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1198|回复: 6

请问如何找到memcpy()函数的实现

[复制链接]
发表于 2004-10-30 21:26:35 | 显示全部楼层 |阅读模式
我下了glic-2.2,可是找到不到memcpy()在哪个目录/文件
发表于 2004-10-30 22:40:28 | 显示全部楼层
内核源码的include/asm/string.h中
发表于 2006-6-19 14:15:30 | 显示全部楼层
extern void * memcpy(void *, const void *, __kernel_size_t);
只有声明,没有定义呀!
回复 支持 反对

使用道具 举报

发表于 2006-6-19 21:44:30 | 显示全部楼层
string.c
回复 支持 反对

使用道具 举报

发表于 2006-6-19 21:59:51 | 显示全部楼层
Post by dxzhang
内核源码的include/asm/string.h中

内核源代码里的实现,除非写内核模块,否则是用不到的
不过参考一下却是可以的
回复 支持 反对

使用道具 举报

发表于 2006-6-20 10:18:25 | 显示全部楼层
static inline void *
__memcpy(void * to, const void * from, size_t n)
{
int d0, d1, d2;
__asm__ __volatile__(
        "rep ; movsl\n\t"
        "testb $2,%b4\n\t"
        "je 1f\n\t"
        "movsw\n"
        "1:\ttestb $1,%b4\n\t"
        "je 2f\n\t"
        "movsb\n"
        "2:"
        : "=&c" (d0), "=&D" (d1), "=&S" (d2)
        :"0" (n/4), "q" (n),"1" ((long) to),"2" ((long) from)
        : "memory");
return (to);
}
回复 支持 反对

使用道具 举报

发表于 2006-6-21 10:02:01 | 显示全部楼层

  1. #ifndef __HAVE_ARCH_MEMCPY
  2. /**
  3. * memcpy - Copy one area of memory to another
  4. * @dest: Where to copy to
  5. * @src: Where to copy from
  6. * @count: The size of the area.
  7. *
  8. * You should not use this function to access IO space, use memcpy_toio()
  9. * or memcpy_fromio() instead.
  10. */
  11. void * memcpy(void * dest,const void *src,size_t count)
  12. {
  13.         char *tmp = (char *) dest, *s = (char *) src;

  14.         while (count--)
  15.                 *tmp++ = *s++;

  16.         return dest;
  17. }
  18. EXPORT_SYMBOL(memcpy);
  19. #endif
复制代码
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表