Rev 1264 | Rev 1702 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 1264 | Rev 1612 | ||
|---|---|---|---|
| Line 38... | Line 38... | ||
| 38 | * functions. |
38 | * functions. |
| 39 | */ |
39 | */ |
| 40 | 40 | ||
| 41 | #include <memstr.h> |
41 | #include <memstr.h> |
| 42 | #include <arch/types.h> |
42 | #include <arch/types.h> |
| - | 43 | #include <align.h> |
|
| 43 | 44 | ||
| 44 | /** Copy block of memory |
45 | /** Copy block of memory |
| 45 | * |
46 | * |
| 46 | * Copy cnt bytes from src address to dst address. |
47 | * Copy cnt bytes from src address to dst address. |
| 47 | * The copying is done word-by-word and then byte-by-byte. |
48 | * The copying is done word-by-word and then byte-by-byte. |
| Line 54... | Line 55... | ||
| 54 | */ |
55 | */ |
| 55 | void *_memcpy(void * dst, const void *src, size_t cnt) |
56 | void *_memcpy(void * dst, const void *src, size_t cnt) |
| 56 | { |
57 | { |
| 57 | int i, j; |
58 | int i, j; |
| 58 | 59 | ||
| - | 60 | if (ALIGN_UP((__address) src, sizeof(__native)) != (__address) src || |
|
| - | 61 | ALIGN_UP((__address) dst, sizeof(__native)) != (__address) dst) { |
|
| - | 62 | for (i = 0; i < cnt; i++) |
|
| - | 63 | ((__u8 *) dst)[i] = ((__u8 *) src)[i]; |
|
| - | 64 | } else { |
|
| - | 65 | ||
| 59 | for (i = 0; i < cnt/sizeof(__native); i++) |
66 | for (i = 0; i < cnt/sizeof(__native); i++) |
| 60 | ((__native *) dst)[i] = ((__native *) src)[i]; |
67 | ((__native *) dst)[i] = ((__native *) src)[i]; |
| 61 | 68 | ||
| 62 | for (j = 0; j < cnt%sizeof(__native); j++) |
69 | for (j = 0; j < cnt%sizeof(__native); j++) |
| 63 | ((__u8 *)(((__native *) dst) + i))[j] = ((__u8 *)(((__native *) src) + i))[j]; |
70 | ((__u8 *)(((__native *) dst) + i))[j] = ((__u8 *)(((__native *) src) + i))[j]; |
| - | 71 | } |
|
| 64 | 72 | ||
| 65 | return (char *)src; |
73 | return (char *)src; |
| 66 | } |
74 | } |
| 67 | 75 | ||
| 68 | /** Fill block of memory |
76 | /** Fill block of memory |