From: Sascha Hauer <s.hauer@pengutronix.de>
To: Alexander Shiyan <shc_work@mail.ru>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH] crypto: crc32: Optimize dynamic CRC table generation
Date: Mon, 20 Jun 2016 08:40:27 +0200 [thread overview]
Message-ID: <20160620064027.GP9677@pengutronix.de> (raw)
In-Reply-To: <1466362372-4248-1-git-send-email-shc_work@mail.ru>
Hi Alexander,
On Sun, Jun 19, 2016 at 09:52:52PM +0300, Alexander Shiyan wrote:
> In barebox we have an option for dynamic formation of the CRC32
> table (DYNAMIC_CRC_TABLE), but the source code declares a static
> array which is simply filled with data, the resulting code becomes
> even more than without DYNAMIC_CRC_TABLE option, due to the BSS usage.
> CONFIG_DYNAMIC_CRC_TABLE=n
> text data bss dec hex filename
> 1884 0 0 1884 75c crc32.o
> CONFIG_DYNAMIC_CRC_TABLE=y
> text data bss dec hex filename
> 1066 4 1024 2094 82e crc32.o
>
> This patch provides dynamic buffer allocation for the CRC table,
> which saves about 1 Kbyte, as it should be.
> CONFIG_DYNAMIC_CRC_TABLE=y
> text data bss dec hex filename
> 1062 0 4 1066 42a crc32.o
>
> Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
> ---
> crypto/crc32.c | 15 +++++++--------
> 1 file changed, 7 insertions(+), 8 deletions(-)
>
> diff --git a/crypto/crc32.c b/crypto/crc32.c
> index 3bff6fe..c510c31 100644
> --- a/crypto/crc32.c
> +++ b/crypto/crc32.c
> @@ -24,9 +24,7 @@
>
> #ifdef CONFIG_DYNAMIC_CRC_TABLE
>
> -static int crc_table_empty = 1;
> -static ulong crc_table[256];
> -static void make_crc_table(void);
> +static ulong *crc_table;
>
> /*
> Generate a table for a byte-wise 32-bit CRC calculation on the polynomial:
> @@ -65,6 +63,8 @@ static void make_crc_table(void)
> for (n = 0; n < sizeof(p)/sizeof(char); n++)
> poly |= 1L << (31 - p[n]);
>
> + crc_table = malloc(sizeof(ulong) * 256);
> +
Either return value cheching or xmalloc please. Changed it to xmalloc
while applying.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
prev parent reply other threads:[~2016-06-20 6:40 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-19 18:52 Alexander Shiyan
2016-06-20 6:40 ` Sascha Hauer [this message]
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=20160620064027.GP9677@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=shc_work@mail.ru \
/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