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.
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
;
23 int i
= 8 - (((unsigned long) d
) & 0x7);
26 while (i
-- && count
--) {
30 if (((((unsigned long) d
) & 0x7) == 0) &&
31 ((((unsigned long) s
) & 0x7) == 0)) {
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
;
47 *(unsigned long long *) d
=
48 *(unsigned long long *) s
;
55 if (((((unsigned long) d
) & 0x3) == 0) &&
56 ((((unsigned long) s
) & 0x3) == 0)) {
58 *(unsigned long *) d
= *(unsigned long *) s
;
65 if (((((unsigned long) d
) & 0x1) == 0) &&
66 ((((unsigned long) s
) & 0x1) == 0)) {
68 *(unsigned short *) d
= *(unsigned short *) s
;