From owner-freebsd-arch@FreeBSD.ORG Wed Jun 28 09:42:36 2006 Return-Path: X-Original-To: arch@freebsd.org Delivered-To: freebsd-arch@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 547B516A403 for ; Wed, 28 Jun 2006 09:42:36 +0000 (UTC) (envelope-from yar@comp.chem.msu.su) Received: from comp.chem.msu.su (comp.chem.msu.su [158.250.32.97]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6836243DA3 for ; Wed, 28 Jun 2006 09:42:35 +0000 (GMT) (envelope-from yar@comp.chem.msu.su) Received: from comp.chem.msu.su (localhost [127.0.0.1]) by comp.chem.msu.su (8.13.4/8.13.3) with ESMTP id k5S9gMpZ051205; Wed, 28 Jun 2006 13:42:22 +0400 (MSD) (envelope-from yar@comp.chem.msu.su) Received: (from yar@localhost) by comp.chem.msu.su (8.13.4/8.13.3/Submit) id k5S9gMJl051204; Wed, 28 Jun 2006 13:42:22 +0400 (MSD) (envelope-from yar) Date: Wed, 28 Jun 2006 13:42:21 +0400 From: Yar Tikhiy To: "M. Warner Losh" Message-ID: <20060628094221.GA50978@comp.chem.msu.su> References: <20060627.135817.-490997979.imp@bsdimp.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20060627.135817.-490997979.imp@bsdimp.com> User-Agent: Mutt/1.5.9i Cc: arch@freebsd.org Subject: Re: SET, CLR, ISSET in types.h for _KERNEL builds X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Jun 2006 09:42:36 -0000 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