mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Stephane Eranian <eranian@hpl.hp.com>
To: Andrew Morton <akpm@osdl.org>
Cc: "H. Peter Anvin" <hpa@zytor.com>,
	linux-kernel@vger.kernel.org, Andi Kleen <ak@suse.de>
Subject: Re: i386 and x86-64 bitops function prototypes differ
Date: Thu, 1 Feb 2007 15:27:09 -0800	[thread overview]
Message-ID: <20070201232709.GF1175@frankl.hpl.hp.com> (raw)
In-Reply-To: <20070201145525.d4d950c0.akpm@osdl.org>

Andrew,

On Thu, Feb 01, 2007 at 02:55:25PM -0800, Andrew Morton wrote:
> On Thu, 1 Feb 2007 01:15:55 -0800
> Stephane Eranian <eranian@hpl.hp.com> wrote:
> 
> > Hello,
> > 
> > On Fri, Jan 26, 2007 at 09:49:54AM -0800, H. Peter Anvin wrote:
> > > >
> > > >I ran into compiler warnings with the perfmon code when I tried
> > > >using test() and __set_bit() on i386. 
> > > >
> > > >For some reason, the i386 bitops functions use unsigned long * for
> > > >the address whereas x86-64/ia64 use void *.
> > > >
> > > >I do not quite understand why such difference?
> > > >Is this just for historical reasons?
> > > >
> > > >Thanks.
> > > >
> > > 
> > > Arguably void * is the right thing for a littleendian architecture.  For 
> > > bigendian architectures it unfortunately matters what the chunk size is, 
> > > regardless of if the chunks are numbered in bigendian (reverse) or 
> > > littleendian (forward) order.
> > > 
> > 
> > I agree with you, but i386 is definitively little endian, so here is a patch
> > against 2.6.20-rc6-mm3 to make x86-64 and i386 have the same prototypes for
> > bit manipulation routines.
> > 
> > changelog:
> > 	- change all bit manipulation inline routine to use void * as their
> > 	  address argument instead of unsigned long *. Match x86-64
> > 
> > signed-off-by: stephane eranian <eranian@hpl.hp.com>
> > 
> > --- linux-2.6.20-rc6-mm3.orig/include/asm-i386/bitops.h	2007-01-31 09:24:21.000000000 -0800
> > +++ linux-2.6.20-rc6-mm3.base/include/asm-i386/bitops.h	2007-01-31 09:31:46.000000000 -0800
> > @@ -33,7 +33,7 @@
> >   * Note that @nr may be almost arbitrarily large; this function is not
> >   * restricted to acting on a single-word quantity.
> >   */
> > -static inline void set_bit(int nr, volatile unsigned long * addr)
> > +static inline void set_bit(int nr, volatile void * addr)
> 
> These bitops are only valid on long*'s.  Or a least, they require a
> long-aligned address, and using long* is how we communicate and enforce
> that.
> 
Yes, I realize this now.

> Numerous architectures implement these functions using ulong*.  If we make
> this change, we risk someone doing set_bit() on, say, a char *.  That
> change would compile and run happily on x86 and would then fail on, say,
> arm or h8/300.
> 
> So I'd say that x86_64 is wrong, and should be changed to take ulong*.

We need to fix x86-64 and also ia64 it seems. I'll see if I can do that.
Thanks.

-- 
-Stephane

  reply	other threads:[~2007-02-01 23:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-26 14:35 Stephane Eranian
2007-01-26 17:49 ` H. Peter Anvin
2007-02-01  9:15   ` Stephane Eranian
2007-02-01 22:55     ` Andrew Morton
2007-02-01 23:27       ` Stephane Eranian [this message]
2007-02-02  7:12       ` Andi Kleen

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=20070201232709.GF1175@frankl.hpl.hp.com \
    --to=eranian@hpl.hp.com \
    --cc=ak@suse.de \
    --cc=akpm@osdl.org \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.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

all inboxes | Powered by JetHome®