1 /* 2 * This file is subject to the terms and conditions of the GNU General Public 3 * License. See the file COPYING in the main directory of this archive 4 * for more details. 5 */ 6 7 #include <linux/module.h> 8 #include <linux/string.h> 9 10 void *memcpy(void *to, const void *from, size_t n) 11 { 12 void *xto = to; 13 size_t temp, temp1; 14 15 if (!n) 16 return xto; 17 if ((long)to & 1) { 18 char *cto = to; 19 const char *cfrom = from; 20 *cto++ = *cfrom++; 21 to = cto; 22 from = cfrom; 23 n--; 24 } 25 if (n > 2 && (long)to & 2) { 26 short *sto = to; 27 const short *sfrom = from; 28 *sto++ = *sfrom++; 29 to = sto; 30 from = sfrom; 31 n -= 2; 32 } 33 temp = n >> 2; 34 if (temp) { 35 long *lto = to; 36 const long *lfrom = from; 37 #if defined(__mc68020__) || defined(__mc68030__) || \ 38 defined(__mc68040__) || defined(__mc68060__) || defined(__mcpu32__) 39 asm volatile ( 40 " movel %2,%3\n" 41 " andw #7,%3\n" 42 " lsrl #3,%2\n" 43 " negw %3\n" 44 " jmp %%pc@(1f,%3:w:2)\n" 45 "4: movel %0@+,%1@+\n" 46 " movel %0@+,%1@+\n" 47 " movel %0@+,%1@+\n" 48 " movel %0@+,%1@+\n" 49 " movel %0@+,%1@+\n" 50 " movel %0@+,%1@+\n" 51 " movel %0@+,%1@+\n" 52 " movel %0@+,%1@+\n" 53 "1: dbra %2,4b\n" 54 " clrw %2\n" 55 " subql #1,%2\n" 56 " jpl 4b" 57 : "=a" (lfrom), "=a" (lto), "=d" (temp), "=&d" (temp1) 58 : "0" (lfrom), "1" (lto), "2" (temp)); 59 #else 60 for (; temp; temp--) 61 *lto++ = *lfrom++; 62 #endif 63 to = lto; 64 from = lfrom; 65 } 66 if (n & 2) { 67 short *sto = to; 68 const short *sfrom = from; 69 *sto++ = *sfrom++; 70 to = sto; 71 from = sfrom; 72 } 73 if (n & 1) { 74 char *cto = to; 75 const char *cfrom = from; 76 *cto = *cfrom; 77 } 78 return xto; 79 } 80 EXPORT_SYMBOL(memcpy); 81