All of lore.kernel.org
 help / color / mirror / Atom feed
From: Frederic Weisbecker <fweisbec@gmail.com>
To: Jeremy Fitzhardinge <jeremy@goop.org>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@elte.hu>, LKML <linux-kernel@vger.kernel.org>,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Paul Mackerras <paulus@samba.org>
Subject: Re: [PATCH] perf tools: Prevent from BITS_PER_LONG redefinition
Date: Wed, 30 Dec 2009 22:45:52 +0100	[thread overview]
Message-ID: <20091230214549.GF6322@nowhere> (raw)
In-Reply-To: <4B2DB1F8.2070006@goop.org>

On Sat, Dec 19, 2009 at 09:11:20PM -0800, Jeremy Fitzhardinge wrote:
> On 12/19/2009 06:34 AM, Frederic Weisbecker wrote:
>> 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 :)
>>    
>
> You can use if() with a constant expression instead of #if.



I did not write this code. But yes you're right, although I
think CPP is more suitable here because fls() can be called
from fastpath and this conditional build makes one check less
and lesser i-cache footprint.


  reply	other threads:[~2009-12-30 21:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-18 22:05 [PATCH] perf tools: Prevent from BITS_PER_LONG redefinition Frederic Weisbecker
2009-12-19  9:26 ` Peter Zijlstra
2009-12-19 14:34   ` Frederic Weisbecker
2009-12-20  5:11     ` Jeremy Fitzhardinge
2009-12-30 21:45       ` Frederic Weisbecker [this message]
2009-12-31 11:09         ` Jeremy Fitzhardinge
2010-01-02 17:01           ` Frederic Weisbecker

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=20091230214549.GF6322@nowhere \
    --to=fweisbec@gmail.com \
    --cc=acme@redhat.com \
    --cc=jeremy@goop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=paulus@samba.org \
    --cc=peterz@infradead.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.