linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: dave.martin@linaro.org (Dave Martin)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 4/6] ARM: zImage: gather some string functions into string.c
Date: Wed, 14 Sep 2011 14:13:14 +0100	[thread overview]
Message-ID: <20110914131314.GC2104@arm.com> (raw)
In-Reply-To: <1315978906-15829-5-git-send-email-nico@fluxnic.net>

On Wed, Sep 14, 2011 at 01:41:44AM -0400, Nicolas Pitre wrote:
> From: Nicolas Pitre <nicolas.pitre@linaro.org>
> 
> This is a small subset of string functions needed by commits to come.
> Except for memcpy() which is unchanged from its original location, their
> implementation is meant to be small, and -Os is enforced to prevent gcc
> from doing pointless loop unrolling.
> 
> Signed-off-by: Nicolas Pitre <nicolas.pitre@linaro.org>
> ---
>  arch/arm/boot/compressed/Makefile |    4 +
>  arch/arm/boot/compressed/misc.c   |   42 +------------
>  arch/arm/boot/compressed/string.c |  127 +++++++++++++++++++++++++++++++++++++
>  3 files changed, 132 insertions(+), 41 deletions(-)
>  create mode 100644 arch/arm/boot/compressed/string.c
> 
> diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile
> index 4867647b97..c20ddc69d9 100644
> --- a/arch/arm/boot/compressed/Makefile
> +++ b/arch/arm/boot/compressed/Makefile
> @@ -26,6 +26,10 @@ HEAD	= head.o
>  OBJS	+= misc.o decompress.o
>  FONTC	= $(srctree)/drivers/video/console/font_acorn_8x8.c
>  
> +# string library code (-Os is enforced to keep it much smaller)
> +OBJS		+= string.o
> +CFLAGS_string.o	:= -Os
> +
>  #
>  # Architecture dependencies
>  #
> diff --git a/arch/arm/boot/compressed/misc.c b/arch/arm/boot/compressed/misc.c
> index 832d37236c..8e2a8fca5e 100644
> --- a/arch/arm/boot/compressed/misc.c
> +++ b/arch/arm/boot/compressed/misc.c
> @@ -18,14 +18,9 @@
>  
>  unsigned int __machine_arch_type;
>  
> -#define _LINUX_STRING_H_
> -
>  #include <linux/compiler.h>	/* for inline */
> -#include <linux/types.h>	/* for size_t */
> -#include <linux/stddef.h>	/* for NULL */
> +#include <linux/types.h>
>  #include <linux/linkage.h>
> -#include <asm/string.h>
> -
>  
>  static void putstr(const char *ptr);
>  extern void error(char *x);
> @@ -101,41 +96,6 @@ static void putstr(const char *ptr)
>  	flush();
>  }
>  
> -
> -void *memcpy(void *__dest, __const void *__src, size_t __n)
> -{
> -	int i = 0;
> -	unsigned char *d = (unsigned char *)__dest, *s = (unsigned char *)__src;
> -
> -	for (i = __n >> 3; i > 0; i--) {
> -		*d++ = *s++;
> -		*d++ = *s++;
> -		*d++ = *s++;
> -		*d++ = *s++;
> -		*d++ = *s++;
> -		*d++ = *s++;
> -		*d++ = *s++;
> -		*d++ = *s++;
> -	}
> -
> -	if (__n & 1 << 2) {
> -		*d++ = *s++;
> -		*d++ = *s++;
> -		*d++ = *s++;
> -		*d++ = *s++;
> -	}
> -
> -	if (__n & 1 << 1) {
> -		*d++ = *s++;
> -		*d++ = *s++;
> -	}
> -
> -	if (__n & 1)
> -		*d++ = *s++;
> -
> -	return __dest;
> -}

Have you seen this?
http://en.wikipedia.org/wiki/Duff%27s_device

Once I finished vomiting, this actually struck be as rather neat.

If I've understood right, it seems a good fit for the manual unrolling
you do here.

Cheers
---Dave

  reply	other threads:[~2011-09-14 13:13 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-14  5:41 [PATCH 0/6] zImage improvements with DTB append and ATAG compatibility Nicolas Pitre
2011-09-14  5:41 ` [PATCH 1/6] ARM: zImage: ensure it is always a multiple of 64 bits in size Nicolas Pitre
2011-09-14  5:41 ` [PATCH 2/6] ARM: zImage: Allow the appending of a device tree binary Nicolas Pitre
2011-09-14 13:32   ` Dave Martin
2011-09-14 14:04     ` Nicolas Pitre
2011-09-14 14:20       ` Dave Martin
2011-09-14 15:10         ` Nicolas Pitre
2011-09-14 16:10           ` Dave Martin
2011-09-14  5:41 ` [PATCH 3/6] ARM: zImage: make sure appended DTB doesn't get overwritten by kernel .bss Nicolas Pitre
2011-09-14  5:41 ` [PATCH 4/6] ARM: zImage: gather some string functions into string.c Nicolas Pitre
2011-09-14 13:13   ` Dave Martin [this message]
2011-09-14 13:45     ` Nicolas Pitre
2011-09-14 14:23       ` Dave Martin
2011-09-14 14:43         ` Nicolas Pitre
2011-09-14  5:41 ` [PATCH 5/6] ARM: zImage: allow supplementing appended DTB with traditional ATAG data Nicolas Pitre
2011-09-14  5:41 ` [PATCH 6/6] ARM: zImage: prevent constant copy+rebuild of lib1funcs.S Nicolas Pitre
2011-09-16  3:58   ` Stephen Boyd
2011-09-16  4:48     ` Nicolas Pitre
2011-09-16  7:15     ` Russell King - ARM Linux
2011-09-16 17:20       ` Stephen Boyd
2011-09-14  8:54 ` [PATCH 0/6] zImage improvements with DTB append and ATAG compatibility Shawn Guo
2011-09-14 13:19 ` Dave Martin
2011-09-14 15:26 ` Thomas Abraham
2011-09-14 22:56 ` David Brown

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=20110914131314.GC2104@arm.com \
    --to=dave.martin@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).