linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: nicolas.pitre@linaro.org (Nicolas Pitre)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2] lib/decompress_unxz.c: removing all memory helper functions
Date: Tue, 12 Jun 2012 13:26:22 -0400 (EDT)	[thread overview]
Message-ID: <alpine.LFD.2.02.1206121316190.23555@xanadu.home> (raw)
In-Reply-To: <20120612191804.4211462a@tukaani.org>

On Tue, 12 Jun 2012, Lasse Collin wrote:

> On 2012-06-11 T Makphaibulchoke wrote:
> > +#ifndef __HAVE_PREBOOT_ARCH_MEMMOVE
> > +void *memmove(void *__dest, __const void *__src, size_t count)
> > +{
> > +	unsigned char *d = __dest;
> > +	const unsigned char *s = __src;
> > +
> > +	if (__dest == __src)
> > +		return __dest;
> > +
> > +	if (__dest < __src)
> > +		return memcpy(__dest, __src, count);
> > +
> > +	while (count--)
> > +		d[count] = s[count];
> > +	return __dest;
> > +}
> > +#endif
> 
> The use of memcpy when __dest < __src is OK with some memcpy
> implementations, but in a generic case it isn't guaranteed to work.

Of course, if the memcpy implementation is also provided along with this 
memmove code, as it was the case on ARM before this patch, then you can 
guarantee it.  And if that memcpy() happens to be slightly more 
optimized then this is a win.

> I think it would be better to just copy memmove from lib/string.c.

Instead of copying, maybe this would be much better to make the content 
of lib/string.c usable in a pre-boot environment.


Nicolas

  reply	other threads:[~2012-06-12 17:26 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-12  3:05 [PATCH v2] lib/decompress_unxz.c: removing all memory helper functions T Makphaibulchoke
2012-06-12  3:16 ` H. Peter Anvin
2012-06-12 14:35   ` Russell King - ARM Linux
2012-06-14 13:47     ` Russell King - ARM Linux
2012-06-14 14:35       ` H. Peter Anvin
2012-06-14 15:44         ` Russell King - ARM Linux
2012-06-14 16:15           ` H. Peter Anvin
2012-06-13  9:32   ` Martin Schwidefsky
2012-06-14 18:23   ` Russell King - ARM Linux
2012-06-12  3:27 ` Paul Mundt
2012-06-12 16:18 ` Lasse Collin
2012-06-12 17:26   ` Nicolas Pitre [this message]
2012-06-12 17:30     ` H. Peter Anvin
2012-06-12 17:40       ` Joe Perches
2012-06-12 19:45         ` Thavatchai Makphaibulcboke
2012-06-12 17:44       ` Nicolas Pitre
2012-06-12 17:48         ` H. Peter Anvin
2012-06-12 17:49           ` H. Peter Anvin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LFD.2.02.1206121316190.23555@xanadu.home \
    --to=nicolas.pitre@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).