[libc++] Use __has_include instead of complex logic in thread.cpp
authorLouis Dionne <ldionne@apple.com>
Mon, 5 Oct 2020 20:39:33 +0000 (16:39 -0400)
committerLouis Dionne <ldionne@apple.com>
Mon, 5 Oct 2020 20:41:25 +0000 (16:41 -0400)
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.

libcxx/src/thread.cpp

index 5f44e9e..e1dc972 100644 (file)
 #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__)