MOXA linux-2.6.x / linux-2.6.19-uc1 from UC-7110-LX-BOOTLOADER-1.9_VERSION-4.2.tgz
[linux-2.6.19-moxart.git] / arch / nios2nommu / lib / memcpy.c
blob6586b99aab1e8481bf3c6b2a0d4ee64b970396ab
1 /*--------------------------------------------------------------------
3 * arch/nios2nommu/lib/memcpy.c
5 * Derived from various works, Alpha, ix86, M68K, Sparc, ...et al
7 * Copyright (C) 2004 Microtronix Datacom Ltd
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
20 * Jun/09/2004 dgt Split out separate source file from string.c
22 ---------------------------------------------------------------------*/
24 #include <linux/types.h>
25 #include <linux/autoconf.h>
26 #include <asm/nios.h>
27 #include <asm/string.h>
29 #ifdef __HAVE_ARCH_MEMCPY
30 void * memcpy(void * d, const void * s, size_t count)
32 unsigned long dst, src;
33 dst = (unsigned long) d;
34 src = (unsigned long) s;
36 if ((count < 8) || ((dst ^ src) & 3))
37 goto restup;
39 if (dst & 1) {
40 *(char*)dst++=*(char*)src++;
41 count--;
43 if (dst & 2) {
44 *(short*)dst=*(short*)src;
45 src += 2;
46 dst += 2;
47 count -= 2;
49 while (count > 3) {
50 *(long*)dst=*(long*)src;
51 src += 4;
52 dst += 4;
53 count -= 4;
56 restup:
57 while (count--)
58 *(char*)dst++=*(char*)src++;
60 return d;
62 #endif