Re: Is it possible/safe to use C++ in a NKE?
Re: Is it possible/safe to use C++ in a NKE?
- Subject: Re: Is it possible/safe to use C++ in a NKE?
- From: Andrew Myrick <email@hidden>
- Date: Thu, 28 Jan 2010 13:31:24 -0800
On Jan 28, 2010, at 12:59 PM, Martin Hardman wrote: Hi I’m shortly about to embark upon developing an NKE to peak/poke into TCP traffic, and trying to find out the details regarding C++ support for doing so. I came across the following quote from the Kernel extension release notes for Snow Leopard: Mixed C/C++ Kexts Mac OS X Snow Leopard features support for kexts that use both C and C++ code. On prior releases of Mac OS X, making use of Libkern C++ classes in a generic (C-based) kext was a risky proposition, since the I/O Kit auto-unloading mechanism destroyed any kext referencing such classes if there were no instances of them. Apart from that, even if non- Libkern C++ was used, the stub routine invoked at unload called the kext’s static C++ destructors before the kext’s stop routine, and when the kext was auto-unloaded the stop routine wasn’t invoked at all. Snow Leopard corrects these issues by: Marking only kexts that define subclasses of IOService for auto-unload. Non-I/O Kit kexts loaded on Snow Leopard can safely use and subclass Libkern C++ classes. Altering the stub unload routine to call the kext’s stop routine first, then the kext’s static C++ destructors. Important: To gain this behavior you must build your kext to be targeted against Snow Leopard, as the stub routine is built into the kext. Always unloading a kext by calling both the stop routine and then the C++ static destructors, regardless of kext type (generic or I/O Kit). Can I make the conclusion that developing my NKE in C++ is going to be a viable safe possibility? If so, will it be non back-portable to Leopard etc.?
It's safe in general for 10.6, and it's safe for 10.5 and earlier if you don't use the OSObject-based classes found in libkern.
-Andrew |
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden