Date: Tue, 30 Oct 2007 13:12:29 -0700 From: Alfred Perlstein <alfred@freebsd.org> To: Bakul Shah <bakul@bitblocks.com> Cc: Poul-Henning Kamp <phk@phk.freebsd.dk>, Garance A Drosehn <gad@FreeBSD.org>, freebsd-arch@FreeBSD.org Subject: Re: C++ in the kernel Message-ID: <20071030201229.GA33488@elvis.mu.org> In-Reply-To: <20071030181124.EC35B5B30@mail.bitblocks.com> References: <20071030173734.GV33488@elvis.mu.org> <20071030181124.EC35B5B30@mail.bitblocks.com>
next in thread | previous in thread | raw e-mail | index | archive | help
* Bakul Shah <bakul@bitblocks.com> [071030 11:11] wrote:
> > * Bakul Shah <bakul@bitblocks.com> [071030 09:36] wrote:
> > >
> > > The structured macro paper referenced on the K wiki page also
> > > seems rather interesting. A powerful macro facility needs to
> > > be well integrated with the language (much like Lisp or
> > > Scheme's macros) so that you can write for instance
> > >
> > > critical_section(lock) {
> > > ...
> > > bar:
> > > ...
> > > if (cond1) break;
> > > ...
> > > if (cond2) goto foo;
> > > ...
> > > if (cond3) goto bar;
> > > ...
> > > if (cond4) return; // from enclosing function
> > > ...
> > > }
> > > ...
> > > foo:
> >
> >
> > do you mean like C++:
> >
> > do {
> > critical_object critical_instance();
> >
> >
> >
> >
> > }
>
> No idea but I can not see how that will do what I had in mind. A purely
> lexical translation of the snippet I gave above would be something like:
You can create an object on the stack that locks the mutex given
to it like so:
do {
mtx_lock_object mtx_locker(&lock);
}
When the object is destroyed by stack popping, the lock will be freed.
It's the same thing.
-Alfred
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20071030201229.GA33488>
