public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Oleg Verych <olecom@flower.upol.cz>
To: David Howells <dhowells@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	Al Viro <viro@ftp.linux.org.uk>,
	akpm@linux-foundation.org, benh@kernel.crashing.org,
	linux-kernel@vger.kernel.org, hpa@zytor.com,
	johannes@sipsolutions.net
Subject: ALIGN via ilog2 without gccisms (Re: [PATCH] Fix get_order())
Date: Wed, 7 Mar 2007 17:02:53 +0100	[thread overview]
Message-ID: <E1HOybN-00031m-6M@flower> (raw)
In-Reply-To: <8543.1173267786@redhat.com>

> From: David Howells
> Newsgroups: gmane.linux.kernel
> Subject: Re: [PATCH] Fix get_order()
> Date: Wed, 07 Mar 2007 11:43:06 +0000
>
[]
> Various archs (including i386, x86_64, powerpc and frv) have instructions that
> can be used to calculate integer log2(N).
>
Probably it can be used to get rid of gccisms and "type fluff" due to
bitwise arithmetics in ALIGN?
Here:

#define ALIGN(x,a)		__ALIGN_MASK(x,(typeof(x))(a)-1)
#define __ALIGN_MASK(x,mask)	(((x)+(mask))&~(mask))

like that:

#define ALIGN(x,y)		__ALIGN_MASK(x,ilog2(y))
#define __ALIGN_MASK(x,bits)	(((((x) >> (bits)) << 1) + 2) << (bits - 1))

Note side effect, that this one always yields even result. Maybe this is
good, due to avoidance of misaligned access.

____

  reply	other threads:[~2007-03-07 15:53 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-06 17:39 [PATCH] Fix get_order() David Howells
2007-03-06 17:58 ` H. Peter Anvin
2007-03-06 18:21   ` David Howells
2007-03-06 18:41 ` Linus Torvalds
2007-03-06 18:51   ` David Howells
2007-03-07  3:28 ` Linus Torvalds
2007-03-07 11:43   ` David Howells
2007-03-07 16:02     ` Oleg Verych [this message]
2007-03-07 16:38       ` ALIGN via ilog2 without gccisms (Re: [PATCH] Fix get_order()) Linus Torvalds
2007-03-07 17:24         ` Oleg Verych
2007-03-07 18:05           ` Linus Torvalds
2007-03-09 23:13         ` ALIGN " Oleg Verych
2007-03-09 23:15           ` Linus Torvalds
2007-03-10  0:31             ` Oleg Verych
2007-03-10  8:01         ` ALIGN Oleg Verych

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=E1HOybN-00031m-6M@flower \
    --to=olecom@flower.upol.cz \
    --cc=akpm@linux-foundation.org \
    --cc=benh@kernel.crashing.org \
    --cc=dhowells@redhat.com \
    --cc=hpa@zytor.com \
    --cc=johannes@sipsolutions.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@ftp.linux.org.uk \
    /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