Date: Wed, 28 Jun 2006 13:42:21 +0400 From: Yar Tikhiy <yar@comp.chem.msu.su> To: "M. Warner Losh" <imp@bsdimp.com> Cc: arch@freebsd.org Subject: Re: SET, CLR, ISSET in types.h for _KERNEL builds Message-ID: <20060628094221.GA50978@comp.chem.msu.su> In-Reply-To: <20060627.135817.-490997979.imp@bsdimp.com> References: <20060627.135817.-490997979.imp@bsdimp.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Jun 27, 2006 at 01:58:17PM -0600, M. Warner Losh wrote: > NetBSD recently added SET, CLR, ISSET to sys/types.h (only if _KERNEL > is defined). I'd like to do something similar in FreeBSD. I see no > reason to needless deviate from NetBSD here. One could make an > argument for lots of different files, but at the end of the day does > it really matter enough to justify having it be different than NetBSD? > > Here's my proposed diff, inline, for your consideration: > > Index: types.h > =================================================================== > RCS file: /home/ncvs/src/sys/sys/types.h,v > retrieving revision 1.95 > diff -u -r1.95 types.h > --- types.h 26 Nov 2005 12:42:35 -0000 1.95 > +++ types.h 27 Jun 2006 19:57:23 -0000 > @@ -294,6 +294,11 @@ > > #define offsetof(type, field) __offsetof(type, field) > > +/* Macros to clear/set/test flags. */ > +#define SET(t, f) (t) |= (f) > +#define CLR(t, f) (t) &= ~(f) > +#define ISSET(t, f) ((t) & (f)) > + > #endif /* !_KERNEL */ > > /* > > NOTE: That /* !_KERNEL */ should have the '!' removed, but I didn't > want to confuse things by doing that too. > > Comments? I'd rather enclose the whole RHS of SET and CLR in parentheses. It's still C; SET and CLR can be used in expressions and cause precedence artefacts if not parenthesised. -- Yar
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060628094221.GA50978>