aboutsummaryrefslogtreecommitdiffstats
path: root/src/chrono.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2018-07-28 11:07:56 +0000
committerDimitry Andric <dim@FreeBSD.org>2018-07-28 11:07:56 +0000
commitf36202620b428c45a1c8d91743727c9313424fb2 (patch)
tree14928d8970ba4890a6370aca4c38fc832d45f21f /src/chrono.cpp
parent0294ba5648d889e48ffee8ddad25944e258940ae (diff)
downloadsrc-f36202620b428c45a1c8d91743727c9313424fb2.tar.gz
src-f36202620b428c45a1c8d91743727c9313424fb2.zip
Vendor import of libc++ trunk r338150:vendor/libc++/libc++-trunk-r338150
Notes
Notes: svn path=/vendor/libc++/dist/; revision=336819 svn path=/vendor/libc++/libc++-trunk-r338150/; revision=336820; tag=vendor/libc++/libc++-trunk-r338150
Diffstat (limited to 'src/chrono.cpp')
-rw-r--r--src/chrono.cpp41
1 files changed, 12 insertions, 29 deletions
diff --git a/src/chrono.cpp b/src/chrono.cpp
index d0e184ad32fb..882d50b9d731 100644
--- a/src/chrono.cpp
+++ b/src/chrono.cpp
@@ -11,27 +11,10 @@
#include "cerrno" // errno
#include "system_error" // __throw_system_error
#include <time.h> // clock_gettime, CLOCK_MONOTONIC and CLOCK_REALTIME
+#include "include/apple_availability.h"
-#if (__APPLE__)
-#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)
-#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101200
-#define _LIBCXX_USE_CLOCK_GETTIME
-#endif
-#elif defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__)
-#if __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 100000
-#define _LIBCXX_USE_CLOCK_GETTIME
-#endif
-#elif defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__)
-#if __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ >= 100000
-#define _LIBCXX_USE_CLOCK_GETTIME
-#endif
-#elif defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__)
-#if __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ >= 30000
-#define _LIBCXX_USE_CLOCK_GETTIME
-#endif
-#endif // __ENVIRONMENT_.*_VERSION_MIN_REQUIRED__
-#else
-#define _LIBCXX_USE_CLOCK_GETTIME
+#if !defined(__APPLE__)
+#define _LIBCPP_USE_CLOCK_GETTIME
#endif // __APPLE__
#if defined(_LIBCPP_WIN32API)
@@ -42,7 +25,7 @@
#include <winapifamily.h>
#endif
#else
-#if !defined(CLOCK_REALTIME) || !defined(_LIBCXX_USE_CLOCK_GETTIME)
+#if !defined(CLOCK_REALTIME) || !defined(_LIBCPP_USE_CLOCK_GETTIME)
#include <sys/time.h> // for gettimeofday and timeval
#endif // !defined(CLOCK_REALTIME)
#endif // defined(_LIBCPP_WIN32API)
@@ -92,16 +75,16 @@ system_clock::now() _NOEXCEPT
static_cast<__int64>(ft.dwLowDateTime)};
return time_point(duration_cast<duration>(d - nt_to_unix_epoch));
#else
-#if defined(_LIBCXX_USE_CLOCK_GETTIME) && defined(CLOCK_REALTIME)
- struct timespec tp;
- if (0 != clock_gettime(CLOCK_REALTIME, &tp))
- __throw_system_error(errno, "clock_gettime(CLOCK_REALTIME) failed");
- return time_point(seconds(tp.tv_sec) + microseconds(tp.tv_nsec / 1000));
+#if defined(_LIBCPP_USE_CLOCK_GETTIME) && defined(CLOCK_REALTIME)
+ struct timespec tp;
+ if (0 != clock_gettime(CLOCK_REALTIME, &tp))
+ __throw_system_error(errno, "clock_gettime(CLOCK_REALTIME) failed");
+ return time_point(seconds(tp.tv_sec) + microseconds(tp.tv_nsec / 1000));
#else
timeval tv;
gettimeofday(&tv, 0);
return time_point(seconds(tv.tv_sec) + microseconds(tv.tv_usec));
-#endif // _LIBCXX_USE_CLOCK_GETTIME && CLOCK_REALTIME
+#endif // _LIBCPP_USE_CLOCK_GETTIME && CLOCK_REALTIME
#endif
}
@@ -129,7 +112,7 @@ const bool steady_clock::is_steady;
#if defined(__APPLE__)
// Darwin libc versions >= 1133 provide ns precision via CLOCK_UPTIME_RAW
-#if defined(_LIBCXX_USE_CLOCK_GETTIME) && defined(CLOCK_UPTIME_RAW)
+#if defined(_LIBCPP_USE_CLOCK_GETTIME) && defined(CLOCK_UPTIME_RAW)
steady_clock::time_point
steady_clock::now() _NOEXCEPT
{
@@ -191,7 +174,7 @@ steady_clock::now() _NOEXCEPT
static FP fp = init_steady_clock();
return time_point(duration(fp()));
}
-#endif // defined(_LIBCXX_USE_CLOCK_GETTIME) && defined(CLOCK_UPTIME_RAW)
+#endif // defined(_LIBCPP_USE_CLOCK_GETTIME) && defined(CLOCK_UPTIME_RAW)
#elif defined(_LIBCPP_WIN32API)