Subject: Re: changes to bit-twiddling macros & __arraycount()
To: None <tech-kern@NetBSD.org, tech-userlevel@NetBSD.org>
From: David Young <dyoung@pobox.com>
List: tech-userlevel
Date: 08/13/2006 10:37:00
On Sun, Aug 13, 2006 at 02:27:13PM +0200, Martin Husemann wrote:
> On Sat, Aug 12, 2006 at 08:04:17PM -0500, David Young wrote:
> > I want them in userland for the convenience of programs for control &
> > diagnostics of device drivers.  Portability is not key.
> 
> I personally think we should get rid of the bit macros completely - they
> decrease code readability and lead to abuse.
> 
> As an especially bad example: we have code in our tree that does:
> 
>    switch (ISSET(t->c_cflag, CSIZE)) {
>     case CS5:
>       ..
>     case CS6:
>       ..
>     ..

Very well, but you are talking about different bit macros than mine.
I never intended for mine to be used with ISSET and family, and that
is not the way they are used.  Moreover, my macros ease reading and
writing code.  Using __BITS()/__SHIFTIN()/__SHIFTOUT() for register
definitions eases comparisons between source code and standards documents
or datasheets, obviates the need for separate xxx_SHIFT #defines,
and saves a developer the trouble of "manually" shifting bits into a
hexadecimal mask.

Dave

-- 
David Young             OJC Technologies
dyoung@ojctech.com      Urbana, IL * (217) 278-3933