lkml.org 
[lkml]   [2009]   [Dec]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] perf tools: Prevent from BITS_PER_LONG redefinition
On Sat, Dec 19, 2009 at 10:26:07AM +0100, Peter Zijlstra wrote:
> On Fri, 2009-12-18 at 23:05 +0100, Frederic Weisbecker wrote:
> > +#ifndef BITS_PER_LONG
> > /* CHECKME: Not sure both always match */
> > #define BITS_PER_LONG __WORDSIZE
> > +#endif
>
> Why use __WORDSIZE if you're not sure?
>
> (8*sizeof(long)) is simple and unambiguous.


Yeah but we need it from the CPP level.
We include such code located in kernel headers:

static __always_inline unsigned long __fls(unsigned long word)
{
int num = BITS_PER_LONG - 1;

#if BITS_PER_LONG == 64
if (!(word & (~0ul << 32))) {
num -= 32;
word <<= 32;
}
#endif
if (!(word & (~0ul << (BITS_PER_LONG-16)))) {
num -= 16;
word <<= 16;
}


And sizeof() is not defined :)



\
 
 \ /
  Last update: 2009-12-19 15:37    [W:1.172 / U:0.276 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site