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]
Message-ID: <yw1xaaoi8tjx.fsf@unicorn.mansr.com>
Date:	Thu, 19 Aug 2010 17:18:42 +0100
From:	Måns Rullgård <mans@...sr.com>
To:	linux-kernel@...r.kernel.org
Subject: Re: [RFC][PATCH] introduce ptr_diff()

David Howells <dhowells@...hat.com> writes:

> Namhyung Kim <namhyung@...il.com> wrote:
>
>> +	if (is_power_of_2(__size))				\
>> +		__diff = (__addr1 - __addr2) >> ilog2(__size);	\
>> +	else							\
>> +		__diff = (__addr1 - __addr2) / __size;		\
>
> You shouldn't need to do this.  The compiler's optimiser should switch a
> divide to a shift for a power-of-2 divisor.

Only when the numerator is provably non-negative, which is certainly
not the case here.

-- 
Måns Rullgård
mans@...sr.com

--
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