diff --git a/libcxx/src/chrono.cpp b/libcxx/src/chrono.cpp --- a/libcxx/src/chrono.cpp +++ b/libcxx/src/chrono.cpp @@ -31,8 +31,8 @@ # include // for gettimeofday and timeval #endif -#if !defined(__APPLE__) && defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0 -# define _LIBCPP_USE_CLOCK_GETTIME +#if defined(__APPLE__) || (defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0) +# define _LIBCPP_HAS_CLOCK_GETTIME #endif #if defined(_LIBCPP_WIN32API) @@ -116,7 +116,7 @@ return system_clock::time_point(duration_cast(d - nt_to_unix_epoch)); } -#elif defined(_LIBCPP_USE_CLOCK_GETTIME) && defined(CLOCK_REALTIME) +#elif defined(_LIBCPP_HAS_CLOCK_GETTIME) 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(_LIBCPP_USE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC) +# elif defined(_LIBCPP_HAS_CLOCK_GETTIME) 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 @@ -27,8 +27,8 @@ # include // for gettimeofday and timeval #endif -#if !defined(__APPLE__) && defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0 -# define _LIBCPP_USE_CLOCK_GETTIME +#if defined(__APPLE__) || (defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0) +# define _LIBCPP_HAS_CLOCK_GETTIME #endif _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM @@ -44,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(_LIBCPP_USE_CLOCK_GETTIME) && defined(CLOCK_REALTIME) +#elif defined(_LIBCPP_HAS_CLOCK_GETTIME) typedef chrono::duration __nsecs; struct timespec tp; if (0 != clock_gettime(CLOCK_REALTIME, &tp)) @@ -56,7 +56,7 @@ timeval tv; gettimeofday(&tv, 0); return time_point(__secs(tv.tv_sec) + __microsecs(tv.tv_usec)); -#endif // CLOCK_REALTIME +#endif } _LIBCPP_END_NAMESPACE_FILESYSTEM