[libcxx-commits] [libcxx] 477a687 - [libc++] Use __has_include instead of complex logic in thread.cpp
    Louis Dionne via libcxx-commits 
    libcxx-commits at lists.llvm.org
       
    Mon Oct  5 13:41:40 PDT 2020
    
    
  
Author: Louis Dionne
Date: 2020-10-05T16:41:25-04:00
New Revision: 477a68760b24f07a45253fb41e89368328b3a4a8
URL: https://github.com/llvm/llvm-project/commit/477a68760b24f07a45253fb41e89368328b3a4a8
DIFF: https://github.com/llvm/llvm-project/commit/477a68760b24f07a45253fb41e89368328b3a4a8.diff
LOG: [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.
Added: 
    
Modified: 
    libcxx/src/thread.cpp
Removed: 
    
################################################################################
diff  --git a/libcxx/src/thread.cpp b/libcxx/src/thread.cpp
index 5f44e9e40fc7..e1dc972cba7f 100644
--- a/libcxx/src/thread.cpp
+++ b/libcxx/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__)
        
    
    
More information about the libcxx-commits
mailing list