From: "Heiko Stübner" <heiko@sntech.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 1/5] string: Provide a slimmed-down memset()
Date: Tue, 04 Apr 2017 11:38:29 +0200 [thread overview]
Message-ID: <1984088.BcMe8LTxMJ@diego> (raw)
In-Reply-To: <20170402155032.27473-2-sjg@chromium.org>
Am Sonntag, 2. April 2017, 09:50:28 CEST schrieb Simon Glass:
> Most of the time the optimised memset() is what we want. For extreme
> situations such as TPL it may be too large. For example on the 'rock'
> board, using a simple loop saves a useful 48 bytes. With gcc 4.9 and
> the rodata bug, this patch is enough to reduce the TPL image below the
> limit.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
> Changes in v2:
> - Adjust the option to be SPL-only
> - Change the option to default to off (name it CONFIG_SPL_TINY_MEMSET)
>
> lib/Kconfig | 8 ++++++++
> lib/string.c | 6 ++++--
> 2 files changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/lib/Kconfig b/lib/Kconfig
> index 65c01573e1..58b5717dcd 100644
> --- a/lib/Kconfig
> +++ b/lib/Kconfig
> @@ -52,6 +52,14 @@ config LIB_RAND
> help
> This library provides pseudo-random number generator functions.
>
> +config SPL_TINY_MEMSET
> + bool "Use a very small memset() in SPL"
> + help
> + The faster memset() is the arch-specific one (if available) enabled
> + by CONFIG_USE_ARCH_MEMSET. If that is not enabled, we can still get
> + better performance by write a word at a time. Enable this option
> + to reduce code size slightly at the cost of some speed.
Wording sounds off, I guess we could do something like
[...better performance by] writing a word at a time. In very size-constrained
environments even this may be to big though. [Enable this option...]
Otherwise
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
> +
> source lib/dhry/Kconfig
>
> source lib/rsa/Kconfig
> diff --git a/lib/string.c b/lib/string.c
> index 67d5f6a421..c1a28c14ce 100644
> --- a/lib/string.c
> +++ b/lib/string.c
> @@ -437,8 +437,10 @@ char *strswab(const char *s)
> void * memset(void * s,int c,size_t count)
> {
> unsigned long *sl = (unsigned long *) s;
> - unsigned long cl = 0;
> char *s8;
> +
> +#if !CONFIG_IS_ENABLED(TINY_MEMSET)
> + unsigned long cl = 0;
> int i;
>
> /* do it one word at a time (32 bits or 64 bits) while possible */
> @@ -452,7 +454,7 @@ void * memset(void * s,int c,size_t count)
> count -= sizeof(*sl);
> }
> }
> - /* fill 8 bits at a time */
> +#endif /* fill 8 bits at a time */
> s8 = (char *)sl;
> while (count--)
> *s8++ = c;
next prev parent reply other threads:[~2017-04-04 9:38 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-02 15:50 [U-Boot] [PATCH v2 0/5] Patches to reduce TPL code size Simon Glass
2017-04-02 15:50 ` [U-Boot] [PATCH v2 1/5] string: Provide a slimmed-down memset() Simon Glass
2017-04-04 9:38 ` Heiko Stübner [this message]
2017-04-05 1:05 ` Simon Glass
2017-04-02 15:50 ` [U-Boot] [PATCH v2 2/5] rockchip: rock: Enable CONFIG_SPL_TINY_MEMSET Simon Glass
2017-04-02 15:50 ` [U-Boot] [PATCH v2 3/5] Makefile: Provide an option to select SPL or TPL Simon Glass
2017-04-06 16:26 ` [U-Boot] [U-Boot, v2, " Tom Rini
2017-04-02 15:50 ` [U-Boot] [PATCH v2 4/5] dm: core: Allow driver model to be disabled for TPL Simon Glass
2017-04-06 16:26 ` [U-Boot] [U-Boot, v2, " Tom Rini
2017-04-02 15:50 ` [U-Boot] [PATCH v2 5/5] dm: serial: Allow driver-model serial " Simon Glass
2017-04-06 16:26 ` [U-Boot] [U-Boot, v2, " Tom Rini
2017-04-04 9:34 ` [U-Boot] [PATCH v2 0/5] Patches to reduce TPL code size Heiko Stübner
2017-04-04 10:43 ` Heiko Stuebner
2017-04-09 19:27 ` Simon Glass
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=1984088.BcMe8LTxMJ@diego \
--to=heiko@sntech.de \
--cc=u-boot@lists.denx.de \
/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