arm64: dts: Revert "specify console via command line"
[linux/fpc-iii.git] / arch / nios2 / lib / memmove.c
blob866c021f278c3e9407064abcbe1abf8410f73506
1 /*
2 * Copyright (C) 2011 Tobias Klauser <tklauser@distanz.ch>
3 * Copyright (C) 2004 Microtronix Datacom Ltd
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 */
10 #include <linux/types.h>
11 #include <linux/string.h>
13 void *memmove(void *d, const void *s, size_t count)
15 unsigned long dst, src;
17 if (!count)
18 return d;
20 if (d < s) {
21 dst = (unsigned long) d;
22 src = (unsigned long) s;
24 if ((count < 8) || ((dst ^ src) & 3))
25 goto restup;
27 if (dst & 1) {
28 *(char *)dst++ = *(char *)src++;
29 count--;
31 if (dst & 2) {
32 *(short *)dst = *(short *)src;
33 src += 2;
34 dst += 2;
35 count -= 2;
37 while (count > 3) {
38 *(long *)dst = *(long *)src;
39 src += 4;
40 dst += 4;
41 count -= 4;
43 restup:
44 while (count--)
45 *(char *)dst++ = *(char *)src++;
46 } else {
47 dst = (unsigned long) d + count;
48 src = (unsigned long) s + count;
50 if ((count < 8) || ((dst ^ src) & 3))
51 goto restdown;
53 if (dst & 1) {
54 src--;
55 dst--;
56 count--;
57 *(char *)dst = *(char *)src;
59 if (dst & 2) {
60 src -= 2;
61 dst -= 2;
62 count -= 2;
63 *(short *)dst = *(short *)src;
65 while (count > 3) {
66 src -= 4;
67 dst -= 4;
68 count -= 4;
69 *(long *)dst = *(long *)src;
71 restdown:
72 while (count--) {
73 src--;
74 dst--;
75 *(char *)dst = *(char *)src;
79 return d;