[libc++] Split a few utilities out of __threading_support

This change is the basis for a further refactoring where I'm going to
split up the various implementations we have in __threading_support to
make that code easier to understand.

Note that I had to make __convert_to_timespec a template to break
circular dependencies. Concretely, we never seem to use it with anything
other than ::timespec, but I am wary of hardcoding that assumption as
part of this change, since I suspect there's a reason for going through
these hoops in the first place.

Differential Revision: https://reviews.llvm.org/D116944

NOKEYCHECK=True
GitOrigin-RevId: df51be85e4aee2365338186e38aebf7ffe81fc90
diff --git a/src/atomic.cpp b/src/atomic.cpp
index 9b61a16..250d33e 100644
--- a/src/atomic.cpp
+++ b/src/atomic.cpp
@@ -9,9 +9,10 @@
 #include <__config>
 #ifndef _LIBCPP_HAS_NO_THREADS
 
-#include <climits>
 #include <atomic>
+#include <climits>
 #include <functional>
+#include <thread>
 
 #ifdef __linux__