[libc++] Use __has_include instead of complex logic in thread.cpp

We might end up including more headers than strictly necessary this way,
but it's much simpler and it makes it easier to port thread.cpp to systems
not handled by the existing conditionals.

Cr-Mirrored-From: https://chromium.googlesource.com/external/github.com/llvm/llvm-project
Cr-Mirrored-Commit: 477a68760b24f07a45253fb41e89368328b3a4a8
diff --git a/src/thread.cpp b/src/thread.cpp
index 5f44e9e..e1dc972 100644
--- a/src/thread.cpp
+++ b/src/thread.cpp
@@ -14,17 +14,21 @@
 #include "vector"
 #include "future"
 #include "limits"
-#include <sys/types.h>
 
-#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
+#if __has_include(<sys/types.h>)
+# include <sys/types.h>
+#endif
+
+#if __has_include(<sys/param.h>)
 # include <sys/param.h>
-# if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) || defined(__APPLE__)
-#   include <sys/sysctl.h>
-# endif
-#endif // defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
+#endif
+
+#if __has_include(<sys/sysctl.h>)
+# include <sys/sysctl.h>
+#endif
 
 #if __has_include(<unistd.h>)
-#include <unistd.h>
+# include <unistd.h>
 #endif
 
 #if defined(__NetBSD__)