[CF] Unify implementations of _CFProcessPath.
[CF] Unify implementations of _CFProcessPath.

Firstly, _CFProcessPath has no implementation for TARGET_OS_BSD. Indeed,
there is no portable implementation of this action across multiple
platforms. As an initial implementation for TARGET_OS_BSD, use the
environment to help us. Some shells set the environment variable "_" to
the path used to invoke the binary. This mirrors the implementation for
TARGET_OS_OSX, so add the same conditionals on __CFProcessIsRestricted.

Relying on the shell has drawbacks, including that the shell doesn't set
the full path to the current executable if it isn't part of the PATH
(or, of course, specified explicitly). Perhaps on some other platforms
there is some miscellaneous kernel trickery that could be done, but
let's defer that to the future and keep getenv("_") as a last resort.

Second, given that, we should bring the implementations together (like
we've done elsewhere), not to mention that _CFProcessPath is fundamental
to other parts of CF. This highlights the repetition in each
implementation, so here we also factor off some of it and share it
across the implementations to facilitate code reuse.

apple/swift-corelibs-foundation,apple/swift-corelibs-foundation,apple/swift-corelibs-foundation,apple/swift-corelibs-foundation,apple/swift-corelibs-foundation