kern/99979: Get Ready for Kernel Module in C++

M. Warner Losh imp at bsdimp.com
Tue Jul 11 21:30:07 UTC 2006


In message: <1152642474.29859 at origin.intron.ac>
            mag at intron.ac writes:
: Why do you all consider importing C++ code to FreeBSD kernel to be so
: complicated at the beginning?

Many people reading this list have conducted experiments in the past
at various employers.  Everyone who has conducted the experiments
reports that the 'trivial' parts of C++ are trivial to do in the
kernel.  new/delete support is easy.  Subclassing is easy, so long as
it is single inheritance.  Some limited template support is possible.
Exceptions can be made to be not too bad, but at the expense of much
of the exception functionality.  If you look at the number of weasil
words I used here to describe the functionality, you'll see that the
'easy' parts of C++ aren't a very large subset of the entire language,
and many would argue aren't a useful enough subset to be worth the
efforts to clean up the code and make it production quality.

However, C++ has so many standard libraries and interfaces that
importing them into the kernel is a daunting task.  STL is right out,
for example, as are the insertion and extraction operators.

Also, g++ has traditionally produced worse code for C++ than for C,
even when the source is identical.  This stems mainly from subtle
differences in the semantics of the two languages.  This was true in
2.3 times, in 2.4 times, and is still true with 3.4.4 that we have in
current, although a few simple tests indicates that things have gotten
much better.

Basically, people here have tried it in the past and given up.  They
are very leery of any changes in this direction, and need some sort of
proof to be convinced otherwise.

Warner


More information about the freebsd-hackers mailing list