[libcxx-commits] [PATCH] D79784: [libc++] Adjust how we guard the inclusion of unistd.h

John Brawn via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed May 13 05:54:33 PDT 2020


john.brawn updated this revision to Diff 263678.
john.brawn edited the summary of this revision.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79784/new/

https://reviews.llvm.org/D79784

Files:
  libcxx/src/chrono.cpp
  libcxx/src/filesystem/operations.cpp
  libcxx/src/thread.cpp


Index: libcxx/src/thread.cpp
===================================================================
--- libcxx/src/thread.cpp
+++ libcxx/src/thread.cpp
@@ -23,9 +23,9 @@
 # endif
 #endif // defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
 
-#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) || defined(__CloudABI__) || defined(__Fuchsia__) || defined(__wasi__)
-# include <unistd.h>
-#endif // defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) || defined(__CloudABI__) || defined(__Fuchsia__) || defined(__wasi__)
+#if __has_include(<unistd.h>)
+#include <unistd.h>
+#endif
 
 #if defined(__NetBSD__)
 #pragma weak pthread_create // Do not create libpthread dependency
Index: libcxx/src/filesystem/operations.cpp
===================================================================
--- libcxx/src/filesystem/operations.cpp
+++ libcxx/src/filesystem/operations.cpp
@@ -36,10 +36,6 @@
 #define _LIBCPP_USE_COPYFILE
 #endif
 
-#if !defined(_WIN32)
-#include <unistd.h>
-#endif
-
 #if !defined(__APPLE__) && _POSIX_TIMERS > 0
 #define _LIBCPP_USE_CLOCK_GETTIME
 #endif
Index: libcxx/src/chrono.cpp
===================================================================
--- libcxx/src/chrono.cpp
+++ libcxx/src/chrono.cpp
@@ -12,7 +12,7 @@
 #include <time.h>        // clock_gettime, CLOCK_MONOTONIC and CLOCK_REALTIME
 #include "include/apple_availability.h"
 
-#if !defined(_WIN32)
+#if __has_include(<unistd.h>)
 #include <unistd.h>
 #endif
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79784.263678.patch
Type: text/x-patch
Size: 1479 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20200513/9bb3114f/attachment.bin>


More information about the libcxx-commits mailing list