From owner-freebsd-hackers@FreeBSD.ORG Tue Sep 9 10:21:48 2003 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 62DCE16A4BF for ; Tue, 9 Sep 2003 10:21:48 -0700 (PDT) Received: from mail.sandvine.com (sandvine.com [199.243.201.138]) by mx1.FreeBSD.org (Postfix) with ESMTP id 974FC43FB1 for ; Tue, 9 Sep 2003 10:21:47 -0700 (PDT) (envelope-from don@sandvine.com) Received: by mail.sandvine.com with Internet Mail Service (5.5.2653.19) id ; Tue, 9 Sep 2003 13:21:46 -0400 Message-ID: From: Don Bowman To: 'John Giacomoni' , freebsd-hackers@freebsd.org Date: Tue, 9 Sep 2003 13:21:42 -0400 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: text/plain; charset="iso-8859-1" Subject: RE: C++ code in a kernel module? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Sep 2003 17:21:48 -0000 > From: John Giacomoni [mailto:John.Giacomoni@colorado.edu] > On Tuesday, Sep 9, 2003, at 00:29 America/Denver, Peter Jeremy wrote: > > > On Mon, Sep 08, 2003 at 11:12:59PM -0400, Alexander Kabaev wrote: > >> On Mon, 8 Sep 2003 23:02:33 -0400 > >> "Matthew Emmerton" wrote: > >> > >>> I've been silently following this thread, and unless I missed > >>> something, has anyone asked John why he wants/needs to > use C++ in the > >>> kernel? > >>> > >> Tools, not policy :) > > > > True but if John explains more of what he is trying to do, maybe > > someone can suggest either a way to avoid C++ or some insights as to > > how he can get his C++ modules to work. > > > > Peter > > simple, I have preexisting C++ code which we are currently > using in userland and wish to push down into the kernel. > > It would be ideal to keep the source bases the same without > a rewrite to C. Admitting of course the possibility of having > to modify to be compatible with both use modes. > > At present I am attempting to see what we can and cannot do > in the kernel with C++ Speaking as someone who has implemented this for VxWorks [which is similar to BSD in some ways], its not easy, but its not impossible. here's the things you have to do: libstdc++/libgcc -> need to be linked in. static constructors/destructors need to be called, exception tables need to be linked. libgcc does this and is called from crt. If you want it to work for loadable modules, same deal, call the constructors/add the exception tables when module is loaded. thread-safety model in exception handling needs a .h file written for it and placed in the compiler. I think thr-vxworks.h was the one i wrote. none of this is impossible, or even particularly hard. it will just take some time. I think its very worthwhile, it would allow using e.g. STL, boost, etc in things like ipfw or other add-ins that have complex proprietary and often slower data structures. There's more to life than SLIST.