diff --git a/libcxx/src/chrono.cpp b/libcxx/src/chrono.cpp --- a/libcxx/src/chrono.cpp +++ b/libcxx/src/chrono.cpp @@ -44,6 +44,10 @@ # endif #endif // defined(_LIBCPP_WIN32API) +#if defined(__Fuchsia__) +# include +#endif + #if __has_include() # include #endif @@ -266,7 +270,18 @@ return steady_clock::time_point(seconds(ts.tv_sec) + nanoseconds(ts.tv_nsec)); } -#elif defined(CLOCK_MONOTONIC) +# elif defined(__Fuchsia__) + +static steady_clock::time_point __libcpp_steady_clock_now() noexcept { + // Implicitly link against the vDSO system call ABI without + // requiring the final link to specify -lzircon explicitly when + // statically linking libc++. +# pragma comment(lib, "zircon") + + return steady_clock::time_point(nanoseconds(_zx_clock_get_monotonic())); +} + +# elif defined(CLOCK_MONOTONIC) static steady_clock::time_point __libcpp_steady_clock_now() { struct timespec tp; @@ -275,9 +290,9 @@ return steady_clock::time_point(seconds(tp.tv_sec) + nanoseconds(tp.tv_nsec)); } -#else -# error "Monotonic clock not implemented on this platform" -#endif +# else +# error "Monotonic clock not implemented on this platform" +# endif const bool steady_clock::is_steady;