summaryrefslogtreecommitdiff
path: root/deps/uv/src/unix/darwin.c
diff options
context:
space:
mode:
Diffstat (limited to 'deps/uv/src/unix/darwin.c')
-rw-r--r--deps/uv/src/unix/darwin.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/deps/uv/src/unix/darwin.c b/deps/uv/src/unix/darwin.c
index cf95da2169..b1ffbc37b4 100644
--- a/deps/uv/src/unix/darwin.c
+++ b/deps/uv/src/unix/darwin.c
@@ -34,8 +34,12 @@
#include <mach-o/dyld.h> /* _NSGetExecutablePath */
#include <sys/resource.h>
#include <sys/sysctl.h>
+#include <time.h>
#include <unistd.h> /* sysconf */
+#undef NANOSEC
+#define NANOSEC ((uint64_t) 1e9)
+
int uv__platform_loop_init(uv_loop_t* loop) {
loop->cf_state = NULL;
@@ -53,6 +57,11 @@ void uv__platform_loop_delete(uv_loop_t* loop) {
uint64_t uv__hrtime(uv_clocktype_t type) {
+#ifdef MAC_OS_X_VERSION_10_12
+ struct timespec ts;
+ clock_gettime(CLOCK_MONOTONIC, &ts);
+ return (((uint64_t) ts.tv_sec) * NANOSEC + ts.tv_nsec);
+#else
static mach_timebase_info_data_t info;
if ((ACCESS_ONCE(uint32_t, info.numer) == 0 ||
@@ -61,6 +70,7 @@ uint64_t uv__hrtime(uv_clocktype_t type) {
abort();
return mach_absolute_time() * info.numer / info.denom;
+#endif
}