Date: Fri, 8 Jan 2010 22:14:09 -0800 From: Juli Mallett <jmallett@FreeBSD.org> To: David Xu <davidxu@freebsd.org> Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r201885 - head/sys/kern Message-ID: <eaa228be1001082214r7485a3f0se1b878d6667ac30c@mail.gmail.com> In-Reply-To: <201001090605.o0965Vr8013970@svn.freebsd.org> References: <201001090605.o0965Vr8013970@svn.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, Jan 8, 2010 at 22:05, David Xu <davidxu@freebsd.org> 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'?
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?eaa228be1001082214r7485a3f0se1b878d6667ac30c>