lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 30 Dec 2009 22:45:52 +0100
From:	Frederic Weisbecker <fweisbec@...il.com>
To:	Jeremy Fitzhardinge <jeremy@...p.org>
Cc:	Peter Zijlstra <peterz@...radead.org>, Ingo Molnar <mingo@...e.hu>,
	LKML <linux-kernel@...r.kernel.org>,
	Arnaldo Carvalho de Melo <acme@...hat.com>,
	Paul Mackerras <paulus@...ba.org>
Subject: Re: [PATCH] perf tools: Prevent from BITS_PER_LONG redefinition

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.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ