[U-Boot-Users] RFC: Common bitshifts
Wolfgang Denk
wd at denx.de
Mon Mar 12 13:03:34 CET 2007
In message <000001c7649a$41f7f9a0$9a4d010a at Emea.Arm.com> you wrote:
>
> defining standard bit shifts e.g
>
> #define BIT0 (1<<0)
> #define BIT1 (1<<1)
> #define BIT2 (1<<2)
> #define BIT3 (1<<3)
> #define BIT4 (1<<4)
> #define BIT5 (1<<5)
I really dislike definitions like these, as they basicly make the
code unreadable. You always have to look up the definition in a
gazillion of herader files (and make your to catch the right one) to
be able to see what the code actually does.
I recommend to get rid of all use of such definitions.
> a) Is it acceptable to replace these two (and references thereto) with
> include/bitshifts.h?
No, it is not.
> The shifts are not arm specific, and could be useful to others.
Yes, this is ARM specific. On PowerPC, BIT0 may be one of (1<<7),
(1<<15), (1<<31) or (1<<63) depending if you are dealing with an
object of 1, 2, 4, or 8 bytes - on PowerPC, bit 0 is the MSB!
As mentioned before, definitions like these are confusing to
dangerous and should be removed.
> b) If so, should I submit a seperate patch to the main tree, or is it
> acceptable to make this part of the
> patch for the new board?
Please do neither one not the other.
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, HRB 165235 Munich, CEO: Wolfgang Denk
Office: Kirchenstr. 5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Q: Do you know what the death rate around here is?
A: One per person.
More information about the U-Boot
mailing list