Note: This was tested on Linux x86_64 with a host compiler of Clang 3.4 and a glibc standard library. Attempts were made to test on Cygwin, but it was pretty severely broken prior to this patch. It is likely that I have accidentally broken other OSes and C libraries. I'm open to recommendations on ways to test this that are better than "Submit, watch build bots, revert as necessary".
This patch attempts to consolidate the handling of *_l and posix locale management functions into the support headers. Outside of the support headers, _CXX_* versions of the functions will be called instead. _CXX_ was chosen as the prefix as it is a reserved name for the "implementation", so we won't conflict with user names. Double underscores were avoided as a prefix because some C libraries already use double underscores for internal versions of these functions and structures (e.g. GLIBC has an __locale_t, so we use _CXX_locale_t instead).
This patch also adds a configuration option that I see being useful for embedded users. Setting LIBCXX_ENABLE_LOCALE_EXTENSIONS to OFF will stub out a lot of the locale functionality in an inline friendly way.
As a consequence of fixing the locale portability headers, some other support headers got rearranged. Notably, monolothic support headers got split along functionality lines, and helpers for __builtin_* replacements got moved around as well.