From owner-svn-src-all@FreeBSD.ORG Sat Jan 9 06:14:48 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9131910656A6; Sat, 9 Jan 2010 06:14:48 +0000 (UTC) (envelope-from juli@clockworksquid.com) Received: from mail-px0-f182.google.com (mail-px0-f182.google.com [209.85.216.182]) by mx1.freebsd.org (Postfix) with ESMTP id 5D4EA8FC15; Sat, 9 Jan 2010 06:14:48 +0000 (UTC) Received: by pxi12 with SMTP id 12so13486188pxi.3 for ; Fri, 08 Jan 2010 22:14:29 -0800 (PST) MIME-Version: 1.0 Sender: juli@clockworksquid.com Received: by 10.142.1.27 with SMTP id 27mr3125721wfa.33.1263017669057; Fri, 08 Jan 2010 22:14:29 -0800 (PST) In-Reply-To: <201001090605.o0965Vr8013970@svn.freebsd.org> References: <201001090605.o0965Vr8013970@svn.freebsd.org> From: Juli Mallett Date: Fri, 8 Jan 2010 22:14:09 -0800 X-Google-Sender-Auth: 932e51e83bb5edef Message-ID: To: David Xu Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r201885 - head/sys/kern X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Jan 2010 06:14:48 -0000 On Fri, Jan 8, 2010 at 22:05, David Xu wrote: > #define TYPE_SIMPLE_WAIT 0 > -#define TYPE_CV 1 > -#define TYPE_SIMPLE_LOCK 2 > -#define TYPE_NORMAL_UMUTEX 3 > -#define TYPE_PI_UMUTEX 4 > -#define TYPE_PP_UMUTEX 5 > -#define TYPE_RWLOCK 6 > +#define TYPE_CV (TYPE_SIMPLE_WAIT+1) > +#define TYPE_SEM (TYPE_CV+1) > +#define TYPE_SIMPLE_LOCK (TYPE_SEM+1) > +#define TYPE_NORMAL_UMUTEX (TYPE_SIMPLE_LOCK+1) > +#define TYPE_PI_UMUTEX (TYPE_NORMAL_UMUTEX+1) > +#define TYPE_PP_UMUTEX (TYPE_PI_UMUTEX+1) > +#define TYPE_RWLOCK (TYPE_PP_UMUTEX+1) > I am not sure I get the benefit of defining them this way. Certainly it does nothing to improve stability in the face of additions, removals or re-sorting (in the latter case, it makes figuring out how to define a new one exceptionally hard.) I am not aware of a trend towards defining constants this way in the kernel (there are none in sys/ that I see) and find it kind of baffling and needlessly obtuse. If there is a need to define them in such an unusual manner, it would be nice to see a comment that says why. If you don't need to use #defines and have a dislike assigning numbers by hand, why not simply use 'enum'?