From: Michal Nazarewicz <mina86@mina86.com>
To: Denys Vlasenko <vda.linux@googlemail.com>
Cc: linux-kernel@vger.kernel.org, m.nazarewicz@samsung.com,
"Douglas W. Jones" <jones@cs.uiowa.edu>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH 2/3] lib: vsprintf: optimised put_dec() for 32-bit machines
Date: Fri, 06 Aug 2010 09:08:11 +0200 [thread overview]
Message-ID: <87eiec9q1w.fsf@erwin.mina86.com> (raw)
In-Reply-To: <201008060718.38345.vda.linux@googlemail.com> (Denys Vlasenko's message of "Fri, 6 Aug 2010 07:18:38 +0200")
Denys Vlasenko <vda.linux@googlemail.com> writes:
> On Friday 06 August 2010 00:38, Michal Nazarewicz wrote:
>> The disadvantage is that the proposed function is 2.5-3.5 bigger.
>> Those are not big functions though -- we are talking here about
>> proposed function being below 512.
> It's a slippery slope. Here's where it ends: glibc
> has memcpy() function which is "only" 8k of code or so.
> I'm not joking.
I'm aware of that. I assume that someone more clever then me will
decide whether to accept this patch or not. (Also we win a few bytes on
put_dec_full() and put_dec_8bit()). :P
>> +#if BITS_PER_LONG == 64
>> +
> ...
>> +#else
> ...
>> +/*
>> + * Based on code by Douglas W. Jones found at
>> + * <http://www.cs.uiowa.edu/~jones/bcd/decimal.html#sixtyfour>. This
>> + * performs no 64-bit division and hence should be faster on 32-bit
>> + * machines then the version of the function above.
>> + */
>> +static noinline_for_stack
>> +char *put_dec(char *buf, unsigned long long n)
>> +{
>> + uint32_t d3, d2, d1, q;
>> +
>> + if (!n) {
>> + *buf++ = '0';
>> + return buf;
>> + }
>> +
>> + d1 = (n >> 16) & 0xFFFF;
>> + d2 = (n >> 32) & 0xFFFF;
>> + d3 = (n >> 48) & 0xFFFF;
>
> Are you assuming that sizeof(long long) == 8, always?
Well... yes. C requires long long to be at least 64-bit and I don't
see it being larger in any foreseeable feature. Wouldn't it be enough
to put a static assert here?
--
Best regards, _ _
.o. | Liege of Serenly Enlightened Majesty of o' \,=./ `o
..o | Computer Science, Michal "mina86" Nazarewicz (o o)
ooo +--<mina86-tlen.pl>--<jid:mina86-jabber.org>--ooO--(_)--Ooo--
next prev parent reply other threads:[~2010-08-06 7:08 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-05 22:38 [PATCH 1/3] lib: vsprintf: optimised put_dec_trunc() and put_dec_full() Michal Nazarewicz
2010-08-05 22:38 ` [PATCH 2/3] lib: vsprintf: optimised put_dec() for 32-bit machines Michal Nazarewicz
2010-08-05 22:38 ` [PATCH 3/3] lib: vsprintf: added a put_dec() test and benchmark tool Michal Nazarewicz
2010-08-06 5:10 ` Denys Vlasenko
2010-08-06 8:34 ` Michał Nazarewicz
2010-08-06 15:57 ` Raja R Harinath
2010-08-06 19:26 ` Denys Vlasenko
2010-08-06 20:58 ` Michal Nazarewicz
2010-08-06 5:18 ` [PATCH 2/3] lib: vsprintf: optimised put_dec() for 32-bit machines Denys Vlasenko
2010-08-06 7:08 ` Michal Nazarewicz [this message]
2010-08-06 7:35 ` Denys Vlasenko
2010-08-06 8:54 ` Michał Nazarewicz
2010-08-06 3:58 ` [PATCH 1/3] lib: vsprintf: optimised put_dec_trunc() and put_dec_full() Denys Vlasenko
2010-08-06 6:56 ` Michal Nazarewicz
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=87eiec9q1w.fsf@erwin.mina86.com \
--to=mina86@mina86.com \
--cc=akpm@linux-foundation.org \
--cc=jones@cs.uiowa.edu \
--cc=linux-kernel@vger.kernel.org \
--cc=m.nazarewicz@samsung.com \
--cc=vda.linux@googlemail.com \
/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