From owner-freebsd-hackers@FreeBSD.ORG Wed Feb 11 22:22:20 2009 Return-Path: Delivered-To: hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BC8A010656C3 for ; Wed, 11 Feb 2009 22:22:20 +0000 (UTC) (envelope-from bruce@cran.org.uk) Received: from muon.cran.org.uk (brucec-1-pt.tunnel.tserv4.nyc4.ipv6.he.net [IPv6:2001:470:1f06:c09::2]) by mx1.freebsd.org (Postfix) with ESMTP id 6F7EA8FC29 for ; Wed, 11 Feb 2009 22:22:20 +0000 (UTC) (envelope-from bruce@cran.org.uk) Received: from muon.cran.org.uk (localhost [127.0.0.1]) by muon.cran.org.uk (Postfix) with ESMTP id 9E43919256; Wed, 11 Feb 2009 22:22:18 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on muon X-Spam-Level: X-Spam-Status: No, score=-2.6 required=8.0 tests=AWL,BAYES_00,NO_RELAYS autolearn=ham version=3.2.5 Received: from gluon (unknown [IPv6:2a01:348:10f:0:240:f4ff:fe57:9871]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by muon.cran.org.uk (Postfix) with ESMTPSA; Wed, 11 Feb 2009 22:22:18 +0000 (GMT) Date: Wed, 11 Feb 2009 22:22:13 +0000 From: Bruce Cran To: Christoph Mallon Message-ID: <20090211222213.7509f5e3@gluon> In-Reply-To: <49934846.10905@gmx.de> References: <43a2dc1a0902101243w5ce35609x35dbe440c39d80a8@mail.gmail.com> <4992D1B0.8020708@icyb.net.ua> <43a2dc1a0902110840t1e4c8856lb5b33cc153ea4acb@mail.gmail.com> <49934846.10905@gmx.de> X-Mailer: Claws Mail 3.5.0 (GTK+ 2.14.4; i486-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: hackers@freebsd.org, Aniruddha Bohra , Andriy Gapon Subject: Re: a little bit of c++ in kernel [module] X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Feb 2009 22:22:21 -0000 On Wed, 11 Feb 2009 22:51:02 +0100 Christoph Mallon wrote: > Aniruddha Bohra schrieb: > > On Wed, Feb 11, 2009 at 8:25 AM, Andriy Gapon > > wrote: > >> on 10/02/2009 22:43 Aniruddha Bohra said the following: > >>> You can see Click: http://read.cs.ucla.edu/click/ > >>> It does not run on FreeBSD >4. > >>> I have an old diff which builds on the work by Marko Zec and Bruce > >>> Simpson, that allows me to load the click module. > >>> http://www.cs.rutgers.edu/~bohra/click-1.5.0.diff > >> 1. options -fpermissive -fno-exceptions -fno-rtti are passed to > >> c++ compiler 2. there are new/delete implementations that use > >> kernel malloc > >> > >> I think that #1 means that there are no exceptions, (non-trivial) > >> dynamic_cast and typeid for kernel c++ code. > > > > Correct. > > That's a pity. Lack of exceptions negates some major benefits of C++. > > >> 1. do you use any global/static objects with constructors? did you > >> have to write any code to call on those constructors when the > >> module is loaded? > > > > Not sure about this one. But AFAIK, there are no global static > > objects with constructors in Click code. > > There is one router object that is always initialized and it is > > updated by writing to the clickfs file system. > > The other objects are created with new. > > > >> 2. did you have to write any other run-time support code or > >> platform glue code (besides new/delete)? > > > > Apart from the new and delete, I think the other things were the > > pseudofs code to initialize the file system, > > the locks in include/click/sync.hh, the glue code in atomic.hh. > > > > > >> 3. I assume virtual inheritance can be used in kernel code? do you > >> use it? > > Virtual inheritence needs no support from the "outside", so it is > available. > > > Yes. For example, all objects inherit from "Element" and that > > defines virtual functions. (include/click/element.hh) > > Virtual inheritance is something completely different than virtual > methods. Microsoft has an overview of using C++ in kernel drivers at http://www.microsoft.com/whdc/driver/kernel/KMcode.mspx . It sounds like the situation on FreeBSD may be somewhat similar. -- Bruce Cran