This is a different approach to adding support for z/OS POSIX(OFF) based on the suggestions in D110349.
However, since z/OS still needs to use the pthread version of the __threading_support API, instead of _LIBCPP_HAS_THREAD_API_EXTERNAL we implement something very close to _LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL.
We couldn't quite use _LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL for two reasons: First, we only want to affect libcxx's internal uses of __threading_support (i.e. those inside libcxx/src not libcxx/include). Second, we don't want to affect anything in the C++11 Threading Support Library, since the user shouldn't be using that anyways if the base threading support library (e.g. pthread) isn't available.
This is the 4th of 4 changes to add support for POSIX(OFF) on z/OS.
See D117366 for more background, and D110349 for discussion of an alternative implementation.
To me, this is horrendous, and a very strong reason to prefer what I proposed in D113054. Even if we go with the approach outlined in this PR for everything else except exception storage, I think that at the very least the runtime-dependent threading changes should be allowed to creep out of internal_threading_support.h and into cxa_exception_storage.cpp.
We may also not have any choice in the matter when adding support for a platform like AIX where __libcpp_is_threading_api_enabled() can change during program execution.