I recall when NetBSD added them about year or two ago. It isn't that clear to me that they serve that much use, or really help clear code up that much. But I'll defer to consensus.
-- Garrett Jason King wrote: > On Wed, Jun 11, 2008 at 10:38 PM, James C. McPherson > <[EMAIL PROTECTED]> wrote: > >> Jason King wrote: >> >>> I'm curious to know if anyone feels if there might be utility in >>> providing macros in a header file for defining and manipulating >>> bitmasks (analogous to __BIT(x), __BITS(a,b), __SHIFTIN, __SHIFTOUT, >>> etc on some of the BSDs)? In some of the driver work I've done, I've >>> found it makes manipulating registers full of bit fields clearer. >>> >> Something like the LE_* and BE_* macros from <sys/byteorder.h> ? >> >> I used those as a base and created my own specific macros in >> $SRC/cmd/fwflash/common/fwflash.h >> > > No -- see > http://src.opensolaris.org/source/xref/emancipation/drivers/cge/bitops.h > for the definitions, and > http://src.opensolaris.org/source/xreg/emancipation/drivers/cge/cge.c > for some examples. > > A simple one is: > > /* define a mask for bits 4-12 inclusive */ > #define MY_FIELD_MASK __BITS(4,12) > > uint32_t val; > val = __SHIFTOUT(ddi_get32(handle, addr), MY_FIELD_MASK); > ddi_put32(handle, addr, val | __SHIFTIN(5, MY_FIELD_MASK)); > > Seems like operations like these (extracting/setting values from the > middle of a register, etc.) are fairly common in drivers, and just > might make things easier to read. > _______________________________________________ > opensolaris-code mailing list > opensolaris-code@opensolaris.org > http://mail.opensolaris.org/mailman/listinfo/opensolaris-code > _______________________________________________ opensolaris-code mailing list opensolaris-code@opensolaris.org http://mail.opensolaris.org/mailman/listinfo/opensolaris-code