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: <1195582635.4675.145.camel@localhost>
Date:	Tue, 20 Nov 2007 10:17:15 -0800
From:	Joe Perches <joe@...ches.com>
To:	Herbert Xu <herbert@...dor.apana.org.au>
Cc:	Linus Torvalds <torvalds@...ux-foundation.org>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [KERNEL]: Avoid divide in IS_ALIGN

On Tue, 2007-11-20 at 21:56 +0800, Herbert Xu wrote:
> [KERNEL]: Avoid divide in IS_ALIGN
> I was happy to discover the brand new IS_ALIGN macro and quickly
> used it in my code.  To my dismay I found that the generated code
> used division to perform the test.
> This patch fixes it by changing the % test to an &.  This avoids
> the division.

Perhaps this should use is_power_of_2?

#define IS_ALIGNED(x, a) 				\
	({ typeof(x) _a = (typeof(x))(a); 		\
	   is_power_of_2(_a) ? (((x) & (_a - 1)) == 0)	\
			     : (((x) % _a == 0); })

gcc -o2/oS seems to do the right thing.

-
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