[libcxx-commits] [libcxx] 59b3102 - [libc++] chrono: check _POSIX_TIMERS before using clock_gettime

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Thu May 7 10:15:22 PDT 2020


Author: Mara Sophie Grosch
Date: 2020-05-07T13:15:10-04:00
New Revision: 59b3102739c5988c9fc7ea77888de1bc8ce9c8ab

URL: https://github.com/llvm/llvm-project/commit/59b3102739c5988c9fc7ea77888de1bc8ce9c8ab
DIFF: https://github.com/llvm/llvm-project/commit/59b3102739c5988c9fc7ea77888de1bc8ce9c8ab.diff

LOG: [libc++] chrono: check _POSIX_TIMERS before using clock_gettime

clock_gettime is documented to be available when _POSIX_TIMERS is
defined. Add a check for this.

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

Added: 
    

Modified: 
    libcxx/src/chrono.cpp
    libcxx/src/filesystem/operations.cpp

Removed: 
    


################################################################################
diff  --git a/libcxx/src/chrono.cpp b/libcxx/src/chrono.cpp
index 9e8a1b32b41d..48c02c8d0682 100644
--- a/libcxx/src/chrono.cpp
+++ b/libcxx/src/chrono.cpp
@@ -12,9 +12,13 @@
 #include <time.h>        // clock_gettime, CLOCK_MONOTONIC and CLOCK_REALTIME
 #include "include/apple_availability.h"
 
-#if !defined(__APPLE__)
+#if !defined(_WIN32)
+#include <unistd.h>
+#endif
+
+#if !defined(__APPLE__) && _POSIX_TIMERS > 0
 #define _LIBCPP_USE_CLOCK_GETTIME
-#endif // __APPLE__
+#endif
 
 #if defined(_LIBCPP_WIN32API)
 #define WIN32_LEAN_AND_MEAN

diff  --git a/libcxx/src/filesystem/operations.cpp b/libcxx/src/filesystem/operations.cpp
index 876399fb4d4e..2c91ffd2df1d 100644
--- a/libcxx/src/filesystem/operations.cpp
+++ b/libcxx/src/filesystem/operations.cpp
@@ -36,7 +36,11 @@
 #define _LIBCPP_USE_COPYFILE
 #endif
 
-#if !defined(__APPLE__)
+#if !defined(_WIN32)
+#include <unistd.h>
+#endif
+
+#if !defined(__APPLE__) && _POSIX_TIMERS > 0
 #define _LIBCPP_USE_CLOCK_GETTIME
 #endif
 


        


More information about the libcxx-commits mailing list