[linux drivers] Is it possible to use boost in a Linux driver?

Does anybody know if it's possible to use boost within a Linux driver?

Sid Sacek wrote:
Does anybody know if it's possible to use boost within a Linux driver?
First you'd have to use C++ in a Linux driver, which is tricky all by itself. Humm, I'd say, all in all, no. You definitely don't have unwinding in kernel mode. This means you must disable exceptions. But the exception replacement system in Boost calls abort(), I believe, and I don't think this call links in kernel objects. (I don't want to know what it would do.) Sebastian

Sid Sacek wrote:
Does anybody know if it's possible to use boost within a Linux driver?
Not in general, no. I don't expect it is, as typically kernel-space code doesn't have access to a full C++ runtime. May be a small subset (not involving the standard C++ library) would work. Regards, Stefan -- ...ich hab' noch einen Koffer in Berlin...

Ok thanks Stefan and Sebastian, I see what you're both getting at. It might be doable only to a degree, but then it's probably not worth the effort. Regards, -Sid Sacek -----Original Message----- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of Stefan Seefeld Sent: Tuesday, January 13, 2009 1:08 PM To: boost@lists.boost.org Subject: Re: [boost] [linux drivers] Is it possible to use boost in a Linux driver? Sid Sacek wrote:
Does anybody know if it's possible to use boost within a Linux driver?
Not in general, no. I don't expect it is, as typically kernel-space code doesn't have access to a full C++ runtime. May be a small subset (not involving the standard C++ library) would work. Regards, Stefan -- ...ich hab' noch einen Koffer in Berlin... _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Does anybody know if it's possible to use boost within a Linux driver?
For reference, here's the Linux kernel FAQ item on C++ in the kernel (including drivers): http://www.kernel.org/pub/linux/docs/lkml/#s15-3 HTH, -Ossama

Othman, Ossama wrote:
Does anybody know if it's possible to use boost within a Linux driver?
For reference, here's the Linux kernel FAQ item on C++ in the kernel (including drivers):
Hmm, unfortunately that page has a very low signal-to-noise ratio. There is little actual information to be found there, only folklore (which may or may not be true). In particular, the often heard claim about "C++ is slow" and "C++ compilers suck" needs to be substantiated by real numbers / comparisons. (I'm working in High Performance Computing, working mostly with C++.) The one real argument unfortunately only alluded to is exception handling (stack unwinding). It would be nice to have a technically accurate description of the involved mechanism (let's take the now established C++ ABI for that) and discuss why it is hard / impossible to use in kernel code. I'm sure there are a great many good discussions to be had over this (and I do know that C++ and POSIX folks like to get into those), but the above page just isn't a good resource to get informed, unfortunately. </rambling> Regards, Stefan -- ...ich hab' noch einen Koffer in Berlin...

Hi Stefan,
Othman, Ossama wrote:
For reference, here's the Linux kernel FAQ item on C++ in the kernel (including drivers):
Hmm, unfortunately that page has a very low signal-to-noise ratio. There is little actual information to be found there, only folklore (which may or may not be true).
Yes indeed.
In particular, the often heard claim about "C++ is slow" and "C++ compilers suck" needs to be substantiated by real numbers / comparisons. (I'm working in High Performance Computing, working mostly with C++.)
Quite right.
The one real argument unfortunately only alluded to is exception handling (stack unwinding). It would be nice to have a technically accurate description of the involved mechanism (let's take the now established C++ ABI for that) and discuss why it is hard / impossible to use in kernel code.
I'm sure there are a great many good discussions to be had over this (and I do know that C++ and POSIX folks like to get into those), but the above page just isn't a good resource to get informed, unfortunately.
I agree. I just wanted to point out that getting C++ code into the kernel is essentially non-starter. Even those writing drivers that won't be going into the kernel (such as proprietary drivers) and contain C++ will most likely have a tough time due to lack of support from the kernel and many kernel developers. Thanks, -Ossama

Othman, Ossama wrote:
For reference, here's the Linux kernel FAQ item on C++ in the kernel (including drivers):
Hmm, unfortunately that page has a very low signal-to-noise ratio. There is little actual information to be found there, only folklore (which may or may not be true). In particular, the often heard claim about "C++ is slow" and "C++ compilers suck" needs to be substantiated by real numbers / comparisons. (I'm working in High Performance Computing, working mostly with C++.) No, it doesn't. The page isn't about why C++ is inappropriate for kernels, but about why C++ won't make it into the kernel, written as the opinions of several people. The page points out that many kernel hackers don't like C++ - it certainly doesn't need to defend the opinions of
Stefan Seefeld wrote: these hackers. Sebastian

Stefan Seefeld wrote:
The one real argument unfortunately only alluded to is exception handling (stack unwinding). It would be nice to have a technically accurate description of the involved mechanism (let's take the now established C++ ABI for that) and discuss why it is hard / impossible to use in kernel code.
Contrary to popular belief, it is certainly not impossible. As a matter of fact, this has been done. You can have the whole C++ runtime in any kernel, including linux. Using C++ without exceptions doesn't have much point anyway, since the point of C++ is RAII.

Mathias Gaunard-2 wrote:
Stefan Seefeld wrote:
The one real argument unfortunately only alluded to is exception handling (stack unwinding). It would be nice to have a technically accurate description of the involved mechanism (let's take the now established C++ ABI for that) and discuss why it is hard / impossible to use in kernel code.
Contrary to popular belief, it is certainly not impossible. As a matter of fact, this has been done. You can have the whole C++ runtime in any kernel, including linux.
Using C++ without exceptions doesn't have much point anyway, since the point of C++ is RAII.
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Hi, IMO exceptions and RAII are orthogonal. The destructor will be called even if exceptions are not allowed. Vicente -- View this message in context: http://www.nabble.com/-linux-drivers--Is-it-possible-to-use-boost-in-a-Linux... Sent from the Boost - Dev mailing list archive at Nabble.com.

Does anybody know if it's possible to use boost within a Linux driver?
short answer - from principle point of view: yes. A longer answer: probably without the full set of c++ language features. This means no exception handling (EH), no rtti. Some years ago I wrote a c++ kernel module (2.4.x). You have to write some stub for the c++ specific linker symbols from g++ e.g. __ctor, __dtor etc. There where some discussion on net about c++ modules inside linux kernel. You have to google for it. The problem is the c++ runtime library and some general problems, e.g. how to handle uncaught exceptions? kernel panic? not a real solution - therefore no EH. Regards, Olaf

Olaf Peter wrote:
Does anybody know if it's possible to use boost within a Linux driver?
short answer - from principle point of view: yes.
A longer answer: probably without the full set of c++ language features. This means no exception handling (EH), no rtti. Some years ago I wrote a c++ kernel module (2.4.x). You have to write some stub for the c++ specific linker symbols from g++ e.g. __ctor, __dtor etc. There where some discussion on net about c++ modules inside linux kernel. You have to google for it. The problem is the c++ runtime library and some general problems, e.g. how to handle uncaught exceptions? kernel panic? not a real solution - therefore no EH.
Or, to quote from the linked page # Is it a good idea to write a new driver in C++# Is it a good idea to write a new driver in C++? The short answer is no, because there isn't any support for C++ drivers in the kernel. # Why not add a C++ interface layer to the kernel to support C++ drivers? The short answer is why bother, since there aren't any C++ drivers for Linux. So, you cannot write a driver in C++ because it isn't supported. Linus is very happy with that. Bo Persson
participants (8)
-
Bo Persson
-
Mathias Gaunard
-
Olaf Peter
-
Othman, Ossama
-
Sebastian Redl
-
Sid Sacek
-
Stefan Seefeld
-
Vicente Botet Escriba