cvs commit: src/share/man/man9 Makefile condvar.9 lock.9
mi_switch.9 mtx_pool.9 mutex.9 rwlock.9 sleep.9 sleepqueue.9
sx.9 thread_exit.9 src/sys/kern kern_synch.c src/sys/sys
mutex.h rwlock.h sleepqueue.h sx.h systm.h
John Baldwin
jhb at freebsd.org
Mon Mar 12 19:54:36 UTC 2007
On Monday 12 March 2007 14:56, Pawel Jakub Dawidek wrote:
> On Mon, Mar 12, 2007 at 11:16:23AM -0400, John Baldwin wrote:
> > On Saturday 10 March 2007 15:52, Pawel Jakub Dawidek wrote:
> > > What about something like this:
> > >
> > > #define cv_wait(cv, lock) do {
> > > switch (LO_CLASSINDEX((struct lock_object *)(lock))) {
> >
> > The problem with a cast is you use type checking. Might as well do this:
> >
> > #define cv_wait(cv, lock) _cv_wait((cv), (struct lock_object *)(lock))
>
> This will skip type checking and my version only cast to provide type
> checking, so when you pass some random variable it will give you an
> error.
Not really, you may pass some garbage and the LO_CLASSINDEX turns out to be a
mutex. :) You only get a runtime error, not a compile-time one.
Type-checking by the compiler is nice because you get compile-time errors.
--
John Baldwin
More information about the cvs-src
mailing list