public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Michał Nazarewicz" <m.nazarewicz@samsung.com>
To: Michal Nazarewicz <mina86@mina86.com>,
	Denys Vlasenko <vda.linux@googlemail.com>
Cc: linux-kernel@vger.kernel.org,
	"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 10:54:27 +0200	[thread overview]
Message-ID: <op.vg0do1xe7p4s8u@pikus> (raw)
In-Reply-To: <201008060935.26989.vda.linux@googlemail.com>

On Fri, 06 Aug 2010 09:35:26 +0200, Denys Vlasenko <vda.linux@googlemail.com> wrote:

> On Friday 06 August 2010 09:08, Michal Nazarewicz wrote:
>> >> +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.
>
> "640k will be enough for everybody"?
>
>> Wouldn't it be enough to put a static assert here?
>
> I'd prefer the code which works with arbitrarily wide long long.
> If needed, use
>
> if (sizeof(long long) == 8)
> 	64-bit code
> else
> 	generic code

Thanks.  That seems like a perfect solution.  I rearrange the code
and try to post updated version after the weekend.

-- 
Best regards,                                        _     _
| Humble Liege of Serenely Enlightened Majesty of  o' \,=./ `o
| Computer Science,  Michał "mina86" Nazarewicz       (o o)
+----[mina86*mina86.com]---[mina86*jabber.org]----ooO--(_)--Ooo--

  reply	other threads:[~2010-08-06  8:52 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
2010-08-06  7:35       ` Denys Vlasenko
2010-08-06  8:54         ` Michał Nazarewicz [this message]
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=op.vg0do1xe7p4s8u@pikus \
    --to=m.nazarewicz@samsung.com \
    --cc=akpm@linux-foundation.org \
    --cc=jones@cs.uiowa.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mina86@mina86.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