Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

m68k: remove duplicate memcpy() implementation

Merging the mmu and non-mmu directories we ended up with duplicate
implementations of memcpy(). One is a little more optimized for the
>= 68020 case, but that can easily be inserted into a single
implementation of memcpy(). Clean up the exporting of this symbol
too, otherwise we end up exporting it twice on a no-mmu build.

Signed-off-by: Greg Ungerer <gerg@uclinux.org>
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>

+75 -131
-6
arch/m68k/kernel/m68k_ksyms_no.c
··· 31 31 /* Networking helper routines. */ 32 32 EXPORT_SYMBOL(csum_partial_copy_nocheck); 33 33 34 - /* The following are special because they're not called 35 - explicitly (the C compiler generates them). Fortunately, 36 - their interface isn't gonna change any time soon now, so 37 - it's OK to leave it out of version control. */ 38 - EXPORT_SYMBOL(memcpy); 39 - 40 34 /* 41 35 * libgcc functions - functions that are used internally by the 42 36 * compiler... (prototypes are not correct though, but that
+2 -3
arch/m68k/lib/Makefile
··· 4 4 # 5 5 6 6 lib-y := ashldi3.o ashrdi3.o lshrdi3.o muldi3.o \ 7 - memset.o memmove.o checksum.o 7 + memcpy.o memset.o memmove.o checksum.o 8 8 9 9 ifdef CONFIG_MMU 10 10 lib-y += string.o uaccess.o 11 11 else 12 - lib-y += mulsi3.o divsi3.o udivsi3.o modsi3.o umodsi3.o \ 13 - memcpy.o delay.o 12 + lib-y += mulsi3.o divsi3.o udivsi3.o modsi3.o umodsi3.o delay.o 14 13 endif 15 14
+73 -55
arch/m68k/lib/memcpy.c
··· 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 + */ 1 6 2 - #include <linux/types.h> 7 + #include <linux/module.h> 8 + #include <linux/string.h> 3 9 4 - void * memcpy(void * to, const void * from, size_t n) 10 + void *memcpy(void *to, const void *from, size_t n) 5 11 { 6 - #ifdef CONFIG_COLDFIRE 7 - void *xto = to; 8 - size_t temp; 12 + void *xto = to; 13 + size_t temp, temp1; 9 14 10 - if (!n) 11 - return xto; 12 - if ((long) to & 1) 13 - { 14 - char *cto = to; 15 - const char *cfrom = from; 16 - *cto++ = *cfrom++; 17 - to = cto; 18 - from = cfrom; 19 - n--; 20 - } 21 - if (n > 2 && (long) to & 2) 22 - { 23 - short *sto = to; 24 - const short *sfrom = from; 25 - *sto++ = *sfrom++; 26 - to = sto; 27 - from = sfrom; 28 - n -= 2; 29 - } 30 - temp = n >> 2; 31 - if (temp) 32 - { 33 - long *lto = to; 34 - const long *lfrom = from; 35 - for (; temp; temp--) 36 - *lto++ = *lfrom++; 37 - to = lto; 38 - from = lfrom; 39 - } 40 - if (n & 2) 41 - { 42 - short *sto = to; 43 - const short *sfrom = from; 44 - *sto++ = *sfrom++; 45 - to = sto; 46 - from = sfrom; 47 - } 48 - if (n & 1) 49 - { 50 - char *cto = to; 51 - const char *cfrom = from; 52 - *cto = *cfrom; 53 - } 54 - return xto; 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)); 55 59 #else 56 - const char *c_from = from; 57 - char *c_to = to; 58 - while (n-- > 0) 59 - *c_to++ = *c_from++; 60 - return((void *) to); 60 + for (; temp; temp--) 61 + *lto++ = *lfrom++; 61 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; 62 79 } 80 + EXPORT_SYMBOL(memcpy);
-67
arch/m68k/lib/string.c
··· 20 20 return __kernel_strcpy(dest + __kernel_strlen(dest), src); 21 21 } 22 22 EXPORT_SYMBOL(strcat); 23 - 24 - void *memcpy(void *to, const void *from, size_t n) 25 - { 26 - void *xto = to; 27 - size_t temp, temp1; 28 - 29 - if (!n) 30 - return xto; 31 - if ((long)to & 1) { 32 - char *cto = to; 33 - const char *cfrom = from; 34 - *cto++ = *cfrom++; 35 - to = cto; 36 - from = cfrom; 37 - n--; 38 - } 39 - if (n > 2 && (long)to & 2) { 40 - short *sto = to; 41 - const short *sfrom = from; 42 - *sto++ = *sfrom++; 43 - to = sto; 44 - from = sfrom; 45 - n -= 2; 46 - } 47 - temp = n >> 2; 48 - if (temp) { 49 - long *lto = to; 50 - const long *lfrom = from; 51 - 52 - asm volatile ( 53 - " movel %2,%3\n" 54 - " andw #7,%3\n" 55 - " lsrl #3,%2\n" 56 - " negw %3\n" 57 - " jmp %%pc@(1f,%3:w:2)\n" 58 - "4: movel %0@+,%1@+\n" 59 - " movel %0@+,%1@+\n" 60 - " movel %0@+,%1@+\n" 61 - " movel %0@+,%1@+\n" 62 - " movel %0@+,%1@+\n" 63 - " movel %0@+,%1@+\n" 64 - " movel %0@+,%1@+\n" 65 - " movel %0@+,%1@+\n" 66 - "1: dbra %2,4b\n" 67 - " clrw %2\n" 68 - " subql #1,%2\n" 69 - " jpl 4b" 70 - : "=a" (lfrom), "=a" (lto), "=d" (temp), "=&d" (temp1) 71 - : "0" (lfrom), "1" (lto), "2" (temp)); 72 - to = lto; 73 - from = lfrom; 74 - } 75 - if (n & 2) { 76 - short *sto = to; 77 - const short *sfrom = from; 78 - *sto++ = *sfrom++; 79 - to = sto; 80 - from = sfrom; 81 - } 82 - if (n & 1) { 83 - char *cto = to; 84 - const char *cfrom = from; 85 - *cto = *cfrom; 86 - } 87 - return xto; 88 - } 89 - EXPORT_SYMBOL(memcpy);