From: Andreas Schwab <schwab@suse.de>
To: "linux-os (Dick Johnson)" <linux-os@analogic.com>
Cc: "Herbert Xu" <herbert@gondor.apana.org.au>,
"Linus Torvalds" <torvalds@linux-foundation.org>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>
Subject: Re: [KERNEL]: Avoid divide in IS_ALIGN
Date: Wed, 21 Nov 2007 14:35:07 +0100 [thread overview]
Message-ID: <jefxyzlo1g.fsf@sykes.suse.de> (raw)
In-Reply-To: <Pine.LNX.4.61.0711210800140.25473@chaos.analogic.com> (linux-os@analogic.com's message of "Wed\, 21 Nov 2007 08\:06\:36 -0500")
"linux-os (Dick Johnson)" <linux-os@analogic.com> writes:
> Executing this script.............
>
> cat <<EOF >/tmp/xxx.c
> #include <stdio.h>
>
> #define IS_ALIGNED(x,a) (((x) % ((typeof(x))(a))) == 0)
> #define _IS_ALIGNED(x, a) (((x) & ((typeof(x))(a) - 1)) == 0)
>
> int main()
> {
> int i;
> long p = 0x12345678;
> for(i=1; i< 0x11; i++)
> printf("Old = %d, new = %d\n", IS_ALIGNED(p, i), _IS_ALIGNED(p, i));
Alignment is only defined for powers of two.
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
prev parent reply other threads:[~2007-11-21 13:35 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-20 13:56 [KERNEL]: Avoid divide in IS_ALIGN Herbert Xu
2007-11-20 18:17 ` Joe Perches
2007-11-20 20:22 ` Andrew Morton
2007-11-20 21:43 ` linux-os (Dick Johnson)
2007-11-21 13:06 ` linux-os (Dick Johnson)
2007-11-21 13:35 ` Andreas Schwab [this message]
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=jefxyzlo1g.fsf@sykes.suse.de \
--to=schwab@suse.de \
--cc=akpm@linux-foundation.org \
--cc=herbert@gondor.apana.org.au \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-os@analogic.com \
--cc=torvalds@linux-foundation.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox