public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] Do not copy to same address
@ 2011-04-12  6:58 Matthias Weisser
  2011-04-12  7:05 ` Mike Frysinger
                   ` (2 more replies)
  0 siblings, 3 replies; 22+ messages in thread
From: Matthias Weisser @ 2011-04-12  6:58 UTC (permalink / raw)
  To: u-boot

In some cases (e.g. bootm with a elf payload) there is a in place copy of
data to the same address. Catching this saves some ms while booting.

Signed-off-by: Matthias Weisser <weisserm@arcor.de>
---
 lib/string.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/lib/string.c b/lib/string.c
index b375b81..b8a9203 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -445,6 +445,9 @@ char * bcopy(const char * src, char * dest, int count)
 {
 	char *tmp = dest;
 
+	if (src == dest)
+		return dest;
+
 	while (count--)
 		*tmp++ = *src++;
 
@@ -467,6 +470,9 @@ void * memcpy(void *dest, const void *src, size_t count)
 	unsigned long *dl = (unsigned long *)dest, *sl = (unsigned long *)src;
 	char *d8, *s8;
 
+	if (src == dest)
+		return dest;
+
 	/* while all data is aligned (common case), copy a word at a time */
 	if ( (((ulong)dest | (ulong)src) & (sizeof(*dl) - 1)) == 0) {
 		while (count >= sizeof(*dl)) {
@@ -497,6 +503,9 @@ void * memmove(void * dest,const void *src,size_t count)
 {
 	char *tmp, *s;
 
+	if (src == dest)
+		return dest;
+
 	if (dest <= src) {
 		tmp = (char *) dest;
 		s = (char *) src;
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2011-07-25 22:28 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-12  6:58 [U-Boot] [PATCH] Do not copy to same address Matthias Weisser
2011-04-12  7:05 ` Mike Frysinger
2011-04-12  7:16   ` Matthias Weißer
2011-04-12  7:06 ` Albert ARIBAUD
2011-04-12  7:13   ` Matthias Weißer
2011-04-12  7:27     ` Albert ARIBAUD
2011-04-12  7:49       ` Matthias Weißer
2011-04-14  6:28         ` Albert ARIBAUD
2011-05-23  9:03 ` [U-Boot] [PATCH V2] memcpy/memmove: " Matthias Weisser
2011-05-23 21:07   ` Alexander Holler
2011-05-23 21:55     ` Wolfgang Denk
2011-05-23 22:12       ` Alexander Holler
2011-05-23 22:22         ` Wolfgang Denk
2011-05-23 22:38           ` Alexander Holler
2011-05-24  3:47             ` Mike Frysinger
2011-05-24 13:03               ` Alexander Holler
2011-05-24 19:37           ` Scott Wood
2011-05-24 20:39             ` Wolfgang Denk
2011-06-14  6:18   ` Matthias Weißer
2011-06-16 16:04     ` Matthias Weisser
2011-06-30  6:31     ` Matthias Weißer
2011-07-25 22:28   ` Wolfgang Denk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox