a little bit of c++ in kernel [module]

David Schultz das at FreeBSD.ORG
Wed Feb 11 14:49:37 PST 2009


On Wed, Feb 11, 2009, Bruce Cran wrote:
> On Wed, 11 Feb 2009 22:51:02 +0100
> Christoph Mallon <christoph.mallon at gmx.de> wrote:
> 
> > Aniruddha Bohra schrieb:
> > > On Wed, Feb 11, 2009 at 8:25 AM, Andriy Gapon <avg at icyb.net.ua>
> > > 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.

FreeBSD doesn't support loading kernel code and data into pageable
memory like Windows does, so a lot of the paging-related problems
they're talking about aren't issues for us.


More information about the freebsd-hackers mailing list