lkml.org 
[lkml]   [2010]   [Aug]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH 2/3] lib: vsprintf: optimised put_dec() for 32-bit machines
Date
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

--
vda



\
 
 \ /
  Last update: 2010-08-06 09:37    [W:0.049 / U:0.904 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site