You wouldn't patent OSX (or I think be able to (Method For Turning Hot-Dogs Into Computer Outputs via Human Interaction, anyone?)), that would fall under both copyright (for the code) and trademark (for the name). What they would patent would be, for example, the specific display methods used by Cocoa or Carbon (especially as they differed from any prior art).
If they made some improvement to the BSD TCP/IP stack, they might try to patent the method by which the improvement worked, which would be up to the USTPO (or equivalent elsewhere) to grant, and up to Apple's lawyers to enforce, and up to the courts to uphold, but even if the patent holds it would still only apply to the improvement, not at all to the original BSD TCP/IP implementation.