Rev 534 | Rev 1264 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 534 | Rev 882 | ||
---|---|---|---|
Line 27... | Line 27... | ||
27 | */ |
27 | */ |
28 | 28 | ||
29 | #include <memstr.h> |
29 | #include <memstr.h> |
30 | #include <arch/types.h> |
30 | #include <arch/types.h> |
31 | 31 | ||
32 | - | ||
33 | /** Copy block of memory |
32 | /** Copy block of memory |
34 | * |
33 | * |
35 | * Copy cnt bytes from src address to dst address. |
34 | * Copy cnt bytes from src address to dst address. |
36 | * The copying is done byte-by-byte. The source |
35 | * The copying is done word-by-word and then byte-by-byte. |
37 | * and destination memory areas cannot overlap. |
36 | * The source and destination memory areas cannot overlap. |
38 | * |
37 | * |
39 | * @param src Origin address to copy from. |
38 | * @param src Origin address to copy from. |
40 | * @param dst Origin address to copy to. |
39 | * @param dst Origin address to copy to. |
41 | * @param cnt Number of bytes to copy. |
40 | * @param cnt Number of bytes to copy. |
42 | * |
41 | * |
43 | */ |
42 | */ |
44 | void *_memcpy(void * dst, const void *src, size_t cnt) |
43 | void *_memcpy(void * dst, const void *src, size_t cnt) |
45 | { |
44 | { |
46 | int i; |
45 | int i, j; |
47 | 46 | ||
48 | for (i=0; i<cnt; i++) |
47 | for (i = 0; i < cnt/sizeof(__native); i++) |
49 | *((__u8 *) (dst + i)) = *((__u8 *) (src + i)); |
48 | ((__native *) dst)[i] = ((__native *) src)[i]; |
- | 49 | ||
- | 50 | for (j = 0; j < cnt%sizeof(__native); j++) |
|
- | 51 | ((__u8 *)(((__native *) dst) + i))[j] = ((__u8 *)(((__native *) src) + i))[j]; |
|
50 | 52 | ||
51 | return (char *)src; |
53 | return (char *)src; |
52 | } |
54 | } |
53 | 55 | ||
54 | /** Fill block of memory |
56 | /** Fill block of memory |