mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Re: bitmaps/bitops
       [not found] <mailman.1047762781.3457.linux-kernel2news@redhat.com>
@ 2003-03-16  1:31 ` Pete Zaitcev
  2003-03-16  1:41   ` bitmaps/bitops Paul Mackerras
  2003-03-16 21:42   ` bitmaps/bitops Alan Cox
  0 siblings, 2 replies; 5+ messages in thread
From: Pete Zaitcev @ 2003-03-16  1:31 UTC (permalink / raw)
  To: Randy.Dunlap; +Cc: linux-kernel

> but the prototype for test_and_set_bit() depends on $(ARCH), and it's
> not consistent, with the second arg (bitmap address) being one of:
>   volatile void *
>   void *
>   volatile unsigned long *

It should be unsigned long pointer. I have no idea why
volatile is still alive. Perhaps Linus can remember why he
left it in on is386. Other arch maintainers midnlessly ape him
in this area. I think I even kept his e-mail where he explains
why volatile has to go.

-- Pete

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: bitmaps/bitops
  2003-03-16  1:31 ` bitmaps/bitops Pete Zaitcev
@ 2003-03-16  1:41   ` Paul Mackerras
  2003-03-16 21:42   ` bitmaps/bitops Alan Cox
  1 sibling, 0 replies; 5+ messages in thread
From: Paul Mackerras @ 2003-03-16  1:41 UTC (permalink / raw)
  To: Pete Zaitcev; +Cc: Randy.Dunlap, linux-kernel

Pete Zaitcev writes:

> > but the prototype for test_and_set_bit() depends on $(ARCH), and it's
> > not consistent, with the second arg (bitmap address) being one of:
> >   volatile void *
> >   void *
> >   volatile unsigned long *
> 
> It should be unsigned long pointer. I have no idea why
> volatile is still alive. Perhaps Linus can remember why he
> left it in on is386. Other arch maintainers midnlessly ape him
> in this area. I think I even kept his e-mail where he explains
> why volatile has to go.

The volatile is there (at least in ppc) because without it you get
compile warnings.  I don't see why the bitops particularly should be
the anti-volatile police.  I agree that using volatile is usually a
bad idea (unless you are accessing a memory-mapped I/O device).

Paul.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: bitmaps/bitops
  2003-03-16  1:31 ` bitmaps/bitops Pete Zaitcev
  2003-03-16  1:41   ` bitmaps/bitops Paul Mackerras
@ 2003-03-16 21:42   ` Alan Cox
  1 sibling, 0 replies; 5+ messages in thread
From: Alan Cox @ 2003-03-16 21:42 UTC (permalink / raw)
  To: Pete Zaitcev; +Cc: Randy.Dunlap, Linux Kernel Mailing List

On Sun, 2003-03-16 at 01:31, Pete Zaitcev wrote:
> > but the prototype for test_and_set_bit() depends on $(ARCH), and it's
> > not consistent, with the second arg (bitmap address) being one of:
> >   volatile void *
> >   void *
> >   volatile unsigned long *
> 
> It should be unsigned long pointer. I have no idea why
> volatile is still alive. Perhaps Linus can remember why he
> left it in on is386. Other arch maintainers midnlessly ape him
> in this area. I think I even kept his e-mail where he explains
> why volatile has to go.

Several 2.4 drivers assume the test_and_set point is a memory
barrier for locking. Lots of

	if(test_and_set_bit(0, &foo))
	{
		x=foodev->blah

Since its inline code and not a memory barrier otherwise there
is little stop the compile doing

	x=foodev->blah

first


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: bitmaps/bitops
  2003-03-15 21:09 bitmaps/bitops Randy.Dunlap
@ 2003-03-15 21:51 ` Geert Uytterhoeven
  0 siblings, 0 replies; 5+ messages in thread
From: Geert Uytterhoeven @ 2003-03-15 21:51 UTC (permalink / raw)
  To: Randy.Dunlap; +Cc: Linux Kernel Development

On Sat, 15 Mar 2003, Randy.Dunlap wrote:
> Not picking on this code, but as an example:
> 
> drivers/ieee1394/ieee1394_transactions.c, line 152 (in 2.5.64),
> uses:  test_and_set_bit(bit_number, tp->pool),
> 
> where tp->pool is declared by using a DECLARE_BITMAP(), like so:
> struct hpsb_tlabel_pool {
> 	DECLARE_BITMAP(pool, 64);
> 
> That makes sense (at least to me), but gcc complains about the
> type of <pool> when used in test_and_set_bit():
>   drivers/ieee1394/ieee1394_transactions.c:152: warning: passing arg 2 of
> `test_and_set_bit' from incompatible pointer type
> 
> Is this an error, a bug, a nuisance, or just another "ignore gcc 2.96"
> problem?
> 
> For reference, DECLARE_BITMAP() generates an array of unsigned longs:
> #define DECLARE_BITMAP(name,bits) \
> 	unsigned long name[BITS_TO_LONGS(bits)]
> but the prototype for test_and_set_bit() depends on $(ARCH), and it's
> not consistent, with the second arg (bitmap address) being one of:
>   volatile void *
>   void *
>   volatile unsigned long *
> 
> 
> If there's (kernel) surgery required here, unless it's trivial, I think
> that I'd leave it for early 2.7.

Bitops operate on long. Architectures for which it really matters have used
`unsigned long *' in there function signatures since quite some time.

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds


^ permalink raw reply	[flat|nested] 5+ messages in thread

* bitmaps/bitops
@ 2003-03-15 21:09 Randy.Dunlap
  2003-03-15 21:51 ` bitmaps/bitops Geert Uytterhoeven
  0 siblings, 1 reply; 5+ messages in thread
From: Randy.Dunlap @ 2003-03-15 21:09 UTC (permalink / raw)
  To: linux-kernel

Hi,

Not picking on this code, but as an example:

drivers/ieee1394/ieee1394_transactions.c, line 152 (in 2.5.64),
uses:  test_and_set_bit(bit_number, tp->pool),

where tp->pool is declared by using a DECLARE_BITMAP(), like so:
struct hpsb_tlabel_pool {
	DECLARE_BITMAP(pool, 64);

That makes sense (at least to me), but gcc complains about the
type of <pool> when used in test_and_set_bit():
  drivers/ieee1394/ieee1394_transactions.c:152: warning: passing arg 2 of
`test_and_set_bit' from incompatible pointer type

Is this an error, a bug, a nuisance, or just another "ignore gcc 2.96"
problem?

For reference, DECLARE_BITMAP() generates an array of unsigned longs:
#define DECLARE_BITMAP(name,bits) \
	unsigned long name[BITS_TO_LONGS(bits)]
but the prototype for test_and_set_bit() depends on $(ARCH), and it's
not consistent, with the second arg (bitmap address) being one of:
  volatile void *
  void *
  volatile unsigned long *


If there's (kernel) surgery required here, unless it's trivial, I think
that I'd leave it for early 2.7.

~Randy




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2003-03-16 20:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <mailman.1047762781.3457.linux-kernel2news@redhat.com>
2003-03-16  1:31 ` bitmaps/bitops Pete Zaitcev
2003-03-16  1:41   ` bitmaps/bitops Paul Mackerras
2003-03-16 21:42   ` bitmaps/bitops Alan Cox
2003-03-15 21:09 bitmaps/bitops Randy.Dunlap
2003-03-15 21:51 ` bitmaps/bitops Geert Uytterhoeven

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®