diff --git a/libcxx/src/chrono.cpp b/libcxx/src/chrono.cpp --- a/libcxx/src/chrono.cpp +++ b/libcxx/src/chrono.cpp @@ -24,7 +24,7 @@ #include "include/apple_availability.h" #if __has_include() -# include +# include // _POSIX_TIMERS #endif #if __has_include() @@ -116,7 +116,7 @@ return system_clock::time_point(duration_cast(d - nt_to_unix_epoch)); } -#elif defined(CLOCK_REALTIME) && defined(_LIBCPP_USE_CLOCK_GETTIME) +#elif defined(_LIBCPP_USE_CLOCK_GETTIME) && defined(CLOCK_REALTIME) static system_clock::time_point __libcpp_system_clock_now() { struct timespec tp; @@ -226,7 +226,7 @@ return steady_clock::time_point(nanoseconds(_zx_clock_get_monotonic())); } -# elif defined(CLOCK_MONOTONIC) +# elif defined(_LIBCPP_USE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC) static steady_clock::time_point __libcpp_steady_clock_now() { struct timespec tp; diff --git a/libcxx/src/filesystem/filesystem_clock.cpp b/libcxx/src/filesystem/filesystem_clock.cpp --- a/libcxx/src/filesystem/filesystem_clock.cpp +++ b/libcxx/src/filesystem/filesystem_clock.cpp @@ -19,10 +19,18 @@ # include #endif -#if !defined(CLOCK_REALTIME) && !defined(_LIBCPP_WIN32API) +#if __has_include() +# include // _POSIX_TIMERS +#endif + +#if __has_include() # include // for gettimeofday and timeval #endif +#if !defined(__APPLE__) && defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0 +# define _LIBCPP_USE_CLOCK_GETTIME +#endif + _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM const bool _FilesystemClock::is_steady; @@ -36,7 +44,7 @@ detail::TimeSpec tp = detail::filetime_to_timespec(time); return time_point(__secs(tp.tv_sec) + chrono::duration_cast(__nsecs(tp.tv_nsec))); -#elif defined(CLOCK_REALTIME) +#elif defined(_LIBCPP_USE_CLOCK_GETTIME) && defined(CLOCK_REALTIME) typedef chrono::duration __nsecs; struct timespec tp; if (0 != clock_gettime(CLOCK_REALTIME, &tp))