[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
Cr-Mirrored-From: https://chromium.googlesource.com/external/github.com/llvm/llvm-project
Cr-Mirrored-Commit: 59b3102739c5988c9fc7ea77888de1bc8ce9c8ab
diff --git a/src/chrono.cpp b/src/chrono.cpp
index 9e8a1b3..48c02c8 100644
--- a/src/chrono.cpp
+++ b/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