Is it possible/safe to use C++ in a NKE?
Is it possible/safe to use C++ in a NKE?
- Subject: Is it possible/safe to use C++ in a NKE?
- From: Martin Hardman <email@hidden>
- Date: Thu, 28 Jan 2010 15:59:28 -0500
- Acceptlanguage: en-US
- Thread-topic: Is it possible/safe to use C++ in a NKE?
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.?
Thanks
Martin
|
_______________________________________________
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