[PATCH] ocfs2: zero_user_page conversion
[wrt350n-kernel.git] / arch / sh64 / lib / memcpy.c
blobfba436a92bfa2e7c5e047cd32164f03142743e8a
1 /*
2 * Copyright (C) 2002 Mark Debbage (Mark.Debbage@superh.com)
4 * May be copied or modified under the terms of the GNU General Public
5 * License. See linux/COPYING for more information.
7 */
9 #include <linux/types.h>
10 #include <asm/string.h>
12 // This is a simplistic optimization of memcpy to increase the
13 // granularity of access beyond one byte using aligned
14 // loads and stores. This is not an optimal implementation
15 // for SH-5 (especially with regard to prefetching and the cache),
16 // and a better version should be provided later ...
18 void *memcpy(void *dest, const void *src, size_t count)
20 char *d = (char *) dest, *s = (char *) src;
22 if (count >= 32) {
23 int i = 8 - (((unsigned long) d) & 0x7);
25 if (i != 8)
26 while (i-- && count--) {
27 *d++ = *s++;
30 if (((((unsigned long) d) & 0x7) == 0) &&
31 ((((unsigned long) s) & 0x7) == 0)) {
32 while (count >= 32) {
33 unsigned long long t1, t2, t3, t4;
34 t1 = *(unsigned long long *) (s);
35 t2 = *(unsigned long long *) (s + 8);
36 t3 = *(unsigned long long *) (s + 16);
37 t4 = *(unsigned long long *) (s + 24);
38 *(unsigned long long *) (d) = t1;
39 *(unsigned long long *) (d + 8) = t2;
40 *(unsigned long long *) (d + 16) = t3;
41 *(unsigned long long *) (d + 24) = t4;
42 d += 32;
43 s += 32;
44 count -= 32;
46 while (count >= 8) {
47 *(unsigned long long *) d =
48 *(unsigned long long *) s;
49 d += 8;
50 s += 8;
51 count -= 8;
55 if (((((unsigned long) d) & 0x3) == 0) &&
56 ((((unsigned long) s) & 0x3) == 0)) {
57 while (count >= 4) {
58 *(unsigned long *) d = *(unsigned long *) s;
59 d += 4;
60 s += 4;
61 count -= 4;
65 if (((((unsigned long) d) & 0x1) == 0) &&
66 ((((unsigned long) s) & 0x1) == 0)) {
67 while (count >= 2) {
68 *(unsigned short *) d = *(unsigned short *) s;
69 d += 2;
70 s += 2;
71 count -= 2;
76 while (count--) {
77 *d++ = *s++;
80 return d;