[libcxx-commits] [PATCH] D155022: [libc++] Fix clock selection in chrono.cpp and filesystem_clock.cpp
Louis Dionne via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Jul 12 15:07:50 PDT 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7e6f2b749bf7: [libc++] Fix clock selection in chrono.cpp and filesystem_clock.cpp (authored by ldionne).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D155022/new/
https://reviews.llvm.org/D155022
Files:
libcxx/src/chrono.cpp
libcxx/src/filesystem/filesystem_clock.cpp
Index: libcxx/src/filesystem/filesystem_clock.cpp
===================================================================
--- libcxx/src/filesystem/filesystem_clock.cpp
+++ libcxx/src/filesystem/filesystem_clock.cpp
@@ -27,8 +27,8 @@
# include <sys/time.h> // 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<duration>(__nsecs(tp.tv_nsec)));
-#elif defined(_LIBCPP_USE_CLOCK_GETTIME) && defined(CLOCK_REALTIME)
+#elif defined(_LIBCPP_HAS_CLOCK_GETTIME)
typedef chrono::duration<rep, nano> __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
Index: libcxx/src/chrono.cpp
===================================================================
--- libcxx/src/chrono.cpp
+++ libcxx/src/chrono.cpp
@@ -31,8 +31,8 @@
# include <sys/time.h> // 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<system_clock::duration>(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;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155022.539755.patch
Type: text/x-patch
Size: 2302 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20230712/5fa2ec72/attachment-0001.bin>
More information about the libcxx-commits
mailing list