Re: Header difference between open-source and 10.11 SDK
Re: Header difference between open-source and 10.11 SDK
- Subject: Re: Header difference between open-source and 10.11 SDK
- From: Damien DeVille <email@hidden>
- Date: Mon, 28 Dec 2015 17:32:03 +0000
> 1. Why are the headers different?
Usually, any difference between the public headers and the xnu ones is due to some sections being in `XNU_KERNEL_PRIVATE` def blocks. Code in these blocks are available to the kernel when it’s being built but not included when preprocessing the public headers. Code in these sections is not part of the KPI and thus not available to kexts for example.
> 2. Could I safely use the open-source version of this header, and expect my code to work on OS-X 10.11 in runtime?
Things might work for this very version of Darwin but will very likely break in the future. In particular:
- Some functions that you are using could be removed or updated in a future version.
- Structs that you are using could change. This happens all the time, for almost every new version of the kernel. In your example, a new member could be added to the top of the `socket` struct and this would break any existing code that you have that accesses these members directly. Usually, this is why one should always use an API to set or get a member of a struct (and is why most kernel structs are publicly opaque).
Another thing to keep in mind if you’re developing a kext: while you could declare a private function in you code, successfully link to it while building and call it from your code, `kextd` (the user-space daemon in charge of loading kexts on OS X) will fail to load the kext due to a linked symbol not being part of the KPI.
The Kernel Programming Guide has more info about what is and is not a KPI: https://developer.apple.com/library/mac/documentation/Darwin/Conceptual/KernelProgramming/About/About.html.
Thanks,
Damien
> On Dec 28, 2015, at 5:17 PM, Motti Shneor <email@hidden> wrote:
>
> Hello.
> I apologize - this might be a novice question.
>
> I’m trying to use some structs defined in sys/socketvar.h (as published in the latest 10.11.2 darwin open source version) but my code won't build in Xcode 7 and latest 10.11 SDK, because the sys/socketvar.h header in the SDK is much shorter and lacks lots of stuff.
>
> 1. Why are the headers different?
> 2. Could I safely use the open-source version of this header, and expect my code to work on OS-X 10.11 in runtime?
>
> If this is part of a “bigger picture” issue, please direct me to the proper reading.
>
> Thanks.
>
> Motti Shneor
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Darwin-dev mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden