1,5 → 1,6 |
/* |
* Copyright (C) 2001-2004 Jakub Jermar |
* Copyright (C) 2005 HelenOS project |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
212,41 → 213,4 |
return v; |
} |
|
/** Copy memory |
* |
* Copy a given number of bytes (3rd argument) |
* from the memory location defined by 2nd argument |
* to the memory location defined by 1st argument. |
* The memory areas cannot overlap. |
* |
* @param destination |
* @param source |
* @param number of bytes |
* @return destination |
*/ |
static inline void * memcpy(void * dst, const void * src, size_t cnt) |
{ |
__u32 d0, d1, d2; |
|
__asm__ __volatile__( |
/* copy all full dwords */ |
"rep movsl\n\t" |
/* load count again */ |
"movl %4, %%ecx\n\t" |
/* ecx = ecx mod 4 */ |
"andl $3, %%ecx\n\t" |
/* are there last <=3 bytes? */ |
"jz 1f\n\t" |
/* copy last <=3 bytes */ |
"rep movsb\n\t" |
/* exit from asm block */ |
"1:\n" |
: "=&c" (d0), "=&D" (d1), "=&S" (d2) |
: "0" (cnt / 4), "g" (cnt), "1" ((__u32) dst), "2" ((__u32) src) |
: "memory"); |
|
return dst; |
} |
|
|
#endif |