From owner-freebsd-arch@FreeBSD.ORG Tue Oct 30 20:12:30 2007 Return-Path: Delivered-To: freebsd-arch@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 26F1F16A419; Tue, 30 Oct 2007 20:12:30 +0000 (UTC) (envelope-from bright@elvis.mu.org) Received: from elvis.mu.org (elvis.mu.org [192.203.228.196]) by mx1.freebsd.org (Postfix) with ESMTP id 1648E13C481; Tue, 30 Oct 2007 20:12:29 +0000 (UTC) (envelope-from bright@elvis.mu.org) Received: by elvis.mu.org (Postfix, from userid 1192) id 8D0661A4D81; Tue, 30 Oct 2007 13:12:29 -0700 (PDT) Date: Tue, 30 Oct 2007 13:12:29 -0700 From: Alfred Perlstein To: Bakul Shah Message-ID: <20071030201229.GA33488@elvis.mu.org> References: <20071030173734.GV33488@elvis.mu.org> <20071030181124.EC35B5B30@mail.bitblocks.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20071030181124.EC35B5B30@mail.bitblocks.com> User-Agent: Mutt/1.4.2.3i Cc: Poul-Henning Kamp , Garance A Drosehn , freebsd-arch@FreeBSD.org Subject: Re: C++ in the kernel 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: Tue, 30 Oct 2007 20:12:30 -0000 * Bakul Shah [071030 11:11] wrote: > > * Bakul Shah [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