All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wolfgang Denk <wd@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 2/3] Add generic bit operations
Date: Thu, 04 Jun 2009 13:58:03 +0200	[thread overview]
Message-ID: <20090604115803.BB5AA832E416@gemini.denx.de> (raw)
In-Reply-To: <20090604114818.GH26688@buzzloop.caiaq.de>

Dear Daniel Mack,

In message <20090604114818.GH26688@buzzloop.caiaq.de> you wrote:
>
> > > +#define BIT(nr)			(1UL << (nr))
> > > +#define BIT_MASK(nr)		(1UL << ((nr) % BITS_PER_LONG))
> > > +#define BIT_WORD(nr)		((nr) / BITS_PER_LONG)
> > > +#define BITS_PER_BYTE		8
> > > +#define BITS_TO_LONGS(nr)	DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))
> > 
> > You see, this is plain wrong on PowerPC.
> > 
> > On PowerPC, bit number 0 is the most significant bit, not the least
> > significant one as you assume here. So using this well-intended code
> > on a PowerPC system will most likely get you in trouble.
> 
> Well, the idea is to let those platforms use the generic operations that
> do not bring their owm ones. The code above is not on use by PPC, so it
> doesn't harm either.

But it is not a generic operation. The notion of "bit number" is a
generic concept, but here we have a machine dependent implementation
that sails under the name "asm-generic/bitops.h".

But it is NOT generic.

> > Let's get rid of this stuff, it is confusing.
> 
> Hmm, and how?

Just don't use it. Use masks instead of bit numbers.

What's wrong with using 0x00008000 instead of BIT(15) (which would be
0x00010000 on 32 bit Power systems).

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Prof:        So the American government went to IBM to come up with a
             data encryption standard and they came up with ...
Student:     EBCDIC!

  reply	other threads:[~2009-06-04 11:58 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-04 10:27 [U-Boot] (no subject) Daniel Mack
2009-06-04 10:27 ` [U-Boot] [PATCH 1/3] ARM: remove unused bit operations Daniel Mack
2009-06-04 10:27   ` [U-Boot] [PATCH 2/3] Add generic " Daniel Mack
2009-06-04 10:27     ` [U-Boot] [PATCH 3/3] ARM: add unaligned macros Daniel Mack
2009-06-04 17:42       ` Daniel Mack
2009-06-04 19:03         ` Wolfgang Denk
2009-06-04 19:23           ` Daniel Mack
2009-06-05  3:21             ` Stefan Roese
2009-06-04 11:45     ` [U-Boot] [PATCH 2/3] Add generic bit operations Wolfgang Denk
2009-06-04 11:48       ` Daniel Mack
2009-06-04 11:58         ` Wolfgang Denk [this message]
2009-06-04 11:47     ` Wolfgang Denk
2009-06-04 11:54       ` Daniel Mack
     [not found]         ` <20090604115922.E6893832E416@gemini.denx.de>
2009-06-04 18:00           ` Daniel Mack
2009-06-04 18:18             ` Stefan Roese
2009-06-04 19:06             ` Wolfgang Denk
2009-06-05 20:44     ` Jean-Christophe PLAGNIOL-VILLARD
2009-06-07 22:41       ` Daniel Mack

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=20090604115803.BB5AA832E416@gemini.denx.de \
    --to=wd@denx.de \
    --cc=u-boot@lists.denx.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.